From ab9b9fa8c4aabbdfb6752b15910476deb0cca8a3 Mon Sep 17 00:00:00 2001 From: mertmit Date: Tue, 26 Jul 2022 20:08:18 +0300 Subject: [PATCH 01/27] feat(gui-v2): project metadata Signed-off-by: mertmit --- .../dashboard/settings/Metadata.vue | 110 ++++++++++++++++++ .../dashboard/settings/SettingsModal.vue | 3 +- 2 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 packages/nc-gui-v2/components/dashboard/settings/Metadata.vue diff --git a/packages/nc-gui-v2/components/dashboard/settings/Metadata.vue b/packages/nc-gui-v2/components/dashboard/settings/Metadata.vue new file mode 100644 index 0000000000..334bec0c80 --- /dev/null +++ b/packages/nc-gui-v2/components/dashboard/settings/Metadata.vue @@ -0,0 +1,110 @@ + + + diff --git a/packages/nc-gui-v2/components/dashboard/settings/SettingsModal.vue b/packages/nc-gui-v2/components/dashboard/settings/SettingsModal.vue index ddc82ef0cc..ccb6bd4974 100644 --- a/packages/nc-gui-v2/components/dashboard/settings/SettingsModal.vue +++ b/packages/nc-gui-v2/components/dashboard/settings/SettingsModal.vue @@ -2,6 +2,7 @@ import type { FunctionalComponent, SVGAttributes } from 'vue' import AuditTab from './AuditTab.vue' import AppStore from './AppStore.vue' +import Metadata from './Metadata.vue' import StoreFrontOutline from '~icons/mdi/storefront-outline' import TeamFillIcon from '~icons/ri/team-fill' import MultipleTableIcon from '~icons/mdi/table-multiple' @@ -61,7 +62,7 @@ const tabsInfo: TabGroup = { subTabs: { metaData: { title: 'Metadata', - body: () => AuditTab, + body: () => Metadata, }, acl: { title: 'UI Access Control', From d3e11dafafc73981e58d6b91e7a264d5f22159d0 Mon Sep 17 00:00:00 2001 From: mertmit Date: Tue, 26 Jul 2022 20:08:30 +0300 Subject: [PATCH 02/27] feat(gui-v2): project UI ACL Signed-off-by: mertmit --- .../dashboard/settings/SettingsModal.vue | 3 +- .../components/dashboard/settings/UIAcl.vue | 167 ++++++++++++++++++ 2 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 packages/nc-gui-v2/components/dashboard/settings/UIAcl.vue diff --git a/packages/nc-gui-v2/components/dashboard/settings/SettingsModal.vue b/packages/nc-gui-v2/components/dashboard/settings/SettingsModal.vue index ccb6bd4974..b3eb076fa7 100644 --- a/packages/nc-gui-v2/components/dashboard/settings/SettingsModal.vue +++ b/packages/nc-gui-v2/components/dashboard/settings/SettingsModal.vue @@ -3,6 +3,7 @@ import type { FunctionalComponent, SVGAttributes } from 'vue' import AuditTab from './AuditTab.vue' import AppStore from './AppStore.vue' import Metadata from './Metadata.vue' +import UIAcl from './UIAcl.vue' import StoreFrontOutline from '~icons/mdi/storefront-outline' import TeamFillIcon from '~icons/ri/team-fill' import MultipleTableIcon from '~icons/mdi/table-multiple' @@ -66,7 +67,7 @@ const tabsInfo: TabGroup = { }, acl: { title: 'UI Access Control', - body: () => AuditTab, + body: () => UIAcl, }, }, }, diff --git a/packages/nc-gui-v2/components/dashboard/settings/UIAcl.vue b/packages/nc-gui-v2/components/dashboard/settings/UIAcl.vue new file mode 100644 index 0000000000..7a2b5eeaea --- /dev/null +++ b/packages/nc-gui-v2/components/dashboard/settings/UIAcl.vue @@ -0,0 +1,167 @@ + + + From ab835aed092808526492de226d9b9dc065d24cf2 Mon Sep 17 00:00:00 2001 From: mertmit Date: Tue, 26 Jul 2022 20:43:41 +0300 Subject: [PATCH 03/27] fix(gui-v2): make UI ACL role columns same size Signed-off-by: mertmit --- packages/nc-gui-v2/components/dashboard/settings/UIAcl.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/nc-gui-v2/components/dashboard/settings/UIAcl.vue b/packages/nc-gui-v2/components/dashboard/settings/UIAcl.vue index 7a2b5eeaea..b361ded48f 100644 --- a/packages/nc-gui-v2/components/dashboard/settings/UIAcl.vue +++ b/packages/nc-gui-v2/components/dashboard/settings/UIAcl.vue @@ -55,7 +55,6 @@ const columns = [ { title: tableHeaderRenderer('Table name'), name: 'table_name', - onFilter: (value: string, record: any) => record._ptn.indexOf(value) === 0, }, { title: tableHeaderRenderer('View name'), @@ -65,14 +64,17 @@ const columns = [ // { icon: MdiGridIcon, color: 'blue' }, title: tableHeaderRenderer('Editor'), name: 'editor', + width: 150, }, { title: tableHeaderRenderer('Commenter'), name: 'commenter', + width: 150, }, { title: tableHeaderRenderer('Viewer'), name: 'viewer', + width: 150, }, ] From ce93117f890ceb2348ffd7da2f8b1fe3645fbb49 Mon Sep 17 00:00:00 2001 From: mertmit Date: Tue, 26 Jul 2022 20:44:28 +0300 Subject: [PATCH 04/27] feat(gui-v2): improved UI ACL table role handling Signed-off-by: mertmit --- .../components/dashboard/settings/UIAcl.vue | 53 ++++++------------- 1 file changed, 15 insertions(+), 38 deletions(-) diff --git a/packages/nc-gui-v2/components/dashboard/settings/UIAcl.vue b/packages/nc-gui-v2/components/dashboard/settings/UIAcl.vue index b361ded48f..c50ff05a51 100644 --- a/packages/nc-gui-v2/components/dashboard/settings/UIAcl.vue +++ b/packages/nc-gui-v2/components/dashboard/settings/UIAcl.vue @@ -10,6 +10,7 @@ const { $api, $e } = useNuxtApp() const { project } = useProject() const toast = useToast() +const roles = $ref>(['editor', 'commenter', 'viewer']) let isLoading = $ref(false) let tables = $ref>([]) let searchInput = $ref('') @@ -123,44 +124,20 @@ const columns = [ {{ record.title }} -
- - - - -
-
- - - - -
-
- - - - +
+
+ + + + +
From bb2a0e395e12b8b9eb6cd484568d37b06ab9984e Mon Sep 17 00:00:00 2001 From: mertmit Date: Tue, 26 Jul 2022 21:42:03 +0300 Subject: [PATCH 05/27] fix(gui-v2): requested changes for PR Signed-off-by: mertmit --- .../dashboard/settings/Metadata.vue | 4 +- .../components/dashboard/settings/UIAcl.vue | 45 +++++++++---------- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/packages/nc-gui-v2/components/dashboard/settings/Metadata.vue b/packages/nc-gui-v2/components/dashboard/settings/Metadata.vue index 334bec0c80..54bbb68ebb 100644 --- a/packages/nc-gui-v2/components/dashboard/settings/Metadata.vue +++ b/packages/nc-gui-v2/components/dashboard/settings/Metadata.vue @@ -10,11 +10,12 @@ const toast = useToast() let isLoading = $ref(false) let isDifferent = $ref(false) -let metadiff = $ref>([]) +let metadiff = $ref([]) async function loadMetaDiff() { try { if (!project.value?.id) return + isLoading = true isDifferent = false metadiff = await $api.project.metaDiffGet(project.value?.id) @@ -34,6 +35,7 @@ async function loadMetaDiff() { async function syncMetaDiff() { try { if (!project.value?.id || !isDifferent) return + isLoading = true await $api.project.metaDiffSync(project.value.id) toast.info(`Table metadata recreated successfully`) diff --git a/packages/nc-gui-v2/components/dashboard/settings/UIAcl.vue b/packages/nc-gui-v2/components/dashboard/settings/UIAcl.vue index c50ff05a51..19efc18801 100644 --- a/packages/nc-gui-v2/components/dashboard/settings/UIAcl.vue +++ b/packages/nc-gui-v2/components/dashboard/settings/UIAcl.vue @@ -10,14 +10,23 @@ const { $api, $e } = useNuxtApp() const { project } = useProject() const toast = useToast() -const roles = $ref>(['editor', 'commenter', 'viewer']) +const roles = $ref(['editor', 'commenter', 'viewer']) let isLoading = $ref(false) -let tables = $ref>([]) -let searchInput = $ref('') +let tables = $ref([]) +let searchInput = $ref('') + +const filteredTables = computed(() => + tables.filter( + (el) => + (typeof el?._ptn === 'string' && el._ptn.toLowerCase().includes(searchInput.toLowerCase())) || + (typeof el?.title === 'string' && el.title.toLowerCase().includes(searchInput.toLowerCase())), + ), +) async function loadTableList() { try { if (!project.value?.id) return + isLoading = true // TODO includeM2M tables = await $api.project.modelVisibilityList(project.value?.id, { @@ -33,6 +42,7 @@ async function loadTableList() { async function saveUIAcl() { try { if (!project.value?.id) return + await $api.project.modelVisibilitySet( project.value.id, tables.filter((t) => t.edited), @@ -44,6 +54,11 @@ async function saveUIAcl() { $e('a:proj-meta:ui-acl') } +const onRoleCheck = (record: any, role: string) => { + record.disabled[role] = !record.disabled[role] + record.edited = true +} + onMounted(async () => { if (tables.length === 0) { await loadTableList() @@ -102,20 +117,7 @@ const columns = [
- + - + + diff --git a/packages/nc-gui-v2/pages/nc/[projectId]/index/index.vue b/packages/nc-gui-v2/pages/nc/[projectId]/index/index.vue new file mode 100644 index 0000000000..8119a0ec08 --- /dev/null +++ b/packages/nc-gui-v2/pages/nc/[projectId]/index/index.vue @@ -0,0 +1,11 @@ + + + + + diff --git a/packages/nc-gui-v2/pages/nc/[projectId]/index/index/index.vue b/packages/nc-gui-v2/pages/nc/[projectId]/index/index/index.vue new file mode 100644 index 0000000000..d40f82d345 --- /dev/null +++ b/packages/nc-gui-v2/pages/nc/[projectId]/index/index/index.vue @@ -0,0 +1,17 @@ + + + + + From 6292e1f2aa4442d94cfb5cca955ef3c222e88f8c Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 23 Jul 2022 13:43:26 +0530 Subject: [PATCH 09/27] wip(gui-v2): route based tab navigation Signed-off-by: Pranav C --- packages/nc-gui-v2/composables/useTabs.ts | 37 ++++++++++++++++++- .../pages/nc/[projectId]/index/index.vue | 33 ++++++++++++++--- .../index/table/[title]/[viewTitle]/index.vue | 9 +++++ .../index/index/table/[title]/index.vue | 9 +++++ 4 files changed, 81 insertions(+), 7 deletions(-) create mode 100644 packages/nc-gui-v2/pages/nc/[projectId]/index/index/table/[title]/[viewTitle]/index.vue create mode 100644 packages/nc-gui-v2/pages/nc/[projectId]/index/index/table/[title]/index.vue diff --git a/packages/nc-gui-v2/composables/useTabs.ts b/packages/nc-gui-v2/composables/useTabs.ts index d2fef08531..e2e5a65517 100644 --- a/packages/nc-gui-v2/composables/useTabs.ts +++ b/packages/nc-gui-v2/composables/useTabs.ts @@ -15,7 +15,42 @@ function getPredicate(key: Partial) { export default () => { const tabs = useState('tabs', () => []) - const activeTab = useState('activeTab', () => 0) + // const activeTab = useState('activeTab', () => 0) + + const route = useRoute() + const router = useRouter() + const { tables } = useProject() + + const activeTab: WritableComputedRef = computed({ + get() { + if ((route?.name as string)?.startsWith('nc-projectId-index-index-table-title') && tables?.value?.length) { + const tab: Partial = { type: 'table', title: route.params.title as string } + const id = tables.value?.find((t) => t.title === tab.title)?.id + tab.id = id as string + let index = tabs.value.findIndex((t) => t.id === tab.id) + if (index === -1) { + tabs.value.push(tab as TabItem) + index = tabs.value.length - 1 + } + return index + } + return -1 + }, + set(index: number) { + if (index === -1) { + router.push(`/nc/${route.params.projectId}`) + } else { + router.push(`/nc/${route.params.projectId}/table/${tabs.value?.[index]?.title}`) + } + }, + + // if (route.params.title) { + // const tab = tabs.value.find(t => t.id === route.params.tab) + // if (tab) { + // activeTab.value = tabs.value.indexOf(tab) + // } + // } + }) const addTab = (tabMeta: TabItem) => { const tabIndex = tabs.value.findIndex((tab) => tab.id === tabMeta.id) diff --git a/packages/nc-gui-v2/pages/nc/[projectId]/index/index.vue b/packages/nc-gui-v2/pages/nc/[projectId]/index/index.vue index 8119a0ec08..2f2ce1a288 100644 --- a/packages/nc-gui-v2/pages/nc/[projectId]/index/index.vue +++ b/packages/nc-gui-v2/pages/nc/[projectId]/index/index.vue @@ -1,11 +1,32 @@ - - + diff --git a/packages/nc-gui-v2/pages/nc/[projectId]/index/index/table/[title]/[viewTitle]/index.vue b/packages/nc-gui-v2/pages/nc/[projectId]/index/index/table/[title]/[viewTitle]/index.vue new file mode 100644 index 0000000000..8435a144c0 --- /dev/null +++ b/packages/nc-gui-v2/pages/nc/[projectId]/index/index/table/[title]/[viewTitle]/index.vue @@ -0,0 +1,9 @@ + + + + + diff --git a/packages/nc-gui-v2/pages/nc/[projectId]/index/index/table/[title]/index.vue b/packages/nc-gui-v2/pages/nc/[projectId]/index/index/table/[title]/index.vue new file mode 100644 index 0000000000..10745f6de9 --- /dev/null +++ b/packages/nc-gui-v2/pages/nc/[projectId]/index/index/table/[title]/index.vue @@ -0,0 +1,9 @@ + + + + + From 73d532f145335744f8c90b20f7d7d2a4ed2d4521 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Mon, 25 Jul 2022 12:36:21 +0530 Subject: [PATCH 10/27] fix(gui-v2): handle closing active tab Signed-off-by: Pranav C --- packages/nc-gui-v2/composables/useTabs.ts | 26 +++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/nc-gui-v2/composables/useTabs.ts b/packages/nc-gui-v2/composables/useTabs.ts index e2e5a65517..2485fb46bb 100644 --- a/packages/nc-gui-v2/composables/useTabs.ts +++ b/packages/nc-gui-v2/composables/useTabs.ts @@ -1,4 +1,6 @@ +import type { WritableComputedRef } from '@vue/reactivity' import { useState } from '#app' +import useProject from '~/composables/useProject' export interface TabItem { type: 'table' | 'view' | 'auth' @@ -43,13 +45,6 @@ export default () => { router.push(`/nc/${route.params.projectId}/table/${tabs.value?.[index]?.title}`) } }, - - // if (route.params.title) { - // const tab = tabs.value.find(t => t.id === route.params.tab) - // if (tab) { - // activeTab.value = tabs.value.indexOf(tab) - // } - // } }) const addTab = (tabMeta: TabItem) => { @@ -67,13 +62,18 @@ export default () => { const clearTabs = () => { tabs.value = [] } - - const closeTab = (key: number | Partial) => { - if (typeof key === 'number') tabs.value.splice(key, 1) - else { - const index = tabs.value.findIndex(getPredicate(key)) - if (index > -1) tabs.value.splice(index, 1) + const closeTab = async (key: number | Partial) => { + const index = typeof key === 'number' ? key : tabs.value.findIndex(getPredicate(key)) + if (activeTab.value === index) { + let newTabIndex = index - 1 + if (newTabIndex < 0 && tabs.value?.length > 1) newTabIndex = index + 1 + if (newTabIndex === -1) { + await router.push(`/nc/${route.params.projectId}`) + } else { + await router.push(`/nc/${route.params.projectId}/table/${tabs.value?.[newTabIndex]?.title}`) + } } + tabs.value.splice(index, 1) } const updateTab = (key: number | Partial, newTabItemProps: Partial) => { From 78a8c1caa62396810c431528e3ab52833b550797 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Mon, 25 Jul 2022 13:03:46 +0530 Subject: [PATCH 11/27] feat(gui-v2): render smartsheet based on route Signed-off-by: Pranav C --- .../components/dashboard/TreeView.vue | 2 +- .../nc-gui-v2/components/tabs/Smartsheet.vue | 19 +++++------- packages/nc-gui-v2/composables/useTabs.ts | 29 ++++++++++++++----- packages/nc-gui-v2/context/index.ts | 5 ++-- .../nc-gui-v2/pages/nc/[projectId]/index.vue | 2 ++ .../pages/nc/[projectId]/index/index.vue | 8 +++-- .../[title]/[viewTitle]/index.vue | 4 ++- .../index/{table => [type]}/[title]/index.vue | 4 ++- .../pages/nc/[projectId]/index/index/auth.vue | 5 ++++ .../pages/project/index/create-external.vue | 1 - .../nocodb-sdk/src/lib/helperFunctions.ts | 13 +++++---- 11 files changed, 58 insertions(+), 34 deletions(-) rename packages/nc-gui-v2/pages/nc/[projectId]/index/index/{table => [type]}/[title]/[viewTitle]/index.vue (64%) rename packages/nc-gui-v2/pages/nc/[projectId]/index/index/{table => [type]}/[title]/index.vue (64%) create mode 100644 packages/nc-gui-v2/pages/nc/[projectId]/index/index/auth.vue diff --git a/packages/nc-gui-v2/components/dashboard/TreeView.vue b/packages/nc-gui-v2/components/dashboard/TreeView.vue index ab122869b1..2a0b628fda 100644 --- a/packages/nc-gui-v2/components/dashboard/TreeView.vue +++ b/packages/nc-gui-v2/components/dashboard/TreeView.vue @@ -192,7 +192,7 @@ const reloadTables = async () => { } const addTableTab = (table: TableType) => { $e('a:table:open') - addTab({ title: table.title, id: table.id }) + addTab({ title: table.title, id: table.id, type: table.type as any }) } diff --git a/packages/nc-gui-v2/components/tabs/Smartsheet.vue b/packages/nc-gui-v2/components/tabs/Smartsheet.vue index cfbf6b7a07..763689697a 100644 --- a/packages/nc-gui-v2/components/tabs/Smartsheet.vue +++ b/packages/nc-gui-v2/components/tabs/Smartsheet.vue @@ -1,25 +1,22 @@