From 4465e7d7e555519adebcea92b22acc5fb3ad1b64 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 12 Nov 2024 06:06:46 +0000 Subject: [PATCH] refactor: allow owner/creator to transfer ownership of a view --- .../nc-gui/components/dlg/ReAssign/index.vue | 16 +++++++++++++--- .../smartsheet/toolbar/ViewActionMenu.vue | 2 +- packages/nc-gui/lib/acl.ts | 1 + packages/nocodb/src/services/views.service.ts | 19 ++++++++++++------- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/packages/nc-gui/components/dlg/ReAssign/index.vue b/packages/nc-gui/components/dlg/ReAssign/index.vue index c25b62c3e3..2eabc3bd65 100644 --- a/packages/nc-gui/components/dlg/ReAssign/index.vue +++ b/packages/nc-gui/components/dlg/ReAssign/index.vue @@ -74,6 +74,15 @@ const searchQuery = ref('') const selectedUser = ref() const userSelectMenu = ref(false) +const currentOwner = computed(() => { + return ( + (props.view && basesUser.value.get(props.view.base_id)?.find((u) => u.id === props.view.owned_by)) || { + id: props.view.owned_by, + display_name: 'Unknown', + } + ) +}) + const filterdBaseUsers = computed(() => { let users = props.view.base_id ? basesUser.value.get(props.view.base_id) || [] : [] if (searchQuery.value) { @@ -83,7 +92,8 @@ const filterdBaseUsers = computed(() => { }) } - return users.filter((u) => u.id !== user.value?.id) + // exclude current owner from the list + return users.filter((u) => u.id !== currentOwner.value?.id) }) const { user } = useGlobal() @@ -142,12 +152,12 @@ const inputEl = (el: HTMLInputElement) => {
Re-assign this view
-
Once reassigned, you will no longer be able to edit the view configuration.
+
Once reassigned, current owner will no longer be able to edit the view configuration.
Current owner
- +
New owner
diff --git a/packages/nc-gui/components/smartsheet/toolbar/ViewActionMenu.vue b/packages/nc-gui/components/smartsheet/toolbar/ViewActionMenu.vue index 0e951e78ee..f408984bf0 100644 --- a/packages/nc-gui/components/smartsheet/toolbar/ViewActionMenu.vue +++ b/packages/nc-gui/components/smartsheet/toolbar/ViewActionMenu.vue @@ -337,7 +337,7 @@ const isViewOwner = computed(() => { - +