Skip to content
This repository was archived by the owner on Jan 21, 2024. It is now read-only.

Commit 08c58ae

Browse files
authored
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. 修改插件异常信息的获取方式。 适配:halo-dev/halo#3355 #### Which issue(s) this PR fixes: Fixes halo-dev/halo#3352 #### Special notes for your reviewer: 测试方式: 1. Halo 需要切换到 halo-dev/halo#3355 分支。 2. Console 需要 `pnpm build:packages` 3. 根据 halo-dev/halo#3355 中的描述进行测试。 #### Does this PR introduce a user-facing change? ```release-note None ```
1 parent 0eff787 commit 08c58ae

File tree

3 files changed

+16
-19
lines changed

3 files changed

+16
-19
lines changed

packages/api-client/src/models/plugin-status.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
* Do not edit the class manually.
1313
*/
1414

15+
// May contain unused imports in some cases
16+
// @ts-ignore
17+
import { Condition } from './condition'
18+
1519
/**
1620
*
1721
* @export
@@ -26,28 +30,16 @@ export interface PluginStatus {
2630
phase?: PluginStatusPhaseEnum
2731
/**
2832
*
29-
* @type {string}
30-
* @memberof PluginStatus
31-
*/
32-
reason?: string
33-
/**
34-
*
35-
* @type {string}
33+
* @type {Array<Condition>}
3634
* @memberof PluginStatus
3735
*/
38-
message?: string
36+
conditions?: Array<Condition>
3937
/**
4038
*
4139
* @type {string}
4240
* @memberof PluginStatus
4341
*/
4442
lastStartTime?: string
45-
/**
46-
*
47-
* @type {string}
48-
* @memberof PluginStatus
49-
*/
50-
lastTransitionTime?: string
5143
/**
5244
*
5345
* @type {string}

src/modules/system/plugins/components/PluginListItem.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ const handleResetSettingConfig = async () => {
6666
},
6767
});
6868
};
69+
70+
const getFailedMessage = (plugin: Plugin) => {
71+
if (plugin.status?.conditions?.length) {
72+
const lastCondition = plugin.status.conditions[0];
73+
return [lastCondition.reason, lastCondition.message].join(":");
74+
}
75+
};
6976
</script>
7077
<template>
7178
<PluginUploadModal
@@ -105,7 +112,7 @@ const handleResetSettingConfig = async () => {
105112
<VEntityField v-if="plugin?.status?.phase === 'FAILED'">
106113
<template #description>
107114
<VStatusDot
108-
v-tooltip="`${plugin?.status?.reason}:${plugin?.status?.message}`"
115+
v-tooltip="getFailedMessage(plugin)"
109116
state="error"
110117
animate
111118
/>

src/modules/system/plugins/layouts/PluginLayout.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const handleFetchPlugin = async () => {
7070
};
7171
7272
const handleFetchSettings = async () => {
73-
if (!plugin.value) return;
73+
if (!plugin.value || !plugin.value.spec.settingName) return;
7474
const { data } = await apiClient.plugin.fetchPluginSetting({
7575
name: plugin.value?.metadata.name,
7676
});
@@ -112,9 +112,7 @@ onMounted(async () => {
112112
return;
113113
}
114114
115-
if (isStarted.value) {
116-
await handleFetchSettings();
117-
}
115+
await handleFetchSettings();
118116
119117
tabs.value = cloneDeep(initialTabs);
120118

0 commit comments

Comments
 (0)