From fafa4fb17e45e4ad92854e701d1e4e967d76d063 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Wed, 30 Nov 2022 22:19:23 +0800 Subject: [PATCH] fix(nc-gui): disable when the page is index --- packages/nc-gui/components/dashboard/TreeView.vue | 15 ++++++++++++++- .../nc-gui/components/general/ShareBaseButton.vue | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/nc-gui/components/dashboard/TreeView.vue b/packages/nc-gui/components/dashboard/TreeView.vue index fc8b89847a..bf05399189 100644 --- a/packages/nc-gui/components/dashboard/TreeView.vue +++ b/packages/nc-gui/components/dashboard/TreeView.vue @@ -16,6 +16,7 @@ import { useDialog, useNuxtApp, useProject, + useRoute, useTable, useTabs, useToggle, @@ -37,6 +38,8 @@ const { deleteTable } = useTable() const { isUIAllowed } = useUIPermission() +const route = useRoute() + const [searchActive, toggleSearchActive] = useToggle() let key = $ref(0) @@ -219,13 +222,23 @@ const onSearchCloseIconClick = () => { toggleSearchActive(false) } +const isCreateTableAllowed = computed( + () => + isUIAllowed('table-create') && + route.name !== 'index' && + route.name !== 'index-index' && + route.name !== 'index-index-create' && + route.name !== 'index-index-create-external' && + route.name !== 'index-user-index', +) + useEventListener(document, 'keydown', async (e: KeyboardEvent) => { const cmdOrCtrl = isMac() ? e.metaKey : e.ctrlKey if (e.altKey && !e.shiftKey && !cmdOrCtrl) { switch (e.keyCode) { case 84: { // ALT + T - if (isUIAllowed('table-create') && !isDrawerOrModalExist()) { + if (isCreateTableAllowed.value && !isDrawerOrModalExist()) { // prevent the key `T` is inputted to table title input e.preventDefault() openTableCreateDialog() diff --git a/packages/nc-gui/components/general/ShareBaseButton.vue b/packages/nc-gui/components/general/ShareBaseButton.vue index 45cd622554..eb44eb6632 100644 --- a/packages/nc-gui/components/general/ShareBaseButton.vue +++ b/packages/nc-gui/components/general/ShareBaseButton.vue @@ -11,6 +11,7 @@ const isShareBaseAllowed = computed( () => isUIAllowed('newUser') && route.name !== 'index' && + route.name !== 'index-index' && route.name !== 'index-index-create' && route.name !== 'index-index-create-external' && route.name !== 'index-user-index',