systemSetupInfo.ts 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { useApplicationStore } from '#shared/stores/application.ts'
  3. import log from '#shared/utils/log.ts'
  4. import type {
  5. NavigationGuard,
  6. RouteLocationNormalized,
  7. NavigationGuardNext,
  8. } from 'vue-router'
  9. const systemSetupInfo: NavigationGuard = (
  10. to: RouteLocationNormalized,
  11. from: RouteLocationNormalized,
  12. next: NavigationGuardNext,
  13. ) => {
  14. const application = useApplicationStore()
  15. if (
  16. application.config.system_init_done ||
  17. (to.fullPath && to.fullPath.startsWith('/guided-setup'))
  18. ) {
  19. next()
  20. return
  21. }
  22. if (application.config.import_mode) {
  23. log.debug(`Route guard for '${to.path}': system setup - import mode.`)
  24. next({
  25. path: `/guided-setup/import/${application.config.import_backend}/status`,
  26. replace: true,
  27. })
  28. return
  29. }
  30. log.debug(`Route guard for '${to.path}': system setup - not initialized.`)
  31. next({ path: '/guided-setup', replace: true })
  32. }
  33. export default systemSetupInfo