Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

gui on duplicate target base / workspace

Fendy Heryantodd5c34eae3c1
diff --git a/packages/nc-gui/components/dlg/Table/Duplicate.vue b/packages/nc-gui/components/dlg/Table/Duplicate.vue
index c6b06ce4f9..2d754d2f12 100644
--- a/packages/nc-gui/components/dlg/Table/Duplicate.vue
+++ b/packages/nc-gui/components/dlg/Table/Duplicate.vue
@@ -1,5 +1,12 @@
<script setup lang="ts">
-import { type LinkToAnotherRecordType, type TableType, UITypes } from 'nocodb-sdk'
+import {
+ type BaseType,
+ type LinkToAnotherRecordType,
+ type TableType,
+ UITypes,
+ type WorkspaceType,
+ WorkspaceUserRoles,
+} from 'nocodb-sdk'
const props = defineProps<{
modelValue: boolean
@@ -16,7 +23,7 @@ const { $e, $poller } = useNuxtApp()
const basesStore = useBases()
-const { createProject: _createProject } = basesStore
+const { createProject: _createProject, loadProjects } = basesStore
const { openTable } = useTablesStore()
@@ -24,6 +31,8 @@ const baseStore = useBase()
const { loadTables } = baseStore
+const { base: activeBase } = storeToRefs(baseStore)
+
const { tables } = storeToRefs(baseStore)
const { getMeta } = useMetas()
@@ -34,6 +43,14 @@ const { activeTable: _activeTable } = storeToRefs(useTablesStore())
const { refreshCommandPalette } = useCommandPalette()
+const { workspacesList, activeWorkspace } = useWorkspace()
+
+// #region target base
+const wsDropdownOpen = ref(false)
+const baseDropdownOpen = ref(false)
+const targetWorkspace = ref(activeWorkspace)
+const targetBase = ref(activeBase.value)
+
const targetTableMeta = computedAsync(async () => {
return getMeta(props.table.id)
})
@@ -43,6 +60,30 @@ const canTargetOtherBase = computedAsync(async () => {
return isEeUI && !targetTableMeta.value.columns?.some((col) => [UITypes.Links, UITypes.LinkToAnotherRecord].includes(col.uidt))
})
+const workspaceOptions = computed(() => {
+ if (!isEeUI) return []
+ return workspacesList.filter((ws) =>
+ [WorkspaceUserRoles.CREATOR, WorkspaceUserRoles.OWNER].includes(ws.roles as WorkspaceUserRoles),
+ )
+})
+
+const selectWorkspace = (option: WorkspaceType) => {
+ targetWorkspace.value = option
+ wsDropdownOpen.value = false
+}
+
+const targetBases = computedAsync(async () => {
+ if (!isEeUI || !targetWorkspace.value) {
+ return []
+ }
+ return await loadProjects(undefined, targetWorkspace.value.id)
+})
+const selectBase = (option: BaseType) => {
+ targetBase.value = option
+ baseDropdownOpen.value = false
+}
+// #endregion taget base
+
const options = ref({
includeData: true,
includeViews: true,
@@ -186,15 +227,14 @@ const isEaster = ref(false)
<div v-if="canTargetOtherBase" class="mb-5">
<NcDivider divider-class="!my-5" />
- <div class="text-nc-content-gray font-medium leading-5">
+ <div class="text-nc-content-gray font-medium leading-5 mb-2">
{{ $t('labels.workspace') }}
- <!--
- <NcDropdown v-model:visible="dropdownOpen" class="mt-2">
+ <NcDropdown v-model:visible="wsDropdownOpen" class="mt-2">
<div
class="rounded-lg border-1 transition-all cursor-pointer flex items-center border-nc-border-gray-medium h-8 py-1 gap-2 px-3"
style="box-shadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.08)"
:class="{
- '!border-brand-500 !shadow-selected': dropdownOpen,
+ '!border-brand-500 !shadow-selected': wsDropdownOpen,
}"
>
<GeneralWorkspaceIcon size="small" :workspace="targetWorkspace" />
@@ -209,7 +249,7 @@ const isEaster = ref(false)
</div>
<GeneralIcon
:class="{
- 'transform rotate-180': dropdownOpen,
+ 'transform rotate-180': wsDropdownOpen,
}"
class="text-nc-content-gray transition-all w-4 h-4"
icon="ncChevronDown"
@@ -237,7 +277,7 @@ const isEaster = ref(false)
</template>
<template #listItem="{ option }">
- <div class="flex gap-2 w-full items-center" @click="selectOption(option)">
+ <div class="flex gap-2 w-full items-center" @click="selectWorkspace(option)">
<GeneralWorkspaceIcon :workspace="option" size="small" />
<div class="flex-1 text-[13px] truncate font-semibold leading-5 capitalize w-full">
@@ -254,7 +294,81 @@ const isEaster = ref(false)
</template>
</NcList>
</template>
- </NcDropdown> -->
+ </NcDropdown>
+ </div>
+
+ <div class="text-nc-content-gray font-medium leading-5">
+ {{ $t('objects.project') }}
+ <NcDropdown v-model:visible="baseDropdownOpen" class="mt-2">
+ <div
+ class="rounded-lg border-1 transition-all cursor-pointer flex items-center border-nc-border-gray-medium h-8 py-1 gap-2 px-3"
+ style="box-shadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.08)"
+ :class="{
+ '!border-brand-500 !shadow-selected': baseDropdownOpen,
+ }"
+ >
+ <!-- TODO: base icon
+ <GeneralWorkspaceIcon size="small" :workspace="targetWorkspace" />
+ -->
+
+ <div class="flex-1 capitalize truncate">
+ {{ targetBase?.title }}
+ </div>
+
+ <div class="flex gap-2 items-center">
+ <div v-if="activeBase?.id === targetBase?.id" class="text-nc-content-gray-muted leading-4.5 text-xs">
+ {{ $t('labels.currentBase') }}
+ </div>
+ <GeneralIcon
+ :class="{
+ 'transform rotate-180': baseDropdownOpen,
+ }"
+ class="text-nc-content-gray transition-all w-4 h-4"
+ icon="ncChevronDown"
+ />
+ </div>
+ </div>
+
+ <template #overlay>
+ <NcList
+ :value="targetBase"
+ :item-height="28"
+ close-on-select
+ class="nc-base-workspace-selection"
+ :min-items-for-search="6"
+ container-class-name="w-full"
+ :list="targetBases"
+ option-label-key="title"
+ >
+ <template #listHeader>
+ <div class="text-nc-content-gray-muted text-[13px] px-3 pt-2.5 pb-1.5 font-medium leading-5">
+ {{ $t('labels.duplicateBaseMessage') }}
+ </div>
+
+ <NcDivider />
+ </template>
+
+ <template #listItem="{ option }">
+ <div class="flex gap-2 w-full items-center" @click="selectBase(option)">
+ <!-- TODO: base icon
+ <GeneralWorkspaceIcon :workspace="option" size="small" />
+ -->
+
+ <div class="flex-1 text-[13px] truncate font-semibold leading-5 capitalize w-full">
+ {{ option.title }}
+ </div>
+
+ <div class="flex items-center gap-2">
+ <div v-if="activeBase?.id === option.id" class="text-nc-content-gray-muted leading-4.5 text-xs">
+ {{ $t('labels.currentBase') }}
+ </div>
+ <GeneralIcon v-if="option.id === targetBase?.id" class="text-brand-500 w-4 h-4" icon="ncCheck" />
+ </div>
+ </div>
+ </template>
+ </NcList>
+ </template>
+ </NcDropdown>
</div>
</div>
</div>