Browse Source

fix(nc-gui): add redirection page

Ramesh Mane 1 week ago
parent
commit
0f955a0c7f
  1. 17
      packages/nc-gui/components/dlg/share-and-collaborate/SharePage.vue
  2. 17
      packages/nc-gui/pages/shared/[slug].vue
  3. 4
      packages/nocodb/src/schema/swagger.json
  4. 8
      packages/nocodb/src/services/views.service.ts

17
packages/nc-gui/components/dlg/share-and-collaborate/SharePage.vue

@ -54,6 +54,10 @@ const url = computed(() => {
return sharedViewUrl() ?? '' return sharedViewUrl() ?? ''
}) })
const preFillFormSearchParams = computed(() => {
return viewStore.preFillFormSearchParams && formPreFill.value.preFillEnabled ? viewStore.preFillFormSearchParams : ''
})
const passwordProtectedLocal = ref(false) const passwordProtectedLocal = ref(false)
const passwordProtected = computed(() => { const passwordProtected = computed(() => {
@ -134,7 +138,11 @@ const dashboardUrl1 = computed(() => {
}) })
const copyCustomUrl = () => { const copyCustomUrl = () => {
copy(`${dashboardUrl1.value}}#/shared/${customUrl.value}`) copy(
`${dashboardUrl1.value}#/p/${customUrl.value}${
preFillFormSearchParams.value && activeView.value?.type === ViewTypes.FORM ? `?${preFillFormSearchParams.value}` : ''
}`,
)
} }
onMounted(() => { onMounted(() => {
@ -242,7 +250,7 @@ const handleChangeFormPreFill = (value: { preFillEnabled?: boolean; preFilledMod
} }
} }
function sharedViewUrl() { function sharedViewUrl(withPrefill = true) {
if (!activeView.value) return if (!activeView.value) return
let viewType let viewType
@ -275,7 +283,7 @@ function sharedViewUrl() {
} }
return `${encodeURI(`${dashboardUrl1}#/nc/${viewType}/${activeView.value.uuid}${surveyMode.value ? '/survey' : ''}`)}${ return `${encodeURI(`${dashboardUrl1}#/nc/${viewType}/${activeView.value.uuid}${surveyMode.value ? '/survey' : ''}`)}${
viewStore.preFillFormSearchParams && formPreFill.value.preFillEnabled ? `?${viewStore.preFillFormSearchParams}` : '' withPrefill && preFillFormSearchParams.value ? `?${preFillFormSearchParams.value}` : ''
}` }`
} }
@ -346,6 +354,7 @@ async function updateSharedView() {
meta, meta,
password: activeView.value.password, password: activeView.value.password,
custom_url_path: customUrl.value ?? null, custom_url_path: customUrl.value ?? null,
original_url: sharedViewUrl(false),
}) })
activeView.value.custom_url_path = customUrl.value ?? null activeView.value.custom_url_path = customUrl.value ?? null
} catch (e: any) { } catch (e: any) {
@ -405,7 +414,7 @@ async function savePreFilledMode() {
v-if="isOpenCustomUrl" v-if="isOpenCustomUrl"
class="flex items-center mt-2 pl-2 pr-1 w-full border-1 rounded-lg focus-within:(border-1 border-nc-border-brand shadow-selected)" class="flex items-center mt-2 pl-2 pr-1 w-full border-1 rounded-lg focus-within:(border-1 border-nc-border-brand shadow-selected)"
> >
<div class="text-nc-content-gray-muted">{{ dashboardUrl1 }}#/shared/</div> <div class="text-nc-content-gray-muted">{{ dashboardUrl1 }}#/p/</div>
<a-input <a-input
ref="customUrlInputRef" ref="customUrlInputRef"
v-model:value="customUrl" v-model:value="customUrl"

17
packages/nc-gui/pages/shared/[slug].vue

@ -1,17 +0,0 @@
<script setup lang="ts">
definePageMeta({
public: true,
requiresAuth: false,
hasSidebar: false,
})
const route = useRoute()
useMetas()
</script>
<template>
<div class="h-full">This is shared page use for redirection purpose only {{ route.params.slug }}</div>
</template>
<style lang="scss" scoped></style>

4
packages/nocodb/src/schema/swagger.json

@ -24972,6 +24972,10 @@
"$ref": "#/components/schemas/StringOrNull", "$ref": "#/components/schemas/StringOrNull",
"description": "Password to restrict access" "description": "Password to restrict access"
}, },
"original_url": {
"$ref": "#/components/schemas/StringOrNull",
"description": "Original url user to redirect from custom url path"
},
"custom_url_path": { "custom_url_path": {
"$ref": "#/components/schemas/StringOrNull", "$ref": "#/components/schemas/StringOrNull",
"description": "Custom url path" "description": "Custom url path"

8
packages/nocodb/src/services/views.service.ts

@ -282,6 +282,11 @@ export class ViewsService {
if (param.sharedView.custom_url_path) { if (param.sharedView.custom_url_path) {
await CustomUrl.update(view.fk_custom_url_id, { await CustomUrl.update(view.fk_custom_url_id, {
custom_path: param.sharedView.custom_url_path, custom_path: param.sharedView.custom_url_path,
...(customUrl.original_path !== param.sharedView.original_url
? {
original_path: param.sharedView.original_url,
}
: {}),
}); });
} else { } else {
await CustomUrl.delete({ id: view.fk_custom_url_id }); await CustomUrl.delete({ id: view.fk_custom_url_id });
@ -293,8 +298,7 @@ export class ViewsService {
base_id: view.base_id, base_id: view.base_id,
fk_model_id: view.fk_model_id, fk_model_id: view.fk_model_id,
view_id: view.id, view_id: view.id,
// Todo: add original path original_path: param.sharedView.original_url,
original_path: '',
custom_path: param.sharedView.custom_url_path, custom_path: param.sharedView.custom_url_path,
}); });
} }

Loading…
Cancel
Save