From 554b563226816b31654354eed5da126795a7adb2 Mon Sep 17 00:00:00 2001 From: Matheus Cristian Date: Thu, 23 May 2024 11:48:11 -0300 Subject: [PATCH 1/4] feat(intelligence-next): redirects to intelligence-next repository if page is not found on this repository --- config.js.tmpl | 1 + src/router/index.js | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/config.js.tmpl b/config.js.tmpl index e51d94671..b60da4fb6 100644 --- a/config.js.tmpl +++ b/config.js.tmpl @@ -27,6 +27,7 @@ const runtimeVariables = (() => ({ SENTRY_ENVIRONMENT: ('${SENTRY_ENVIRONMENT}' || ''), NEXUS_API_BASE_URL: '${NEXUS_API_BASE_URL}', FLOWS_API_BASE_URL: '${FLOWS_API_BASE_URL}', + INTELLIGENCE_NEXT_URL: '${INTELLIGENCE_NEXT_URL}', get(name){ return this[name]; diff --git a/src/router/index.js b/src/router/index.js index 2b2810b93..bdd9e571f 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -42,6 +42,8 @@ import nexusaiAPI from '../api/nexusaiAPI'; Vue.use(Router); +let nextFromRedirect = ''; + const router = new Router({ mode: 'history', routes: [ @@ -87,13 +89,18 @@ const router = new Router({ store.state.Auth.connectOrgUuid = to.query?.org_uuid; store.state.Auth.connectProjectUuid = to.query?.project_uuid; + sessionStorage.setItem('orgUuid', store.state.Auth.connectOrgUuid); + sessionStorage.setItem( 'projectUuid', store.state.Auth.connectProjectUuid, ); - if (to.query.next) { - next(to.query.next); + const nextPath = to.query.next || to.query.next_from_redirect; + + if (nextPath) { + nextFromRedirect = to.query.next_from_redirect; + next(nextPath); } else { next('/home'); } @@ -395,6 +402,32 @@ const router = new Router({ path: '*', name: '404', component: NotFound, + beforeEnter(to, _from, next) { + if (to.fullPath === nextFromRedirect) { + next(); + } else { + const bearerToken = window.localStorage + .getItem('authToken') + .replace(' ', '+'); + + const intelligenceOrgId = store.state.Auth.org; + const orgUuid = sessionStorage.getItem('orgUuid'); + const projectUuid = sessionStorage.getItem('projectUuid'); + + const path = `/loginexternal/${bearerToken}/${intelligenceOrgId}/${projectUuid}/`; + + const redirectUrl = new URL( + path, + runtimeVariables.get('INTELLIGENCE_NEXT_URL'), + ); + + redirectUrl.searchParams.append('org_uuid', orgUuid); + redirectUrl.searchParams.append('project_uuid', projectUuid); + redirectUrl.searchParams.append('next_from_redirect', to.fullPath); + + location.href = redirectUrl.toString(); + } + }, }, { path: '/safariAlert/', From 06847fffc3950c0b8cdfd18ddaee22d132c46a5d Mon Sep 17 00:00:00 2001 From: Matheus Cristian Date: Wed, 29 May 2024 09:46:17 -0300 Subject: [PATCH 2/4] feat(intelligence-next): removes Brain related and content Intelligences pages --- src/router/index.js | 69 --------------------------------------------- 1 file changed, 69 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index bdd9e571f..e0cb38d1c 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -156,75 +156,6 @@ const router = new Router({ }, ], }, - { - path: '/brain/preview', - name: 'brain-preview-full-page', - component: RouterPreviewFullPage, - beforeEnter: async (to, from, next) => { - store.dispatch('externalLogin', { token: `Bearer ${to.query?.token}` }); - store.dispatch('projectSelected', { project: to.query?.project_uuid }); - - store.state.Auth.connectProjectUuid = to.query?.project_uuid; - - sessionStorage.setItem( - 'projectUuid', - store.state.Auth.connectProjectUuid, - ); - - next(); - }, - }, - { - path: '/router', - name: 'router', - component: RepositoryContentBasesForm, - redirect: () => { - return { name: 'router-personalization' }; - }, - async beforeEnter(_to, _from, next) { - const { data } = await nexusaiAPI.router.read({ - projectUuid: store.state.Auth.connectProjectUuid, - }); - - store.state.router.contentBaseUuid = data.uuid; - store.state.router.intelligenceUuid = data.intelligence; - - next(); - }, - children: [ - { - path: 'personalization', - name: 'router-personalization', - }, - { - path: 'content', - name: 'router-content', - }, - { - path: 'actions', - name: 'router-actions', - }, - { - path: 'tunings', - name: 'router-tunings', - }, - ], - }, - { - path: '/intelligences/:intelligenceUuid', - name: 'intelligence-home', - component: RepositoryContentBases, - }, - { - path: '/intelligences/:intelligenceUuid/edit', - name: 'intelligence-edit', - component: RepositoryContentAdjustment, - }, - { - path: '/intelligences/:intelligenceUuid/bases/:contentBaseUuid/edit', - name: 'intelligence-content-base-edit', - component: RepositoryContentBasesForm, - }, { path: '/dashboard', name: 'dashboard', From 78c14e5df90dd379d032648f66dbb247660b4bfd Mon Sep 17 00:00:00 2001 From: Matheus Cristian Date: Wed, 29 May 2024 09:54:52 -0300 Subject: [PATCH 3/4] feat(intelligence-next): changes router push to real final path --- .../CreateRepository/CreateRepositoryForm.vue | 7 +------ .../repository/home/HomeRepositoryCard.vue | 17 ++++------------- src/views/repository/content/Bases.vue | 9 +++------ src/views/repository/content/BasesForm.vue | 9 +-------- .../repository/content/ContentAdjustments.vue | 9 +++------ src/views/repository/content/Navigation.vue | 7 +------ 6 files changed, 13 insertions(+), 45 deletions(-) diff --git a/src/components/repository/CreateRepository/CreateRepositoryForm.vue b/src/components/repository/CreateRepository/CreateRepositoryForm.vue index 39e068c29..c157e8425 100644 --- a/src/components/repository/CreateRepository/CreateRepositoryForm.vue +++ b/src/components/repository/CreateRepository/CreateRepositoryForm.vue @@ -213,12 +213,7 @@ export default { description: this.data.description, }); - this.$router.push({ - name: 'intelligence-home', - params: { - intelligenceUuid: data.uuid, - }, - }); + this.$router.push(`/intelligences/${data.uuid}`); } else { const response = await repositoryV2.create({ organization: this.getOrgSelected, diff --git a/src/components/repository/home/HomeRepositoryCard.vue b/src/components/repository/home/HomeRepositoryCard.vue index 77c6ca15d..24bbb24bb 100644 --- a/src/components/repository/home/HomeRepositoryCard.vue +++ b/src/components/repository/home/HomeRepositoryCard.vue @@ -663,12 +663,7 @@ export default { (this.type === 'repository' && this.repositoryDetail?.repository_type === 'content') ) { - this.$router.push({ - name: 'intelligence-home', - params: { - intelligenceUuid: this.repositoryDetail.uuid, - }, - }); + this.$router.push(`/intelligences/${this.repositoryDetail.uuid}`); } else if (this.type === 'repository') { let name; @@ -685,13 +680,9 @@ export default { }, }); } else if (this.type === 'base') { - this.$router.push({ - name: 'intelligence-content-base-edit', - params: { - intelligenceUuid: this.$route.params.intelligenceUuid, - contentBaseUuid: this.repositoryDetail.uuid, - }, - }); + this.$router.push( + `/intelligences/${this.$route.params.intelligenceUuid}/bases/${this.repositoryDetail.uuid}/edit`, + ); } }, async copyIntelligence() { diff --git a/src/views/repository/content/Bases.vue b/src/views/repository/content/Bases.vue index 141bb4f02..021f7e9d4 100644 --- a/src/views/repository/content/Bases.vue +++ b/src/views/repository/content/Bases.vue @@ -193,12 +193,9 @@ @close="isAddContentBaseOpen = false" @success=" ($event) => - $router.push({ - name: 'intelligence-content-base-edit', - params: { - contentBaseUuid: $event.uuid, - }, - }) + $router.push( + `/intelligences/${$route.params.intelligenceUuid}/bases/${$event.uuid}/edit`, + ) " > diff --git a/src/views/repository/content/BasesForm.vue b/src/views/repository/content/BasesForm.vue index b4b806df2..39fe19053 100644 --- a/src/views/repository/content/BasesForm.vue +++ b/src/views/repository/content/BasesForm.vue @@ -4,14 +4,7 @@ :title="contentBase.title" :dontShowBack="isRouterView" :brainIsDeactivated="!routerTunings.brainOn" - @back=" - $router.push({ - name: 'intelligence-home', - params: { - intelligenceUuid: intelligenceUuid, - }, - }) - " + @back="$router.push(`/intelligences/${intelligenceUuid}`)" > Date: Wed, 29 May 2024 12:34:52 -0300 Subject: [PATCH 4/4] feat(intelligence-next): changes router home to intelligence-next --- src/components/TutorialModal.vue | 4 +--- src/components/payment/PaymentOptions.vue | 4 +--- src/components/repository/sidebar/SideBar.vue | 12 ++++++++---- src/router/index.js | 5 ----- src/views/CreateRepository.vue | 15 +++++---------- src/views/LandingPage.vue | 8 ++------ src/views/auth/RecoverPassword.vue | 4 +--- src/views/auth/SignIn.vue | 4 +--- src/views/auth/SignUp.vue | 17 ++++++++++------- src/views/repository/content/Bases.vue | 2 +- 10 files changed, 30 insertions(+), 45 deletions(-) diff --git a/src/components/TutorialModal.vue b/src/components/TutorialModal.vue index 968f64268..d63e6d503 100644 --- a/src/components/TutorialModal.vue +++ b/src/components/TutorialModal.vue @@ -317,9 +317,7 @@ export default { if (target === 'home' || target === 'new') { if (target === 'home') return; this.setTutorialActive(name); - this.$router.push({ - name: 'home', - }); + this.$router.push('/home'); this.closeTutorialMenu(); } else if ( Object.keys(this.finished).includes(previous) || diff --git a/src/components/payment/PaymentOptions.vue b/src/components/payment/PaymentOptions.vue index ff3e3cf35..b30826274 100644 --- a/src/components/payment/PaymentOptions.vue +++ b/src/components/payment/PaymentOptions.vue @@ -86,9 +86,7 @@ export default { }, methods: { goToHome() { - this.$router.push({ - name: 'home', - }); + this.$router.push('/home'); }, goToPayment() { this.$router.push({ diff --git a/src/components/repository/sidebar/SideBar.vue b/src/components/repository/sidebar/SideBar.vue index edf5f7449..547966270 100644 --- a/src/components/repository/sidebar/SideBar.vue +++ b/src/components/repository/sidebar/SideBar.vue @@ -599,10 +599,14 @@ export default { path !== this.$router.currentRoute.name || path === 'repository-settings' ) { - this.$router.push({ - name: `${path}`, - ...opts, - }); + if (path === 'home') { + this.$router.push('/home'); + } else { + this.$router.push({ + name: `${path}`, + ...opts, + }); + } } }, setInitialSelectedMenu() { diff --git a/src/router/index.js b/src/router/index.js index e0cb38d1c..dae090ccf 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -130,11 +130,6 @@ const router = new Router({ } }, }, - { - path: '/home', - name: 'home', - component: Home, - }, { path: '/new/', name: 'new', diff --git a/src/views/CreateRepository.vue b/src/views/CreateRepository.vue index 0a318cf4c..fd18e4b96 100644 --- a/src/views/CreateRepository.vue +++ b/src/views/CreateRepository.vue @@ -1,6 +1,6 @@ @@ -14,9 +14,7 @@ export default { CreateRepositoryForm, }, computed: { - ...mapGetters([ - 'authenticated', - ]), + ...mapGetters(['authenticated']), }, mounted() { this.checkIsAuthenticated(); @@ -24,12 +22,10 @@ export default { methods: { checkIsAuthenticated() { if (!this.authenticated) { - this.$router.push({ - name: 'home' - }); + this.$router.push('/home'); } - } - } + }, + }, }; @@ -38,5 +34,4 @@ export default { height: 100vh; width: 100%; } - diff --git a/src/views/LandingPage.vue b/src/views/LandingPage.vue index 5eb10279f..d83b965a9 100644 --- a/src/views/LandingPage.vue +++ b/src/views/LandingPage.vue @@ -129,9 +129,7 @@ export default { }, watch: { authenticated() { - this.$router.push({ - name: 'home', - }); + this.$router.push('/home'); }, }, mounted() { @@ -141,9 +139,7 @@ export default { }, methods: { showAllBots() { - this.$router.push({ - name: 'home', - }); + this.$router.push('/home'); }, signIn() { this.$router.push({ diff --git a/src/views/auth/RecoverPassword.vue b/src/views/auth/RecoverPassword.vue index bdd10b77e..74d8f5912 100644 --- a/src/views/auth/RecoverPassword.vue +++ b/src/views/auth/RecoverPassword.vue @@ -29,9 +29,7 @@ export default { }, methods: { onAuthenticated() { - this.$router.push({ - name: 'home', - }); + this.$router.push('/home'); }, }, }; diff --git a/src/views/auth/SignIn.vue b/src/views/auth/SignIn.vue index 3b6c57e8e..8e403e5dc 100644 --- a/src/views/auth/SignIn.vue +++ b/src/views/auth/SignIn.vue @@ -41,9 +41,7 @@ export default { }, methods: { onAuthenticated() { - this.$router.push({ - name: 'home', - }); + this.$router.push('/home'); }, goToCreate() { this.$router.push({ diff --git a/src/views/auth/SignUp.vue b/src/views/auth/SignUp.vue index afb4e864a..8bfa32906 100644 --- a/src/views/auth/SignUp.vue +++ b/src/views/auth/SignUp.vue @@ -88,13 +88,16 @@ export default { }, watch: { authenticated() { - this.$router.push({ - name: - this.authenticated && - runtimeVariables.get('VUE_APP_BOTHUB_WEBAPP_PAYMENT_ENABLED') - ? 'payment-options' - : 'home', - }); + if ( + this.authenticated && + runtimeVariables.get('VUE_APP_BOTHUB_WEBAPP_PAYMENT_ENABLED') + ) { + this.$router.push({ + name: 'payment-options', + }); + } else { + this.$router.push('/home'); + } }, }, mounted() { diff --git a/src/views/repository/content/Bases.vue b/src/views/repository/content/Bases.vue index 021f7e9d4..5e48b4afd 100644 --- a/src/views/repository/content/Bases.vue +++ b/src/views/repository/content/Bases.vue @@ -9,7 +9,7 @@ type="tertiary" iconCenter="arrow_left_alt" scheme="neutral-dark" - @click="$router.push({ name: 'home' })" + @click="$router.push('/home')" />