mirror of https://github.com/halo-dev/halo-admin
feat: add deleting plugin setting and configMap support
Signed-off-by: Ryan Wang <i@ryanc.cc>pull/636/head
parent
95d58fbcdb
commit
ca141d7da6
|
@ -107,6 +107,9 @@ const { isStarted, changeStatus, uninstall } = usePluginLifeCycle(plugin);
|
||||||
<VButton v-close-popper block type="danger" @click="uninstall">
|
<VButton v-close-popper block type="danger" @click="uninstall">
|
||||||
卸载
|
卸载
|
||||||
</VButton>
|
</VButton>
|
||||||
|
<VButton v-close-popper block type="danger" @click="uninstall(true)">
|
||||||
|
卸载并删除配置
|
||||||
|
</VButton>
|
||||||
</template>
|
</template>
|
||||||
</VEntity>
|
</VEntity>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { useDialog } from "@halo-dev/components";
|
||||||
interface usePluginLifeCycleReturn {
|
interface usePluginLifeCycleReturn {
|
||||||
isStarted: ComputedRef<boolean | undefined>;
|
isStarted: ComputedRef<boolean | undefined>;
|
||||||
changeStatus: () => void;
|
changeStatus: () => void;
|
||||||
uninstall: () => void;
|
uninstall: (deleteExtensions?: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function usePluginLifeCycle(
|
export function usePluginLifeCycle(
|
||||||
|
@ -45,13 +45,17 @@ export function usePluginLifeCycle(
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const uninstall = () => {
|
const uninstall = (deleteExtensions?: boolean) => {
|
||||||
if (!plugin?.value) return;
|
if (!plugin?.value) return;
|
||||||
|
|
||||||
const { enabled } = plugin.value.spec;
|
const { enabled } = plugin.value.spec;
|
||||||
|
|
||||||
dialog.warning({
|
dialog.warning({
|
||||||
title: `确定要卸载该插件吗?`,
|
title: `${
|
||||||
|
deleteExtensions
|
||||||
|
? "是否确认卸载该插件以及对应的配置?"
|
||||||
|
: "是否确认卸载该插件?"
|
||||||
|
}`,
|
||||||
description: `${
|
description: `${
|
||||||
enabled ? "当前插件还在启用状态,将在停止运行后卸载。" : ""
|
enabled ? "当前插件还在启用状态,将在停止运行后卸载。" : ""
|
||||||
}`,
|
}`,
|
||||||
|
@ -73,8 +77,27 @@ export function usePluginLifeCycle(
|
||||||
await apiClient.extension.plugin.deletepluginHaloRunV1alpha1Plugin({
|
await apiClient.extension.plugin.deletepluginHaloRunV1alpha1Plugin({
|
||||||
name: plugin.value.metadata.name,
|
name: plugin.value.metadata.name,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// delete plugin setting and configMap
|
||||||
|
if (!deleteExtensions) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { settingName, configMapName } = plugin.value.spec;
|
||||||
|
|
||||||
|
if (settingName) {
|
||||||
|
await apiClient.extension.setting.deletev1alpha1Setting({
|
||||||
|
name: settingName,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configMapName) {
|
||||||
|
await apiClient.extension.configMap.deletev1alpha1ConfigMap({
|
||||||
|
name: configMapName,
|
||||||
|
});
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error("Failed to uninstall plugin", e);
|
||||||
} finally {
|
} finally {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue