From ff7af9f0d939afeb6a5029e6aa57314bbe50b552 Mon Sep 17 00:00:00 2001 From: longjuan <769022681@qq.com> Date: Thu, 19 Oct 2023 13:32:25 +0800 Subject: [PATCH 1/7] fix: plugin extension tab cannot be displayed when only having plugin view permissions (#4746) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind bug /area console #### What this PR does / why we need it: 修复用户仅拥有插件查看权限时,有setting的插件会导致无法加载插件扩展tab的问题 #### Which issue(s) this PR fixes: Fixes #4732 #### Special notes for your reviewer: 1. 使用如下测试版 s3 插件 [plugin-s3-1.5.0-SNAPSHOT.jar.zip](https://github.com/halo-dev/halo/files/12914987/plugin-s3-1.5.0-SNAPSHOT.jar.zip) 2. 创建一个用户,仅赋予 S3 Link 权限(依赖于插件查看和附件管理权限) 3. 登录这个新用户,打开 s3 插件详情 4. 观察 关联S3文件 功能是否正常出现 #### Does this PR introduce a user-facing change? ```release-note 修复部分场景下插件详情的扩展 tab 不能正常显示的问题 ``` --- console/src/modules/system/plugins/PluginDetail.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/console/src/modules/system/plugins/PluginDetail.vue b/console/src/modules/system/plugins/PluginDetail.vue index 1f321e05ec..d17a55f823 100644 --- a/console/src/modules/system/plugins/PluginDetail.vue +++ b/console/src/modules/system/plugins/PluginDetail.vue @@ -51,7 +51,10 @@ const { data: plugin } = useQuery({ return data; }, onSuccess(data) { - if (!data.spec.settingName) { + if ( + !data.spec.settingName || + !currentUserHasPermission(["system:plugins:manage"]) + ) { tabs.value = [...initialTabs.value, ...getTabsFromExtensions()]; } }, From 4af82712e1b07b2510b1cdac5bf19499edf7aca4 Mon Sep 17 00:00:00 2001 From: zjy4fun Date: Thu, 19 Oct 2023 16:36:25 +0800 Subject: [PATCH 2/7] Fix the display error in the comments page status filter text (#4743) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind bug /area console #### What this PR does / why we need it: ![fix-status-filter-2](https://github.com/halo-dev/halo/assets/106857035/e1f0a7ea-1328-45f2-ad06-cf14e91b8e4a) #### Which issue(s) this PR fixes: Fixes #4731 #### Special notes for your reviewer: #### Does this PR introduce a user-facing change? ```release-note 修复 Console 端评论状态筛选无法显示筛选结果的问题 ``` --- console/src/modules/contents/comments/CommentList.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/console/src/modules/contents/comments/CommentList.vue b/console/src/modules/contents/comments/CommentList.vue index 80a2301108..7b8c99b775 100644 --- a/console/src/modules/contents/comments/CommentList.vue +++ b/console/src/modules/contents/comments/CommentList.vue @@ -273,13 +273,13 @@ const handleApproveInBatch = async () => { }, { label: t('core.comment.filters.status.items.approved'), - value: 'true', + value: true, }, { label: t( 'core.comment.filters.status.items.pending_review' ), - value: 'false', + value: false, }, ]" /> From 21e975d60a08f58cb00fc730684afb9a46075c5f Mon Sep 17 00:00:00 2001 From: John Niang Date: Thu, 19 Oct 2023 22:24:44 -0500 Subject: [PATCH 3/7] Upgrade to Spring Boot 3.1.5 (#4758) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind cleanup #### What this PR does / why we need it: Upgrade to Spring Boot 3.1.5. See https://github.com/spring-projects/spring-boot/releases/tag/v3.1.5 for more. #### Does this PR introduce a user-facing change? ```release-note 升级依赖 Spring Boot 至 3.1.5 ``` --- application/build.gradle | 2 +- platform/application/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/application/build.gradle b/application/build.gradle index 24e90ad94e..71baa80605 100644 --- a/application/build.gradle +++ b/application/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'org.springframework.boot' version '3.1.4' + id 'org.springframework.boot' version '3.1.5' id 'io.spring.dependency-management' version '1.1.0' id "com.gorylenko.gradle-git-properties" version "2.3.2" id "checkstyle" diff --git a/platform/application/build.gradle b/platform/application/build.gradle index 6f728cac86..bf775c48d2 100644 --- a/platform/application/build.gradle +++ b/platform/application/build.gradle @@ -1,7 +1,7 @@ import org.springframework.boot.gradle.plugin.SpringBootPlugin plugins { - id 'org.springframework.boot' version '3.1.4' apply false + id 'org.springframework.boot' version '3.1.5' apply false id 'java-platform' id 'halo.publish' id 'signing' From 772c7fcf97ca49e1f68200ba4dc8aa1dd556b32d Mon Sep 17 00:00:00 2001 From: guqing <38999863+guqing@users.noreply.github.com> Date: Mon, 23 Oct 2023 11:07:13 +0800 Subject: [PATCH 4/7] refactor: provide API for change plugin motion status synchronously (#4745) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind improvement /area core /area console #### What this PR does / why we need it: 提供允许同步更改插件运行状态的 API #### Which issue(s) this PR fixes: Fixes #4744 #### Does this PR introduce a user-facing change? ```release-note 提供允许同步更改插件运行状态的 API ``` --- .../extension/endpoint/PluginEndpoint.java | 73 +++++++++++++++++++ .../extensions/role-template-plugin.yaml | 2 +- 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/application/src/main/java/run/halo/app/core/extension/endpoint/PluginEndpoint.java b/application/src/main/java/run/halo/app/core/extension/endpoint/PluginEndpoint.java index 0a3ca14c33..d6d015c1ff 100644 --- a/application/src/main/java/run/halo/app/core/extension/endpoint/PluginEndpoint.java +++ b/application/src/main/java/run/halo/app/core/extension/endpoint/PluginEndpoint.java @@ -40,7 +40,9 @@ import java.util.function.Predicate; import java.util.function.Supplier; import lombok.AllArgsConstructor; +import lombok.Data; import lombok.extern.slf4j.Slf4j; +import org.pf4j.PluginState; import org.reactivestreams.Publisher; import org.springdoc.webflux.core.fn.SpringdocRouteBuilder; import org.springframework.beans.factory.DisposableBean; @@ -201,6 +203,27 @@ public RouterFunction endpoint() { .response(responseBuilder() .implementation(Plugin.class)) ) + .PUT("plugins/{name}/plugin-state", this::changePluginRunningState, + builder -> builder.operationId("ChangePluginRunningState") + .description("Change the running state of a plugin by name.") + .tag(tag) + .parameter(parameterBuilder() + .name("name") + .in(ParameterIn.PATH) + .required(true) + .implementation(String.class) + ) + .requestBody(requestBodyBuilder() + .required(true) + .content(contentBuilder() + .mediaType(MediaType.APPLICATION_JSON_VALUE) + .schema(schemaBuilder() + .implementation(RunningStateRequest.class)) + ) + ) + .response(responseBuilder() + .implementation(Plugin.class)) + ) .GET("plugins", this::list, builder -> { builder.operationId("ListPlugins") .tag(tag) @@ -255,6 +278,56 @@ public RouterFunction endpoint() { .build(); } + Mono changePluginRunningState(ServerRequest request) { + final var name = request.pathVariable("name"); + return request.bodyToMono(RunningStateRequest.class) + .flatMap(runningState -> { + final var enable = runningState.isEnable(); + return client.get(Plugin.class, name) + .flatMap(plugin -> { + plugin.getSpec().setEnabled(enable); + return client.update(plugin); + }) + .flatMap(plugin -> { + if (runningState.isAsync()) { + return Mono.just(plugin); + } + return waitForPluginToMeetExpectedState(name, p -> { + // when enabled = true,excepted phase = started || failed + // when enabled = false,excepted phase = !started + var phase = p.statusNonNull().getPhase(); + if (enable) { + return PluginState.STARTED.equals(phase) + || PluginState.FAILED.equals(phase); + } + return !PluginState.STARTED.equals(phase); + }); + }); + }) + .flatMap(plugin -> ServerResponse.ok().bodyValue(plugin)); + } + + Mono waitForPluginToMeetExpectedState(String name, Predicate predicate) { + return Mono.defer(() -> client.get(Plugin.class, name) + .map(plugin -> { + if (predicate.test(plugin)) { + return plugin; + } + throw new IllegalStateException("Plugin " + name + " is not in expected state"); + }) + ) + .retryWhen(Retry.backoff(10, Duration.ofMillis(100)) + .filter(IllegalStateException.class::isInstance) + ); + } + + @Data + @Schema(name = "PluginRunningStateRequest") + static class RunningStateRequest { + private boolean enable; + private boolean async; + } + private Mono fetchJsBundle(ServerRequest request) { Optional versionOption = request.queryParam("v"); return versionOption.map(s -> diff --git a/application/src/main/resources/extensions/role-template-plugin.yaml b/application/src/main/resources/extensions/role-template-plugin.yaml index e3e9bc1bd8..82ff040a29 100644 --- a/application/src/main/resources/extensions/role-template-plugin.yaml +++ b/application/src/main/resources/extensions/role-template-plugin.yaml @@ -17,7 +17,7 @@ rules: verbs: [ "create", "patch", "update", "delete", "deletecollection" ] - apiGroups: [ "api.console.halo.run" ] resources: [ "plugins/upgrade", "plugins/resetconfig", "plugins/config", "plugins/reload", - "plugins/install-from-uri", "plugins/upgrade-from-uri" ] + "plugins/install-from-uri", "plugins/upgrade-from-uri", "plugins/plugin-state" ] verbs: [ "*" ] - apiGroups: [ "api.console.halo.run" ] resources: [ "plugin-presets" ] From baca058bb315c515592a84d786d2d65e4650cb9d Mon Sep 17 00:00:00 2001 From: guqing <38999863+guqing@users.noreply.github.com> Date: Mon, 23 Oct 2023 16:13:24 +0800 Subject: [PATCH 5/7] fix: incorrect results when filtering unpublished posts (#4736) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind bug /area core /milestone 2.10.x #### What this PR does / why we need it: 修复筛选未发布文章时结果不正确的问题 #### Which issue(s) this PR fixes: Fixes #4730 #### Does this PR introduce a user-facing change? ```release-note 修复筛选未发布文章时结果不正确的问题 ``` --- .../halo/app/core/extension/reconciler/PostReconciler.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/application/src/main/java/run/halo/app/core/extension/reconciler/PostReconciler.java b/application/src/main/java/run/halo/app/core/extension/reconciler/PostReconciler.java index 68e8585354..eb182a51a7 100644 --- a/application/src/main/java/run/halo/app/core/extension/reconciler/PostReconciler.java +++ b/application/src/main/java/run/halo/app/core/extension/reconciler/PostReconciler.java @@ -13,6 +13,7 @@ import java.util.Optional; import java.util.Set; import lombok.AllArgsConstructor; +import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.jsoup.Jsoup; import org.springframework.context.ApplicationEvent; @@ -102,6 +103,10 @@ public Result reconcile(Request request) { post.getMetadata().setAnnotations(annotations); } + if (!annotations.containsKey(Post.PUBLISHED_LABEL)) { + labels.put(Post.PUBLISHED_LABEL, BooleanUtils.FALSE); + } + var status = post.getStatus(); if (status == null) { status = new Post.PostStatus(); From e20ab8f880dbb53d300d08905c00a3eeece7e0d4 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Thu, 26 Oct 2023 10:56:14 +0800 Subject: [PATCH 6/7] refactor: use new api to change plugin status (#4747) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /area console /kind improvement #### What this PR does / why we need it: 适配 https://github.com/halo-dev/halo/pull/4745 ,使用新的接口启动/停止插件。 #### Which issue(s) this PR fixes: Fixes #4744 #### Special notes for your reviewer: #### Does this PR introduce a user-facing change? ```release-note None ``` --- .../api-client/src/.openapi-generator/FILES | 1 + ...pi-console-halo-run-v1alpha1-plugin-api.ts | 157 ++++++++++++++++++ .../api-client/src/models/contributor-vo.ts | 10 ++ .../packages/api-client/src/models/index.ts | 1 + .../models/plugin-running-state-request.ts | 33 ++++ .../system/plugins/composables/use-plugin.ts | 70 ++------ .../modules/system/plugins/tabs/Detail.vue | 8 +- console/src/views/system/SetupInitialData.vue | 32 ++-- 8 files changed, 232 insertions(+), 80 deletions(-) create mode 100644 console/packages/api-client/src/models/plugin-running-state-request.ts diff --git a/console/packages/api-client/src/.openapi-generator/FILES b/console/packages/api-client/src/.openapi-generator/FILES index 2f683a17ee..b77775a670 100644 --- a/console/packages/api-client/src/.openapi-generator/FILES +++ b/console/packages/api-client/src/.openapi-generator/FILES @@ -187,6 +187,7 @@ models/personal-access-token-list.ts models/personal-access-token.ts models/plugin-author.ts models/plugin-list.ts +models/plugin-running-state-request.ts models/plugin-spec.ts models/plugin-status.ts models/plugin.ts diff --git a/console/packages/api-client/src/api/api-console-halo-run-v1alpha1-plugin-api.ts b/console/packages/api-client/src/api/api-console-halo-run-v1alpha1-plugin-api.ts index 0372193067..12e8463ddf 100644 --- a/console/packages/api-client/src/api/api-console-halo-run-v1alpha1-plugin-api.ts +++ b/console/packages/api-client/src/api/api-console-halo-run-v1alpha1-plugin-api.ts @@ -46,6 +46,8 @@ import { Plugin } from "../models"; // @ts-ignore import { PluginList } from "../models"; // @ts-ignore +import { PluginRunningStateRequest } from "../models"; +// @ts-ignore import { Setting } from "../models"; // @ts-ignore import { UpgradeFromUriRequest } from "../models"; @@ -57,6 +59,75 @@ export const ApiConsoleHaloRunV1alpha1PluginApiAxiosParamCreator = function ( configuration?: Configuration ) { return { + /** + * Change the running state of a plugin by name. + * @param {string} name + * @param {PluginRunningStateRequest} pluginRunningStateRequest + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + changePluginRunningState: async ( + name: string, + pluginRunningStateRequest: PluginRunningStateRequest, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'name' is not null or undefined + assertParamExists("changePluginRunningState", "name", name); + // verify required parameter 'pluginRunningStateRequest' is not null or undefined + assertParamExists( + "changePluginRunningState", + "pluginRunningStateRequest", + pluginRunningStateRequest + ); + const localVarPath = + `/apis/api.console.halo.run/v1alpha1/plugins/{name}/plugin-state`.replace( + `{${"name"}}`, + encodeURIComponent(String(name)) + ); + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { + method: "PUT", + ...baseOptions, + ...options, + }; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication BasicAuth required + // http basic authentication required + setBasicAuthToObject(localVarRequestOptions, configuration); + + // authentication BearerAuth required + // http bearer authentication required + await setBearerAuthToObject(localVarHeaderParameter, configuration); + + localVarHeaderParameter["Content-Type"] = "application/json"; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + localVarRequestOptions.data = serializeDataIfNeeded( + pluginRunningStateRequest, + localVarRequestOptions, + configuration + ); + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, /** * Merge all CSS bundles of enabled plugins into one. * @param {*} [options] Override http request option. @@ -855,6 +926,33 @@ export const ApiConsoleHaloRunV1alpha1PluginApiFp = function ( const localVarAxiosParamCreator = ApiConsoleHaloRunV1alpha1PluginApiAxiosParamCreator(configuration); return { + /** + * Change the running state of a plugin by name. + * @param {string} name + * @param {PluginRunningStateRequest} pluginRunningStateRequest + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async changePluginRunningState( + name: string, + pluginRunningStateRequest: PluginRunningStateRequest, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.changePluginRunningState( + name, + pluginRunningStateRequest, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, /** * Merge all CSS bundles of enabled plugins into one. * @param {*} [options] Override http request option. @@ -1194,6 +1292,24 @@ export const ApiConsoleHaloRunV1alpha1PluginApiFactory = function ( ) { const localVarFp = ApiConsoleHaloRunV1alpha1PluginApiFp(configuration); return { + /** + * Change the running state of a plugin by name. + * @param {ApiConsoleHaloRunV1alpha1PluginApiChangePluginRunningStateRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + changePluginRunningState( + requestParameters: ApiConsoleHaloRunV1alpha1PluginApiChangePluginRunningStateRequest, + options?: AxiosRequestConfig + ): AxiosPromise { + return localVarFp + .changePluginRunningState( + requestParameters.name, + requestParameters.pluginRunningStateRequest, + options + ) + .then((request) => request(axios, basePath)); + }, /** * Merge all CSS bundles of enabled plugins into one. * @param {*} [options] Override http request option. @@ -1397,6 +1513,27 @@ export const ApiConsoleHaloRunV1alpha1PluginApiFactory = function ( }; }; +/** + * Request parameters for changePluginRunningState operation in ApiConsoleHaloRunV1alpha1PluginApi. + * @export + * @interface ApiConsoleHaloRunV1alpha1PluginApiChangePluginRunningStateRequest + */ +export interface ApiConsoleHaloRunV1alpha1PluginApiChangePluginRunningStateRequest { + /** + * + * @type {string} + * @memberof ApiConsoleHaloRunV1alpha1PluginApiChangePluginRunningState + */ + readonly name: string; + + /** + * + * @type {PluginRunningStateRequest} + * @memberof ApiConsoleHaloRunV1alpha1PluginApiChangePluginRunningState + */ + readonly pluginRunningStateRequest: PluginRunningStateRequest; +} + /** * Request parameters for fetchPluginConfig operation in ApiConsoleHaloRunV1alpha1PluginApi. * @export @@ -1635,6 +1772,26 @@ export interface ApiConsoleHaloRunV1alpha1PluginApiUpgradePluginFromUriRequest { * @extends {BaseAPI} */ export class ApiConsoleHaloRunV1alpha1PluginApi extends BaseAPI { + /** + * Change the running state of a plugin by name. + * @param {ApiConsoleHaloRunV1alpha1PluginApiChangePluginRunningStateRequest} requestParameters Request parameters. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ApiConsoleHaloRunV1alpha1PluginApi + */ + public changePluginRunningState( + requestParameters: ApiConsoleHaloRunV1alpha1PluginApiChangePluginRunningStateRequest, + options?: AxiosRequestConfig + ) { + return ApiConsoleHaloRunV1alpha1PluginApiFp(this.configuration) + .changePluginRunningState( + requestParameters.name, + requestParameters.pluginRunningStateRequest, + options + ) + .then((request) => request(this.axios, this.basePath)); + } + /** * Merge all CSS bundles of enabled plugins into one. * @param {*} [options] Override http request option. diff --git a/console/packages/api-client/src/models/contributor-vo.ts b/console/packages/api-client/src/models/contributor-vo.ts index bc02317f18..ad59631fb3 100644 --- a/console/packages/api-client/src/models/contributor-vo.ts +++ b/console/packages/api-client/src/models/contributor-vo.ts @@ -12,6 +12,10 @@ * Do not edit the class manually. */ +// May contain unused imports in some cases +// @ts-ignore +import { Metadata } from "./metadata"; + /** * * @export @@ -36,6 +40,12 @@ export interface ContributorVo { * @memberof ContributorVo */ displayName?: string; + /** + * + * @type {Metadata} + * @memberof ContributorVo + */ + metadata: Metadata; /** * * @type {string} diff --git a/console/packages/api-client/src/models/index.ts b/console/packages/api-client/src/models/index.ts index 46e5a3e834..9307469393 100644 --- a/console/packages/api-client/src/models/index.ts +++ b/console/packages/api-client/src/models/index.ts @@ -111,6 +111,7 @@ export * from "./personal-access-token-list"; export * from "./plugin"; export * from "./plugin-author"; export * from "./plugin-list"; +export * from "./plugin-running-state-request"; export * from "./plugin-spec"; export * from "./plugin-status"; export * from "./policy"; diff --git a/console/packages/api-client/src/models/plugin-running-state-request.ts b/console/packages/api-client/src/models/plugin-running-state-request.ts new file mode 100644 index 0000000000..1121d2122b --- /dev/null +++ b/console/packages/api-client/src/models/plugin-running-state-request.ts @@ -0,0 +1,33 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Halo Next API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * + * @export + * @interface PluginRunningStateRequest + */ +export interface PluginRunningStateRequest { + /** + * + * @type {boolean} + * @memberof PluginRunningStateRequest + */ + async?: boolean; + /** + * + * @type {boolean} + * @memberof PluginRunningStateRequest + */ + enable?: boolean; +} diff --git a/console/src/modules/system/plugins/composables/use-plugin.ts b/console/src/modules/system/plugins/composables/use-plugin.ts index 9408e7247e..6bb856d096 100644 --- a/console/src/modules/system/plugins/composables/use-plugin.ts +++ b/console/src/modules/system/plugins/composables/use-plugin.ts @@ -1,6 +1,6 @@ import type { ComputedRef, Ref } from "vue"; import { computed } from "vue"; -import type { Plugin } from "@halo-dev/api-client"; +import { type Plugin } from "@halo-dev/api-client"; import cloneDeep from "lodash.clonedeep"; import { apiClient } from "@/utils/api-client"; import { Dialog, Toast } from "@halo-dev/components"; @@ -43,22 +43,14 @@ export function usePluginLifeCycle( mutationFn: async () => { if (!plugin?.value) return; - const { data: pluginToUpdate } = - await apiClient.extension.plugin.getpluginHaloRunV1alpha1Plugin({ - name: plugin.value.metadata.name, - }); + const { enabled } = plugin.value.spec; - pluginToUpdate.spec.enabled = !pluginToUpdate.spec.enabled; - - const { data: newPlugin } = - await apiClient.extension.plugin.updatepluginHaloRunV1alpha1Plugin({ - name: pluginToUpdate.metadata.name, - plugin: pluginToUpdate, - }); - - await checkStatus(newPlugin); - - return newPlugin; + return await apiClient.plugin.changePluginRunningState({ + name: plugin.value.metadata.name, + pluginRunningStateRequest: { + enable: !enabled, + }, + }); }, retry: 3, retryDelay: 1000, @@ -67,38 +59,6 @@ export function usePluginLifeCycle( }, }); - function checkStatus(plugin: Plugin) { - const maxRetry = 5; - let retryCount = 0; - return new Promise((resolve, reject) => { - const check = () => { - if (retryCount >= maxRetry) { - reject(false); - return; - } - apiClient.extension.plugin - .getpluginHaloRunV1alpha1Plugin({ name: plugin.metadata.name }) - .then((response) => { - const { enabled } = response.data.spec; - const { phase } = response.data.status || {}; - if ( - (enabled && phase === "STARTED") || - (!enabled && phase !== "STARTED") - ) { - resolve(true); - } else { - setTimeout(check, 1000); - retryCount++; - } - }) - .catch(() => { - reject(false); - }); - }; - check(); - }); - } - const uninstall = (deleteExtensions?: boolean) => { if (!plugin?.value) return; @@ -260,15 +220,11 @@ export function usePluginBatchOperations(names: Ref) { onConfirm: async () => { try { for (let i = 0; i < names.value.length; i++) { - const { data: pluginToUpdate } = - await apiClient.extension.plugin.getpluginHaloRunV1alpha1Plugin({ - name: names.value[i], - }); - - pluginToUpdate.spec.enabled = enabled; - await apiClient.extension.plugin.updatepluginHaloRunV1alpha1Plugin({ - name: pluginToUpdate.metadata.name, - plugin: pluginToUpdate, + await apiClient.plugin.changePluginRunningState({ + name: names.value[i], + pluginRunningStateRequest: { + enable: enabled, + }, }); } diff --git a/console/src/modules/system/plugins/tabs/Detail.vue b/console/src/modules/system/plugins/tabs/Detail.vue index 2e1e14af82..310e27bd65 100644 --- a/console/src/modules/system/plugins/tabs/Detail.vue +++ b/console/src/modules/system/plugins/tabs/Detail.vue @@ -16,7 +16,7 @@ import { formatDatetime } from "@/utils/date"; import { useQuery } from "@tanstack/vue-query"; const plugin = inject>("plugin"); -const { changeStatus } = usePluginLifeCycle(plugin); +const { changeStatus, changingStatus } = usePluginLifeCycle(plugin); interface RoleTemplateGroup { module: string | null | undefined; @@ -72,7 +72,11 @@ const pluginRoleTemplateGroups = computed(() => {
- +
{ - const { data: pluginToUpdate } = - await apiClient.extension.plugin.getpluginHaloRunV1alpha1Plugin({ - name: plugin.metadata.name, - }); - - pluginToUpdate.spec.enabled = true; - - return apiClient.extension.plugin.updatepluginHaloRunV1alpha1Plugin( - { - name: plugin.metadata.name, - plugin: pluginToUpdate, + return await apiClient.plugin.changePluginRunningState({ + name: plugin.metadata.name, + pluginRunningStateRequest: { + enable: true, }, - { - mute: true, - } - ); + }); }, retry: 3, retryDelay: 1000, From 2dbfbd1bd007bc0f97ad5b3c9a454ef194741273 Mon Sep 17 00:00:00 2001 From: Takagi <1103069291@qq.com> Date: Thu, 26 Oct 2023 15:58:15 +0800 Subject: [PATCH 7/7] fix: resolve the issue of occasional blank annotation and error occurrences (#4772) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind bug #### What this PR does / why we need it: 在获取自定义元数据时,将空白 key 与重复的 key 过滤,用于解决可能出现的额外空白元数据及报错问题。 #### How to test it? 尝试点击编辑文章 -> 设置,查看是否有额外空白元数据的出现。 由于是概率性问题,因此若本地环境未复现,则需要使用生产环境进行验证。 #### Which issue(s) this PR fixes: Fixes #4764 #### Does this PR introduce a user-facing change? ```release-note 解决文章设置中可能出现空白元数据的问题 ``` --- console/src/components/form/AnnotationsForm.vue | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/console/src/components/form/AnnotationsForm.vue b/console/src/components/form/AnnotationsForm.vue index ecac8aa2ab..11cb240052 100644 --- a/console/src/components/form/AnnotationsForm.vue +++ b/console/src/components/form/AnnotationsForm.vue @@ -109,8 +109,15 @@ const handleProcessCustomAnnotations = () => { value, }; } + return { + key: "", + value: "", + }; }) - .filter((item) => item) as { key: string; value: string }[]; + .filter((item) => item.key) + .filter( + (item, index, self) => self.findIndex((t) => t.key === item.key) === index + ); annotations.value = formSchemas .map((item) => {