1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-04 00:18:01 +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: 'created', displayName: 'Created' },
{ type: 'Last seen', displayName: 'Last seen' },
{ type: 'strategies', displayName: 'Strategies' },
{ type: 'project', displayName: 'Project' },
{ type: 'metrics', displayName: 'Metrics' },
];

View File

@ -3,12 +3,11 @@ import PropTypes from 'prop-types';
import classnames from 'classnames';
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 TimeAgo from 'react-timeago';
import Status from '../../status-component';
import FeatureToggleListItemChip from './FeatureToggleListItemChip';
import ConditionallyRender from '../../../common/ConditionallyRender/ConditionallyRender';
import { UPDATE_FEATURE } from '../../../AccessProvider/permissions';
@ -33,14 +32,11 @@ const FeatureToggleListItem = ({
}) => {
const styles = useStyles();
const isArchive = !!revive;
const { name, description, type, stale, createdAt, project, lastSeenAt } =
feature;
const featureUrl =
toggleFeature === undefined
? `/projects/${feature.project}/archived/${name}/metrics`
: getTogglePath(feature.project, name);
return (
<ListItem
{...rest}
@ -53,27 +49,48 @@ const FeatureToggleListItem = ({
<FeatureType type={type} />
</span>
<span className={classnames(styles.listItemLink)}>
<Link
to={featureUrl}
className={classnames(
commonStyles.listLink,
commonStyles.truncate
)}
>
<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>
<ConditionallyRender condition={!isArchive} show={
<Link
to={getTogglePath(feature.project, name)}
className={classnames(
commonStyles.listLink,
commonStyles.truncate
)}
>
<span className={commonStyles.toggleName}>
{name}&nbsp;
</span>
</div>
</Link>
<span className={styles.listItemToggle}>
</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
className={classnames(
@ -82,7 +99,7 @@ const FeatureToggleListItem = ({
)}
>
<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>
<ConditionallyRender
condition={revive}

View File

@ -95,7 +95,25 @@ exports[`renders correctly with one feature 1`] = `
</span>
<span
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>
`;
@ -194,6 +212,22 @@ exports[`renders correctly with one feature without permission 1`] = `
</span>
<span
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>
`;

View File

@ -92,9 +92,9 @@ export const mapStateToPropsConfigurable = isFeature => state => {
}
return 0;
});
} else if (settings.sort === 'strategies') {
} else if (settings.sort === 'project') {
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') {
features = features.sort((a, b) => {