mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
fix: disable revive feature when project is deleted
This commit is contained in:
parent
1e47975dc8
commit
9cc1e56f13
@ -32,13 +32,25 @@ const FeatureToggleListItem = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const styles = useStyles();
|
const styles = useStyles();
|
||||||
|
|
||||||
// const {projects} = useProjects()
|
const { projects } = useProjects();
|
||||||
const isArchive = !!revive;
|
const isArchive = !!revive;
|
||||||
|
|
||||||
const { name, description, type, stale, createdAt, project, lastSeenAt } =
|
const { name, description, type, stale, createdAt, project, lastSeenAt } =
|
||||||
feature;
|
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 (
|
return (
|
||||||
<ListItem
|
<ListItem
|
||||||
{...rest}
|
{...rest}
|
||||||
@ -112,12 +124,15 @@ const FeatureToggleListItem = ({
|
|||||||
<Link
|
<Link
|
||||||
to={`/projects/${project}`}
|
to={`/projects/${project}`}
|
||||||
style={{ textDecoration: 'none' }}
|
style={{ textDecoration: 'none' }}
|
||||||
|
className={classnames({
|
||||||
|
[`${styles.disabledLink}`]: !isProjectDeleted(),
|
||||||
|
})}
|
||||||
>
|
>
|
||||||
<Chip
|
<Chip
|
||||||
color="primary"
|
color="primary"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
className={styles.typeChip}
|
className={styles.typeChip}
|
||||||
style={{ marginLeft: '8px' }}
|
style={{ marginLeft: '8px', cursor: 'pointer' }}
|
||||||
title={`Project: ${project}`}
|
title={`Project: ${project}`}
|
||||||
label={project}
|
label={project}
|
||||||
/>
|
/>
|
||||||
@ -129,7 +144,10 @@ const FeatureToggleListItem = ({
|
|||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={hasAccess(UPDATE_FEATURE, project)}
|
condition={hasAccess(UPDATE_FEATURE, project)}
|
||||||
show={
|
show={
|
||||||
<IconButton onClick={() => console.log('ho')}>
|
<IconButton
|
||||||
|
onClick={reviveFeature}
|
||||||
|
disabled={!isProjectDeleted()}
|
||||||
|
>
|
||||||
<Undo />
|
<Undo />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
}
|
}
|
||||||
|
@ -29,4 +29,7 @@ export const useStyles = makeStyles(theme => ({
|
|||||||
listItemStrategies: {
|
listItemStrategies: {
|
||||||
marginLeft: 'auto',
|
marginLeft: 'auto',
|
||||||
},
|
},
|
||||||
|
disabledLink:{
|
||||||
|
pointerEvents: 'none'
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
Loading…
Reference in New Issue
Block a user