mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
fix: rename isProjectDeleted to projectExists and add PermissionIconButton
This commit is contained in:
parent
64481e9c51
commit
8d38b5cd7f
@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
|||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
|
|
||||||
import { Link } from 'react-router-dom';
|
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 { Undo } from '@material-ui/icons';
|
||||||
|
|
||||||
import TimeAgo from 'react-timeago';
|
import TimeAgo from 'react-timeago';
|
||||||
@ -18,6 +18,7 @@ import { getTogglePath } from '../../../../utils/route-path-helpers';
|
|||||||
import FeatureStatus from '../../FeatureView2/FeatureStatus/FeatureStatus';
|
import FeatureStatus from '../../FeatureView2/FeatureStatus/FeatureStatus';
|
||||||
import FeatureType from '../../FeatureView2/FeatureType/FeatureType';
|
import FeatureType from '../../FeatureView2/FeatureType/FeatureType';
|
||||||
import useProjects from '../../../../hooks/api/getters/useProjects/useProjects';
|
import useProjects from '../../../../hooks/api/getters/useProjects/useProjects';
|
||||||
|
import PermissionIconButton from '../../../common/PermissionIconButton/PermissionIconButton';
|
||||||
|
|
||||||
const FeatureToggleListItem = ({
|
const FeatureToggleListItem = ({
|
||||||
feature,
|
feature,
|
||||||
@ -38,7 +39,7 @@ const FeatureToggleListItem = ({
|
|||||||
const { name, description, type, stale, createdAt, project, lastSeenAt } =
|
const { name, description, type, stale, createdAt, project, lastSeenAt } =
|
||||||
feature;
|
feature;
|
||||||
|
|
||||||
const isProjectDeleted = () => {
|
const projectExists = () => {
|
||||||
let projectExist = projects.find(proj => proj.id === project);
|
let projectExist = projects.find(proj => proj.id === project);
|
||||||
if (projectExist) {
|
if (projectExist) {
|
||||||
return true;
|
return true;
|
||||||
@ -47,7 +48,7 @@ const FeatureToggleListItem = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const reviveFeature = () => {
|
const reviveFeature = () => {
|
||||||
if (isProjectDeleted()) {
|
if (projectExists()) {
|
||||||
revive(feature.name);
|
revive(feature.name);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -125,7 +126,7 @@ const FeatureToggleListItem = ({
|
|||||||
to={`/projects/${project}`}
|
to={`/projects/${project}`}
|
||||||
style={{ textDecoration: 'none' }}
|
style={{ textDecoration: 'none' }}
|
||||||
className={classnames({
|
className={classnames({
|
||||||
[`${styles.disabledLink}`]: !isProjectDeleted(),
|
[`${styles.disabledLink}`]: !projectExists(),
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<Chip
|
<Chip
|
||||||
@ -141,18 +142,14 @@ const FeatureToggleListItem = ({
|
|||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={revive}
|
condition={revive}
|
||||||
show={
|
show={
|
||||||
<ConditionallyRender
|
<PermissionIconButton
|
||||||
condition={hasAccess(UPDATE_FEATURE, project)}
|
permission={UPDATE_FEATURE}
|
||||||
show={
|
projectId={project}
|
||||||
<IconButton
|
disabled={!projectExists()}
|
||||||
onClick={reviveFeature}
|
onClick={reviveFeature}
|
||||||
disabled={!isProjectDeleted()}
|
|
||||||
>
|
>
|
||||||
<Undo />
|
<Undo />
|
||||||
</IconButton>
|
</PermissionIconButton>
|
||||||
}
|
|
||||||
elseShow={<span style={{ width: '48px ' }} />}
|
|
||||||
/>
|
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
Loading…
Reference in New Issue
Block a user