Skip to content

Commit

Permalink
Merge pull request #4507 from LibreSign/fix/display-error-at-same-route
Browse files Browse the repository at this point in the history
fix: display error at same route
  • Loading branch information
vitormattos authored Jan 28, 2025
2 parents 4138c59 + 71375c0 commit d6c7c3d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
<NcContent app-name="libresign" :class="{'sign-external-page': isSignExternalPage}">
<LeftSidebar />
<NcAppContent :class="{'icon-loading' : loading }">
<router-view v-if="!loading" :key="$route.name " :loading.sync="loading" />
<DefaultPageError v-if="isDoNothingError" />
<router-view v-else-if="!loading" :key="$route.name " :loading.sync="loading" />
<NcEmptyContent v-if="isRoot" :description="t('libresign', 'LibreSign, digital signature app for Nextcloud.')">
<template #icon>
<img :src="LogoLibreSign">
Expand All @@ -25,6 +26,7 @@ import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js'

import LeftSidebar from './Components/LeftSidebar/LeftSidebar.vue'
import RightSidebar from './Components/RightSidebar/RightSidebar.vue'
import DefaultPageError from './views/DefaultPageError.vue'

import LogoLibreSign from './../img/logo-gray.svg'

Expand All @@ -36,6 +38,7 @@ export default {
NcEmptyContent,
LeftSidebar,
RightSidebar,
DefaultPageError,
},
data() {
return {
Expand All @@ -50,6 +53,9 @@ export default {
isSignExternalPage() {
return this.$route.path.startsWith('/p/')
},
isDoNothingError() {
return this.$route.params?.action === 2000
},
},
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/SelectAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const selectAction = (action, to, from) => {
case 1500: // ACTION_CREATE_ACCOUNT
return 'CreateAccount' + external
case 2000: // ACTION_DO_NOTHING
return 'DefaultPageError' + external
return to.name
case 2500: // ACTION_SIGN
return 'SignPDF' + external
case 2625: // ACTION_SIGN_INTERNAL
Expand Down
11 changes: 9 additions & 2 deletions src/router/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const router = new Router({
props: true,
},
{
path: '/p/sign/:uuid/error',
path: '/p/error',
name: 'DefaultPageErrorExternal',
component: () => import('../views/DefaultPageError.vue'),
props: true,
Expand All @@ -79,6 +79,12 @@ const router = new Router({
component: () => import('../views/Validation.vue'),
props: true,
},
{
path: '/validation/:uuid',
name: 'ValidationFileShortUrl',
component: () => import('../views/Validation.vue'),
props: true,
},
{
path: '/p/incomplete',
name: 'IncompleteExternal',
Expand Down Expand Up @@ -191,7 +197,8 @@ router.beforeEach((to, from, next) => {
const actionElement = document.querySelector('#initial-state-libresign-action')
let action
if (actionElement) {
action = selectAction(loadState('libresign', 'action', ''), to, from)
to.params.action = loadState('libresign', 'action', '')
action = selectAction(to.params.action, to, from)
document.querySelector('#initial-state-libresign-action')?.remove()
}
if (Object.hasOwn(to, 'name') && typeof to.name === 'string' && !to.name.endsWith('External') && isExternal(to, from)) {
Expand Down

0 comments on commit d6c7c3d

Please sign in to comment.