mirror of https://github.com/halo-dev/halo
Fix role dependency handling in role editing form (#7684)
#### What type of PR is this? /area ui /kind bug /milestone 2.21.x #### What this PR does / why we need it: See #7676 #### Which issue(s) this PR fixes: Fixes #7676 #### Special notes for your reviewer: #### Does this PR introduce a user-facing change? ```release-note 修复角色修改表单中,所选权限可能出现不完整的问题。 ```pull/7700/head
parent
3345ccb035
commit
e6f8783389
|
@ -4,6 +4,7 @@ import { useRoleForm, useRoleTemplateSelection } from "@/composables/use-role";
|
||||||
import { rbacAnnotations } from "@/constants/annotations";
|
import { rbacAnnotations } from "@/constants/annotations";
|
||||||
import { pluginLabels, roleLabels } from "@/constants/labels";
|
import { pluginLabels, roleLabels } from "@/constants/labels";
|
||||||
import { setFocus } from "@/formkit/utils/focus";
|
import { setFocus } from "@/formkit/utils/focus";
|
||||||
|
import { resolveDeepDependencies } from "@/utils/role";
|
||||||
import type { Role } from "@halo-dev/api-client";
|
import type { Role } from "@halo-dev/api-client";
|
||||||
import { coreApiClient } from "@halo-dev/api-client";
|
import { coreApiClient } from "@halo-dev/api-client";
|
||||||
import { VButton, VModal, VSpace } from "@halo-dev/components";
|
import { VButton, VModal, VSpace } from "@halo-dev/components";
|
||||||
|
@ -61,11 +62,9 @@ onMounted(() => {
|
||||||
|
|
||||||
if (props.role) {
|
if (props.role) {
|
||||||
formState.value = cloneDeep(props.role);
|
formState.value = cloneDeep(props.role);
|
||||||
const dependencies =
|
selectedRoleTemplates.value = new Set<string>(
|
||||||
props.role.metadata.annotations?.[rbacAnnotations.DEPENDENCIES];
|
resolveDeepDependencies(props.role, roleTemplates.value || [])
|
||||||
if (dependencies) {
|
);
|
||||||
selectedRoleTemplates.value = new Set(JSON.parse(dependencies));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -74,13 +73,8 @@ const editingModalTitle = props.role
|
||||||
: t("core.role.editing_modal.titles.create");
|
: t("core.role.editing_modal.titles.create");
|
||||||
|
|
||||||
const handleCreateOrUpdateRole = async () => {
|
const handleCreateOrUpdateRole = async () => {
|
||||||
try {
|
|
||||||
await handleCreateOrUpdate();
|
await handleCreateOrUpdate();
|
||||||
|
|
||||||
modal.value?.close();
|
modal.value?.close();
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
@ -196,7 +190,10 @@ const handleCreateOrUpdateRole = async () => {
|
||||||
</dt>
|
</dt>
|
||||||
<dd class="text-sm text-gray-900">
|
<dd class="text-sm text-gray-900">
|
||||||
<ul class="space-y-2">
|
<ul class="space-y-2">
|
||||||
<li v-for="(roleTemplate, index) in group.roles" :key="index">
|
<li
|
||||||
|
v-for="roleTemplate in group.roles"
|
||||||
|
:key="roleTemplate.metadata.name"
|
||||||
|
>
|
||||||
<label
|
<label
|
||||||
class="inline-flex w-full cursor-pointer flex-row items-center gap-4 rounded-base border p-5 hover:border-primary"
|
class="inline-flex w-full cursor-pointer flex-row items-center gap-4 rounded-base border p-5 hover:border-primary"
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in New Issue