Use routify
This commit is contained in:
parent
5f6210e9a0
commit
bfd52b6c50
|
@ -5,7 +5,7 @@ import {
|
||||||
} from "@budibase/frontend-core"
|
} from "@budibase/frontend-core"
|
||||||
import { store } from "./builderStore"
|
import { store } from "./builderStore"
|
||||||
import { get } from "svelte/store"
|
import { get } from "svelte/store"
|
||||||
import { auth } from "./stores/portal"
|
import { auth, navigation } from "./stores/portal"
|
||||||
|
|
||||||
export const API = createAPIClient({
|
export const API = createAPIClient({
|
||||||
attachHeaders: headers => {
|
attachHeaders: headers => {
|
||||||
|
@ -52,8 +52,8 @@ export const API = createAPIClient({
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
window.location = `${updatingUrl}?returnUrl=${encodeURIComponent(
|
navigation.actions.goTo(
|
||||||
window.location
|
`${updatingUrl}?returnUrl=${encodeURIComponent(window.location)}`
|
||||||
)}`
|
)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
<script>
|
<script>
|
||||||
import { isActive, redirect, params } from "@roxi/routify"
|
import { isActive, redirect, params } from "@roxi/routify"
|
||||||
import { admin, auth, licensing } from "stores/portal"
|
import { admin, auth, licensing, navigation } from "stores/portal"
|
||||||
import { onMount } from "svelte"
|
import { onMount } from "svelte"
|
||||||
import { CookieUtils, Constants } from "@budibase/frontend-core"
|
import { CookieUtils, Constants } from "@budibase/frontend-core"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
import Branding from "./Branding.svelte"
|
import Branding from "./Branding.svelte"
|
||||||
|
import { goto } from "@roxi/routify"
|
||||||
|
|
||||||
let loaded = false
|
let loaded = false
|
||||||
|
|
||||||
|
@ -17,6 +18,8 @@
|
||||||
|
|
||||||
$: useAccountPortal = cloud && !$admin.disableAccountPortal
|
$: useAccountPortal = cloud && !$admin.disableAccountPortal
|
||||||
|
|
||||||
|
navigation.actions.init($goto)
|
||||||
|
|
||||||
const validateTenantId = async () => {
|
const validateTenantId = async () => {
|
||||||
const host = window.location.host
|
const host = window.location.host
|
||||||
if (host.includes("localhost:") || !baseUrl) {
|
if (host.includes("localhost:") || !baseUrl) {
|
||||||
|
|
|
@ -16,5 +16,6 @@ export { environment } from "./environment"
|
||||||
export { menu } from "./menu"
|
export { menu } from "./menu"
|
||||||
export { auditLogs } from "./auditLogs"
|
export { auditLogs } from "./auditLogs"
|
||||||
export { features } from "./features"
|
export { features } from "./features"
|
||||||
|
export { navigation } from "./navigation"
|
||||||
|
|
||||||
export const sideBarCollapsed = writable(false)
|
export const sideBarCollapsed = writable(false)
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
import { writable } from "svelte/store"
|
||||||
|
|
||||||
|
export function createNavigationStore() {
|
||||||
|
const { subscribe } = writable([])
|
||||||
|
|
||||||
|
let initialisated = false
|
||||||
|
let _goTo
|
||||||
|
|
||||||
|
const init = goToFunc => {
|
||||||
|
initialisated = true
|
||||||
|
if (typeof goToFunc !== "function") {
|
||||||
|
throw new Error('A valid "goToFunc" must be provided')
|
||||||
|
}
|
||||||
|
|
||||||
|
_goTo = goToFunc
|
||||||
|
}
|
||||||
|
|
||||||
|
const goTo = (...params) => {
|
||||||
|
if (!initialisated) {
|
||||||
|
throw new Error("You need to call navigation.init first")
|
||||||
|
}
|
||||||
|
|
||||||
|
_goTo(...params)
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
subscribe,
|
||||||
|
actions: {
|
||||||
|
init,
|
||||||
|
goTo,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const navigation = createNavigationStore()
|
Loading…
Reference in New Issue