Skip to content

Commit

Permalink
fix: lost the activated theme settings when saving the system settings (
Browse files Browse the repository at this point in the history
#3691)

#### What type of PR is this?

/kind bug
/area console
/milestone 2.5.x

#### What this PR does / why we need it:

修复保存系统设置之后,启用主题的设置丢失,恢复为了默认主题。原因是因为在 #3606 中使用了新的 useSettingFormConvert 方法,但这个方法未考虑到某些 ConfigMap 的分组并未在表单中定义,也就是数据转换方法是以表单的定义为基准,所以丢失了 `theme.active` 设置。

#### Which issue(s) this PR fixes:

Fixes #3673 

#### Special notes for your reviewer:

测试方式:

1. 安装若干主题并启用。
2. 然后去系统设置修改任意数据并保存。
3. 检查主题是否被修改为默认主题。

#### Does this PR introduce a user-facing change?

```release-note
修复保存系统设置之后导致激活主题的设置值丢失,恢复为了默认主题的问题。
```
  • Loading branch information
ruibaby authored Apr 5, 2023
1 parent a466ee7 commit 9b8cec4
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion console/src/composables/use-setting-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,14 @@ export function useSettingFormConvert(
configMap.value?.data?.[form.group] || "{}"
);
});

Object.keys(configMap.value?.data || {}).forEach((key) => {
if (!forms?.find((item) => item.group === key)) {
configMapFormData.value[key] = JSON.parse(
configMap.value?.data?.[key] || "{}"
);
}
});
},
{
immediate: true,
Expand All @@ -236,10 +244,18 @@ export function useSettingFormConvert(
[key: string]: string;
} = {};

setting.value?.spec.forms.forEach((item: SettingForm) => {
const { forms } = setting.value?.spec || {};

forms?.forEach((item: SettingForm) => {
data[item.group] = JSON.stringify(configMapFormData?.value?.[item.group]);
});

Object.keys(configMap.value?.data || {}).forEach((key) => {
if (!forms?.find((item) => item.group === key)) {
data[key] = configMap.value?.data?.[key] || "{}";
}
});

configMapToUpdate.data = data;
return configMapToUpdate;
}
Expand Down

0 comments on commit 9b8cec4

Please sign in to comment.