Skip to content

Commit

Permalink
fix: add default disabled state for only mine filter (#585)
Browse files Browse the repository at this point in the history
* fix: add default disabled state for only mine filter

Signed-off-by: Olga Nad <[email protected]>

* fix: tests

Signed-off-by: Olga Nad <[email protected]>

* fix: use api context to default filter state

Signed-off-by: Olga Nad <[email protected]>

* fix: revert test updates

Signed-off-by: Olga Nad <[email protected]>

Signed-off-by: Olga Nad <[email protected]>
  • Loading branch information
olga-union authored Sep 14, 2022
1 parent a5cad5d commit 6fa1cc1
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<boolean>(
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) {
Expand All @@ -53,7 +56,7 @@ export function useOnlyMyExecutionsFilterState({

return {
onlyMyExecutionsValue,
isFilterDisabled: isFilterDisabled ?? false,
isFilterDisabled: isFilterDisabled ?? defaultIsFilterDisabled,
onOnlyMyExecutionsFilterChange: setOnlyMyExecutionsValue,
getFilter,
};
Expand Down

0 comments on commit 6fa1cc1

Please sign in to comment.