mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-08 16:03:27 +00:00
allow back navigation for home tabs
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
xl: 'text-xl'
|
||||
}
|
||||
|
||||
const { selected, update } = getContext<TabsContext>('Tabs')
|
||||
const { selected, update, hashNavigation } = getContext<TabsContext>('Tabs')
|
||||
</script>
|
||||
|
||||
<button
|
||||
@@ -33,7 +33,13 @@
|
||||
$selected?.startsWith(value) ? selectedClass : ''
|
||||
)}
|
||||
style={`${style} ${$selected?.startsWith(value) ? selectedStyle : ''}`}
|
||||
on:click={() => update(value)}
|
||||
on:click={() => {
|
||||
if (hashNavigation) {
|
||||
window.location.hash = value
|
||||
} else {
|
||||
update(value)
|
||||
}
|
||||
}}
|
||||
on:pointerdown|stopPropagation
|
||||
>
|
||||
<slot />
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
export type TabsContext = {
|
||||
selected: Writable<string>
|
||||
update: (value: string) => void
|
||||
hashNavigation: boolean
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -18,6 +19,8 @@
|
||||
export { c as class }
|
||||
export let wrapperClass = ''
|
||||
export let style = ''
|
||||
export let hashNavigation = false
|
||||
export let dflt: string | undefined = undefined
|
||||
|
||||
$: selected && updateSelected()
|
||||
|
||||
@@ -30,14 +33,31 @@
|
||||
update: (value: string) => {
|
||||
selectedStore.set(value)
|
||||
selected = value
|
||||
}
|
||||
},
|
||||
hashNavigation
|
||||
})
|
||||
|
||||
function updateSelected() {
|
||||
selectedStore.set(selected)
|
||||
}
|
||||
|
||||
function hashChange() {
|
||||
if (hashNavigation) {
|
||||
const hash = window.location.hash
|
||||
if (hash) {
|
||||
const id = hash.replace('#', '')
|
||||
selectedStore.set(id)
|
||||
selected = id
|
||||
} else if (dflt) {
|
||||
selectedStore.set(dflt)
|
||||
selected = dflt
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window on:hashchange={hashChange} />
|
||||
|
||||
<div class="overflow-x-auto {wrapperClass}">
|
||||
<div
|
||||
class={twMerge('border-b border-gray-200 flex flex-row whitespace-nowrap scrollbar-hidden', c)}
|
||||
|
||||
@@ -161,7 +161,7 @@
|
||||
isEditor={false}
|
||||
context={{
|
||||
username: $userStore?.username ?? 'anonymous',
|
||||
email: $userStore?.email ?? 'anonymous',
|
||||
email: $userStore?.email ?? 'anonymous'
|
||||
}}
|
||||
summary={appViewerApp?.app.summary ?? ''}
|
||||
noBackend
|
||||
@@ -194,7 +194,7 @@
|
||||
|
||||
{#if !$userStore?.operator}
|
||||
<div class="w-full overflow-auto scrollbar-hidden">
|
||||
<Tabs bind:selected={tab}>
|
||||
<Tabs dflt="workspace" hashNavigation bind:selected={tab}>
|
||||
<Tab size="md" value="workspace">
|
||||
<div class="flex gap-2 items-center my-1">
|
||||
<Building size={18} />
|
||||
|
||||
Reference in New Issue
Block a user