feat: common changes for site protection (#3878)

This commit is contained in:
Akash K
2024-03-07 23:43:20 +05:30
committed by GitHub
parent 439cd82c88
commit 6d66d12a9e
4 changed files with 16 additions and 4 deletions

View File

@@ -994,5 +994,10 @@
"personal": "My Workspace", "personal": "My Workspace",
"team": "Team Workspace", "team": "Team Workspace",
"title": "Workspaces" "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"
} }
} }

View File

@@ -34,7 +34,7 @@ export type HoppModule = {
to: RouteLocationNormalized, to: RouteLocationNormalized,
from: RouteLocationNormalized, from: RouteLocationNormalized,
router: Router router: Router
) => void ) => void | Promise<void>
/** /**
* Called by the router to tell all the modules that a route navigation has completed * Called by the router to tell all the modules that a route navigation has completed

View File

@@ -47,15 +47,21 @@ export default <HoppModule>{
routes, routes,
}) })
router.beforeEach((to, from) => { router.beforeEach(async (to, from) => {
_isLoadingInitialRoute.value = isInitialRoute(from) _isLoadingInitialRoute.value = isInitialRoute(from)
const onBeforeRouteChangePromises: Promise<any>[] = []
HOPP_MODULES.forEach((mod) => { 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) => { 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 // Instead of this a better architecture is for the router

View File

@@ -44,4 +44,5 @@ export default defineComponent({
<route lang="yaml"> <route lang="yaml">
meta: meta:
layout: empty layout: empty
onlyGuest: true
</route> </route>