refactor: support configuring plugin when the plugin is stopped (#875)

#### What type of PR is this?

/kind improvement

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

1. 插件停止时支持配置插件设置项。
2. 修改插件异常信息的获取方式。

适配:https://github.com/halo-dev/halo/pull/3355

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

Fixes https://github.com/halo-dev/halo/issues/3352

#### Special notes for your reviewer:

测试方式:

1. Halo 需要切换到 https://github.com/halo-dev/halo/pull/3355 分支。
2. Console 需要 `pnpm build:packages`
3. 根据 https://github.com/halo-dev/halo/pull/3355 中的描述进行测试。

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

```release-note
None
```
pull/888/head
Ryan Wang 2023-02-24 17:52:25 +08:00 committed by GitHub
parent 0eff78787e
commit 08c58ae179
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 19 deletions

View File

@ -12,6 +12,10 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
// May contain unused imports in some cases
// @ts-ignore
import { Condition } from './condition'
/** /**
* *
* @export * @export
@ -26,28 +30,16 @@ export interface PluginStatus {
phase?: PluginStatusPhaseEnum phase?: PluginStatusPhaseEnum
/** /**
* *
* @type {string} * @type {Array<Condition>}
* @memberof PluginStatus * @memberof PluginStatus
*/ */
reason?: string conditions?: Array<Condition>
/**
*
* @type {string}
* @memberof PluginStatus
*/
message?: string
/** /**
* *
* @type {string} * @type {string}
* @memberof PluginStatus * @memberof PluginStatus
*/ */
lastStartTime?: string lastStartTime?: string
/**
*
* @type {string}
* @memberof PluginStatus
*/
lastTransitionTime?: string
/** /**
* *
* @type {string} * @type {string}

View File

@ -66,6 +66,13 @@ const handleResetSettingConfig = async () => {
}, },
}); });
}; };
const getFailedMessage = (plugin: Plugin) => {
if (plugin.status?.conditions?.length) {
const lastCondition = plugin.status.conditions[0];
return [lastCondition.reason, lastCondition.message].join(":");
}
};
</script> </script>
<template> <template>
<PluginUploadModal <PluginUploadModal
@ -105,7 +112,7 @@ const handleResetSettingConfig = async () => {
<VEntityField v-if="plugin?.status?.phase === 'FAILED'"> <VEntityField v-if="plugin?.status?.phase === 'FAILED'">
<template #description> <template #description>
<VStatusDot <VStatusDot
v-tooltip="`${plugin?.status?.reason}:${plugin?.status?.message}`" v-tooltip="getFailedMessage(plugin)"
state="error" state="error"
animate animate
/> />

View File

@ -70,7 +70,7 @@ const handleFetchPlugin = async () => {
}; };
const handleFetchSettings = async () => { const handleFetchSettings = async () => {
if (!plugin.value) return; if (!plugin.value || !plugin.value.spec.settingName) return;
const { data } = await apiClient.plugin.fetchPluginSetting({ const { data } = await apiClient.plugin.fetchPluginSetting({
name: plugin.value?.metadata.name, name: plugin.value?.metadata.name,
}); });
@ -112,9 +112,7 @@ onMounted(async () => {
return; return;
} }
if (isStarted.value) { await handleFetchSettings();
await handleFetchSettings();
}
tabs.value = cloneDeep(initialTabs); tabs.value = cloneDeep(initialTabs);