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

feat: stort by stale

This commit is contained in:
Ivar Conradi Østhus 2020-08-07 10:12:05 +02:00
parent 303b6edb99
commit a0bad364e8
4 changed files with 52 additions and 2 deletions

View File

@ -35,7 +35,22 @@ exports[`renders correctly with one feature 1`] = `
href="/features/strategies/Another"
onClick={[Function]}
>
Another
<span
className="toggleName"
>
Another
 
</span>
<small
className="mdl-color-text--blue-grey-300"
>
<time
dateTime="2018-02-04T20:27:52.127Z"
title="2018-02-04T20:27:52.127Z"
>
3 years ago
</time>
</small>
<span
className="mdl-list__item-sub-title truncate"
>
@ -88,7 +103,22 @@ exports[`renders correctly with one feature without permission 1`] = `
href="/features/strategies/Another"
onClick={[Function]}
>
Another
<span
className="toggleName"
>
Another
 
</span>
<small
className="mdl-color-text--blue-grey-300"
>
<time
dateTime="2018-02-04T20:27:52.127Z"
title="2018-02-04T20:27:52.127Z"
>
3 years ago
</time>
</small>
<span
className="mdl-list__item-sub-title truncate"
>

View File

@ -136,6 +136,12 @@ exports[`renders correctly with one feature 1`] = `
>
Enabled
</react-mdl-MenuItem>
<react-mdl-MenuItem
data-target="stale"
disabled={false}
>
Stale
</react-mdl-MenuItem>
<react-mdl-MenuItem
data-target="created"
disabled={false}
@ -301,6 +307,12 @@ exports[`renders correctly with one feature without permissions 1`] = `
>
Enabled
</react-mdl-MenuItem>
<react-mdl-MenuItem
data-target="stale"
disabled={false}
>
Stale
</react-mdl-MenuItem>
<react-mdl-MenuItem
data-target="created"
disabled={false}

View File

@ -111,6 +111,9 @@ export default class FeatureListComponent extends React.Component {
<MenuItem disabled={settings.sort === 'enabled'} data-target="enabled">
Enabled
</MenuItem>
<MenuItem disabled={settings.sort === 'stale'} data-target="stale">
Stale
</MenuItem>
<MenuItem disabled={settings.sort === 'created'} data-target="created">
Created
</MenuItem>

View File

@ -33,6 +33,11 @@ export const mapStateToPropsConfigurable = isFeature => state => {
// eslint-disable-next-line
a.enabled === b.enabled ? 0 : a.enabled ? -1 : 1
);
} else if (settings.sort === 'stale') {
features = features.sort((a, b) =>
// eslint-disable-next-line
a.stale === b.stale ? 0 : a.stale ? -1 : 1
);
} else if (settings.sort === 'created') {
features = features.sort((a, b) => (new Date(a.createdAt) > new Date(b.createdAt) ? -1 : 1));
} else if (settings.sort === 'name') {