perf: improve the conditions for fetching role templates on the plugin details page (#3626)

#### What type of PR is this?

/kind improvement
/area console
/milestone 2.4.x

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

优化插件详情页面获取角色模板的条件,不查询 label 中带了 `halo.run/hidden` 的角色模板。

#### Special notes for your reviewer:

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

```release-note
优化 Console 端在插件详情页面上获取角色模板的条件
```
pull/3643/head
Ryan Wang 2023-03-30 23:26:14 +08:00 committed by GitHub
parent ddca7731dd
commit 54ca1889ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -4,7 +4,7 @@ import type { Ref } from "vue";
import { computed, inject } from "vue";
import { apiClient } from "@/utils/api-client";
import type { Plugin, Role } from "@halo-dev/api-client";
import { pluginLabels } from "@/constants/labels";
import { pluginLabels, roleLabels } from "@/constants/labels";
import { rbacAnnotations } from "@/constants/annotations";
import { usePluginLifeCycle } from "./composables/use-plugin";
import { formatDatetime } from "@/utils/date";
@ -24,7 +24,11 @@ const { data: pluginRoleTemplates } = useQuery({
const { data } = await apiClient.extension.role.listv1alpha1Role({
page: 0,
size: 0,
labelSelector: [`${pluginLabels.NAME}=${plugin?.value?.metadata.name}`],
labelSelector: [
`${pluginLabels.NAME}=${plugin?.value?.metadata.name}`,
`${roleLabels.TEMPLATE}=true`,
"!halo.run/hidden",
],
});
return data.items;