From eff5e3f19440e909f8626f6d1e6fcf3f093bfa4a Mon Sep 17 00:00:00 2001 From: mertmit Date: Sun, 2 Oct 2022 21:10:32 +0300 Subject: [PATCH] feat: delete base Signed-off-by: mertmit --- .../dashboard/settings/DataSources.vue | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/packages/nc-gui/components/dashboard/settings/DataSources.vue b/packages/nc-gui/components/dashboard/settings/DataSources.vue index 128c502cf0..924dc5f2be 100644 --- a/packages/nc-gui/components/dashboard/settings/DataSources.vue +++ b/packages/nc-gui/components/dashboard/settings/DataSources.vue @@ -21,8 +21,8 @@ const emits = defineEmits(['update:state', 'update:reload']) const vModel = useVModel(props, 'state', emits) const vReload = useVModel(props, 'reload', emits) -const { $api } = useNuxtApp() -const { project } = useProject() +const { $api, $e } = useNuxtApp() +const { project, loadProject } = useProject() let sources = $ref([]) let activeBaseId = $ref('') @@ -67,6 +67,30 @@ const baseAction = (baseId: string, action: string) => { vModel.value = action } +const deleteBase = (base: BaseType) => { + $e('c:base:delete') + + Modal.confirm({ + title: `Do you want to delete '${base.alias}' project?`, + wrapClassName: 'nc-modal-base-delete', + okText: 'Yes', + okType: 'danger', + cancelText: 'No', + async onOk() { + try { + await $api.base.delete(base.project_id as string, base.id as string) + + $e('a:base:delete') + + sources.splice(sources.indexOf(base), 1) + await loadProject() + } catch (e: any) { + message.error(await extractSdkResponseErrorMsg(e)) + } + }, + }) +} + onMounted(async () => { if (sources.length === 0) { await loadBases() @@ -140,7 +164,7 @@ watch( - +