From 6fa1cc1d374d1ab948c3fc6e4dc90ffa0b10148a Mon Sep 17 00:00:00 2001 From: olga-union <101579322+olga-union@users.noreply.github.com> Date: Wed, 14 Sep 2022 15:02:29 -0500 Subject: [PATCH] fix: add default disabled state for only mine filter (#585) * fix: add default disabled state for only mine filter Signed-off-by: Olga Nad * fix: tests Signed-off-by: Olga Nad * fix: use api context to default filter state Signed-off-by: Olga Nad * fix: revert test updates Signed-off-by: Olga Nad Signed-off-by: Olga Nad --- .../Executions/filters/useOnlyMyExecutionsFilterState.ts | 5 ++++- 1 file changed, 4 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..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,12 +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 = apiContext ? false : true; const getFilter = (): FilterOperation | null => { if (!onlyMyExecutionsValue) { @@ -53,7 +56,7 @@ export function useOnlyMyExecutionsFilterState({ return { onlyMyExecutionsValue, - isFilterDisabled: isFilterDisabled ?? false, + isFilterDisabled: isFilterDisabled ?? defaultIsFilterDisabled, onOnlyMyExecutionsFilterChange: setOnlyMyExecutionsValue, getFilter, };