From 391aac62d3c2eebaabeec8c95027729f830639d0 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Sun, 24 Nov 2024 23:48:21 +0800 Subject: [PATCH] feat: add multi-role assignment support for users (#7037) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /area ui /kind feature /milestone 2.20.x #### What this PR does / why we need it: 支持为用户分配多个角色。 image image TODO: - [x] Console / UC 侧边栏显示多个角色 - [x] 支持在管理端查看用户聚合的角色模板列表,或者在分配时显示所选角色其下的角色模板列表,能够让管理员清楚的知道用户具体权限。 #### Which issue(s) this PR fixes: Fixes # #### Special notes for your reviewer: #### Does this PR introduce a user-facing change? ```release-note 支持为用户分配多个角色。 ``` --- ui/console-src/layouts/BasicLayout.vue | 46 +++++- .../modules/system/roles/RoleDetail.vue | 6 +- .../modules/system/users/UserDetail.vue | 14 +- .../modules/system/users/UserList.vue | 20 +-- .../users/components/GrantPermissionModal.vue | 152 ++++++++++++++---- .../system/users/components/RolesView.vue | 107 ++++++++++++ .../modules/system/users/tabs/Detail.vue | 37 +++-- ui/console-src/router/guards/permission.ts | 5 + ui/src/formkit/inputs/role-select.ts | 7 - ui/src/locales/en.yaml | 7 + ui/src/locales/zh-CN.yaml | 7 + ui/src/locales/zh-TW.yaml | 7 + ui/uc-src/layouts/BasicLayout.vue | 55 ++++++- ui/uc-src/modules/profile/tabs/Detail.vue | 23 +-- 14 files changed, 403 insertions(+), 90 deletions(-) create mode 100644 ui/console-src/modules/system/users/components/RolesView.vue diff --git a/ui/console-src/layouts/BasicLayout.vue b/ui/console-src/layouts/BasicLayout.vue index 0eff4a6604..4b89567bbb 100644 --- a/ui/console-src/layouts/BasicLayout.vue +++ b/ui/console-src/layouts/BasicLayout.vue @@ -9,11 +9,13 @@ import { coreMenuGroups } from "@console/router/constant"; import { Dialog, IconAccountCircleLine, + IconArrowDownLine, IconLogoutCircleRLine, IconMore, IconSearch, - IconUserSettings, + IconShieldUser, VAvatar, + VDropdown, VTag, } from "@halo-dev/components"; import { useEventListener } from "@vueuse/core"; @@ -152,10 +154,10 @@ onMounted(() => { > {{ currentUser?.spec.displayName }} -
- +
+ {{ currentRoles[0].metadata.annotations?.[ @@ -163,6 +165,41 @@ onMounted(() => { ] || currentRoles[0].metadata.name }} + +
+ + + {{ $t("core.sidebar.profile.aggregate_role") }} + + +
+ +
@@ -299,6 +336,7 @@ onMounted(() => { .profile-placeholder { height: 70px; + flex: none; .current-profile { height: 70px; diff --git a/ui/console-src/modules/system/roles/RoleDetail.vue b/ui/console-src/modules/system/roles/RoleDetail.vue index d32a9164de..1cc46b693b 100644 --- a/ui/console-src/modules/system/roles/RoleDetail.vue +++ b/ui/console-src/modules/system/roles/RoleDetail.vue @@ -183,8 +183,8 @@ const handleUpdateRole = async () => {
@@ -224,7 +224,7 @@ const handleUpdateRole = async () => {
    -
  • +