mirror of https://github.com/halo-dev/halo
refactor: remove the confirmation box of the enable/disable plugin (#4472)
#### What type of PR is this? /area console /kind improvement /milestone 2.9.x #### What this PR does / why we need it: 移除启动/停止插件的确认弹框。 #### Which issue(s) this PR fixes: Fixes #4471 #### Special notes for your reviewer: 测试启动和停止插件是否正常工作即可。 #### Does this PR introduce a user-facing change? ```release-note 移除 Console 端启动/停止插件的确认弹框。 ```pull/4461/head^2
parent
70eb039468
commit
7a057679da
|
@ -736,9 +736,6 @@ core:
|
|||
uninstall_when_enabled:
|
||||
confirm_text: Stop running and uninstall
|
||||
description: The current plugin is still in the enabled state and will be uninstalled after it stops running. This operation cannot be undone.
|
||||
change_status:
|
||||
active_title: Are you sure you want to active this plugin?
|
||||
inactive_title: Are you sure you want to inactive this plugin?
|
||||
remote_download:
|
||||
title: Remote download address detected, do you want to download?
|
||||
description: "Please carefully verify whether this address can be trusted: {url}"
|
||||
|
|
|
@ -736,9 +736,6 @@ core:
|
|||
uninstall_when_enabled:
|
||||
confirm_text: 停止运行并卸载
|
||||
description: 当前插件还在启用状态,将在停止运行后卸载,该操作不可恢复。
|
||||
change_status:
|
||||
active_title: 确定要启用该插件吗?
|
||||
inactive_title: 确定要停用该插件吗?
|
||||
remote_download:
|
||||
title: 检测到了远程下载地址,是否需要下载?
|
||||
description: 请仔细鉴别此地址是否可信:{url}
|
||||
|
|
|
@ -736,9 +736,6 @@ core:
|
|||
uninstall_when_enabled:
|
||||
confirm_text: 停止運行並卸載
|
||||
description: 當前插件還在啟用狀態,將在停止運行後卸載,該操作不可恢復。
|
||||
change_status:
|
||||
active_title: 確定要啟用該插件嗎?
|
||||
inactive_title: 確定要停用該插件嗎?
|
||||
remote_download:
|
||||
title: 偵測到遠端下載地址,是否需要下載?
|
||||
description: 請仔細鑑別此地址是否可信:{url}
|
||||
|
|
|
@ -40,7 +40,7 @@ const emit = defineEmits<{
|
|||
|
||||
const { plugin } = toRefs(props);
|
||||
|
||||
const { getFailedMessage, changeStatus, uninstall } =
|
||||
const { getFailedMessage, changeStatus, changingStatus, uninstall } =
|
||||
usePluginLifeCycle(plugin);
|
||||
|
||||
const handleResetSettingConfig = async () => {
|
||||
|
@ -205,6 +205,7 @@ const { dropdownItems } = useEntityDropdownItemExtensionPoint<Plugin>(
|
|||
<div class="flex items-center">
|
||||
<VSwitch
|
||||
:model-value="plugin?.spec.enabled"
|
||||
:disabled="changingStatus"
|
||||
@click="changeStatus"
|
||||
/>
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import type { ComputedRef, Ref } from "vue";
|
||||
import { computed } from "vue";
|
||||
import { computed, ref } from "vue";
|
||||
import type { Plugin } from "@halo-dev/api-client";
|
||||
import cloneDeep from "lodash.clonedeep";
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
|
@ -10,6 +10,7 @@ interface usePluginLifeCycleReturn {
|
|||
isStarted: ComputedRef<boolean | undefined>;
|
||||
getFailedMessage: () => string | undefined;
|
||||
changeStatus: () => void;
|
||||
changingStatus: Ref<boolean>;
|
||||
uninstall: (deleteExtensions?: boolean) => void;
|
||||
}
|
||||
|
||||
|
@ -36,37 +37,25 @@ export function usePluginLifeCycle(
|
|||
}
|
||||
};
|
||||
|
||||
const changeStatus = () => {
|
||||
const changingStatus = ref(false);
|
||||
|
||||
const changeStatus = async () => {
|
||||
if (!plugin?.value) return;
|
||||
|
||||
const pluginToUpdate = cloneDeep(plugin.value);
|
||||
|
||||
Dialog.info({
|
||||
title: pluginToUpdate.spec.enabled
|
||||
? t("core.plugin.operations.change_status.inactive_title")
|
||||
: t("core.plugin.operations.change_status.active_title"),
|
||||
confirmText: t("core.common.buttons.confirm"),
|
||||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
try {
|
||||
changingStatus.value = true;
|
||||
const pluginToUpdate = cloneDeep(plugin.value);
|
||||
pluginToUpdate.spec.enabled = !pluginToUpdate.spec.enabled;
|
||||
await apiClient.extension.plugin.updatepluginHaloRunV1alpha1Plugin({
|
||||
name: pluginToUpdate.metadata.name,
|
||||
plugin: pluginToUpdate,
|
||||
});
|
||||
|
||||
Toast.success(
|
||||
pluginToUpdate.spec.enabled
|
||||
? t("core.common.toast.active_success")
|
||||
: t("core.common.toast.inactive_success")
|
||||
);
|
||||
window.location.reload();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
} finally {
|
||||
window.location.reload();
|
||||
changingStatus.value = false;
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const uninstall = (deleteExtensions?: boolean) => {
|
||||
|
@ -150,6 +139,7 @@ export function usePluginLifeCycle(
|
|||
isStarted,
|
||||
getFailedMessage,
|
||||
changeStatus,
|
||||
changingStatus,
|
||||
uninstall,
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue