From e92d102bf4d00e64157e370d9ebfaa41fc594e34 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Tue, 27 Sep 2022 17:13:20 +0800 Subject: [PATCH] refactor: grant permissions to user Signed-off-by: Ryan Wang --- src/modules/system/users/UserList.vue | 27 ++++- .../users/components/GrantPermissionModal.vue | 107 ++++++++++++++++++ .../users/components/UserEditingModal.vue | 47 +------- .../components/UserPasswordChangeModal.vue | 4 +- 4 files changed, 139 insertions(+), 46 deletions(-) create mode 100644 src/modules/system/users/components/GrantPermissionModal.vue diff --git a/src/modules/system/users/UserList.vue b/src/modules/system/users/UserList.vue index fb9fd491..ec3df7e2 100644 --- a/src/modules/system/users/UserList.vue +++ b/src/modules/system/users/UserList.vue @@ -18,6 +18,7 @@ import { } from "@halo-dev/components"; import UserEditingModal from "./components/UserEditingModal.vue"; import UserPasswordChangeModal from "./components/UserPasswordChangeModal.vue"; +import GrantPermissionModal from "./components/GrantPermissionModal.vue"; import { inject, onMounted, ref, watch } from "vue"; import { apiClient } from "@/utils/api-client"; import type { User, UserList } from "@halo-dev/api-client"; @@ -30,6 +31,8 @@ const dialog = useDialog(); const checkedAll = ref(false); const editingModal = ref(false); const passwordChangeModal = ref(false); +const grantPermissionModal = ref(false); + const users = ref({ page: 1, size: 10, @@ -41,7 +44,7 @@ const users = ref({ hasPrevious: false, }); const selectedUserNames = ref([]); -const selectedUser = ref(null); +const selectedUser = ref(); const currentUser = inject("currentUser"); const handleFetchUsers = async () => { @@ -54,7 +57,7 @@ const handleFetchUsers = async () => { } catch (e) { console.error(e); } finally { - selectedUser.value = null; + selectedUser.value = undefined; } }; @@ -149,6 +152,11 @@ const handleOpenPasswordChangeModal = (user: User) => { passwordChangeModal.value = true; }; +const handleOpenGrantPermissionModal = (user: User) => { + selectedUser.value = user; + grantPermissionModal.value = true; +}; + const getRoles = (user: User) => { return JSON.parse( user.metadata.annotations?.[rbacAnnotations.ROLE_NAMES] || "[]" @@ -184,6 +192,12 @@ onMounted(() => { @close="handleFetchUsers" /> + +