Browse Source

fix: Added events for Sidebar table and view node and all the modals assosiated with it

pull/6539/head
Muhammed Mustafa 1 year ago
parent
commit
6f10bda94a
  1. 8
      packages/nc-gui/components/dashboard/TreeView/TableNode.vue
  2. 9
      packages/nc-gui/components/dashboard/TreeView/ViewsNode.vue
  3. 1
      packages/nc-gui/components/dashboard/settings/data-sources/CreateBase.vue
  4. 4
      packages/nc-gui/components/dlg/ProjectDuplicate.vue
  5. 1
      packages/nc-gui/components/dlg/TableCreate.vue
  6. 4
      packages/nc-gui/components/dlg/TableDuplicate.vue
  7. 6
      packages/nc-gui/components/dlg/ViewCreate.vue

8
packages/nc-gui/components/dashboard/TreeView/TableNode.vue

@ -161,6 +161,7 @@ const isTableOpened = computed(() => {
> >
<template #title>{{ table.table_name }}</template> <template #title>{{ table.table_name }}</template>
<div <div
v-e="['c:table:open']"
class="table-context flex items-center gap-1 h-full" class="table-context flex items-center gap-1 h-full"
:data-testid="`nc-tbl-side-node-${table.title}`" :data-testid="`nc-tbl-side-node-${table.title}`"
@contextmenu="setMenuContext('table', table)" @contextmenu="setMenuContext('table', table)"
@ -169,6 +170,7 @@ const isTableOpened = computed(() => {
<div class="flex flex-row h-full items-center"> <div class="flex flex-row h-full items-center">
<NcButton <NcButton
v-if="(table.meta as any)?.hasNonDefaultViews" v-if="(table.meta as any)?.hasNonDefaultViews"
v-e="['c:table:toggle-expand']"
type="text" type="text"
size="xxsmall" size="xxsmall"
class="nc-sidebar-node-btn nc-sidebar-expand" class="nc-sidebar-node-btn nc-sidebar-expand"
@ -191,6 +193,7 @@ const isTableOpened = computed(() => {
> >
<LazyGeneralEmojiPicker <LazyGeneralEmojiPicker
:key="table.meta?.icon" :key="table.meta?.icon"
v-e="['c:table:emoji-picker']"
:emoji="table.meta?.icon" :emoji="table.meta?.icon"
size="small" size="small"
:readonly="!canUserEditEmote || isMobileMode" :readonly="!canUserEditEmote || isMobileMode"
@ -242,6 +245,7 @@ const isTableOpened = computed(() => {
!isSharedBase && !isSharedBase &&
(isUIAllowed('tableRename', { roles: projectRole }) || isUIAllowed('tableDelete', { roles: projectRole })) (isUIAllowed('tableRename', { roles: projectRole }) || isUIAllowed('tableDelete', { roles: projectRole }))
" "
v-e="['c:table:option']"
:trigger="['click']" :trigger="['click']"
class="nc-sidebar-node-btn" class="nc-sidebar-node-btn"
@click.stop @click.stop
@ -255,6 +259,7 @@ const isTableOpened = computed(() => {
<NcMenu> <NcMenu>
<NcMenuItem <NcMenuItem
v-if="isUIAllowed('tableRename', { roles: projectRole })" v-if="isUIAllowed('tableRename', { roles: projectRole })"
v-e="['c:table:rename']"
:data-testid="`sidebar-table-rename-${table.title}`" :data-testid="`sidebar-table-rename-${table.title}`"
@click="openRenameTableDialog(table, project.bases[baseIndex].id)" @click="openRenameTableDialog(table, project.bases[baseIndex].id)"
> >
@ -268,6 +273,7 @@ const isTableOpened = computed(() => {
project.bases?.[baseIndex] && project.bases?.[baseIndex] &&
(project.bases[baseIndex].is_meta || project.bases[baseIndex].is_local) (project.bases[baseIndex].is_meta || project.bases[baseIndex].is_local)
" "
v-e="['c:table:duplicate']"
:data-testid="`sidebar-table-duplicate-${table.title}`" :data-testid="`sidebar-table-duplicate-${table.title}`"
@click="duplicateTable(table)" @click="duplicateTable(table)"
> >
@ -277,6 +283,7 @@ const isTableOpened = computed(() => {
<NcMenuItem <NcMenuItem
v-if="isUIAllowed('tableDelete', { roles: projectRole })" v-if="isUIAllowed('tableDelete', { roles: projectRole })"
v-e="['c:table:delete']"
:data-testid="`sidebar-table-delete-${table.title}`" :data-testid="`sidebar-table-delete-${table.title}`"
class="!text-red-500 !hover:bg-red-50" class="!text-red-500 !hover:bg-red-50"
@click="isTableDeleteDialogVisible = true" @click="isTableDeleteDialogVisible = true"
@ -289,6 +296,7 @@ const isTableOpened = computed(() => {
</NcDropdown> </NcDropdown>
<DashboardTreeViewCreateViewBtn v-if="isUIAllowed('viewCreateOrEdit')"> <DashboardTreeViewCreateViewBtn v-if="isUIAllowed('viewCreateOrEdit')">
<NcButton <NcButton
v-e="['c:view:create']"
type="text" type="text"
size="xxsmall" size="xxsmall"
class="nc-create-view-btn nc-sidebar-node-btn" class="nc-create-view-btn nc-sidebar-node-btn"

9
packages/nc-gui/components/dashboard/TreeView/ViewsNode.vue

@ -193,6 +193,7 @@ function onStopEdit() {
<template> <template>
<a-menu-item <a-menu-item
v-e="['c:view:open']"
class="nc-sidebar-node !min-h-7 !max-h-7 !mb-0.25 select-none group text-gray-700 !flex !items-center !mt-0 hover:(!bg-gray-200 !text-gray-900) cursor-pointer" class="nc-sidebar-node !min-h-7 !max-h-7 !mb-0.25 select-none group text-gray-700 !flex !items-center !mt-0 hover:(!bg-gray-200 !text-gray-900) cursor-pointer"
:class="{ :class="{
'!pl-18 !xs:(pl-19.75)': isDefaultBase, '!pl-18 !xs:(pl-19.75)': isDefaultBase,
@ -205,6 +206,7 @@ function onStopEdit() {
<div v-e="['a:view:open', { view: vModel.type }]" class="text-sm flex items-center w-full gap-1" data-testid="view-item"> <div v-e="['a:view:open', { view: vModel.type }]" class="text-sm flex items-center w-full gap-1" data-testid="view-item">
<div class="flex min-w-6" :data-testid="`view-sidebar-drag-handle-${vModel.alias || vModel.title}`"> <div class="flex min-w-6" :data-testid="`view-sidebar-drag-handle-${vModel.alias || vModel.title}`">
<LazyGeneralEmojiPicker <LazyGeneralEmojiPicker
v-e="['c:view:emoji-picker']"
class="nc-table-icon" class="nc-table-icon"
:emoji="props.view?.meta?.icon" :emoji="props.view?.meta?.icon"
size="small" size="small"
@ -247,6 +249,7 @@ function onStopEdit() {
<template v-if="!isEditing && !isLocked && isUIAllowed('viewCreateOrEdit')"> <template v-if="!isEditing && !isLocked && isUIAllowed('viewCreateOrEdit')">
<NcDropdown v-model:visible="isDropdownOpen" overlay-class-name="!rounded-lg"> <NcDropdown v-model:visible="isDropdownOpen" overlay-class-name="!rounded-lg">
<NcButton <NcButton
v-e="['c:view:option']"
type="text" type="text"
size="xxsmall" size="xxsmall"
class="nc-sidebar-node-btn invisible !group-hover:visible nc-sidebar-view-node-context-btn" class="nc-sidebar-node-btn invisible !group-hover:visible nc-sidebar-view-node-context-btn"
@ -260,11 +263,11 @@ function onStopEdit() {
<template #overlay> <template #overlay>
<NcMenu class="min-w-27" :data-testid="`view-sidebar-view-actions-${vModel.alias || vModel.title}`"> <NcMenu class="min-w-27" :data-testid="`view-sidebar-view-actions-${vModel.alias || vModel.title}`">
<NcMenuItem @click.stop="onDblClick"> <NcMenuItem v-e="['c:view:rename']" @click.stop="onDblClick">
<GeneralIcon icon="edit" /> <GeneralIcon icon="edit" />
<div class="-ml-0.25">{{ $t('general.rename') }}</div> <div class="-ml-0.25">{{ $t('general.rename') }}</div>
</NcMenuItem> </NcMenuItem>
<NcMenuItem @click.stop="onDuplicate"> <NcMenuItem v-e="['c:view:duplicate']" @click.stop="onDuplicate">
<GeneralIcon icon="duplicate" class="nc-view-copy-icon" /> <GeneralIcon icon="duplicate" class="nc-view-copy-icon" />
{{ $t('general.duplicate') }} {{ $t('general.duplicate') }}
</NcMenuItem> </NcMenuItem>
@ -272,7 +275,7 @@ function onStopEdit() {
<NcDivider /> <NcDivider />
<template v-if="!vModel.is_default"> <template v-if="!vModel.is_default">
<NcMenuItem class="!text-red-500 !hover:bg-red-50" @click.stop="onDelete"> <NcMenuItem v-e="['c:view:delete']" class="!text-red-500 !hover:bg-red-50" @click.stop="onDelete">
<GeneralIcon icon="delete" class="text-sm nc-view-delete-icon" /> <GeneralIcon icon="delete" class="text-sm nc-view-delete-icon" />
<div class="-ml-0.25">{{ $t('general.delete') }}</div> <div class="-ml-0.25">{{ $t('general.delete') }}</div>
</NcMenuItem> </NcMenuItem>

1
packages/nc-gui/components/dashboard/settings/data-sources/CreateBase.vue

@ -628,6 +628,7 @@ watch(
</NcButton> </NcButton>
<NcButton <NcButton
v-e="['a:source:create']"
size="small" size="small"
type="primary" type="primary"
:disabled="!testSuccess" :disabled="!testSuccess"

4
packages/nc-gui/components/dlg/ProjectDuplicate.vue

@ -95,7 +95,9 @@ const isEaster = ref(false)
</div> </div>
<div class="flex flex-row gap-x-2 mt-2.5 pt-2.5 justify-end"> <div class="flex flex-row gap-x-2 mt-2.5 pt-2.5 justify-end">
<NcButton key="back" type="secondary" @click="dialogShow = false">{{ $t('general.cancel') }}</NcButton> <NcButton key="back" type="secondary" @click="dialogShow = false">{{ $t('general.cancel') }}</NcButton>
<NcButton key="submit" :loading="isLoading" @click="_duplicate">{{ $t('general.confirm') }} </NcButton> <NcButton key="submit" v-e="['a:base:duplicate']" :loading="isLoading" @click="_duplicate"
>{{ $t('general.confirm') }}
</NcButton>
</div> </div>
</GeneralModal> </GeneralModal>
</template> </template>

1
packages/nc-gui/components/dlg/TableCreate.vue

@ -184,6 +184,7 @@ onMounted(() => {
<NcButton type="secondary" @click="dialogShow = false">{{ $t('general.cancel') }}</NcButton> <NcButton type="secondary" @click="dialogShow = false">{{ $t('general.cancel') }}</NcButton>
<NcButton <NcButton
v-e="['a:table:create']"
type="primary" type="primary"
:disabled="validateInfos.title.validateStatus === 'error'" :disabled="validateInfos.title.validateStatus === 'error'"
:loading="creating" :loading="creating"

4
packages/nc-gui/components/dlg/TableDuplicate.vue

@ -84,7 +84,9 @@ const isEaster = ref(false)
</div> </div>
<div class="flex flex-row gap-x-2 mt-2.5 pt-2.5 justify-end"> <div class="flex flex-row gap-x-2 mt-2.5 pt-2.5 justify-end">
<NcButton key="back" type="secondary" @click="dialogShow = false">{{ $t('general.cancel') }}</NcButton> <NcButton key="back" type="secondary" @click="dialogShow = false">{{ $t('general.cancel') }}</NcButton>
<NcButton key="submit" type="primary" :loading="isLoading" @click="_duplicate">{{ $t('general.confirm') }} </NcButton> <NcButton key="submit" v-e="['a:table:duplicate']" type="primary" :loading="isLoading" @click="_duplicate"
>{{ $t('general.confirm') }}
</NcButton>
</div> </div>
</GeneralModal> </GeneralModal>
</template> </template>

6
packages/nc-gui/components/dlg/ViewCreate.vue

@ -306,7 +306,11 @@ onMounted(async () => {
{{ $t('general.cancel') }} {{ $t('general.cancel') }}
</NcButton> </NcButton>
<NcButton type="primary" :loading="isViewCreating" @click="onSubmit"> <NcButton v-if="form.copy_from_id" v-e="['a:view:duplicate']" type="primary" :loading="isViewCreating" @click="onSubmit">
{{ $t('labels.createView') }}
<template #loading> {{ $t('labels.creatingView') }}</template>
</NcButton>
<NcButton v-if="form.copy_from_id" v-e="['a:view:create']" type="primary" :loading="isViewCreating" @click="onSubmit">
{{ $t('labels.createView') }} {{ $t('labels.createView') }}
<template #loading> {{ $t('labels.creatingView') }}</template> <template #loading> {{ $t('labels.creatingView') }}</template>
</NcButton> </NcButton>

Loading…
Cancel
Save