From 71f324501b983b92c42bd94cc76c76d1f10410e8 Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Thu, 26 Feb 2026 16:43:02 -0300 Subject: [PATCH 1/6] fix(action-mapping): add initialActionCode reactive ref to share action state without route params Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- src/helpers/ActionMapping.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/helpers/ActionMapping.ts b/src/helpers/ActionMapping.ts index 14e7154da0..7c2f559e00 100644 --- a/src/helpers/ActionMapping.ts +++ b/src/helpers/ActionMapping.ts @@ -3,6 +3,8 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ +import { ref } from 'vue' + interface ActionCodes { REDIRECT: number CREATE_ACCOUNT: number @@ -53,6 +55,14 @@ export const ACTION_CODE_TO_ROUTE: Readonly = Object.freeze({ [ACTION_CODES.INCOMPLETE_SETUP]: 'Incomplete', }) +/** + * Shared reactive ref for the initial action code injected by the server + * (#initial-state-libresign-action). Written once by router.ts beforeEach, + * read by App.vue. Lives here (not in router.ts) to avoid App.vue triggering + * the router module's side effects (createRouter, generateUrl) on import. + */ +export const initialActionCode = ref(0) + export const REQUIREMENT_TO_MODAL: Readonly = Object.freeze({ identificationDocuments: 'uploadDocuments', emailCode: 'emailToken', From acfca6207e7836ff2734f6d9b094673934ab470a Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Thu, 26 Feb 2026 16:43:02 -0300 Subject: [PATCH 2/6] fix(router): store initial action code in reactive ref instead of non-path route param Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- src/router/router.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/router/router.ts b/src/router/router.ts index 93868bb297..26344bfa7a 100644 --- a/src/router/router.ts +++ b/src/router/router.ts @@ -8,6 +8,7 @@ import { createRouter, createWebHistory, type Router, type RouteRecordRaw } from import { loadState } from '@nextcloud/initial-state' import { getRootUrl, generateUrl } from '@nextcloud/router' +import { initialActionCode } from '../helpers/ActionMapping' import { isExternal } from '../helpers/isExternal' import { selectAction } from '../helpers/SelectAction' @@ -212,7 +213,7 @@ router.beforeEach((to, from, next) => { let action if (actionElement) { const actionValue = loadState('libresign', 'action', 0) - to.params.action = String(actionValue) + initialActionCode.value = actionValue action = selectAction(actionValue, to, from) document.querySelector('#initial-state-libresign-action')?.remove() } From 63a8570f4ca931b8fd8e5d5f1dc2f694d4cdf082 Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Thu, 26 Feb 2026 16:43:02 -0300 Subject: [PATCH 3/6] fix(app): read initial action code from reactive ref instead of route.params Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- src/App.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/App.vue b/src/App.vue index efe6df4112..5ba4789edc 100644 --- a/src/App.vue +++ b/src/App.vue @@ -37,6 +37,7 @@ import LeftSidebar from './components/LeftSidebar/LeftSidebar.vue' import RightSidebar from './components/RightSidebar/RightSidebar.vue' import DefaultPageError from './views/DefaultPageError.vue' +import { initialActionCode, ACTION_CODES } from './helpers/ActionMapping' import LogoLibreSign from '../img/logo-gray.svg' const route = useRoute() @@ -44,7 +45,7 @@ const loading = ref(false) const isRoot = computed(() => route.path === '/') const isSignExternalPage = computed(() => route.path.startsWith('/p/')) -const isDoNothingError = computed(() => (route.params?.action as number | undefined) === 2000) +const isDoNothingError = computed(() => initialActionCode.value === ACTION_CODES.DO_NOTHING) const showLeftSidebar = computed(() => !route.matched.some(record => record.meta?.hideLeftSidebar === true)) From 42472fe8ff437cdaafb55db5b423e9b9bfe947e4 Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Thu, 26 Feb 2026 16:43:02 -0300 Subject: [PATCH 4/6] test(app): use initialActionCode ref instead of route.params in isDoNothingError tests Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- src/tests/App.spec.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/tests/App.spec.ts b/src/tests/App.spec.ts index e24df2e259..3e466ad860 100644 --- a/src/tests/App.spec.ts +++ b/src/tests/App.spec.ts @@ -6,6 +6,8 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' import { mount } from '@vue/test-utils' +import { initialActionCode, ACTION_CODES } from '../helpers/ActionMapping' + type RouteState = { path: string name: string | undefined @@ -56,6 +58,7 @@ describe('App', () => { routeState.name = 'fileslist' routeState.params = {} routeState.matched = [] + initialActionCode.value = 0 }) it('shows left sidebar on regular internal routes', () => { @@ -182,8 +185,8 @@ describe('App', () => { expect(wrapper.find('.nc-content').classes()).not.toContain('sign-external-page') }) - it('shows DefaultPageError when action param is 2000', () => { - routeState.params = { action: 2000 } + it('shows DefaultPageError when initial action code is DO_NOTHING (2000)', () => { + initialActionCode.value = ACTION_CODES.DO_NOTHING const wrapper = mount(App, { global: { @@ -203,7 +206,7 @@ describe('App', () => { }) it('does not show DefaultPageError on normal routes', () => { - routeState.params = {} + // initialActionCode is already 0 (reset in beforeEach) const wrapper = mount(App, { global: { From ec3a1fc792bd7c8e29b6edb3adda3aab6521d6bd Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Thu, 26 Feb 2026 16:47:54 -0300 Subject: [PATCH 5/6] fix(action-mapping): import ref from @vue/reactivity to avoid TS2305 in non-component context Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- src/helpers/ActionMapping.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/ActionMapping.ts b/src/helpers/ActionMapping.ts index 7c2f559e00..5257a04aa2 100644 --- a/src/helpers/ActionMapping.ts +++ b/src/helpers/ActionMapping.ts @@ -3,7 +3,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -import { ref } from 'vue' +import { ref } from '@vue/reactivity' interface ActionCodes { REDIRECT: number From ff1b8348a2dc4b5bcb97087b26a27a971acf09c7 Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Thu, 26 Feb 2026 16:49:56 -0300 Subject: [PATCH 6/6] chore: remove unecessary comment Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- src/tests/App.spec.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/tests/App.spec.ts b/src/tests/App.spec.ts index 3e466ad860..afa9e28b37 100644 --- a/src/tests/App.spec.ts +++ b/src/tests/App.spec.ts @@ -206,8 +206,6 @@ describe('App', () => { }) it('does not show DefaultPageError on normal routes', () => { - // initialActionCode is already 0 (reset in beforeEach) - const wrapper = mount(App, { global: { stubs: {