From e8fb32a513b303473a39162f6e4643cb7cfdf130 Mon Sep 17 00:00:00 2001 From: Olga Nad Date: Mon, 12 Sep 2022 12:14:08 -0500 Subject: [PATCH 1/4] fix: add default disabled state for only mine filter Signed-off-by: Olga Nad --- .../Executions/filters/useOnlyMyExecutionsFilterState.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/zapp/console/src/components/Executions/filters/useOnlyMyExecutionsFilterState.ts b/packages/zapp/console/src/components/Executions/filters/useOnlyMyExecutionsFilterState.ts index f1d071a68..ef24ce058 100644 --- a/packages/zapp/console/src/components/Executions/filters/useOnlyMyExecutionsFilterState.ts +++ b/packages/zapp/console/src/components/Executions/filters/useOnlyMyExecutionsFilterState.ts @@ -31,6 +31,7 @@ export function useOnlyMyExecutionsFilterState({ const [onlyMyExecutionsValue, setOnlyMyExecutionsValue] = useState( isFlagEnabled ? onlyMineExecutionsSelectedValue : initialValue ?? false, // if flag is enable let's use the value from only mine ); + const defaultIsFilterDisabled = profile.value ? false : true; const getFilter = (): FilterOperation | null => { if (!onlyMyExecutionsValue) { @@ -53,7 +54,7 @@ export function useOnlyMyExecutionsFilterState({ return { onlyMyExecutionsValue, - isFilterDisabled: isFilterDisabled ?? false, + isFilterDisabled: isFilterDisabled ?? defaultIsFilterDisabled, onOnlyMyExecutionsFilterChange: setOnlyMyExecutionsValue, getFilter, }; From bda615d9cfddbc3144f7f161573baacf39ed51af Mon Sep 17 00:00:00 2001 From: Olga Nad Date: Mon, 12 Sep 2022 12:50:14 -0500 Subject: [PATCH 2/4] fix: tests Signed-off-by: Olga Nad --- .../Executions/test/useOnlyMyExecutionsFilterState.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/zapp/console/src/components/Executions/test/useOnlyMyExecutionsFilterState.test.ts b/packages/zapp/console/src/components/Executions/test/useOnlyMyExecutionsFilterState.test.ts index a34c9bfa6..873b55750 100644 --- a/packages/zapp/console/src/components/Executions/test/useOnlyMyExecutionsFilterState.test.ts +++ b/packages/zapp/console/src/components/Executions/test/useOnlyMyExecutionsFilterState.test.ts @@ -13,11 +13,11 @@ describe('useOnlyMyExecutionsFilterState', () => { describe.each` isFilterDisabled | initialValue | expected - ${undefined} | ${undefined} | ${{ isFilterDisabled: false, onlyMyExecutionsValue: false }} + ${undefined} | ${undefined} | ${{ isFilterDisabled: true, onlyMyExecutionsValue: false }} ${false} | ${undefined} | ${{ isFilterDisabled: false, onlyMyExecutionsValue: false }} ${true} | ${undefined} | ${{ isFilterDisabled: true, onlyMyExecutionsValue: false }} - ${undefined} | ${false} | ${{ isFilterDisabled: false, onlyMyExecutionsValue: false }} - ${undefined} | ${true} | ${{ isFilterDisabled: false, onlyMyExecutionsValue: true }} + ${undefined} | ${false} | ${{ isFilterDisabled: true, onlyMyExecutionsValue: false }} + ${undefined} | ${true} | ${{ isFilterDisabled: true, onlyMyExecutionsValue: true }} ${false} | ${false} | ${{ isFilterDisabled: false, onlyMyExecutionsValue: false }} ${false} | ${true} | ${{ isFilterDisabled: false, onlyMyExecutionsValue: true }} ${true} | ${false} | ${{ isFilterDisabled: true, onlyMyExecutionsValue: false }} From bac5f4f3b099cf7372393668f9fdd60ecd71be17 Mon Sep 17 00:00:00 2001 From: Olga Nad Date: Tue, 13 Sep 2022 13:32:51 -0500 Subject: [PATCH 3/4] fix: use api context to default filter state Signed-off-by: Olga Nad --- .../Executions/filters/useOnlyMyExecutionsFilterState.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/zapp/console/src/components/Executions/filters/useOnlyMyExecutionsFilterState.ts b/packages/zapp/console/src/components/Executions/filters/useOnlyMyExecutionsFilterState.ts index ef24ce058..70ee68da1 100644 --- a/packages/zapp/console/src/components/Executions/filters/useOnlyMyExecutionsFilterState.ts +++ b/packages/zapp/console/src/components/Executions/filters/useOnlyMyExecutionsFilterState.ts @@ -4,6 +4,7 @@ import { useUserProfile } from 'components/hooks/useUserProfile'; import { useOnlyMineSelectedValue } from 'components/hooks/useOnlyMineSelectedValue'; import { OnlyMyFilter } from 'basics/LocalCache/onlyMineDefaultConfig'; import { FeatureFlag, useFeatureFlag } from 'basics/FeatureFlags'; +import { useFlyteApi } from '@flyteconsole/flyte-api'; interface OnlyMyExecutionsFilterState { onlyMyExecutionsValue: boolean; @@ -25,13 +26,14 @@ export function useOnlyMyExecutionsFilterState({ initialValue, }: OnlyMyExecutionsFilterStateProps): OnlyMyExecutionsFilterState { const profile = useUserProfile(); + const apiContext = useFlyteApi(); const userId = profile.value?.subject ?? ''; const isFlagEnabled = useFeatureFlag(FeatureFlag.OnlyMine); const onlyMineExecutionsSelectedValue = useOnlyMineSelectedValue(OnlyMyFilter.OnlyMyExecutions); const [onlyMyExecutionsValue, setOnlyMyExecutionsValue] = useState( isFlagEnabled ? onlyMineExecutionsSelectedValue : initialValue ?? false, // if flag is enable let's use the value from only mine ); - const defaultIsFilterDisabled = profile.value ? false : true; + const defaultIsFilterDisabled = apiContext ? false : true; const getFilter = (): FilterOperation | null => { if (!onlyMyExecutionsValue) { From 3bc82fbf932a6c4782c1bf34a2ac0d3cacc5f794 Mon Sep 17 00:00:00 2001 From: Olga Nad Date: Tue, 13 Sep 2022 13:35:47 -0500 Subject: [PATCH 4/4] fix: revert test updates Signed-off-by: Olga Nad --- .../Executions/test/useOnlyMyExecutionsFilterState.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/zapp/console/src/components/Executions/test/useOnlyMyExecutionsFilterState.test.ts b/packages/zapp/console/src/components/Executions/test/useOnlyMyExecutionsFilterState.test.ts index 873b55750..a34c9bfa6 100644 --- a/packages/zapp/console/src/components/Executions/test/useOnlyMyExecutionsFilterState.test.ts +++ b/packages/zapp/console/src/components/Executions/test/useOnlyMyExecutionsFilterState.test.ts @@ -13,11 +13,11 @@ describe('useOnlyMyExecutionsFilterState', () => { describe.each` isFilterDisabled | initialValue | expected - ${undefined} | ${undefined} | ${{ isFilterDisabled: true, onlyMyExecutionsValue: false }} + ${undefined} | ${undefined} | ${{ isFilterDisabled: false, onlyMyExecutionsValue: false }} ${false} | ${undefined} | ${{ isFilterDisabled: false, onlyMyExecutionsValue: false }} ${true} | ${undefined} | ${{ isFilterDisabled: true, onlyMyExecutionsValue: false }} - ${undefined} | ${false} | ${{ isFilterDisabled: true, onlyMyExecutionsValue: false }} - ${undefined} | ${true} | ${{ isFilterDisabled: true, onlyMyExecutionsValue: true }} + ${undefined} | ${false} | ${{ isFilterDisabled: false, onlyMyExecutionsValue: false }} + ${undefined} | ${true} | ${{ isFilterDisabled: false, onlyMyExecutionsValue: true }} ${false} | ${false} | ${{ isFilterDisabled: false, onlyMyExecutionsValue: false }} ${false} | ${true} | ${{ isFilterDisabled: false, onlyMyExecutionsValue: true }} ${true} | ${false} | ${{ isFilterDisabled: true, onlyMyExecutionsValue: false }}