1
0
Fork 0
mirror of synced 2024-09-08 21:51:58 +12:00

Disable command palette and tour for non lock holders and forcefully prevent access to the design and automate pages

This commit is contained in:
Andrew Kingston 2023-05-12 14:33:00 +01:00
parent 5f81584a14
commit d752448403
3 changed files with 30 additions and 3 deletions

View file

@ -13,7 +13,6 @@
Modal, Modal,
notifications, notifications,
} from "@budibase/bbui" } from "@budibase/bbui"
import AppActions from "components/deploy/AppActions.svelte" import AppActions from "components/deploy/AppActions.svelte"
import { API } from "api" import { API } from "api"
import { isActive, goto, layout, redirect } from "@roxi/routify" import { isActive, goto, layout, redirect } from "@roxi/routify"
@ -30,7 +29,9 @@
let promise = getPackage() let promise = getPackage()
let hasSynced = false let hasSynced = false
let commandPaletteModal let commandPaletteModal
let loaded = false
$: loaded && initTour()
$: selected = capitalise( $: selected = capitalise(
$layout.children.find(layout => $isActive(layout.path))?.title ?? "data" $layout.children.find(layout => $isActive(layout.path))?.title ?? "data"
) )
@ -43,6 +44,7 @@
await automationStore.actions.fetch() await automationStore.actions.fetch()
await roles.fetch() await roles.fetch()
await flags.fetch() await flags.fetch()
loaded = true
return pkg return pkg
} catch (error) { } catch (error) {
notifications.error(`Error initialising app: ${error?.message}`) notifications.error(`Error initialising app: ${error?.message}`)
@ -67,13 +69,18 @@
// Event handler for the command palette // Event handler for the command palette
const handleKeyDown = e => { const handleKeyDown = e => {
if (e.key === "k" && (e.ctrlKey || e.metaKey)) { if (e.key === "k" && (e.ctrlKey || e.metaKey) && $store.hasLock) {
e.preventDefault() e.preventDefault()
commandPaletteModal.toggle() commandPaletteModal.toggle()
} }
} }
const initTour = async () => { const initTour = async () => {
// Skip tour if we don't have the lock
if (!$store.hasLock) {
return
}
// Check if onboarding is enabled. // Check if onboarding is enabled.
if (isEnabled(TENANT_FEATURE_FLAGS.ONBOARDING_TOUR)) { if (isEnabled(TENANT_FEATURE_FLAGS.ONBOARDING_TOUR)) {
if (!$auth.user?.onboardedAt) { if (!$auth.user?.onboardedAt) {
@ -110,7 +117,6 @@
// check if user has beta access // check if user has beta access
// const betaResponse = await API.checkBetaAccess($auth?.user?.email) // const betaResponse = await API.checkBetaAccess($auth?.user?.email)
// betaAccess = betaResponse.access // betaAccess = betaResponse.access
initTour()
} catch (error) { } catch (error) {
notifications.error("Failed to sync with production database") notifications.error("Failed to sync with production database")
} }

View file

@ -8,6 +8,15 @@
import { onDestroy, onMount } from "svelte" import { onDestroy, onMount } from "svelte"
import { syncURLToState } from "helpers/urlStateSync" import { syncURLToState } from "helpers/urlStateSync"
import * as routify from "@roxi/routify" import * as routify from "@roxi/routify"
import { store } from "builderStore"
import { redirect } from "@roxi/routify"
// Prevent access for other users than the lock holder
$: {
if (!$store.hasLock) {
$redirect("../data")
}
}
// Keep URL and state in sync for selected screen ID // Keep URL and state in sync for selected screen ID
const stopSyncing = syncURLToState({ const stopSyncing = syncURLToState({

View file

@ -1,2 +1,14 @@
<script>
import { store } from "builderStore"
import { redirect } from "@roxi/routify"
// Prevent access for other users than the lock holder
$: {
if (!$store.hasLock) {
$redirect("../data")
}
}
</script>
<!-- routify:options index=2 --> <!-- routify:options index=2 -->
<slot /> <slot />