π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
fix: cleanup unused code and refactor
Ramesh Mane98c805207e7d
diff --git a/packages/nc-gui/components/workspace/CreateProjectDlg.vue b/packages/nc-gui/components/workspace/CreateProjectDlg.vueindex e595a57dbd..b355aa8027 100644--- a/packages/nc-gui/components/workspace/CreateProjectDlg.vue+++ b/packages/nc-gui/components/workspace/CreateProjectDlg.vue@@ -2,8 +2,6 @@import type { RuleObject } from 'ant-design-vue/es/form'import type { Form, Input } from 'ant-design-vue'import type { VNodeRef } from '@vue/runtime-core'-import { computed } from '@vue/reactivity'-import { trimMatchingQuotes } from 'nocodb-sdk'const props = defineProps<{modelValue: boolean@@ -12,15 +10,8 @@ const props = defineProps<{const emit = defineEmits(['update:modelValue'])-const router = useRouter()-const route = router.currentRoute-const { t } = useI18n()-const { isUIAllowed } = useRoles()--const { orgRoles, workspaceRoles, isBaseRolesLoaded } = useRoles()-const dialogShow = useVModel(props, 'modelValue', emit)const basesStore = useBases()@@ -52,24 +43,8 @@ const formState = ref({const creating = ref(false)-const aiMode = ref<boolean | null>(null)--const modalSize = computed(() => (aiMode.value !== true ? 'small' : 'lg'))-const input: VNodeRef = ref<typeof Input>()-const aiModeInitialValue = ref({- basePrompt: '',- baseName: '',-})--const hasBaseCreatePermission = computed(- () =>- !!isBaseRolesLoaded.value &&- isUIAllowed('baseCreate', { roles: workspaceRoles.value ?? orgRoles.value }) &&- !isSharedBase.value,-)-const createProject = async () => {if (formState.value.title) {formState.value.title = formState.value.title.trim()@@ -116,96 +91,21 @@ const onInit = () => {}, 5)}-const onSandboxInstalled = async (_sandbox: any) => {- // Close the dialog and refresh the base list- dialogShow.value = false- refreshCommandPalette()- // Navigate to the newly installed base if available- // TODO: Once install returns the new baseId, navigate to it- // if (sandbox.installedBaseId) {- // await navigateToProject({- // workspaceId: activeWorkspace.value?.id,- // baseId: sandbox.installedBaseId,- // })- // }-}-const handleResetInitialValue = () => {- // Avoid unnecessary reset of initial value- if (!aiModeInitialValue.value.basePrompt && !route.value?.query?.basePrompt) return- aiModeInitialValue.value = {- basePrompt: '',- baseName: '',+watch(dialogShow, (n) => {+ if (n) {+ onInit()}-- /**- * We don't want to trigger route change here, so we are using `removeQueryParamsFromURL`- */- removeQueryParamsFromURL(['basePrompt', 'baseName'])-}--watch(dialogShow, async (n, o) => {- if (n === o && !n) return-- // If ai prompt is set, don't reset the aiMode value- if (n && aiModeInitialValue.value.basePrompt) return-- if (!n) {- handleResetInitialValue()- }-- aiMode.value = null-})--watch(aiMode, () => {- if (aiMode.value !== false) return-- onInit()})-/**- * this `CreateProjectDlg` is used in multiple places and we are trying to show modal dialog based on the query params- * So to avoid multiple dialogs being shown, we are using `isCreateNewActionMenu` props- */-if (props.isCreateNewActionMenu) {- watch(- [() => route.value.query?.basePrompt, () => route.value.query?.baseName, () => hasBaseCreatePermission.value],- ([basePrompt, baseName, hasPermission]) => {- /**- * Avoid showing prefilled ai base create dialog if basePrompt is not available or if dialog is already shown or if rowId is present in the query params- */- if (!(basePrompt as string)?.trim() || dialogShow.value || route.value.query?.rowId || !hasPermission) return-- aiModeInitialValue.value = {- basePrompt: trimMatchingQuotes(basePrompt as string),- baseName: trimMatchingQuotes(baseName as string),- }-- aiMode.value = true-- dialogShow.value = true- },- {- immediate: true,- },- )-}</script><template>- <NcModal- :key="`${aiMode}`"- v-model:visible="dialogShow"- :size="modalSize"- :width="aiMode === null ? 'auto' : undefined"- :show-separator="false"- :wrap-class-name="- aiMode ? 'nc-modal-ai-base-create' : `nc-modal-wrapper ${aiMode === null ? 'nc-ai-select-base-create-mode-modal' : ''}`- "- >- <template v-if="aiMode === false" #header>- <!-- Create A New Table -->+ <NcModal v-model:visible="dialogShow" size="small" :show-separator="false" wrap-class-name="nc-modal-wrapper">++ <template #header>+ <!-- Create A New Base --><div class="flex flex-row items-center text-base text-nc-content-gray"><GeneralProjectIcon :color="formState.meta.iconColor" class="mr-2.5" />{{@@ -215,97 +115,37 @@ if (props.isCreateNewActionMenu) {}}</div></template>- <template v-if="aiMode === null">- <WorkspaceProjectCreateMode- v-model:ai-mode="aiMode"- :workspace-id="activeWorkspace?.id"- @sandbox-installed="onSandboxInstalled"- @close="dialogShow = false"- />- </template>- <template v-if="aiMode === false">- <div class="mt-1">- <a-form- ref="form"- :model="formState"- name="basic"- layout="vertical"- class="w-full !mx-auto"- no-style- autocomplete="off"- @finish="createProject"- >- <a-form-item name="title" :rules="nameValidationRules" class="!mb-0">- <a-input- ref="input"- v-model:value="formState.title"- name="title"- class="nc-metadb-base-name nc-input-sm nc-input-shadow"- placeholder="Title"- />- </a-form-item>- </a-form>- <div class="flex flex-row justify-end mt-5 gap-x-2">- <NcButton type="secondary" size="small" :disabled="creating" @click="dialogShow = false">{{- $t('general.cancel')+ <div class="mt-1">+ <a-form ref="form" :model="formState" name="basic" layout="vertical" class="w-full !mx-auto" no-style+ autocomplete="off" @finish="createProject">+ <a-form-item name="title" :rules="nameValidationRules" class="!mb-0">+ <a-input ref="input" v-model:value="formState.title" name="title"+ class="nc-metadb-base-name nc-input-sm nc-input-shadow" placeholder="Title" />+ </a-form-item>+ </a-form>++ <div class="flex flex-row justify-end mt-5 gap-x-2">+ <NcButton type="secondary" size="small" :disabled="creating" @click="dialogShow = false">{{+ $t('general.cancel')}}</NcButton>- <NcButton- v-e="['a:base:create']"- data-testid="docs-create-proj-dlg-create-btn"- :loading="creating"- type="primary"- size="small"- :disabled="creating"- :label="`${$t('general.create')} Base`"- :loading-label="`${$t('general.creating')} Base`"- @click="createProject"- >+ <NcButton v-e="['a:base:create']" data-testid="docs-create-proj-dlg-create-btn" :loading="creating"+ type="primary" size="small" :disabled="creating" :label="`${$t('general.create')} Base`"+ :loading-label="`${$t('general.creating')} Base`" @click="createProject">+ {{+ $t('general.createEntity', {+ entity: 'Base',+ })+ }}+ <template #loading>{{- $t('general.createEntity', {+ $t('general.creatingEntity', {entity: 'Base',})}}- <template #loading>- {{- $t('general.creatingEntity', {- entity: 'Base',- })- }}- </template>- </NcButton>- </div>+ </template>+ </NcButton></div>- </template>- <template v-if="aiMode === true">- <WorkspaceProjectAiCreateProject- v-model:ai-mode="aiMode"- v-model:dialog-show="dialogShow"- :is-create-new-action-menu="isCreateNewActionMenu"- :initial-value="aiModeInitialValue"- />- </template>+ </div></NcModal></template>--<style lang="scss">-.nc-modal-ai-base-create .ant-modal-content {- .nc-modal {- @apply !p-0;-- .nc-modal-header {- @apply mb-0 px-4 py-2 items-center gap-3;- }-- .ant-checkbox {- @apply !shadow-none;- }- }-}--.nc-modal-wrapper.nc-ai-select-base-create-mode-modal {- .ant-modal-content {- @apply !rounded-[24px];- }-}-</style>diff --git a/packages/nc-gui/components/dashboard/TreeView/CreateProject/Menu.vue b/packages/nc-gui/components/workspace/project/create/Menu.vuesimilarity index 100%rename from packages/nc-gui/components/dashboard/TreeView/CreateProject/Menu.vuerename to packages/nc-gui/components/workspace/project/create/Menu.vuediff --git a/packages/nc-gui/components/dashboard/TreeView/CreateProject/MenuItem.vue b/packages/nc-gui/components/workspace/project/create/MenuItem.vuesimilarity index 88%rename from packages/nc-gui/components/dashboard/TreeView/CreateProject/MenuItem.vuerename to packages/nc-gui/components/workspace/project/create/MenuItem.vueindex b397a5193e..0a3ab7afd9 100644--- a/packages/nc-gui/components/dashboard/TreeView/CreateProject/MenuItem.vue+++ b/packages/nc-gui/components/workspace/project/create/MenuItem.vue@@ -20,9 +20,7 @@ withDefaults(defineProps<Props>(), {:class="`nc-create-project-menu-item-${variant}`"><div class="nc-icon-wrapper"><slot name="icon">- <GeneralIcon v-if="icon" :icon="icon" class="h-4 w-4 flex-none" :class="{- 'mt-0.5': $slots.subtext || subtext- }" />+ <GeneralIcon v-if="icon" :icon="icon" class="h-4 w-4 flex-none" /></slot></div>@@ -39,7 +37,7 @@ withDefaults(defineProps<Props>(), {<style lang="scss" scoped>.nc-icon-wrapper {- @apply flex items-center justify-center h-4 w-4 children:flex-none;+ @apply flex items-center justify-center h-5 children:flex-none;}.nc-create-project-menu-item-modal {diff --git a/packages/nc-gui/pages/index.vue b/packages/nc-gui/pages/index.vueindex 3954068b8e..9528167138 100644--- a/packages/nc-gui/pages/index.vue+++ b/packages/nc-gui/pages/index.vue@@ -36,7 +36,7 @@ const autoNavigateToProject = async () => {if (!firstBase?.id) return- await basesStore.navigateToProject({ baseId: firstBase.id!, query: extractAiBaseCreateQueryParams(route.value.query) })+ await basesStore.navigateToProject({ baseId: firstBase.id! })}const isSharedView = computed(() => {diff --git a/packages/nc-gui/pages/index/[typeOrId]/[baseId]/index/index/index.vue b/packages/nc-gui/pages/index/[typeOrId]/[baseId]/index/index/index.vueindex f5d6115558..7f6683d600 100644--- a/packages/nc-gui/pages/index/[typeOrId]/[baseId]/index/index/index.vue+++ b/packages/nc-gui/pages/index/[typeOrId]/[baseId]/index/index/index.vue@@ -159,7 +159,7 @@ watch(return}- openTable(activeTables.value[0]!, true, extractAiBaseCreateQueryParams(route.value.query))+ openTable(activeTables.value[0]!, true)},{immediate: true,