Skip to content

Commit

Permalink
feat: common changes for site protection
Browse files Browse the repository at this point in the history
  • Loading branch information
amk-dev authored and AndrewBastin committed Mar 7, 2024
1 parent 439cd82 commit fcf067e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
5 changes: 5 additions & 0 deletions packages/hoppscotch-common/locales/en.json
Expand Up @@ -994,5 +994,10 @@
"personal": "My Workspace",
"team": "Team Workspace",
"title": "Workspaces"
},
"site_protection": {
"login_to_continue": "Login to continue",
"login_to_continue_description": "You need to be logged in to access this Hoppscotch Enterprise Instance.",
"error_fetching_site_protection_status": "Something Went Wrong While Fetching Site Protection Status"
}
}
2 changes: 1 addition & 1 deletion packages/hoppscotch-common/src/modules/index.ts
Expand Up @@ -34,7 +34,7 @@ export type HoppModule = {
to: RouteLocationNormalized,
from: RouteLocationNormalized,
router: Router
) => void
) => void | Promise<void>

/**
* Called by the router to tell all the modules that a route navigation has completed
Expand Down
12 changes: 9 additions & 3 deletions packages/hoppscotch-common/src/modules/router.ts
Expand Up @@ -47,15 +47,21 @@ export default <HoppModule>{
routes,
})

router.beforeEach((to, from) => {
router.beforeEach(async (to, from) => {
_isLoadingInitialRoute.value = isInitialRoute(from)

const onBeforeRouteChangePromises: Promise<any>[] = []

HOPP_MODULES.forEach((mod) => {
mod.onBeforeRouteChange?.(to, from, router)
const res = mod.onBeforeRouteChange?.(to, from, router)
if (res) onBeforeRouteChangePromises.push(res)
})
platform.addedHoppModules?.forEach((mod) => {
mod.onBeforeRouteChange?.(to, from, router)
const res = mod.onBeforeRouteChange?.(to, from, router)
if (res) onBeforeRouteChangePromises.push(res)
})

await Promise.all(onBeforeRouteChangePromises)
})

// Instead of this a better architecture is for the router
Expand Down
1 change: 1 addition & 0 deletions packages/hoppscotch-common/src/pages/enter.vue
Expand Up @@ -44,4 +44,5 @@ export default defineComponent({
<route lang="yaml">
meta:
layout: empty
onlyGuest: true
</route>

0 comments on commit fcf067e

Please sign in to comment.