Skip to content

Commit

Permalink
🔍️ Rename query parameter descriptionEditable to `custom_descriptio…
Browse files Browse the repository at this point in the history
…n` (#457)

🔍️ Rename url parameter descriptionEditable to custom_description

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 authored Dec 19, 2024
1 parent 5e8f2dc commit c7d053d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/kind-knives-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"socialify": minor
---

🔍️ Rename url parameter descriptionEditable to custom_description
2 changes: 1 addition & 1 deletion .devcontainer/post-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

if [ ! -f /home/node/.first_run ]; then
git config --global --add safe.directory $(pwd)
git config --global core.autocrlf true
git config --global core.autocrlf input
git config --global core.editor nano

pnpm config set store-dir $PNPM_STORE_DIR
Expand Down
4 changes: 3 additions & 1 deletion common/configHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ 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
9 changes: 5 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,8 @@ export default function Config({
state: query === '1',
}
if (currentConfig?.editable) {
const editableValue = params.get(`${key}Editable`)
const editableValue =
params.get(`custom_${key}`) || params.get(`${key}Editable`)
if (editableValue != null) {
Object.assign(newChange, {
value: editableValue,
Expand Down

0 comments on commit c7d053d

Please sign in to comment.