Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: common changes for site protection #3878

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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>