mirror of https://github.com/halo-dev/halo-admin
feat: add deleting theme setting and configMap support (#621)
#### What type of PR is this? /kind feature /milestone 2.0 #### What this PR does / why we need it: 支持删除主题的时候删除对应的 Setting 和 ConfigMap 资源。 #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/2325 #### Screenshots: <img width="1004" alt="image" src="https://user-images.githubusercontent.com/21301288/191994812-0ad32b23-e461-4286-9bd7-ce12b413f580.png"> #### Special notes for your reviewer: 测试方式: 1. 安装一个带有设置项的主题并做一定的配置。 2. 选择**卸载并删除配置**的选项。 3. 重新安装主题,检查设置项是否已经恢复为默认。 #### Does this PR introduce a user-facing change? ```release-note 支持卸载主题时,删除对应的 Setting 和 ConfigMap 资源。 ```pull/624/head
parent
87543f9b84
commit
e632ddac9a
|
@ -57,15 +57,38 @@ const handleFetchThemes = async () => {
|
|||
}
|
||||
};
|
||||
|
||||
const handleUninstall = async (theme: Theme) => {
|
||||
const handleUninstall = async (theme: Theme, deleteExtensions?: boolean) => {
|
||||
dialog.warning({
|
||||
title: "是否确定删除该主题?",
|
||||
title: `${
|
||||
deleteExtensions
|
||||
? "是否确认删除该主题以及对应的配置?"
|
||||
: "是否确认删除该主题?"
|
||||
}`,
|
||||
description: "删除后将无法恢复。",
|
||||
onConfirm: async () => {
|
||||
try {
|
||||
await apiClient.extension.theme.deletethemeHaloRunV1alpha1Theme({
|
||||
name: theme.metadata.name,
|
||||
});
|
||||
|
||||
// delete theme setting and configMap
|
||||
if (!deleteExtensions) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { settingName, configMapName } = theme.spec;
|
||||
|
||||
if (settingName) {
|
||||
await apiClient.extension.setting.deletev1alpha1Setting({
|
||||
name: settingName,
|
||||
});
|
||||
}
|
||||
|
||||
if (configMapName) {
|
||||
await apiClient.extension.configMap.deletev1alpha1ConfigMap({
|
||||
name: configMapName,
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Failed to uninstall theme", e);
|
||||
} finally {
|
||||
|
@ -224,6 +247,15 @@ defineExpose({
|
|||
>
|
||||
卸载
|
||||
</VButton>
|
||||
<VButton
|
||||
v-close-popper
|
||||
:disabled="theme.metadata.name === activatedTheme?.metadata?.name"
|
||||
block
|
||||
type="danger"
|
||||
@click="handleUninstall(theme, true)"
|
||||
>
|
||||
卸载并删除配置
|
||||
</VButton>
|
||||
</template>
|
||||
</VEntity>
|
||||
</li>
|
||||
|
|
Loading…
Reference in New Issue