From 5b420eb7a0a96717f649f31bf4ad21a7ae11f15f Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Fri, 10 May 2024 12:50:12 -0700 Subject: [PATCH 1/3] fix: when there is no active tags, prevent the user from requiring tags in the workspace --- src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx b/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx index 90b8dc16952a..40bae0be2d2a 100644 --- a/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx +++ b/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx @@ -13,6 +13,7 @@ import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import * as Policy from '@libs/actions/Policy'; import Navigation from '@libs/Navigation/Navigation'; +import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as PolicyUtils from '@libs/PolicyUtils'; import type {SettingsNavigatorParamList} from '@navigation/types'; import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; @@ -32,6 +33,8 @@ function WorkspaceTagsSettingsPage({route, policyTags}: WorkspaceTagsSettingsPag const styles = useThemeStyles(); const {translate} = useLocalize(); const policyTagName = useMemo(() => PolicyUtils.getTagLists(policyTags)?.[0]?.name ?? '', [policyTags]); + const hasEnabledOptions = OptionsListUtils.hasEnabledOptions(Object.values(policyTags ?? {}).flatMap(({tags}) => Object.values(tags))); + console.log('hasEnabledOptions', hasEnabledOptions); const updateWorkspaceRequiresTag = useCallback( (value: boolean) => { @@ -65,6 +68,7 @@ function WorkspaceTagsSettingsPage({route, policyTags}: WorkspaceTagsSettingsPag isOn={policy?.requiresTag ?? false} accessibilityLabel={translate('workspace.tags.requiresTag')} onToggle={updateWorkspaceRequiresTag} + disabled={!policy?.areTagsEnabled || !hasEnabledOptions} /> From 790466c4487f72c6d0b192a91886093d2935f874 Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Fri, 10 May 2024 12:53:33 -0700 Subject: [PATCH 2/3] fix: delete the log statement --- src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx b/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx index 40bae0be2d2a..893fcec0bb5b 100644 --- a/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx +++ b/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx @@ -34,7 +34,6 @@ function WorkspaceTagsSettingsPage({route, policyTags}: WorkspaceTagsSettingsPag const {translate} = useLocalize(); const policyTagName = useMemo(() => PolicyUtils.getTagLists(policyTags)?.[0]?.name ?? '', [policyTags]); const hasEnabledOptions = OptionsListUtils.hasEnabledOptions(Object.values(policyTags ?? {}).flatMap(({tags}) => Object.values(tags))); - console.log('hasEnabledOptions', hasEnabledOptions); const updateWorkspaceRequiresTag = useCallback( (value: boolean) => { From a6a3c052ee23ed3740bbc7bf973cda050797ba29 Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Mon, 13 May 2024 08:44:17 -0700 Subject: [PATCH 3/3] fix: duplicate declarations --- src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx b/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx index 613b8af76dc6..b91a4fdd04c8 100644 --- a/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx +++ b/src/pages/workspace/tags/WorkspaceTagsSettingsPage.tsx @@ -35,7 +35,6 @@ function WorkspaceTagsSettingsPage({route, policyTags}: WorkspaceTagsSettingsPag const policyTagLists = useMemo(() => PolicyUtils.getTagLists(policyTags), [policyTags]); const doesPolicyContainOnlyOneTagList = policyTagLists.length === 1; const hasEnabledOptions = OptionsListUtils.hasEnabledOptions(Object.values(policyTags ?? {}).flatMap(({tags}) => Object.values(tags))); - const doesPolicyContainOnlyOneTagList = policyTagLists.length === 1; const updateWorkspaceRequiresTag = useCallback( (value: boolean) => {