Skip to content

Commit

Permalink
feat: add potentially stale filter to flags filter (#8798)
Browse files Browse the repository at this point in the history
This PR adds the option to select potentially stale flags from the UI.

It also updates the name we use for parsing from the API: instead of
`potentiallyStale` we use `potentially-stale`. This follows the
precedent set by "kill switch" (which we send as 'kill-switch'), the
only other multi-word option that I could find in our filters.
  • Loading branch information
thomasheartman authored Nov 19, 2024
1 parent 8da201a commit b23dd94
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ export const ProjectOverviewFilters: VFC<IProjectOverviewFilters> = ({
label: 'Stale',
value: 'stale',
},
...(simplifyProjectOverview
? [
{
label: 'Potentially stale',
value: 'potentially-stale',
},
]
: []),
];

const availableFilters: IFilterItem[] = [
Expand Down
4 changes: 2 additions & 2 deletions src/lib/features/feature-search/feature-search-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ const applyStaleConditions = (

const { values, operator } = staleConditions;

if (!values.includes('potentiallyStale')) {
if (!values.includes('potentially-stale')) {
applyGenericQueryParams(query, [
{
...staleConditions,
Expand All @@ -591,7 +591,7 @@ const applyStaleConditions = (

const valueSet = new Set(
values.filter((value) =>
['stale', 'active', 'potentiallyStale'].includes(value || ''),
['stale', 'active', 'potentially-stale'].includes(value || ''),
),
);
const allSelected = valueSet.size === 3;
Expand Down
20 changes: 10 additions & 10 deletions src/lib/features/feature-search/feature.search.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1000,42 +1000,42 @@ test('should search features by potentially stale', async () => {
};

// single filters work
await check('IS:potentiallyStale', ['my_feature_c']);
// (stale or !potentiallyStale)
await check('IS_NOT:potentiallyStale', [
await check('IS:potentially-stale', ['my_feature_c']);
// (stale or !potentially-stale)
await check('IS_NOT:potentially-stale', [
'my_feature_a',
'my_feature_b',
'my_feature_d',
]);

// combo filters work
await check('IS_ANY_OF:active,potentiallyStale', [
await check('IS_ANY_OF:active,potentially-stale', [
'my_feature_a',
'my_feature_c',
]);

// (potentiallyStale OR stale)
await check('IS_ANY_OF:potentiallyStale,stale', [
// (potentially-stale OR stale)
await check('IS_ANY_OF:potentially-stale, stale', [
'my_feature_b',
'my_feature_c',
'my_feature_d',
]);

await check('IS_ANY_OF:active,potentiallyStale,stale', [
await check('IS_ANY_OF:active,potentially-stale,stale', [
'my_feature_a',
'my_feature_b',
'my_feature_c',
'my_feature_d',
]);

await check('IS_NONE_OF:active,potentiallyStale,stale', []);
await check('IS_NONE_OF:active,potentially-stale,stale', []);

await check('IS_NONE_OF:active,potentiallyStale', [
await check('IS_NONE_OF:active,potentially-stale', [
'my_feature_b',
'my_feature_d',
]);

await check('IS_NONE_OF:potentiallyStale,stale', ['my_feature_a']);
await check('IS_NONE_OF:potentially-stale,stale', ['my_feature_a']);
});

test('should filter features by combined operators', async () => {
Expand Down

0 comments on commit b23dd94

Please sign in to comment.