Skip to content

Commit

Permalink
๐Ÿ”๏ธ Rename url parameter descriptionEditable to custom_description
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
wei committed Dec 19, 2024
1 parent 5e8f2dc commit d50b166
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion common/configHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
}
Expand Down
2 changes: 1 addition & 1 deletion common/types/queryType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type QueryType = {
issues: string
pulls: string
description: string
descriptionEditable: string
custom_description: string
owner: string
name: string
logo: string
Expand Down
11 changes: 7 additions & 4 deletions src/components/configuration/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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}`]
}
}
})
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit d50b166

Please sign in to comment.