mirror of https://github.com/nocodb/nocodb
mertmit
1 year ago
7 changed files with 270 additions and 3 deletions
@ -0,0 +1,100 @@
|
||||
<script setup lang="ts"> |
||||
import { ProjectTypes } from 'nocodb-sdk' |
||||
import { isEeUI, useApi, useVModel, useWorkspace } from '#imports' |
||||
|
||||
const props = defineProps<{ |
||||
modelValue: boolean |
||||
onOk: (jobData: { name: string; id: string }) => Promise<void> |
||||
}>() |
||||
|
||||
const emit = defineEmits(['update:modelValue']) |
||||
|
||||
const { api } = useApi() |
||||
|
||||
const { sharedBaseId } = useCopySharedBase() |
||||
|
||||
const { workspacesList } = storeToRefs(useWorkspace()) |
||||
|
||||
const dialogShow = useVModel(props, 'modelValue', emit) |
||||
|
||||
const options = ref({ |
||||
includeData: true, |
||||
includeViews: true, |
||||
}) |
||||
|
||||
const optionsToExclude = computed(() => { |
||||
const { includeData, includeViews } = options.value |
||||
return { |
||||
excludeData: !includeData, |
||||
excludeViews: !includeViews, |
||||
} |
||||
}) |
||||
|
||||
const isLoading = ref(false) |
||||
|
||||
const selectedWorkspace = ref<string>() |
||||
|
||||
const _duplicate = async () => { |
||||
if (!selectedWorkspace.value && isEeUI) return |
||||
|
||||
try { |
||||
isLoading.value = true |
||||
const jobData = await api.base.duplicateShared(selectedWorkspace.value ?? 'nc', sharedBaseId.value, { |
||||
options: optionsToExclude.value, |
||||
base: isEeUI |
||||
? { |
||||
fk_workspace_id: selectedWorkspace.value, |
||||
type: ProjectTypes.DATABASE, |
||||
} |
||||
: {}, |
||||
}) |
||||
|
||||
sharedBaseId.value = null |
||||
|
||||
props.onOk({ ...jobData, workspace_id: selectedWorkspace.value } as any) |
||||
} catch (e: any) { |
||||
message.error(await extractSdkResponseErrorMsg(e)) |
||||
} finally { |
||||
isLoading.value = false |
||||
dialogShow.value = false |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<template> |
||||
<GeneralModal v-model:visible="dialogShow" class="!w-[30rem]" wrap-class-name="nc-modal-project-duplicate"> |
||||
<div> |
||||
<div class="prose-xl font-bold self-center">{{ $t('general.duplicate') }} {{ $t('labels.sharedBase') }}</div> |
||||
<template v-if="isEeUI"> |
||||
<div class="my-4">Select workspace to duplicate shared base to:</div> |
||||
|
||||
<NcSelect |
||||
v-model:value="selectedWorkspace" |
||||
class="w-full" |
||||
:options="workspacesList.map((w) => ({ label: w.title, value: w.id }))" |
||||
placeholder="Select Workspace" |
||||
/> |
||||
</template> |
||||
|
||||
<div class="prose-md self-center text-gray-500 mt-4">{{ $t('title.advancedSettings') }}</div> |
||||
|
||||
<a-divider class="!m-0 !p-0 !my-2" /> |
||||
|
||||
<div class="text-xs p-2"> |
||||
<a-checkbox v-model:checked="options.includeData">{{ $t('labels.includeData') }}</a-checkbox> |
||||
<a-checkbox v-model:checked="options.includeViews">{{ $t('labels.includeView') }}</a-checkbox> |
||||
</div> |
||||
</div> |
||||
<div class="flex flex-row gap-x-2 mt-2.5 pt-2.5 justify-end"> |
||||
<NcButton key="back" type="secondary" @click="dialogShow = false">{{ $t('general.cancel') }}</NcButton> |
||||
<NcButton |
||||
key="submit" |
||||
v-e="['a:shared-base:duplicate']" |
||||
:loading="isLoading" |
||||
:disabled="!selectedWorkspace && isEeUI" |
||||
@click="_duplicate" |
||||
>{{ $t('general.confirm') }} |
||||
</NcButton> |
||||
</div> |
||||
</GeneralModal> |
||||
</template> |
@ -0,0 +1,9 @@
|
||||
import { createSharedComposable, ref } from '#imports' |
||||
|
||||
export const useCopySharedBase = createSharedComposable(() => { |
||||
const sharedBaseId = ref<string | null>(null) |
||||
|
||||
return { |
||||
sharedBaseId, |
||||
} |
||||
}) |
@ -0,0 +1,21 @@
|
||||
<script lang="ts" setup> |
||||
import { useBase, useCopySharedBase, useRoute } from '#imports' |
||||
|
||||
const route = useRoute() |
||||
|
||||
const { sharedBaseId } = useCopySharedBase() |
||||
|
||||
const { forcedProjectId } = storeToRefs(useBase()) |
||||
|
||||
onMounted(() => { |
||||
sharedBaseId.value = route.query.base as string |
||||
if (forcedProjectId?.value) forcedProjectId.value = undefined |
||||
navigateTo(`/`) |
||||
}) |
||||
</script> |
||||
|
||||
<template> |
||||
<div></div> |
||||
</template> |
||||
|
||||
<style scoped></style> |
Loading…
Reference in new issue