From e7d46e53b7744a0bc3cb340b965e7a0f24c40e9c Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 28 Jul 2022 11:51:22 +0530 Subject: [PATCH 01/67] refactor(gui-v2): set icon size to avoid shrinking Signed-off-by: Pranav C --- packages/nc-gui-v2/components/smartsheet-toolbar/AddRow.vue | 2 ++ .../nc-gui-v2/components/smartsheet-toolbar/DeleteTable.vue | 2 ++ 2 files changed, 4 insertions(+) diff --git a/packages/nc-gui-v2/components/smartsheet-toolbar/AddRow.vue b/packages/nc-gui-v2/components/smartsheet-toolbar/AddRow.vue index 9e99331042..4a0162d0d5 100644 --- a/packages/nc-gui-v2/components/smartsheet-toolbar/AddRow.vue +++ b/packages/nc-gui-v2/components/smartsheet-toolbar/AddRow.vue @@ -13,3 +13,5 @@ const emits = defineEmits(['addRow']) + + diff --git a/packages/nc-gui-v2/components/smartsheet-toolbar/DeleteTable.vue b/packages/nc-gui-v2/components/smartsheet-toolbar/DeleteTable.vue index 1f64724d7f..b6606d5703 100644 --- a/packages/nc-gui-v2/components/smartsheet-toolbar/DeleteTable.vue +++ b/packages/nc-gui-v2/components/smartsheet-toolbar/DeleteTable.vue @@ -11,3 +11,5 @@ import MdiDeleteIcon from '~icons/mdi/delete-outline' + + From 491fad361b014ae9002fe6fe600a287f58cfe018 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 28 Jul 2022 12:05:06 +0530 Subject: [PATCH 02/67] refactor(gui-v2): integrate delete table with delete icon Signed-off-by: Pranav C --- .../components/dashboard/TreeView.vue | 54 +-------------- .../smartsheet-toolbar/DeleteTable.vue | 9 ++- .../nc-gui-v2/composables/useDeleteTable.ts | 68 +++++++++++++++++++ 3 files changed, 77 insertions(+), 54 deletions(-) create mode 100644 packages/nc-gui-v2/composables/useDeleteTable.ts diff --git a/packages/nc-gui-v2/components/dashboard/TreeView.vue b/packages/nc-gui-v2/components/dashboard/TreeView.vue index dbadea1fe1..ba44e7bc09 100644 --- a/packages/nc-gui-v2/components/dashboard/TreeView.vue +++ b/packages/nc-gui-v2/components/dashboard/TreeView.vue @@ -27,6 +27,7 @@ const { isUIAllowed } = useUIPermission() const route = useRoute() const { tables, loadTables } = useProject(route.params.projectId as string) const { closeTab } = useTabs() +const { deleteTable } = useDeleteTable() const tablesById = $computed>(() => tables?.value?.reduce((acc: Record, table: TableType) => { @@ -128,59 +129,6 @@ const setMenuContext = (type: 'table' | 'main', value?: any) => { $e('c:table:create:navdraw:right-click') } -const deleteTable = (table: TableType) => { - $e('c:table:delete') - // 'Click Submit to Delete The table' - Modal.confirm({ - title: `Click Yes to Delete The table : ${table.title}`, - okText: 'Yes', - okType: 'danger', - cancelText: 'No', - async onOk() { - const { getMeta, removeMeta } = useMetas() - try { - const meta = (await getMeta(table.id as string)) as TableType - const relationColumns = meta?.columns?.filter((c) => c.uidt === UITypes.LinkToAnotherRecord) - - if (relationColumns?.length) { - const refColMsgs = await Promise.all( - relationColumns.map(async (c, i) => { - const refMeta = (await getMeta( - (c?.colOptions as LinkToAnotherRecordType)?.fk_related_model_id as string, - )) as TableType - return `${i + 1}. ${c.title} is a LinkToAnotherRecord of ${(refMeta && refMeta.title) || c.title}` - }), - ) - toast.info( - h('div', { - innerHTML: `
Unable to delete tables because of the following. -

${refColMsgs.join('
')}

- Delete them & try again
`, - }), - ) - return - } - - await $api.dbTable.delete(table?.id as string) - - closeTab({ - type: TabType.TABLE, - id: table.id, - title: table.title, - }) - - await loadTables() - - removeMeta(table.id as string) - toast.info(`Deleted table ${table.title} successfully`) - $e('a:table:delete') - } catch (e: any) { - toast.error(await extractSdkResponseErrorMsg(e)) - } - }, - }) -} - const renameTableDlg = ref(false) const renameTableMeta = ref() const showRenameTableDlg = (table: TableType, rightClick = false) => { diff --git a/packages/nc-gui-v2/components/smartsheet-toolbar/DeleteTable.vue b/packages/nc-gui-v2/components/smartsheet-toolbar/DeleteTable.vue index b6606d5703..21b579cbe4 100644 --- a/packages/nc-gui-v2/components/smartsheet-toolbar/DeleteTable.vue +++ b/packages/nc-gui-v2/components/smartsheet-toolbar/DeleteTable.vue @@ -1,5 +1,12 @@ diff --git a/packages/nc-gui-v2/composables/useDeleteTable.ts b/packages/nc-gui-v2/composables/useDeleteTable.ts new file mode 100644 index 0000000000..f529ad660d --- /dev/null +++ b/packages/nc-gui-v2/composables/useDeleteTable.ts @@ -0,0 +1,68 @@ +import { Modal } from 'ant-design-vue' +import type { LinkToAnotherRecordType, TableType } from 'nocodb-sdk' +import { UITypes } from 'nocodb-sdk' +import { useToast } from 'vue-toastification' +import useTabs, { TabType } from '~/composables/useTabs' +import { extractSdkResponseErrorMsg } from '~/utils/errorUtils' + +export default () => { + const { $e, $api } = useNuxtApp() + const toast = useToast() + const { getMeta, removeMeta } = useMetas() + const { loadTables } = useProject() + const { closeTab } = useTabs() + + const deleteTable = (table: TableType) => { + $e('c:table:delete') + // 'Click Submit to Delete The table' + Modal.confirm({ + title: `Click Yes to Delete The table : ${table.title}`, + okText: 'Yes', + okType: 'danger', + cancelText: 'No', + async onOk() { + try { + const meta = (await getMeta(table.id as string)) as TableType + const relationColumns = meta?.columns?.filter((c) => c.uidt === UITypes.LinkToAnotherRecord) + + if (relationColumns?.length) { + const refColMsgs = await Promise.all( + relationColumns.map(async (c, i) => { + const refMeta = (await getMeta( + (c?.colOptions as LinkToAnotherRecordType)?.fk_related_model_id as string, + )) as TableType + return `${i + 1}. ${c.title} is a LinkToAnotherRecord of ${(refMeta && refMeta.title) || c.title}` + }), + ) + toast.info( + h('div', { + innerHTML: `
Unable to delete tables because of the following. +

${refColMsgs.join('
')}

+ Delete them & try again
`, + }), + ) + return + } + + await $api.dbTable.delete(table?.id as string) + + closeTab({ + type: TabType.TABLE, + id: table.id, + title: table.title, + }) + + await loadTables() + + removeMeta(table.id as string) + toast.info(`Deleted table ${table.title} successfully`) + $e('a:table:delete') + } catch (e: any) { + toast.error(await extractSdkResponseErrorMsg(e)) + } + }, + }) + } + + return { deleteTable } +} From 0a146c14dc9fa7cbf686fe21bce91bb6c85b54da Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 28 Jul 2022 14:25:36 +0530 Subject: [PATCH 03/67] wip(gui-v2): lock menu Signed-off-by: Pranav C --- .../components/smartsheet-toolbar/LockMenu.vue | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/nc-gui-v2/components/smartsheet-toolbar/LockMenu.vue b/packages/nc-gui-v2/components/smartsheet-toolbar/LockMenu.vue index de9f1e931e..55a6b74351 100644 --- a/packages/nc-gui-v2/components/smartsheet-toolbar/LockMenu.vue +++ b/packages/nc-gui-v2/components/smartsheet-toolbar/LockMenu.vue @@ -49,6 +49,15 @@ const Icon = computed(() => { return MdiAccountGroupIcon } }) + +const changeLockType = (type) => { + $e('a:grid:lockmenu', { lockType: type }) + if (type === 'personal') { + return toast.info('Coming soon') + } + // $emit('input', type); + toast.success(`Successfully Switched to ${type} view`) +}