Merge pull request #5291 from ruibaby/fix/pat-roles

fix: issue of non-template roles being displayed in personal token roles
pull/5310/head
John Niang 2024-01-31 18:13:54 +08:00 committed by GitHub
commit 7543fb6346
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 3 deletions

View File

@ -6,6 +6,7 @@ export enum pluginLabels {
// role
export enum roleLabels {
TEMPLATE = "halo.run/role-template",
HIDDEN = "halo.run/hidden",
SYSTEM_RESERVED = "rbac.authorization.halo.run/system-reserved",
}

View File

@ -7,11 +7,11 @@ import { Dialog, Toast, VButton, VModal, VSpace } from "@halo-dev/components";
import { useMutation, useQueryClient } from "@tanstack/vue-query";
import { useClipboard } from "@vueuse/core";
import type { PatSpec, PersonalAccessToken } from "@halo-dev/api-client";
import { ref } from "vue";
import { computed, ref } from "vue";
import { useRoleTemplateSelection } from "@/composables/use-role";
import { useRoleStore } from "@/stores/role";
import { toRefs } from "vue";
import { useI18n } from "vue-i18n";
import { roleLabels } from "@/constants/labels";
const queryClient = useQueryClient();
const { t } = useI18n();
@ -45,8 +45,17 @@ const formState = ref<
const { permissions } = useRoleStore();
const availableRoleTemplates = computed(() => {
return permissions.permissions.filter((role) => {
return (
role.metadata.labels?.[roleLabels.TEMPLATE] === "true" &&
role.metadata.labels?.[roleLabels.HIDDEN] !== "true"
);
});
});
const { roleTemplateGroups, handleRoleTemplateSelect, selectedRoleTemplates } =
useRoleTemplateSelection(toRefs(permissions).permissions);
useRoleTemplateSelection(availableRoleTemplates);
const { copy } = useClipboard({
legacy: true,