Browse Source

fix(nc-gui): disable when the page is index

pull/4482/head
Wing-Kam Wong 2 years ago
parent
commit
fafa4fb17e
  1. 15
      packages/nc-gui/components/dashboard/TreeView.vue
  2. 1
      packages/nc-gui/components/general/ShareBaseButton.vue

15
packages/nc-gui/components/dashboard/TreeView.vue

@ -16,6 +16,7 @@ import {
useDialog, useDialog,
useNuxtApp, useNuxtApp,
useProject, useProject,
useRoute,
useTable, useTable,
useTabs, useTabs,
useToggle, useToggle,
@ -37,6 +38,8 @@ const { deleteTable } = useTable()
const { isUIAllowed } = useUIPermission() const { isUIAllowed } = useUIPermission()
const route = useRoute()
const [searchActive, toggleSearchActive] = useToggle() const [searchActive, toggleSearchActive] = useToggle()
let key = $ref(0) let key = $ref(0)
@ -219,13 +222,23 @@ const onSearchCloseIconClick = () => {
toggleSearchActive(false) 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) => { useEventListener(document, 'keydown', async (e: KeyboardEvent) => {
const cmdOrCtrl = isMac() ? e.metaKey : e.ctrlKey const cmdOrCtrl = isMac() ? e.metaKey : e.ctrlKey
if (e.altKey && !e.shiftKey && !cmdOrCtrl) { if (e.altKey && !e.shiftKey && !cmdOrCtrl) {
switch (e.keyCode) { switch (e.keyCode) {
case 84: { case 84: {
// ALT + T // ALT + T
if (isUIAllowed('table-create') && !isDrawerOrModalExist()) { if (isCreateTableAllowed.value && !isDrawerOrModalExist()) {
// prevent the key `T` is inputted to table title input // prevent the key `T` is inputted to table title input
e.preventDefault() e.preventDefault()
openTableCreateDialog() openTableCreateDialog()

1
packages/nc-gui/components/general/ShareBaseButton.vue

@ -11,6 +11,7 @@ const isShareBaseAllowed = computed(
() => () =>
isUIAllowed('newUser') && isUIAllowed('newUser') &&
route.name !== 'index' && route.name !== 'index' &&
route.name !== 'index-index' &&
route.name !== 'index-index-create' && route.name !== 'index-index-create' &&
route.name !== 'index-index-create-external' && route.name !== 'index-index-create-external' &&
route.name !== 'index-user-index', route.name !== 'index-user-index',

Loading…
Cancel
Save