fix: show plugin error message (#5838)

#### What type of PR is this?

/area ui
/kind bug
/milestone 2.15.0

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

修复插件异常启动时,指示器显示不正确的问题。

Fixes https://github.com/halo-dev/halo/pull/5520

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

```release-note
None
```
pull/5856/head v2.15.0
Ryan Wang 2024-04-30 14:40:24 +08:00 committed by GitHub
parent 1f71532327
commit 2178bd8b80
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 16 deletions

View File

@ -154,14 +154,11 @@ const { startFields, endFields } = useEntityFieldItemExtensionPoint<Plugin>(
!enabled || (enabled && phase === PluginStatusPhaseEnum.Started);
const getStatusDotState = () => {
if (
enabled &&
phase !==
(PluginStatusPhaseEnum.Started || PluginStatusPhaseEnum.Failed)
) {
return "default";
if (enabled && phase === PluginStatusPhaseEnum.Failed) {
return "error";
}
return "error";
return "default";
};
return [

View File

@ -33,16 +33,8 @@ export function usePluginLifeCycle(
const { enabled } = plugin.value.spec || {};
const { phase } = plugin.value.status || {};
// Starting up
if (
enabled &&
phase !== (PluginStatusPhaseEnum.Started || PluginStatusPhaseEnum.Failed)
) {
return t("core.common.status.starting_up");
}
// Starting failed
if (!isStarted.value) {
if (enabled && phase === PluginStatusPhaseEnum.Failed) {
const lastCondition = plugin.value.status?.conditions?.[0];
return (
@ -51,6 +43,14 @@ export function usePluginLifeCycle(
.join(":") || "Unknown"
);
}
// Starting up
if (
enabled &&
phase !== (PluginStatusPhaseEnum.Started || PluginStatusPhaseEnum.Failed)
) {
return t("core.common.status.starting_up");
}
};
const { isLoading: changingStatus, mutate: changeStatus } = useMutation({