From d50b166fd83b86249f7f7c8ef52f87d3a019175f Mon Sep 17 00:00:00 2001 From: Wei He Date: Wed, 18 Dec 2024 22:37:12 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8D=EF=B8=8F=20Rename=20url=20paramete?= =?UTF-8?q?r=20descriptionEditable=20to=20custom=5Fdescription?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #275 Rename `descriptionEditable` to `custom_description` with backwards compatibility. * Rename `descriptionEditable` to `custom_description` in `common/types/queryType.ts`. * Rename `descriptionEditable` to `custom_description` in `src/components/configuration/config.tsx`. * Add backwards compatibility check for `descriptionEditable` in `src/components/configuration/config.tsx`. * Rename `descriptionEditable` to `custom_description` in `common/configHelper.ts`. * Add backwards compatibility check for `descriptionEditable` in `common/configHelper.ts`. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/wei/socialify/issues/275?shareId=XXXX-XXXX-XXXX-XXXX). --- common/configHelper.ts | 2 +- common/types/queryType.ts | 2 +- src/components/configuration/config.tsx | 11 +++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/common/configHelper.ts b/common/configHelper.ts index bbaf9337..1c8d97fb 100644 --- a/common/configHelper.ts +++ b/common/configHelper.ts @@ -66,7 +66,7 @@ const mergeConfig = ( state: query[key as Key] === '1', }) if (config[key as Key]?.editable) { - const editableValue = query[`${key}Editable` as keyof typeof query] + const editableValue = query[`custom_${key}` as keyof typeof query] || query[`${key}Editable` as keyof typeof query] if (editableValue) { Object.assign(config[key as Key] ?? {}, { value: editableValue }) } diff --git a/common/types/queryType.ts b/common/types/queryType.ts index b9fa8f54..bb03a7b6 100644 --- a/common/types/queryType.ts +++ b/common/types/queryType.ts @@ -11,7 +11,7 @@ type QueryType = { issues: string pulls: string description: string - descriptionEditable: string + custom_description: string owner: string name: string logo: string diff --git a/src/components/configuration/config.tsx b/src/components/configuration/config.tsx index 816fae9a..3600d312 100644 --- a/src/components/configuration/config.tsx +++ b/src/components/configuration/config.tsx @@ -51,7 +51,7 @@ export default function Config({ if (value && value.state === true && value.editable) { urlParams[key] = '1' - urlParams[`${key}Editable`] = value.value + urlParams[`custom_${key}`] = value.value } else if (value && value.state === true) { urlParams[key] = '1' } else if (value && value.required === true) { @@ -62,8 +62,8 @@ export default function Config({ if (!urlParams[key] || urlParams[key] === '0') { delete urlParams[key] - if (`${key}Editable` in urlParams) { - delete urlParams[`${key}Editable`] + if (`custom_${key}` in urlParams) { + delete urlParams[`custom_${key}`] } } }) @@ -100,7 +100,10 @@ export default function Config({ state: query === '1', } if (currentConfig?.editable) { - const editableValue = params.get(`${key}Editable`) + const editableValue = params.get(`custom_${key}`) + if (editableValue == null) { + editableValue = params.get(`${key}Editable`) + } if (editableValue != null) { Object.assign(newChange, { value: editableValue,