1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-09 00:18:00 +01:00

fix: archive should not allow viewing additional details about toggle

This commit is contained in:
Ivar Conradi Østhus 2021-10-12 14:18:10 +02:00
parent 012cfc1806
commit cb35d73135
4 changed files with 84 additions and 33 deletions

View File

@ -19,7 +19,7 @@ const sortingOptions = [
{ type: 'stale', displayName: 'Stale' }, { type: 'stale', displayName: 'Stale' },
{ type: 'created', displayName: 'Created' }, { type: 'created', displayName: 'Created' },
{ type: 'Last seen', displayName: 'Last seen' }, { type: 'Last seen', displayName: 'Last seen' },
{ type: 'strategies', displayName: 'Strategies' }, { type: 'project', displayName: 'Project' },
{ type: 'metrics', displayName: 'Metrics' }, { type: 'metrics', displayName: 'Metrics' },
]; ];

View File

@ -3,12 +3,11 @@ 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 { IconButton, ListItem } from '@material-ui/core'; import { Chip, IconButton, ListItem } 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';
import Status from '../../status-component'; import Status from '../../status-component';
import FeatureToggleListItemChip from './FeatureToggleListItemChip';
import ConditionallyRender from '../../../common/ConditionallyRender/ConditionallyRender'; import ConditionallyRender from '../../../common/ConditionallyRender/ConditionallyRender';
import { UPDATE_FEATURE } from '../../../AccessProvider/permissions'; import { UPDATE_FEATURE } from '../../../AccessProvider/permissions';
@ -33,14 +32,11 @@ const FeatureToggleListItem = ({
}) => { }) => {
const styles = useStyles(); const styles = useStyles();
const isArchive = !!revive;
const { name, description, type, stale, createdAt, project, lastSeenAt } = const { name, description, type, stale, createdAt, project, lastSeenAt } =
feature; feature;
const featureUrl =
toggleFeature === undefined
? `/projects/${feature.project}/archived/${name}/metrics`
: getTogglePath(feature.project, name);
return ( return (
<ListItem <ListItem
{...rest} {...rest}
@ -53,27 +49,48 @@ const FeatureToggleListItem = ({
<FeatureType type={type} /> <FeatureType type={type} />
</span> </span>
<span className={classnames(styles.listItemLink)}> <span className={classnames(styles.listItemLink)}>
<Link <ConditionallyRender condition={!isArchive} show={
to={featureUrl} <Link
className={classnames( to={getTogglePath(feature.project, name)}
commonStyles.listLink, className={classnames(
commonStyles.truncate commonStyles.listLink,
)} commonStyles.truncate
> )}
<span className={commonStyles.toggleName}> >
{name}&nbsp; <span className={commonStyles.toggleName}>
</span> {name}&nbsp;
<span className={styles.listItemToggle}>
</span>
<small>
<TimeAgo date={createdAt} live={false} />
</small>
<div>
<span className={commonStyles.truncate}>
<small>{description}</small>
</span> </span>
</div> <span className={styles.listItemToggle}>
</Link> </span>
<small>
<TimeAgo date={createdAt} live={false} />
</small>
<div>
<span className={commonStyles.truncate}>
<small>{description}</small>
</span>
</div>
</Link>
} elseShow={
<>
<span className={commonStyles.toggleName}>
{name}&nbsp;
</span>
<span className={styles.listItemToggle}>
</span>
<small>
<TimeAgo date={createdAt} live={false} />
</small>
<div>
<span className={commonStyles.truncate}>
<small>{description}</small>
</span>
</div>
</>
}/>
</span> </span>
<span <span
className={classnames( className={classnames(
@ -82,7 +99,7 @@ const FeatureToggleListItem = ({
)} )}
> >
<Status stale={stale} showActive={false} /> <Status stale={stale} showActive={false} />
<FeatureToggleListItemChip type={type} /> <Chip color="primary" variant="outlined" className={styles.typeChip} style={{marginLeft: '8px'}} title={`Project: ${project}`} label={project}/>
</span> </span>
<ConditionallyRender <ConditionallyRender
condition={revive} condition={revive}

View File

@ -95,7 +95,25 @@ exports[`renders correctly with one feature 1`] = `
</span> </span>
<span <span
className="makeStyles-listItemStrategies-6 hideLt920" className="makeStyles-listItemStrategies-6 hideLt920"
/> >
<div
className="MuiChip-root MuiChip-colorPrimary MuiChip-outlined MuiChip-outlinedPrimary"
onKeyDown={[Function]}
onKeyUp={[Function]}
style={
Object {
"marginLeft": "8px",
}
}
title="Project: default"
>
<span
className="MuiChip-label"
>
default
</span>
</div>
</span>
</li> </li>
`; `;
@ -194,6 +212,22 @@ exports[`renders correctly with one feature without permission 1`] = `
</span> </span>
<span <span
className="makeStyles-listItemStrategies-6 hideLt920" className="makeStyles-listItemStrategies-6 hideLt920"
/> >
<div
className="MuiChip-root MuiChip-colorPrimary MuiChip-outlined MuiChip-outlinedPrimary"
onKeyDown={[Function]}
onKeyUp={[Function]}
style={
Object {
"marginLeft": "8px",
}
}
title="Project: undefined"
>
<span
className="MuiChip-label"
/>
</div>
</span>
</li> </li>
`; `;

View File

@ -92,9 +92,9 @@ export const mapStateToPropsConfigurable = isFeature => state => {
} }
return 0; return 0;
}); });
} else if (settings.sort === 'strategies') { } else if (settings.sort === 'project') {
features = features.sort((a, b) => features = features.sort((a, b) =>
a.strategies.length > b.strategies.length ? -1 : 1 a.project.length > b.project.length ? -1 : 1
); );
} else if (settings.sort === 'type') { } else if (settings.sort === 'type') {
features = features.sort((a, b) => { features = features.sort((a, b) => {