mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
fix: use path parameter for old ft view (#450)
* fix: use path parameter for old ft view * fix: update snapshots * fix: change text * fix: add permission button to initial strategies view * fix: remove unused imports
This commit is contained in:
parent
53f481498d
commit
fea7707551
@ -1,7 +1,7 @@
|
|||||||
import { useHistory, useParams } from 'react-router-dom';
|
import { useHistory, useParams } from 'react-router-dom';
|
||||||
import useFeature from '../../../../../hooks/api/getters/useFeature/useFeature';
|
import useFeature from '../../../../../hooks/api/getters/useFeature/useFeature';
|
||||||
import { useStyles } from './FeatureStrategiesEnvironments.styles';
|
import { useStyles } from './FeatureStrategiesEnvironments.styles';
|
||||||
import { Tabs, Tab, Button, useMediaQuery } from '@material-ui/core';
|
import { Tabs, Tab, useMediaQuery } from '@material-ui/core';
|
||||||
import TabPanel from '../../../../common/TabNav/TabPanel';
|
import TabPanel from '../../../../common/TabNav/TabPanel';
|
||||||
import useTabs from '../../../../../hooks/useTabs';
|
import useTabs from '../../../../../hooks/useTabs';
|
||||||
import FeatureStrategiesEnvironmentList from './FeatureStrategiesEnvironmentList/FeatureStrategiesEnvironmentList';
|
import FeatureStrategiesEnvironmentList from './FeatureStrategiesEnvironmentList/FeatureStrategiesEnvironmentList';
|
||||||
@ -22,6 +22,7 @@ import { Add } from '@material-ui/icons';
|
|||||||
import AccessContext from '../../../../../contexts/AccessContext';
|
import AccessContext from '../../../../../contexts/AccessContext';
|
||||||
import { UPDATE_FEATURE } from '../../../../providers/AccessProvider/permissions';
|
import { UPDATE_FEATURE } from '../../../../providers/AccessProvider/permissions';
|
||||||
import useQueryParams from '../../../../../hooks/useQueryParams';
|
import useQueryParams from '../../../../../hooks/useQueryParams';
|
||||||
|
import PermissionButton from '../../../../common/PermissionButton/PermissionButton';
|
||||||
|
|
||||||
const FeatureStrategiesEnvironments = () => {
|
const FeatureStrategiesEnvironments = () => {
|
||||||
const smallScreen = useMediaQuery('(max-width:700px)');
|
const smallScreen = useMediaQuery('(max-width:700px)');
|
||||||
@ -316,8 +317,12 @@ const FeatureStrategiesEnvironments = () => {
|
|||||||
UPDATE_FEATURE
|
UPDATE_FEATURE
|
||||||
)}
|
)}
|
||||||
show={
|
show={
|
||||||
<Button
|
<PermissionButton
|
||||||
variant="contained"
|
variant="contained"
|
||||||
|
permission={
|
||||||
|
UPDATE_FEATURE
|
||||||
|
}
|
||||||
|
projectId={projectId}
|
||||||
color="primary"
|
color="primary"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setExpandedSidebar(
|
setExpandedSidebar(
|
||||||
@ -326,7 +331,7 @@ const FeatureStrategiesEnvironments = () => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Add your first strategy
|
Add your first strategy
|
||||||
</Button>
|
</PermissionButton>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</NoItems>
|
</NoItems>
|
||||||
|
@ -5,18 +5,20 @@ import { useStyles } from './FeatureStrategiesList.styles';
|
|||||||
import { useContext } from 'react';
|
import { useContext } from 'react';
|
||||||
import FeatureStrategiesUIContext from '../../../../../contexts/FeatureStrategiesUIContext';
|
import FeatureStrategiesUIContext from '../../../../../contexts/FeatureStrategiesUIContext';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import { Button, IconButton, Tooltip, useMediaQuery } from '@material-ui/core';
|
import { Button, useMediaQuery } from '@material-ui/core';
|
||||||
import { DoubleArrow } from '@material-ui/icons';
|
import { DoubleArrow } from '@material-ui/icons';
|
||||||
import ConditionallyRender from '../../../../common/ConditionallyRender';
|
import ConditionallyRender from '../../../../common/ConditionallyRender';
|
||||||
import { UPDATE_FEATURE } from '../../../../providers/AccessProvider/permissions';
|
import { UPDATE_FEATURE } from '../../../../providers/AccessProvider/permissions';
|
||||||
import AccessContext from '../../../../../contexts/AccessContext';
|
import PermissionIconButton from '../../../../common/PermissionIconButton/PermissionIconButton';
|
||||||
|
import { useParams } from 'react-router';
|
||||||
|
import { IFeatureViewParams } from '../../../../../interfaces/params';
|
||||||
|
|
||||||
const FeatureStrategiesList = () => {
|
const FeatureStrategiesList = () => {
|
||||||
const smallScreen = useMediaQuery('(max-width:700px)');
|
const smallScreen = useMediaQuery('(max-width:700px)');
|
||||||
const { expandedSidebar, setExpandedSidebar } = useContext(
|
const { expandedSidebar, setExpandedSidebar } = useContext(
|
||||||
FeatureStrategiesUIContext
|
FeatureStrategiesUIContext
|
||||||
);
|
);
|
||||||
const { hasAccess } = useContext(AccessContext);
|
const { projectId } = useParams<IFeatureViewParams>();
|
||||||
|
|
||||||
const styles = useStyles();
|
const styles = useStyles();
|
||||||
|
|
||||||
@ -64,24 +66,18 @@ const FeatureStrategiesList = () => {
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Tooltip
|
|
||||||
title={
|
<span className={styles.iconButtonWrapper}>
|
||||||
hasAccess(UPDATE_FEATURE)
|
<PermissionIconButton
|
||||||
? 'Click to open.'
|
className={styles.iconButton}
|
||||||
: "You don't have access to perform this operation"
|
onClick={toggleSidebar}
|
||||||
}
|
permission={UPDATE_FEATURE}
|
||||||
arrow
|
projectId={projectId}
|
||||||
>
|
>
|
||||||
<span className={styles.iconButtonWrapper}>
|
<DoubleArrow className={iconClasses} />
|
||||||
<IconButton
|
</PermissionIconButton>
|
||||||
className={styles.iconButton}
|
</span>
|
||||||
onClick={toggleSidebar}
|
|
||||||
disabled={!hasAccess(UPDATE_FEATURE)}
|
|
||||||
>
|
|
||||||
<DoubleArrow className={iconClasses} />
|
|
||||||
</IconButton>
|
|
||||||
</span>
|
|
||||||
</Tooltip>
|
|
||||||
{renderStrategies()}
|
{renderStrategies()}
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
@ -67,7 +67,7 @@ const FeatureStrategyExecution = ({
|
|||||||
{constraints.length > 0
|
{constraints.length > 0
|
||||||
? 'who match constraints'
|
? 'who match constraints'
|
||||||
: ''}{' '}
|
: ''}{' '}
|
||||||
are included.
|
is included.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<PercentageCircle
|
<PercentageCircle
|
||||||
@ -154,7 +154,7 @@ const FeatureStrategyExecution = ({
|
|||||||
{constraints?.length > 0
|
{constraints?.length > 0
|
||||||
? 'who match constraints'
|
? 'who match constraints'
|
||||||
: ''}{' '}
|
: ''}{' '}
|
||||||
are included.
|
is included.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<PercentageCircle
|
<PercentageCircle
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
|
import { useParams } from 'react-router';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { CardActions, Switch, TextField } from '@material-ui/core';
|
import { CardActions, Switch, TextField } from '@material-ui/core';
|
||||||
import FeatureTypeSelect from '../../feature-type-select-container';
|
import FeatureTypeSelect from '../../feature-type-select-container';
|
||||||
@ -19,7 +20,6 @@ import {
|
|||||||
import { CREATE_FEATURE } from '../../../providers/AccessProvider/permissions';
|
import { CREATE_FEATURE } from '../../../providers/AccessProvider/permissions';
|
||||||
import { projectFilterGenerator } from '../../../../utils/project-filter-generator';
|
import { projectFilterGenerator } from '../../../../utils/project-filter-generator';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import useQueryParams from '../../../../hooks/useQueryParams';
|
|
||||||
|
|
||||||
const CreateFeature = ({
|
const CreateFeature = ({
|
||||||
input,
|
input,
|
||||||
@ -29,13 +29,13 @@ const CreateFeature = ({
|
|||||||
onSubmit,
|
onSubmit,
|
||||||
user,
|
user,
|
||||||
}) => {
|
}) => {
|
||||||
const params = useQueryParams();
|
const { projectId } = useParams();
|
||||||
const project = params.get('project');
|
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (project) {
|
if (projectId) {
|
||||||
setValue('project', project);
|
setValue('project', projectId);
|
||||||
}
|
}
|
||||||
/* eslint-disable-next-line */
|
/* eslint-disable-next-line */
|
||||||
}, []);
|
}, []);
|
||||||
@ -88,7 +88,7 @@ const CreateFeature = ({
|
|||||||
<section className={styles.formContainer}>
|
<section className={styles.formContainer}>
|
||||||
<ProjectSelect
|
<ProjectSelect
|
||||||
value={input.project}
|
value={input.project}
|
||||||
defaultValue={project}
|
defaultValue={projectId}
|
||||||
onChange={v => setValue('project', v.target.value)}
|
onChange={v => setValue('project', v.target.value)}
|
||||||
filter={projectFilterGenerator(user, CREATE_FEATURE)}
|
filter={projectFilterGenerator(user, CREATE_FEATURE)}
|
||||||
/>
|
/>
|
||||||
|
@ -15,6 +15,8 @@ import CreateStrategy from './AddStrategy/AddStrategy';
|
|||||||
import Dialogue from '../../common/Dialogue/Dialogue';
|
import Dialogue from '../../common/Dialogue/Dialogue';
|
||||||
import ResponsiveButton from '../../common/ResponsiveButton/ResponsiveButton';
|
import ResponsiveButton from '../../common/ResponsiveButton/ResponsiveButton';
|
||||||
import { Add } from '@material-ui/icons';
|
import { Add } from '@material-ui/icons';
|
||||||
|
import { CREATE_FEATURE } from '../../providers/AccessProvider/permissions';
|
||||||
|
import { useParams } from 'react-router';
|
||||||
|
|
||||||
const cleanStrategy = strategy => ({
|
const cleanStrategy = strategy => ({
|
||||||
name: strategy.name,
|
name: strategy.name,
|
||||||
@ -23,6 +25,7 @@ const cleanStrategy = strategy => ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const StrategiesList = props => {
|
const StrategiesList = props => {
|
||||||
|
const { projectId } = useParams();
|
||||||
const [showDelDialog, setShowDelDialog] = useState(false);
|
const [showDelDialog, setShowDelDialog] = useState(false);
|
||||||
const [delStrategy, setDelStrategy] = useState(null);
|
const [delStrategy, setDelStrategy] = useState(null);
|
||||||
const [showCreateStrategy, setShowCreateStrategy] = useState(false);
|
const [showCreateStrategy, setShowCreateStrategy] = useState(false);
|
||||||
@ -172,6 +175,8 @@ const StrategiesList = props => {
|
|||||||
maxWidth="700px"
|
maxWidth="700px"
|
||||||
tooltip="Add strategy"
|
tooltip="Add strategy"
|
||||||
Icon={Add}
|
Icon={Add}
|
||||||
|
permission={CREATE_FEATURE}
|
||||||
|
projectId={projectId}
|
||||||
>
|
>
|
||||||
Add strategy
|
Add strategy
|
||||||
</ResponsiveButton>
|
</ResponsiveButton>
|
||||||
|
@ -71,7 +71,7 @@ Array [
|
|||||||
"layout": "main",
|
"layout": "main",
|
||||||
"menu": Object {},
|
"menu": Object {},
|
||||||
"parent": "/projects",
|
"parent": "/projects",
|
||||||
"path": "/projects/:id/create-toggle",
|
"path": "/projects/:projectId/create-toggle",
|
||||||
"title": "Create",
|
"title": "Create",
|
||||||
"type": "protected",
|
"type": "protected",
|
||||||
},
|
},
|
||||||
|
@ -109,7 +109,7 @@ export const routes = [
|
|||||||
menu: {},
|
menu: {},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/projects/:id/create-toggle',
|
path: '/projects/:projectId/create-toggle',
|
||||||
parent: '/projects',
|
parent: '/projects',
|
||||||
title: 'Create',
|
title: 'Create',
|
||||||
component: CreateFeatureToggle,
|
component: CreateFeatureToggle,
|
||||||
|
Loading…
Reference in New Issue
Block a user