Browse Source

feat(gui-v2): add isLocked for Treeview

pull/3209/head
Wing-Kam Wong 2 years ago
parent
commit
fa64125e4b
  1. 14
      packages/nc-gui-v2/components/dashboard/TreeView.vue
  2. 4
      packages/nc-gui-v2/components/tabs/Smartsheet.vue
  3. 5
      packages/nc-gui-v2/pages/[projectType]/[projectId]/index.vue

14
packages/nc-gui-v2/components/dashboard/TreeView.vue

@ -23,6 +23,8 @@ const { deleteTable } = useTable()
const { isUIAllowed } = useUIPermission()
const isLocked = inject('TreeViewIsLockedInj')
const tablesById = $computed<Record<string, TableType>>(() =>
tables?.value?.reduce((acc: Record<string, TableType>, table: TableType) => {
acc[table.id as string] = table
@ -199,7 +201,11 @@ const activeTable = computed(() => {
<div class="nc-tbl-title flex-1">{{ table.title }}</div>
<a-dropdown v-if="isUIAllowed('table-rename') || isUIAllowed('table-delete')" :trigger="['click']" @click.stop>
<a-dropdown
v-if="!isLocked && (isUIAllowed('table-rename') || isUIAllowed('table-delete'))"
:trigger="['click']"
@click.stop
>
<MdiMenuIcon class="transition-opacity opacity-0 group-hover:opacity-100" />
<template #overlay>
@ -209,7 +215,7 @@ const activeTable = computed(() => {
v-t="['c:table:rename']"
class="!text-xs"
@click="showRenameTableDlg(table)"
><div>Rename</div></a-menu-item
><div>{{ $t('general.rename') }}</div></a-menu-item
>
<a-menu-item
@ -218,7 +224,7 @@ const activeTable = computed(() => {
class="!text-xs"
@click="deleteTable(table)"
>
Delete</a-menu-item
{{ $t('general.delete') }}</a-menu-item
>
</a-menu>
</template>
@ -238,7 +244,7 @@ const activeTable = computed(() => {
</div>
</div>
<template #overlay>
<template v-if="!isLocked" #overlay>
<a-menu class="cursor-pointer">
<template v-if="contextMenuTarget.type === 'table'">
<a-menu-item

4
packages/nc-gui-v2/components/tabs/Smartsheet.vue

@ -57,9 +57,13 @@ provide(ReloadViewDataHookInj, reloadEventHook)
provide(FieldsInj, fields)
provide(IsFormInj, isForm)
const treeViewIsLockedInj = inject('TreeViewIsLockedInj', ref(false))
watch(tabMeta, async (newTabMeta, oldTabMeta) => {
if (newTabMeta !== oldTabMeta && newTabMeta?.id) await getMeta(newTabMeta.id)
})
watch(isLocked, (nextValue) => (treeViewIsLockedInj.value = nextValue), { immediate: true })
</script>
<template>

5
packages/nc-gui-v2/pages/[projectType]/[projectId]/index.vue

@ -4,6 +4,7 @@ import {
navigateTo,
onKeyStroke,
openLink,
provide,
provideSidebar,
ref,
useClipboard,
@ -26,6 +27,10 @@ const { isUIAllowed } = useUIPermission()
const { copy } = useClipboard()
const isLocked = ref(false)
provide('TreeViewIsLockedInj', isLocked)
// create a new sidebar state
const { isOpen, toggle } = provideSidebar({ isOpen: true })

Loading…
Cancel
Save