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 {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 (
|
||||
<ListItem
|
||||
{...rest}
|
||||
@ -112,12 +124,15 @@ const FeatureToggleListItem = ({
|
||||
<Link
|
||||
to={`/projects/${project}`}
|
||||
style={{ textDecoration: 'none' }}
|
||||
className={classnames({
|
||||
[`${styles.disabledLink}`]: !isProjectDeleted(),
|
||||
})}
|
||||
>
|
||||
<Chip
|
||||
color="primary"
|
||||
variant="outlined"
|
||||
className={styles.typeChip}
|
||||
style={{ marginLeft: '8px' }}
|
||||
style={{ marginLeft: '8px', cursor: 'pointer' }}
|
||||
title={`Project: ${project}`}
|
||||
label={project}
|
||||
/>
|
||||
@ -129,7 +144,10 @@ const FeatureToggleListItem = ({
|
||||
<ConditionallyRender
|
||||
condition={hasAccess(UPDATE_FEATURE, project)}
|
||||
show={
|
||||
<IconButton onClick={() => console.log('ho')}>
|
||||
<IconButton
|
||||
onClick={reviveFeature}
|
||||
disabled={!isProjectDeleted()}
|
||||
>
|
||||
<Undo />
|
||||
</IconButton>
|
||||
}
|
||||
|
@ -29,4 +29,7 @@ export const useStyles = makeStyles(theme => ({
|
||||
listItemStrategies: {
|
||||
marginLeft: 'auto',
|
||||
},
|
||||
disabledLink:{
|
||||
pointerEvents: 'none'
|
||||
},
|
||||
}));
|
||||
|
Loading…
Reference in New Issue
Block a user