f501cc4ad5
* WIP can create project * WIP can create project more work * complete body, stencil tests * feat(shared): move workspace plan types into shared * test progress wip * feat(shared): add more logic to canCreateWorkspaceProject * a few more tests, as a treat * chore(authz): round out tests * fixed loaders, new GQL checks, dataLoaders in auth loaders * fix(authz): get workspace limits loader * chore(authz): update loaders * frontend fixed up to snuff * fix(authz): fix workspace plans for tests * fix(authz): classic * fix(authz): 0 counts --------- Co-authored-by: Chuck Driesler <chuck@speckle.systems> Co-authored-by: Kristaps Fabians Geikins <fabis94@live.com>
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
import { activeUserQuery } from '~/lib/auth/composables/activeUser'
|
|
import {
|
|
authLoginPanelQuery,
|
|
authLoginPanelWorkspaceInviteQuery
|
|
} from '~/lib/auth/graphql/queries'
|
|
import { usePreloadApolloQueries } from '~/lib/common/composables/graphql'
|
|
import { mainServerInfoDataQuery } from '~/lib/core/composables/server'
|
|
|
|
/**
|
|
* Prefetches data for specific routes to avoid the problem of serial API requests
|
|
* (e.g. in the case of multiple middlewares)
|
|
*/
|
|
export default defineNuxtPlugin(async (ctx) => {
|
|
const logger = useLogger()
|
|
const route = ctx._route
|
|
const preload = usePreloadApolloQueries()
|
|
const isWorkspacesEnabled = useIsWorkspacesEnabled()
|
|
|
|
if (!route) {
|
|
logger.info('No route obj found, skipping data preload...')
|
|
return
|
|
}
|
|
|
|
const promises: Promise<unknown>[] = []
|
|
|
|
// Standard/global
|
|
promises.push(
|
|
preload({
|
|
queries: [{ query: activeUserQuery }, { query: mainServerInfoDataQuery }]
|
|
})
|
|
)
|
|
|
|
// Preload viewer data
|
|
if (route.meta.key === '/projects/:id/models/resources') {
|
|
// Unable to preload this from vue components due to SSR being essentially turned off for the viewer
|
|
promises.push(
|
|
preload({
|
|
queries: [
|
|
{ query: authLoginPanelQuery },
|
|
...(isWorkspacesEnabled.value
|
|
? [{ query: authLoginPanelWorkspaceInviteQuery }]
|
|
: [])
|
|
]
|
|
})
|
|
)
|
|
}
|
|
|
|
await Promise.all(promises)
|
|
})
|