From 9e5222bccb19018b54a66ceea6cabcd9bbf397c7 Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Mon, 25 Nov 2024 16:27:34 +0000 Subject: [PATCH] fix: custom url is part of ee only --- .../dlg/share-and-collaborate/CustomUrl.vue | 16 ++ .../dlg/share-and-collaborate/SharePage.vue | 138 +++--------------- packages/nc-gui/lang/en.json | 1 + packages/nocodb/src/models/CustomUrl.ts | 3 +- packages/nocodb/src/models/View.ts | 31 ---- packages/nocodb/src/schema/swagger-v2.json | 34 +++++ 6 files changed, 71 insertions(+), 152 deletions(-) create mode 100644 packages/nc-gui/components/dlg/share-and-collaborate/CustomUrl.vue diff --git a/packages/nc-gui/components/dlg/share-and-collaborate/CustomUrl.vue b/packages/nc-gui/components/dlg/share-and-collaborate/CustomUrl.vue new file mode 100644 index 0000000000..213bb06b3b --- /dev/null +++ b/packages/nc-gui/components/dlg/share-and-collaborate/CustomUrl.vue @@ -0,0 +1,16 @@ + + + + + diff --git a/packages/nc-gui/components/dlg/share-and-collaborate/SharePage.vue b/packages/nc-gui/components/dlg/share-and-collaborate/SharePage.vue index ed8215f6bb..547a5f2463 100644 --- a/packages/nc-gui/components/dlg/share-and-collaborate/SharePage.vue +++ b/packages/nc-gui/components/dlg/share-and-collaborate/SharePage.vue @@ -281,7 +281,7 @@ async function saveTheme() { $e(`a:view:share:${viewTheme.value ? 'enable' : 'disable'}-theme`) } -async function updateSharedView() { +async function updateSharedView(custUrl = undefined) { try { if (!activeView.value?.meta) return const meta = activeView.value.meta @@ -289,10 +289,13 @@ async function updateSharedView() { await $api.dbViewShare.update(activeView.value.id!, { meta, password: activeView.value.password, - custom_url_path: customUrl.value ?? null, + ...(custUrl !== undefined ? { custom_url_path: custUrl ?? null } : {}), original_url: sharedViewUrl(false), }) - activeView.value.custom_url_path = customUrl.value ?? null + + if (custUrl !== undefined) { + activeView.value.custom_url_path = custUrl ?? null + } } catch (e: any) { message.error(await extractSdkResponseErrorMsg(e)) } @@ -300,29 +303,11 @@ async function updateSharedView() { return true } -const updateSharedViewWithDebounce = useDebounceFn( - async () => { - await updateSharedView() - }, - 250, - { maxWait: 2000 }, -) - async function savePreFilledMode() { await updateSharedView() } -const isOpenCustomUrlLocal = ref(false) - -const isOpenCustomUrl = computed(() => { - return !!activeView.value?.custom_url_path || isOpenCustomUrlLocal.value -}) - -const customUrlInputRef = ref() - -const customUrl = ref() - -const dashboardUrl1 = computed(() => { +const dashboardBaseUrl = computed(() => { // get base url for workspace const baseUrl = getBaseUrl(workspaceStore.activeWorkspaceId) @@ -333,59 +318,13 @@ const dashboardUrl1 = computed(() => { return dashboardUrl.value }) -const copyCustomUrl = () => { - copy( - `${dashboardUrl1.value}#/p/${customUrl.value}${ +const copyCustomUrl = async (custUrl = '') => { + return await copy( + `${dashboardBaseUrl.value}#/p/${encodeURIComponent(custUrl || activeView.value?.custom_url_path || '')}${ preFillFormSearchParams.value && activeView.value?.type === ViewTypes.FORM ? `?${preFillFormSearchParams.value}` : '' }`, ) } - -const toggleCustomUrl = async () => { - isOpenCustomUrlLocal.value = !isOpenCustomUrl.value - if (!activeView.value) return - if (isUpdating.value.customUrl) return - - isUpdating.value.customUrl = true - try { - if (isOpenCustomUrl.value) { - customUrl.value = null - } else { - customUrl.value = null - } - await updateSharedView() - } finally { - isUpdating.value.customUrl = false - - if (isOpenCustomUrl.value) { - customUrlInputRef.value?.focus() - } - } -} - -const isCustomUrlAvailable = ref(true) - -const checkAvailability = async () => { - try { - const res = await $api.customUrl.checkAvailability({ id: activeView.value?.fk_custom_url_id!, custom_path: customUrl.value }) - console.log('res', res) - } catch (e: any) { - console.error(e) - // message.error(await extractSdkResponseErrorMsg(e)) - } -} - -const checkAvailabilityWithDebounce = useDebounceFn( - async () => { - await checkAvailability() - }, - 250, - { maxWait: 2000 }, -) - -onMounted(() => { - customUrl.value = activeView.value?.custom_url_path -})