From 7d2ea9407c722d76e1ca1bb15e5c060eb8c2840f Mon Sep 17 00:00:00 2001 From: Youssef Date: Fri, 5 Nov 2021 09:19:07 +0100 Subject: [PATCH 1/6] fix: remove typo from UI --- .../FeatureToggleListItem/FeatureToggleListItem.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/FeatureToggleListItem.jsx b/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/FeatureToggleListItem.jsx index 0ddb6c0d9d..549cd66826 100644 --- a/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/FeatureToggleListItem.jsx +++ b/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/FeatureToggleListItem.jsx @@ -83,7 +83,7 @@ const FeatureToggleListItem = ({ <> - {name}  z{' '} + {name} {' '} From e5ff80a9d52912cdb4dc31f2eb58069b67d2a33d Mon Sep 17 00:00:00 2001 From: Youssef Date: Fri, 5 Nov 2021 09:22:01 +0100 Subject: [PATCH 2/6] fix: add correct path for create first toggle button --- .../Project/ProjectFeatureToggles/ProjectFeatureToggles.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeatureToggles.tsx b/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeatureToggles.tsx index bd4354f0fe..24570f6047 100644 --- a/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeatureToggles.tsx +++ b/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeatureToggles.tsx @@ -93,7 +93,7 @@ const ProjectFeatureToggles = ({ condition={hasAccess(CREATE_FEATURE, id)} show={ From 1e47975dc87c5749930bbcf984fce7eda112e641 Mon Sep 17 00:00:00 2001 From: Youssef Date: Fri, 5 Nov 2021 10:14:52 +0100 Subject: [PATCH 3/6] use useProjects to check if project deleted or not --- .../FeatureToggleListItem/FeatureToggleListItem.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/FeatureToggleListItem.jsx b/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/FeatureToggleListItem.jsx index 549cd66826..f839695d36 100644 --- a/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/FeatureToggleListItem.jsx +++ b/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/FeatureToggleListItem.jsx @@ -17,6 +17,7 @@ import { useStyles } from './styles'; import { getTogglePath } from '../../../../utils/route-path-helpers'; import FeatureStatus from '../../FeatureView2/FeatureStatus/FeatureStatus'; import FeatureType from '../../FeatureView2/FeatureType/FeatureType'; +import useProjects from '../../../../hooks/api/getters/useProjects/useProjects'; const FeatureToggleListItem = ({ feature, @@ -31,11 +32,13 @@ const FeatureToggleListItem = ({ }) => { const styles = useStyles(); + // const {projects} = useProjects() const isArchive = !!revive; const { name, description, type, stale, createdAt, project, lastSeenAt } = feature; + // let obj = projects.find(project => project.id === 'projectId'); return ( revive(feature.name)}> + console.log('ho')}> } From 9cc1e56f13b980550fa0f7cd5cb0c05b3d6d5eed Mon Sep 17 00:00:00 2001 From: Youssef Date: Fri, 5 Nov 2021 23:21:21 +0100 Subject: [PATCH 4/6] fix: disable revive feature when project is deleted --- .../FeatureToggleListItem.jsx | 26 ++++++++++++++++--- .../FeatureToggleListItem/styles.js | 3 +++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/FeatureToggleListItem.jsx b/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/FeatureToggleListItem.jsx index f839695d36..87e442ec42 100644 --- a/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/FeatureToggleListItem.jsx +++ b/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/FeatureToggleListItem.jsx @@ -32,13 +32,25 @@ const FeatureToggleListItem = ({ }) => { const styles = useStyles(); - // const {projects} = useProjects() + const { projects } = useProjects(); const isArchive = !!revive; const { name, description, type, stale, createdAt, project, lastSeenAt } = feature; - // let obj = projects.find(project => project.id === 'projectId'); + const isProjectDeleted = () => { + let projectExist = projects.find(proj => proj.id === project); + if (projectExist) { + return true; + } + return false; + }; + + const reviveFeature = () => { + if (isProjectDeleted()) { + revive(feature.name); + } + }; return ( @@ -129,7 +144,10 @@ const FeatureToggleListItem = ({ console.log('ho')}> + } diff --git a/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/styles.js b/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/styles.js index 8519c95cf3..68cc624d86 100644 --- a/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/styles.js +++ b/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/styles.js @@ -29,4 +29,7 @@ export const useStyles = makeStyles(theme => ({ listItemStrategies: { marginLeft: 'auto', }, + disabledLink:{ + pointerEvents: 'none' + }, })); From 64481e9c516c257cd5cc1f581ceb2da7dc5bbae3 Mon Sep 17 00:00:00 2001 From: Youssef Date: Fri, 5 Nov 2021 23:35:44 +0100 Subject: [PATCH 5/6] update snapshots --- .../feature-list-item-component-test.jsx.snap | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/src/component/feature/FeatureToggleList/__tests__/__snapshots__/feature-list-item-component-test.jsx.snap b/frontend/src/component/feature/FeatureToggleList/__tests__/__snapshots__/feature-list-item-component-test.jsx.snap index 15eab0fd69..a5ff10647b 100644 --- a/frontend/src/component/feature/FeatureToggleList/__tests__/__snapshots__/feature-list-item-component-test.jsx.snap +++ b/frontend/src/component/feature/FeatureToggleList/__tests__/__snapshots__/feature-list-item-component-test.jsx.snap @@ -10,7 +10,7 @@ exports[`renders correctly with one feature 1`] = ` >
Date: Mon, 8 Nov 2021 10:22:37 +0100 Subject: [PATCH 6/6] fix: rename isProjectDeleted to projectExists and add PermissionIconButton --- .../FeatureToggleListItem.jsx | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/FeatureToggleListItem.jsx b/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/FeatureToggleListItem.jsx index 87e442ec42..0dff35d269 100644 --- a/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/FeatureToggleListItem.jsx +++ b/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/FeatureToggleListItem.jsx @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import classnames from 'classnames'; import { Link } from 'react-router-dom'; -import { Chip, IconButton, ListItem, Tooltip } from '@material-ui/core'; +import { Chip, ListItem, Tooltip } from '@material-ui/core'; import { Undo } from '@material-ui/icons'; import TimeAgo from 'react-timeago'; @@ -18,6 +18,7 @@ import { getTogglePath } from '../../../../utils/route-path-helpers'; import FeatureStatus from '../../FeatureView2/FeatureStatus/FeatureStatus'; import FeatureType from '../../FeatureView2/FeatureType/FeatureType'; import useProjects from '../../../../hooks/api/getters/useProjects/useProjects'; +import PermissionIconButton from '../../../common/PermissionIconButton/PermissionIconButton'; const FeatureToggleListItem = ({ feature, @@ -38,7 +39,7 @@ const FeatureToggleListItem = ({ const { name, description, type, stale, createdAt, project, lastSeenAt } = feature; - const isProjectDeleted = () => { + const projectExists = () => { let projectExist = projects.find(proj => proj.id === project); if (projectExist) { return true; @@ -47,7 +48,7 @@ const FeatureToggleListItem = ({ }; const reviveFeature = () => { - if (isProjectDeleted()) { + if (projectExists()) { revive(feature.name); } }; @@ -125,7 +126,7 @@ const FeatureToggleListItem = ({ to={`/projects/${project}`} style={{ textDecoration: 'none' }} className={classnames({ - [`${styles.disabledLink}`]: !isProjectDeleted(), + [`${styles.disabledLink}`]: !projectExists(), })} > - - - } - elseShow={} - /> + + + } />