From a0bad364e8a9996ee6650c89eebe3d7fb6bc4b1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivar=20Conradi=20=C3=98sthus?= Date: Fri, 7 Aug 2020 10:12:05 +0200 Subject: [PATCH] feat: stort by stale --- .../feature-list-item-component-test.jsx.snap | 34 +++++++++++++++++-- .../list-component-test.jsx.snap | 12 +++++++ .../src/component/feature/list-component.jsx | 3 ++ .../src/component/feature/list-container.jsx | 5 +++ 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/frontend/src/component/feature/__tests__/__snapshots__/feature-list-item-component-test.jsx.snap b/frontend/src/component/feature/__tests__/__snapshots__/feature-list-item-component-test.jsx.snap index 719d267548..f379b078d6 100644 --- a/frontend/src/component/feature/__tests__/__snapshots__/feature-list-item-component-test.jsx.snap +++ b/frontend/src/component/feature/__tests__/__snapshots__/feature-list-item-component-test.jsx.snap @@ -35,7 +35,22 @@ exports[`renders correctly with one feature 1`] = ` href="/features/strategies/Another" onClick={[Function]} > - Another + + Another +   + + + + @@ -88,7 +103,22 @@ exports[`renders correctly with one feature without permission 1`] = ` href="/features/strategies/Another" onClick={[Function]} > - Another + + Another +   + + + + diff --git a/frontend/src/component/feature/__tests__/__snapshots__/list-component-test.jsx.snap b/frontend/src/component/feature/__tests__/__snapshots__/list-component-test.jsx.snap index a9045b9eac..e445dfd8e7 100644 --- a/frontend/src/component/feature/__tests__/__snapshots__/list-component-test.jsx.snap +++ b/frontend/src/component/feature/__tests__/__snapshots__/list-component-test.jsx.snap @@ -136,6 +136,12 @@ exports[`renders correctly with one feature 1`] = ` > Enabled + + Stale + Enabled + + Stale + Enabled + + Stale + Created diff --git a/frontend/src/component/feature/list-container.jsx b/frontend/src/component/feature/list-container.jsx index 54b5733a92..47b5d6f9d6 100644 --- a/frontend/src/component/feature/list-container.jsx +++ b/frontend/src/component/feature/list-container.jsx @@ -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') {