From bdb5533caed21c8190fbeab717450f4183f21702 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Tue, 4 Jun 2024 14:43:58 +0300 Subject: [PATCH] Merge pull request #42734 from nkdengineer/fix/42205 Fix unable to add custom tag name in a new workspace (cherry picked from commit 92a7b1565b4e4aef0c06629a04d4715c125ed247) --- src/libs/actions/Policy/Tag.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/libs/actions/Policy/Tag.ts b/src/libs/actions/Policy/Tag.ts index 7760f29d6703..8afaf29971ae 100644 --- a/src/libs/actions/Policy/Tag.ts +++ b/src/libs/actions/Policy/Tag.ts @@ -472,6 +472,27 @@ function enablePolicyTags(policyID: string, enabled: boolean) { }, ], }; + const policyTagList = allPolicyTags?.[policyID]; + if (!policyTagList) { + const defaultTagList: PolicyTagList = { + Tag: { + name: 'Tag', + orderWeight: 0, + required: false, + tags: {}, + }, + }; + onyxData.optimisticData?.push({ + onyxMethod: Onyx.METHOD.SET, + key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`, + value: defaultTagList, + }); + onyxData.failureData?.push({ + onyxMethod: Onyx.METHOD.SET, + key: `${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`, + value: null, + }); + } const parameters: EnablePolicyTagsParams = {policyID, enabled};