1
0
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:
Fredrik Strand Oseberg 2021-10-21 09:50:58 +02:00 committed by GitHub
parent 53f481498d
commit fea7707551
7 changed files with 40 additions and 34 deletions

View File

@ -1,7 +1,7 @@
import { useHistory, useParams } from 'react-router-dom';
import useFeature from '../../../../../hooks/api/getters/useFeature/useFeature';
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 useTabs from '../../../../../hooks/useTabs';
import FeatureStrategiesEnvironmentList from './FeatureStrategiesEnvironmentList/FeatureStrategiesEnvironmentList';
@ -22,6 +22,7 @@ import { Add } from '@material-ui/icons';
import AccessContext from '../../../../../contexts/AccessContext';
import { UPDATE_FEATURE } from '../../../../providers/AccessProvider/permissions';
import useQueryParams from '../../../../../hooks/useQueryParams';
import PermissionButton from '../../../../common/PermissionButton/PermissionButton';
const FeatureStrategiesEnvironments = () => {
const smallScreen = useMediaQuery('(max-width:700px)');
@ -316,8 +317,12 @@ const FeatureStrategiesEnvironments = () => {
UPDATE_FEATURE
)}
show={
<Button
<PermissionButton
variant="contained"
permission={
UPDATE_FEATURE
}
projectId={projectId}
color="primary"
onClick={() => {
setExpandedSidebar(
@ -326,7 +331,7 @@ const FeatureStrategiesEnvironments = () => {
}}
>
Add your first strategy
</Button>
</PermissionButton>
}
/>
</NoItems>

View File

@ -5,18 +5,20 @@ import { useStyles } from './FeatureStrategiesList.styles';
import { useContext } from 'react';
import FeatureStrategiesUIContext from '../../../../../contexts/FeatureStrategiesUIContext';
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 ConditionallyRender from '../../../../common/ConditionallyRender';
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 smallScreen = useMediaQuery('(max-width:700px)');
const { expandedSidebar, setExpandedSidebar } = useContext(
FeatureStrategiesUIContext
);
const { hasAccess } = useContext(AccessContext);
const { projectId } = useParams<IFeatureViewParams>();
const styles = useStyles();
@ -64,24 +66,18 @@ const FeatureStrategiesList = () => {
</div>
}
/>
<Tooltip
title={
hasAccess(UPDATE_FEATURE)
? 'Click to open.'
: "You don't have access to perform this operation"
}
arrow
>
<span className={styles.iconButtonWrapper}>
<IconButton
className={styles.iconButton}
onClick={toggleSidebar}
disabled={!hasAccess(UPDATE_FEATURE)}
>
<DoubleArrow className={iconClasses} />
</IconButton>
</span>
</Tooltip>
<span className={styles.iconButtonWrapper}>
<PermissionIconButton
className={styles.iconButton}
onClick={toggleSidebar}
permission={UPDATE_FEATURE}
projectId={projectId}
>
<DoubleArrow className={iconClasses} />
</PermissionIconButton>
</span>
{renderStrategies()}
</section>
);

View File

@ -67,7 +67,7 @@ const FeatureStrategyExecution = ({
{constraints.length > 0
? 'who match constraints'
: ''}{' '}
are included.
is included.
</p>
<PercentageCircle
@ -154,7 +154,7 @@ const FeatureStrategyExecution = ({
{constraints?.length > 0
? 'who match constraints'
: ''}{' '}
are included.
is included.
</p>
<PercentageCircle

View File

@ -1,4 +1,5 @@
import { useEffect } from 'react';
import { useParams } from 'react-router';
import PropTypes from 'prop-types';
import { CardActions, Switch, TextField } from '@material-ui/core';
import FeatureTypeSelect from '../../feature-type-select-container';
@ -19,7 +20,6 @@ import {
import { CREATE_FEATURE } from '../../../providers/AccessProvider/permissions';
import { projectFilterGenerator } from '../../../../utils/project-filter-generator';
import { useHistory } from 'react-router-dom';
import useQueryParams from '../../../../hooks/useQueryParams';
const CreateFeature = ({
input,
@ -29,13 +29,13 @@ const CreateFeature = ({
onSubmit,
user,
}) => {
const params = useQueryParams();
const project = params.get('project');
const { projectId } = useParams();
const history = useHistory();
useEffect(() => {
if (project) {
setValue('project', project);
if (projectId) {
setValue('project', projectId);
}
/* eslint-disable-next-line */
}, []);
@ -88,7 +88,7 @@ const CreateFeature = ({
<section className={styles.formContainer}>
<ProjectSelect
value={input.project}
defaultValue={project}
defaultValue={projectId}
onChange={v => setValue('project', v.target.value)}
filter={projectFilterGenerator(user, CREATE_FEATURE)}
/>

View File

@ -15,6 +15,8 @@ import CreateStrategy from './AddStrategy/AddStrategy';
import Dialogue from '../../common/Dialogue/Dialogue';
import ResponsiveButton from '../../common/ResponsiveButton/ResponsiveButton';
import { Add } from '@material-ui/icons';
import { CREATE_FEATURE } from '../../providers/AccessProvider/permissions';
import { useParams } from 'react-router';
const cleanStrategy = strategy => ({
name: strategy.name,
@ -23,6 +25,7 @@ const cleanStrategy = strategy => ({
});
const StrategiesList = props => {
const { projectId } = useParams();
const [showDelDialog, setShowDelDialog] = useState(false);
const [delStrategy, setDelStrategy] = useState(null);
const [showCreateStrategy, setShowCreateStrategy] = useState(false);
@ -172,6 +175,8 @@ const StrategiesList = props => {
maxWidth="700px"
tooltip="Add strategy"
Icon={Add}
permission={CREATE_FEATURE}
projectId={projectId}
>
Add strategy
</ResponsiveButton>

View File

@ -71,7 +71,7 @@ Array [
"layout": "main",
"menu": Object {},
"parent": "/projects",
"path": "/projects/:id/create-toggle",
"path": "/projects/:projectId/create-toggle",
"title": "Create",
"type": "protected",
},

View File

@ -109,7 +109,7 @@ export const routes = [
menu: {},
},
{
path: '/projects/:id/create-toggle',
path: '/projects/:projectId/create-toggle',
parent: '/projects',
title: 'Create',
component: CreateFeatureToggle,