From d1478fbd3046ceba9d0783f3fbd93b732cf6d813 Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Sat, 26 Oct 2024 06:59:54 +0000 Subject: [PATCH 1/5] fix(nc-gui): prefill form decode query param issue --- .../composables/useSharedFormViewStore.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/nc-gui/composables/useSharedFormViewStore.ts b/packages/nc-gui/composables/useSharedFormViewStore.ts index 32413b57f5..8b152dd551 100644 --- a/packages/nc-gui/composables/useSharedFormViewStore.ts +++ b/packages/nc-gui/composables/useSharedFormViewStore.ts @@ -441,13 +441,25 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share async function handlePreFillForm() { if (Object.keys(route.query || {}).length) { + // Decode both query parameter keys and values if values are present + const decodedQuery = Object.fromEntries( + Object.entries(route.query).map(([key, value]) => [ + decodeURIComponent(key), + value + ? Array.isArray(value) + ? value.map((qp) => decodeURIComponent(qp as string)?.trim()) + : decodeURIComponent(value as string)?.trim() + : value, + ]), + ) + columns.value = await Promise.all( (columns.value || []).map(async (c) => { - const queryParam = route.query[c.title as string] || route.query[encodeURIComponent(c.title as string)] + const decodedQueryParam = decodedQuery[c.title as string] if ( !c.title || - !queryParam || + !decodedQueryParam || isSystemColumn(c) || (isVirtualCol(c) && !isLinksOrLTAR(c)) || (!sharedViewMeta.value.preFillEnabled && !isVirtualCol(c) && !isLinksOrLTAR(c)) || @@ -456,9 +468,6 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share ) { return c } - const decodedQueryParam = Array.isArray(queryParam) - ? queryParam.map((qp) => decodeURIComponent(qp as string).trim()) - : decodeURIComponent(queryParam as string).trim() const preFillValue = await getPreFillValue(c, decodedQueryParam) if (preFillValue !== undefined) { From 5b1cde926b172f3a526fe09e28aae0d90d298c06 Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Sat, 26 Oct 2024 06:59:54 +0000 Subject: [PATCH 2/5] fix(nc-gui): decode only prefill keys --- .../composables/useSharedFormViewStore.ts | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/packages/nc-gui/composables/useSharedFormViewStore.ts b/packages/nc-gui/composables/useSharedFormViewStore.ts index 8b152dd551..d64612aad8 100644 --- a/packages/nc-gui/composables/useSharedFormViewStore.ts +++ b/packages/nc-gui/composables/useSharedFormViewStore.ts @@ -441,25 +441,19 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share async function handlePreFillForm() { if (Object.keys(route.query || {}).length) { - // Decode both query parameter keys and values if values are present - const decodedQuery = Object.fromEntries( - Object.entries(route.query).map(([key, value]) => [ - decodeURIComponent(key), - value - ? Array.isArray(value) - ? value.map((qp) => decodeURIComponent(qp as string)?.trim()) - : decodeURIComponent(value as string)?.trim() - : value, - ]), - ) + // Decode query parameter keys + const decodedQuery = Object.fromEntries(Object.entries(route.query).map(([key, value]) => [decodeURIComponent(key), value])) columns.value = await Promise.all( (columns.value || []).map(async (c) => { - const decodedQueryParam = decodedQuery[c.title as string] + const queryParam = + route.query[c.title as string] || + route.query[encodeURIComponent(c.title as string)] || + decodedQuery[c.title as string] if ( !c.title || - !decodedQueryParam || + !queryParam || isSystemColumn(c) || (isVirtualCol(c) && !isLinksOrLTAR(c)) || (!sharedViewMeta.value.preFillEnabled && !isVirtualCol(c) && !isLinksOrLTAR(c)) || @@ -469,6 +463,10 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share return c } + const decodedQueryParam = Array.isArray(queryParam) + ? queryParam.map((qp) => decodeURIComponent(qp as string).trim()) + : decodeURIComponent(queryParam as string).trim() + const preFillValue = await getPreFillValue(c, decodedQueryParam) if (preFillValue !== undefined) { if (isLinksOrLTAR(c)) { From 487534bde5172b27b9cd89507390e578095e91ba Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Sat, 26 Oct 2024 06:59:54 +0000 Subject: [PATCH 3/5] fix(nc-gui): encode share view url except search params --- .../components/dlg/share-and-collaborate/SharePage.vue | 8 +++----- packages/nc-gui/composables/useSharedFormViewStore.ts | 6 +----- 2 files changed, 4 insertions(+), 10 deletions(-) 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 996d6320ef..f644852665 100644 --- a/packages/nc-gui/components/dlg/share-and-collaborate/SharePage.vue +++ b/packages/nc-gui/components/dlg/share-and-collaborate/SharePage.vue @@ -211,11 +211,9 @@ function sharedViewUrl() { dashboardUrl1 = `${baseUrl}${appInfo.value?.dashboardPath}` } - return encodeURI( - `${dashboardUrl1}#/nc/${viewType}/${activeView.value.uuid}${surveyMode.value ? '/survey' : ''}${ - viewStore.preFillFormSearchParams && formPreFill.value.preFillEnabled ? `?${viewStore.preFillFormSearchParams}` : '' - }`, - ) + return `${encodeURI(`${dashboardUrl1}#/nc/${viewType}/${activeView.value.uuid}${surveyMode.value ? '/survey' : ''}`)}${ + viewStore.preFillFormSearchParams && formPreFill.value.preFillEnabled ? `?${viewStore.preFillFormSearchParams}` : '' + }` } const toggleViewShare = async () => { diff --git a/packages/nc-gui/composables/useSharedFormViewStore.ts b/packages/nc-gui/composables/useSharedFormViewStore.ts index d64612aad8..3dad11c6cd 100644 --- a/packages/nc-gui/composables/useSharedFormViewStore.ts +++ b/packages/nc-gui/composables/useSharedFormViewStore.ts @@ -442,14 +442,10 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share async function handlePreFillForm() { if (Object.keys(route.query || {}).length) { // Decode query parameter keys - const decodedQuery = Object.fromEntries(Object.entries(route.query).map(([key, value]) => [decodeURIComponent(key), value])) columns.value = await Promise.all( (columns.value || []).map(async (c) => { - const queryParam = - route.query[c.title as string] || - route.query[encodeURIComponent(c.title as string)] || - decodedQuery[c.title as string] + const queryParam = route.query[c.title as string] || route.query[encodeURIComponent(c.title as string)] if ( !c.title || From f861f71cdb9d42769c2ab8f459701898b2b7a610 Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Sat, 26 Oct 2024 06:59:55 +0000 Subject: [PATCH 4/5] chore(nc-gui): lint --- packages/nc-gui/components/nc/MenuItem.vue | 4 ++-- .../nc-gui/components/smartsheet/toolbar/ViewActionMenu.vue | 4 ++-- packages/nc-gui/composables/useSharedFormViewStore.ts | 3 --- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/nc-gui/components/nc/MenuItem.vue b/packages/nc-gui/components/nc/MenuItem.vue index a049f0f19f..c7561b2086 100644 --- a/packages/nc-gui/components/nc/MenuItem.vue +++ b/packages/nc-gui/components/nc/MenuItem.vue @@ -4,9 +4,9 @@ * - **Issue**: When conditionally rendering `NcMenuItem` using `v-if` without a corresponding `v-else` fallback, * Vue may throw a * `NotFoundError: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.`. - * + * * - This issue occurs specifically when the `NcMenu` is open, and the condition changes dynamically (e.g., during runtime state changes) - * + * * - **Fix**: Use `v-show` instead of `v-if` when no replacement (fallback) node is provided. This keeps the element * in the DOM but toggles its visibility, preventing the DOM manipulation issue. */ diff --git a/packages/nc-gui/components/smartsheet/toolbar/ViewActionMenu.vue b/packages/nc-gui/components/smartsheet/toolbar/ViewActionMenu.vue index f3674b4097..ef100d2db9 100644 --- a/packages/nc-gui/components/smartsheet/toolbar/ViewActionMenu.vue +++ b/packages/nc-gui/components/smartsheet/toolbar/ViewActionMenu.vue @@ -134,9 +134,9 @@ const onDelete = async () => { * - **Issue**: When conditionally rendering `NcMenuItem` using `v-if` without a corresponding `v-else` fallback, * Vue may throw a * `NotFoundError: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.`. - * + * * - This issue occurs specifically when the `NcMenu` is open, and the condition changes dynamically (e.g., during runtime state changes) - * + * * - **Fix**: Use `v-show` instead of `v-if` when no replacement (fallback) node is provided. This keeps the element * in the DOM but toggles its visibility, preventing the DOM manipulation issue. */ diff --git a/packages/nc-gui/composables/useSharedFormViewStore.ts b/packages/nc-gui/composables/useSharedFormViewStore.ts index 3dad11c6cd..32413b57f5 100644 --- a/packages/nc-gui/composables/useSharedFormViewStore.ts +++ b/packages/nc-gui/composables/useSharedFormViewStore.ts @@ -441,8 +441,6 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share async function handlePreFillForm() { if (Object.keys(route.query || {}).length) { - // Decode query parameter keys - columns.value = await Promise.all( (columns.value || []).map(async (c) => { const queryParam = route.query[c.title as string] || route.query[encodeURIComponent(c.title as string)] @@ -458,7 +456,6 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share ) { return c } - const decodedQueryParam = Array.isArray(queryParam) ? queryParam.map((qp) => decodeURIComponent(qp as string).trim()) : decodeURIComponent(queryParam as string).trim() From 316beea2d6a0976d8b53ecc4857e0ef1910c2dad Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Sat, 26 Oct 2024 06:59:55 +0000 Subject: [PATCH 5/5] fix(nc-gui): remove encode url component from shared prefill form --- packages/nc-gui/composables/useSharedFormViewStore.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nc-gui/composables/useSharedFormViewStore.ts b/packages/nc-gui/composables/useSharedFormViewStore.ts index 32413b57f5..42087f98d0 100644 --- a/packages/nc-gui/composables/useSharedFormViewStore.ts +++ b/packages/nc-gui/composables/useSharedFormViewStore.ts @@ -443,7 +443,7 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share if (Object.keys(route.query || {}).length) { columns.value = await Promise.all( (columns.value || []).map(async (c) => { - const queryParam = route.query[c.title as string] || route.query[encodeURIComponent(c.title as string)] + const queryParam = route.query[c.title as string] if ( !c.title ||