feat: data stores in the data menu and a customizable sidebar

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Guilhem Lemouel
2026-10-29 09:57:24 -07:00
co-authored by Claude Opus 5.5
parent c9ac9f6e3e
commit 91c88777d5
8 changed files with 327 additions and 82 deletions
@@ -1,15 +1,5 @@
<script module lang="ts">
const OBJECT_STORAGE_RESOURCE_TYPES = [
's3',
'azure_blob',
's3_aws_oidc',
'azure_workload_identity',
'gcloud_storage'
]
export function isObjectStorageResourceType(resourceType: string | undefined): boolean {
return resourceType !== undefined && OBJECT_STORAGE_RESOURCE_TYPES.includes(resourceType)
}
import { isObjectStorageResourceType } from './assets/exploreAsset'
export function assetCanBeExplored(
asset: Asset,
@@ -29,12 +19,10 @@
<script lang="ts">
import { isDbType } from '$lib/components/dbTypes'
import { formatAsset, type Asset } from '$lib/components/assets/lib'
import { type Asset } from '$lib/components/assets/lib'
import { Button, ButtonType } from '$lib/components/common'
import S3FilePicker from '$lib/components/S3FilePicker.svelte'
import { VolumeService } from '$lib/gen'
import { globalDbManagerDrawer, globalS3FilePickerExplorer } from '$lib/stores'
import { isS3Uri } from '$lib/utils'
import { exploreAsset } from './assets/exploreAsset'
import { Database, File, HardDriveIcon } from 'lucide-svelte'
import DucklakeIcon from './icons/DucklakeIcon.svelte'
import { useOperatingWorkspace } from '$lib/components/operatingWorkspace.svelte'
@@ -68,12 +56,7 @@
workspace?: string
} = $props()
let dbManagerDrawer = $derived(globalDbManagerDrawer.val)
let ws = $derived(workspace ?? $operatingWorkspace)
const assetUri = $derived(formatAsset(asset))
// Contexts with a select/upload flow pass their own picker; everything else
// (e.g. the resources list) falls back to the global read-only explorer.
let effectiveS3FilePicker = $derived(s3FilePicker ?? globalS3FilePickerExplorer.val)
let isStorageResource = $derived(
asset.kind === 'resource' && isObjectStorageResourceType(_resourceMetadata?.resource_type)
)
@@ -87,53 +70,11 @@
iconOnly={noText}
{btnClasses}
on:click={async () => {
if (asset.kind === 'resource' && isDbType(_resourceMetadata?.resource_type)) {
let [resourcePath, specificTable] = asset.path.split('?table=')
dbManagerDrawer?.openDrawer(
{
type: 'database',
resourceType: _resourceMetadata.resource_type,
resourcePath,
specificTable
},
ws
)
} else if (isStorageResource) {
effectiveS3FilePicker?.open(undefined, { s3ResourcePath: asset.path, workspace: ws })
} else if (asset.kind === 's3object' && isS3Uri(assetUri)) {
effectiveS3FilePicker?.open(assetUri, { workspace: ws })
} else if (asset.kind === 'volume') {
const storage = (await VolumeService.getVolumeStorage({ workspace: ws! })) ?? undefined
effectiveS3FilePicker?.open(
{ s3: `volumes/${ws}/${asset.path}/`, storage },
{ workspace: ws }
)
} else if (asset.kind === 'ducklake') {
let ducklake = asset.path.split('/')[0]
let specificTableSplit = asset.path.split('/')[1]?.split('.') as string[] | undefined
let [specificSchema, specificTable] =
specificTableSplit?.length === 2
? [specificTableSplit[0], specificTableSplit[1]]
: [undefined, specificTableSplit?.[0]]
dbManagerDrawer?.openDrawer({ type: 'ducklake', ducklake, specificSchema, specificTable }, ws)
} else if (asset.kind === 'datatable') {
let datatable = asset.path.split('/')[0]
let specificTableSplit = asset.path.split('/')[1]?.split('.') as string[] | undefined
let [specificSchema, specificTable] =
specificTableSplit?.length === 2
? [specificTableSplit[0], specificTableSplit[1]]
: [undefined, specificTableSplit?.[0]]
dbManagerDrawer?.openDrawer(
{
type: 'database',
resourceType: 'postgresql',
resourcePath: `datatable://${datatable}`,
specificTable,
specificSchema
},
ws
)
}
await exploreAsset(asset, {
workspace: ws,
resourceType: _resourceMetadata?.resource_type,
s3FilePicker
})
onClick?.()
}}
endIcon={asset.kind === 's3object' || isStorageResource
@@ -0,0 +1,67 @@
import { isDbType } from '$lib/components/dbTypes'
import { formatAsset, type Asset } from '$lib/components/assets/lib'
import { VolumeService } from '$lib/gen'
import { globalDbManagerDrawer, globalS3FilePickerExplorer } from '$lib/stores'
import { isS3Uri } from '$lib/utils'
const OBJECT_STORAGE_RESOURCE_TYPES = [
's3',
'azure_blob',
's3_aws_oidc',
'azure_workload_identity',
'gcloud_storage'
]
export function isObjectStorageResourceType(resourceType: string | undefined): boolean {
return resourceType !== undefined && OBJECT_STORAGE_RESOURCE_TYPES.includes(resourceType)
}
// An S3FilePicker instance, typed loosely as `globalS3FilePickerExplorer` is: its instance type
// resolves differently in .ts and .svelte contexts.
type S3Picker = any
/** Opens an asset in its drawer: the database manager for a data table, a ducklake or a database
* resource, the file browser for object storage and volumes. `s3FilePicker` is for a context with
* its own select/upload flow; otherwise the logged layout's read-only explorer is used. */
export async function exploreAsset(
asset: Asset,
opts: { workspace?: string; resourceType?: string; s3FilePicker?: S3Picker }
): Promise<void> {
const ws = opts.workspace
const dbManagerDrawer = globalDbManagerDrawer.val
const s3FilePicker = opts.s3FilePicker ?? globalS3FilePickerExplorer.val
const assetUri = formatAsset(asset)
if (asset.kind === 'resource' && isDbType(opts.resourceType)) {
let [resourcePath, specificTable] = asset.path.split('?table=')
dbManagerDrawer?.openDrawer(
{ type: 'database', resourceType: opts.resourceType, resourcePath, specificTable },
ws
)
} else if (asset.kind === 'resource' && isObjectStorageResourceType(opts.resourceType)) {
s3FilePicker?.open(undefined, { s3ResourcePath: asset.path, workspace: ws })
} else if (asset.kind === 's3object' && isS3Uri(assetUri)) {
s3FilePicker?.open(assetUri, { workspace: ws })
} else if (asset.kind === 'volume') {
const storage = (await VolumeService.getVolumeStorage({ workspace: ws! })) ?? undefined
s3FilePicker?.open({ s3: `volumes/${ws}/${asset.path}/`, storage }, { workspace: ws })
} else if (asset.kind === 'ducklake' || asset.kind === 'datatable') {
const [name, tablePart] = asset.path.split('/')
const specificTableSplit = tablePart?.split('.')
const [specificSchema, specificTable] =
specificTableSplit?.length === 2
? [specificTableSplit[0], specificTableSplit[1]]
: [undefined, specificTableSplit?.[0]]
dbManagerDrawer?.openDrawer(
asset.kind === 'ducklake'
? { type: 'ducklake', ducklake: name, specificSchema, specificTable }
: {
type: 'database',
resourceType: 'postgresql',
resourcePath: `datatable://${name}`,
specificTable,
specificSchema
},
ws
)
}
}
@@ -0,0 +1,91 @@
<!--
@component
The Data menu's configured data tables, ducklakes and object storages, each opening its drawer
(Manage or Explore) as the Assets page's cards do. Mounted with the open menu, so the lists are
fetched on open.
-->
<script lang="ts">
import { resource } from 'runed'
import { Database, File } from 'lucide-svelte'
import type { MenubarMenuElements } from '@melt-ui/svelte'
import MenuItem from '$lib/components/meltComponents/MenuItem.svelte'
import DucklakeIcon from '$lib/components/icons/DucklakeIcon.svelte'
import { SettingService, WorkspaceService } from '$lib/gen'
import type { Asset } from '$lib/components/assets/lib'
import { exploreAsset } from '$lib/components/assets/exploreAsset'
import { useOperatingWorkspace } from '$lib/components/operatingWorkspace.svelte'
import { useRoleCapabilities } from '$lib/operatorWriteRights'
let { item, itemClass }: { item: MenubarMenuElements['item']; itemClass: string } = $props()
const operatingWorkspace = useOperatingWorkspace()
const roleCaps = useRoleCapabilities()
type Store = { asset: Asset; label: string; action: 'Manage' | 'Explore' }
type StoreGroup = { title: string; stores: Store[] }
// A list that fails to load is left out rather than failing the menu.
const groups = resource(
() => ($roleCaps.code ? $operatingWorkspace : undefined),
async (workspace): Promise<StoreGroup[]> => {
if (!workspace) return []
const [tables, ducklakes, storages] = await Promise.all([
WorkspaceService.listDataTables({ workspace }).catch(() => []),
WorkspaceService.listDucklakes({ workspace }).catch(() => []),
SettingService.getSecondaryStorageNames({ workspace, includeDefault: true }).catch(() => [])
])
const all: StoreGroup[] = [
{
title: 'Data tables',
stores: tables.map(({ name }): Store => ({
asset: { kind: 'datatable', path: name },
label: name === 'main' ? 'Main data table' : name,
action: 'Manage'
}))
},
{
title: 'Ducklakes',
stores: ducklakes.map((name): Store => ({
asset: { kind: 'ducklake', path: name },
label: name === 'main' ? 'Main ducklake' : name,
action: 'Manage'
}))
},
{
title: 'Object storage',
stores: storages.map((name): Store => ({
asset: { kind: 's3object', path: name === '_default_' ? '/' : `${name}/` },
label: name === '_default_' ? 'Primary storage' : name,
action: 'Explore'
}))
}
]
return all.filter((g) => g.stores.length > 0)
}
)
</script>
<!-- Headed as DropdownV2's `sectionTitle` rows are. -->
{#each groups.current ?? [] as group (group.title)}
<div class="my-1 border-t border-border-light"></div>
<p class="px-4 pt-1.5 pb-1 text-2xs uppercase tracking-wide text-secondary">{group.title}</p>
{#each group.stores as store (`${store.asset.kind}:${store.asset.path}`)}
<MenuItem
class={itemClass}
{item}
onClick={() => exploreAsset(store.asset, { workspace: $operatingWorkspace })}
>
<div class="flex flex-row items-center gap-2">
{#if store.asset.kind === 'ducklake'}
<DucklakeIcon size={16} />
{:else if store.asset.kind === 'datatable'}
<Database size={16} />
{:else}
<File size={16} />
{/if}
<span class="truncate">{store.label}</span>
<span class="ml-auto pl-4 text-hint">{store.action}</span>
</div>
</MenuItem>
{/each}
{/each}
@@ -0,0 +1,97 @@
<!--
@component
The starred items as a sidebar section, turned on from "Customize sidebar" in the settings menu.
Hidden in the collapsed rail, like the AI chats.
-->
<script lang="ts">
import { slide } from 'svelte/transition'
import { twMerge } from 'tailwind-merge'
import { Bot, CodeXml, LayoutDashboard, Table2, Trash2 } from 'lucide-svelte'
import { page } from '$app/state'
import BarsStaggered from '$lib/components/icons/BarsStaggered.svelte'
import DropdownV2 from '$lib/components/DropdownV2.svelte'
import { globalDbManagerDrawer, workspaceStore } from '$lib/stores'
import { parseDbInputFromAssetSyntax } from '$lib/utils'
import { useLocalStorageValue } from '$lib/svelte5Utils.svelte'
import SidebarSectionHeader from './SidebarSectionHeader.svelte'
import { favoriteManager } from './FavoriteMenu.svelte'
import { sidebarClasses } from './MenuButton.svelte'
import { sidebarPrefs } from './sidebarPrefs.svelte'
let { isCollapsed = false }: { isCollapsed?: boolean } = $props()
const sectionCollapsed = useLocalStorageValue(
'windmill_favorites_section_collapsed',
false,
'boolean'
)
const loaded = $derived(favoriteManager.loadedFor === $workspaceStore)
</script>
{#if sidebarPrefs.favorites.val && !isCollapsed && loaded}
<div class="flex flex-col gap-1">
<SidebarSectionHeader
title="Favorites"
collapsed={sectionCollapsed.val}
onToggle={() => (sectionCollapsed.val = !sectionCollapsed.val)}
/>
{#if !sectionCollapsed.val}
<div transition:slide={{ duration: 180 }} class="flex flex-col gap-0.5">
{#each favoriteManager.current as favorite (`${favorite.kind}:${favorite.path}`)}
{@const selected = favorite.href !== '#' && page.url.pathname === favorite.href}
<div class="relative group/fav">
<!-- An asset's href is `#`: it opens in the database manager instead. -->
<a
href={favorite.href}
title={favorite.path}
onclick={(e) => {
if (favorite.kind !== 'asset') return
e.preventDefault()
const dbInput = parseDbInputFromAssetSyntax(favorite.path)
if (dbInput) globalDbManagerDrawer.val?.openDrawer(dbInput)
}}
class={twMerge(
'flex flex-row items-center gap-2 px-2 py-1 pr-7 rounded text-xs font-normal min-w-0',
selected
? twMerge(sidebarClasses.selectedBg, sidebarClasses.selectedText)
: 'text-secondary hover:bg-surface-hover'
)}
>
<!-- Kind colors mirror the home-page row icons (RowIcon.svelte). -->
{#if favorite.kind == 'script'}
<CodeXml size={14} class="shrink-0 text-blue-500" />
{:else if favorite.kind == 'flow'}
<BarsStaggered size={14} class="shrink-0 text-teal-500" />
{:else if favorite.kind == 'app' || favorite.kind == 'raw_app'}
<LayoutDashboard size={14} class="shrink-0 text-orange-500" />
{:else if favorite.kind == 'agent'}
<Bot size={14} class="shrink-0 text-violet-500" />
{:else}
<Table2 size={14} class="shrink-0 text-primary" />
{/if}
<span class="truncate">{favorite.label}</span>
</a>
<div
class="absolute right-0.5 top-0 h-full flex items-center opacity-0 group-hover/fav:opacity-100 has-[[aria-expanded=true]]:opacity-100 transition-opacity"
>
<DropdownV2
items={[
{
displayName: 'Remove from favorites',
icon: Trash2,
action: () => favoriteManager.unstar(favorite.path, favorite.kind)
}
]}
size="xs"
fixedHeight={false}
/>
</div>
</div>
{:else}
<p class="px-2 py-1 text-2xs text-hint">Star an item to list it here.</p>
{/each}
</div>
{/if}
</div>
{/if}
@@ -19,8 +19,12 @@
Gauge,
Trash2,
KeyRound,
GraduationCap
GraduationCap,
PanelLeft,
Star,
Database
} from 'lucide-svelte'
import { sidebarPrefs } from './sidebarPrefs.svelte'
import { goto } from '$lib/navigation'
import { type Item } from '$lib/utils'
import { logout } from '$lib/logoutKit'
@@ -227,6 +231,25 @@
icon: darkMode ? Sun : Moon,
action: () => toggleDarkMode()
},
{
displayName: 'Customize sidebar',
icon: PanelLeft,
submenuItems: [
{
displayName: 'Favorites section',
icon: Star,
toggle: sidebarPrefs.favorites.val,
action: () => (sidebarPrefs.favorites.val = !sidebarPrefs.favorites.val)
},
{
displayName: 'Group data pages',
description: 'Variables, Resources and Assets under one Data menu',
icon: Database,
toggle: !sidebarPrefs.splitData.val,
action: () => (sidebarPrefs.splitData.val = !sidebarPrefs.splitData.val)
}
]
},
{
// The email is the label itself; the crown icon carries the admin role.
displayName: $userStore?.non_member
@@ -54,6 +54,8 @@
getServiceIcon
} from '../triggers/native/utils'
import type { NativeServiceName } from '$lib/gen/types.gen'
import DataStoresMenuItems from './DataStoresMenuItems.svelte'
import { sidebarPrefs } from './sidebarPrefs.svelte'
import {
Menubar,
Menu,
@@ -250,15 +252,21 @@
let sharingLinks = $derived(
mainMenuLinks.filter((l) => SHARING_LABELS.includes(l.label) && !l.disabled)
)
const groupedLabels = new Set([...MAIN_MENU_GROUPS.flatMap((g) => g.members), ...SHARING_LABELS])
// "Customize sidebar" can split the groups back into links of their own.
let activeMenuGroups = $derived(sidebarPrefs.splitData.val ? [] : MAIN_MENU_GROUPS)
let groupedLabels = $derived(
new Set([...activeMenuGroups.flatMap((g) => g.members), ...SHARING_LABELS])
)
let ungroupedMainLinks = $derived(mainMenuLinks.filter((l) => !groupedLabels.has(l.label)))
// A disabled MenuLink renders nothing, so its page leaves the menu, and a group with no
// page left leaves the nav.
let mainMenuGroups = $derived(
MAIN_MENU_GROUPS.map((g) => ({
...g,
links: mainMenuLinks.filter((l) => g.members.includes(l.label) && !l.disabled)
})).filter((g) => g.links.length > 0)
activeMenuGroups
.map((g) => ({
...g,
links: mainMenuLinks.filter((l) => g.members.includes(l.label) && !l.disabled)
}))
.filter((g) => g.links.length > 0)
)
let defaultExtraTriggerLinks = $derived([
{
@@ -566,6 +574,9 @@
</div>
</MenuItem>
{/each}
{#if group.label === 'Data'}
<DataStoresMenuItems {item} {itemClass} />
{/if}
{/snippet}
</Menu>
{/each}
@@ -0,0 +1,10 @@
import { useLocalStorageValue } from '$lib/svelte5Utils.svelte'
/** What "Customize sidebar" in the settings menu changes, per browser. Module-level so the
* menu that flips a choice and the sidebar that reads it share one value. */
export const sidebarPrefs = {
/** The starred items as a section of their own. */
favorites: useLocalStorageValue('windmill_sidebar_show_favorites', false, 'boolean'),
/** Variables, Resources and Assets as links of their own instead of one Data menu. */
splitData: useLocalStorageValue('windmill_sidebar_split_data', false, 'boolean')
}
@@ -25,6 +25,7 @@
import SidebarUsage from '$lib/components/sidebar/SidebarUsage.svelte'
import SidebarScrollArea from '$lib/components/sidebar/SidebarScrollArea.svelte'
import AiChatsSection from '$lib/components/sidebar/AiChatsSection.svelte'
import FavoritesSection from '$lib/components/sidebar/FavoritesSection.svelte'
import AccountSetupBanner from '$lib/components/sidebar/AccountSetupBanner.svelte'
import FinishAccountSetup from '$lib/components/sidebar/FinishAccountSetup.svelte'
import { accountSetup } from '$lib/components/sidebar/accountSetup.svelte'
@@ -1188,7 +1189,7 @@ outside this layout, and their shortcut must reopen the URL that is their creden
<!-- Settings / instance section: the last section inside the nav's unified scroll area. -->
{#snippet settingsMenu(collapsed: boolean)}
<div class="px-2 pb-1">
<div class="px-2">
<SettingsMenu
isCollapsed={collapsed}
workspaceSettingsTarget={sessionSettingsWorkspace}
@@ -1309,6 +1310,11 @@ outside this layout, and their shortcut must reopen the URL that is their creden
/>
</div>
<!-- The starred items, when "Customize sidebar" turns them on; hidden in the rail. -->
<div class="px-2 empty:hidden">
<FavoritesSection isCollapsed={collapsed} />
</div>
<!-- Section 2: AI sessions, one row each; collapsed, a menu of them. -->
{#if sessionsShown}
<div class="px-2">
@@ -1320,23 +1326,22 @@ outside this layout, and their shortcut must reopen the URL that is their creden
<div class="px-2 empty:hidden">
<AiChatsSection isCollapsed={collapsed} />
</div>
<!-- Section 3: instance settings — mt-auto drops it to the bottom
when the column has spare room, and collapses back to the normal
inter-section gap once the content overflows and scrolls. -->
<div class="mt-auto">
{@render settingsMenu(collapsed)}
</div>
</SidebarScrollArea>
</div>
<!-- Section 3: instance settings, pinned under the scrolled lists: inside them, long
session and chat lists pushed it out of view under the bottom fade. -->
<div class="flex-shrink-0 pt-2">
{@render settingsMenu(collapsed)}
</div>
<div class="flex-shrink-0">
{@render accountSetupBanner(collapsed)}
<SidebarUsage isCollapsed={collapsed} />
</div>
<div
class="flex-shrink-0 flex pt-3 pb-3.5 {collapsed
class="flex-shrink-0 flex pt-1 pb-3.5 {collapsed
? 'flex-col items-center gap-3'
: 'items-center justify-between px-4'}"
>