From 1c934004f57fa33739693b938c3ae5f355e90205 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 27 Aug 2024 07:23:43 +0000 Subject: [PATCH] feat: setup page --- .../nc-gui/components/account/Breadcrumb.vue | 7 ++ packages/nc-gui/components/account/Setup.vue | 62 ++++++++++ .../nc-gui/components/account/setup/Email.vue | 115 ++++++++++++++++++ .../components/account/setup/Storage.vue | 114 +++++++++++++++++ .../composables/useAccountSetupStore.ts | 46 +++++++ packages/nc-gui/lang/en.json | 3 + packages/nc-gui/pages/account/index.vue | 15 +++ .../nc-gui/pages/account/index/[page].vue | 1 + .../account/index/setup/[[nestedPage]].vue | 21 ++++ 9 files changed, 384 insertions(+) create mode 100644 packages/nc-gui/components/account/Setup.vue create mode 100644 packages/nc-gui/components/account/setup/Email.vue create mode 100644 packages/nc-gui/components/account/setup/Storage.vue create mode 100644 packages/nc-gui/composables/useAccountSetupStore.ts create mode 100644 packages/nc-gui/pages/account/index/setup/[[nestedPage]].vue diff --git a/packages/nc-gui/components/account/Breadcrumb.vue b/packages/nc-gui/components/account/Breadcrumb.vue index 097082944b..376f2cf841 100644 --- a/packages/nc-gui/components/account/Breadcrumb.vue +++ b/packages/nc-gui/components/account/Breadcrumb.vue @@ -44,6 +44,13 @@ const breadcrumb = computed(() => { }) break } + case 'setup': { + payload.push({ + title: t('labels.setup'), + active: true, + }) + break + } } switch (route.params.nestedPage) { diff --git a/packages/nc-gui/components/account/Setup.vue b/packages/nc-gui/components/account/Setup.vue new file mode 100644 index 0000000000..8721bef153 --- /dev/null +++ b/packages/nc-gui/components/account/Setup.vue @@ -0,0 +1,62 @@ + + + + + diff --git a/packages/nc-gui/components/account/setup/Email.vue b/packages/nc-gui/components/account/setup/Email.vue new file mode 100644 index 0000000000..10178bed20 --- /dev/null +++ b/packages/nc-gui/components/account/setup/Email.vue @@ -0,0 +1,115 @@ + + + + + diff --git a/packages/nc-gui/components/account/setup/Storage.vue b/packages/nc-gui/components/account/setup/Storage.vue new file mode 100644 index 0000000000..b1471b43ec --- /dev/null +++ b/packages/nc-gui/components/account/setup/Storage.vue @@ -0,0 +1,114 @@ + + + + + diff --git a/packages/nc-gui/composables/useAccountSetupStore.ts b/packages/nc-gui/composables/useAccountSetupStore.ts new file mode 100644 index 0000000000..96cbae53b6 --- /dev/null +++ b/packages/nc-gui/composables/useAccountSetupStore.ts @@ -0,0 +1,46 @@ +import rfdc from 'rfdc' +import type { ColumnReqType, ColumnType, PluginType, TableType } from 'nocodb-sdk' +import { UITypes, isLinksOrLTAR } from 'nocodb-sdk' +import type { Ref } from 'vue' +import type { RuleObject } from 'ant-design-vue/es/form' +import { generateUniqueColumnName } from '~/helpers/parsers/parserHelpers' + +const [useProvideAccountSetupStore, useAccountSetupStore] = createInjectionState(() => { + const apps = ref<(PluginType & { parsedInput?: Record; tags?: string[] })[]>([]) + + const { $api, $e } = useNuxtApp() + + const emailApps = computed(() => apps.value.filter((app) => app.category === 'Email')) + const storageApps = computed(() => apps.value.filter((app) => app.category === ('Storage'))) + + const loadSetupApps = async () => { + try { + const plugins = (await $api.plugin.list()).list ?? [] + + apps.value = plugins.map((p) => ({ + ...p, + tags: p.tags ? p.tags.split(',') : [], + parsedInput: p.input && JSON.parse(p.input as string), + })) as any[] + } catch (e: any) { + message.error(await extractSdkResponseErrorMsg(e)) + } + } + + return { + apps, + emailApps, + storageApps, + loadSetupApps, + } +}) + +export { useProvideAccountSetupStore } + +export function useAccountSetupStoreOrThrow() { + const columnCreateStore = useAccountSetupStore() + + if (columnCreateStore == null) throw new Error('Please call `useProvideAccountSetupStore` on the appropriate parent component') + + return columnCreateStore +} diff --git a/packages/nc-gui/lang/en.json b/packages/nc-gui/lang/en.json index 438ccfc4a3..681f4aa50b 100644 --- a/packages/nc-gui/lang/en.json +++ b/packages/nc-gui/lang/en.json @@ -616,6 +616,9 @@ "categories": "Categories" }, "labels": { + "setup": "Setup", + "setupLabel": "Setup {label}", + "switchToProd": "Switch to a production-ready app database", "fieldID": "Field ID", "addDescription": "Add description", "editDescription": "Edit description", diff --git a/packages/nc-gui/pages/account/index.vue b/packages/nc-gui/pages/account/index.vue index 5bff58c070..b6fefaa2ac 100644 --- a/packages/nc-gui/pages/account/index.vue +++ b/packages/nc-gui/pages/account/index.vue @@ -60,6 +60,21 @@ const logout = async () => {
{{ $t('labels.account') }}
+ +
+ + +
{{ $t('labels.setup') }}
+
+
+
+ diff --git a/packages/nc-gui/pages/account/index/setup/[[nestedPage]].vue b/packages/nc-gui/pages/account/index/setup/[[nestedPage]].vue new file mode 100644 index 0000000000..c92bbadb07 --- /dev/null +++ b/packages/nc-gui/pages/account/index/setup/[[nestedPage]].vue @@ -0,0 +1,21 @@ + + +