Files
windmill/frontend/src/lib/components/WorkspaceDependenciesViewer.svelte
T
PyraandRuben Fiszel d38c96db36 feat: workspace dependencies (#7124)
* commit raw requirements

Signed-off-by: pyranota <pyra@duck.com>

* raw requirements

Signed-off-by: pyranota <pyra@duck.com>

* implement `parse_annotation`

Signed-off-by: pyranota <pyra@duck.com>

* more progress on wdeps

Signed-off-by: pyranota <pyra@duck.com>

* more progress

Signed-off-by: pyranota <pyra@duck.com>

* fixes

Signed-off-by: pyranota <pyra@duck.com>

* more progress

Signed-off-by: pyranota <pyra@duck.com>

* fixes

Signed-off-by: pyranota <pyra@duck.com>

* cli improvements + raw deps

Signed-off-by: pyranota <pyra@duck.com>

* cleanup

Signed-off-by: pyranota <pyra@duck.com>

* fix python versions

Signed-off-by: pyranota <pyra@duck.com>

* progress

Signed-off-by: pyranota <pyra@duck.com>

* update :)

Signed-off-by: pyranota <pyra@duck.com>

* add MaybeLock

Signed-off-by: pyranota <pyra@duck.com>

* go WIP

Signed-off-by: pyranota <pyra@duck.com>

* fix python ignoring py version from requirements

Signed-off-by: pyranota <pyra@duck.com>

* optimize php

Signed-off-by: pyranota <pyra@duck.com>

* require admin to alter

Signed-off-by: pyranota <pyra@duck.com>

* fix(cli): flow generateLocks raw deps

Signed-off-by: pyranota <pyra@duck.com>

* progress in checklist

Signed-off-by: pyranota <pyra@duck.com>

* fix agent workers

Signed-off-by: pyranota <pyra@duck.com>

* nits

Signed-off-by: pyranota <pyra@duck.com>

* nits

Signed-off-by: pyranota <pyra@duck.com>

* nit: remove default features

Signed-off-by: pyranota <pyra@duck.com>

* oh-wow

Signed-off-by: pyranota <pyra@duck.com>

* remove dbg!

Signed-off-by: pyranota <pyra@duck.com>

* nits

Signed-off-by: pyranota <pyra@duck.com>

* add indexes

Signed-off-by: pyranota <pyra@duck.com>

* cleanup

Signed-off-by: pyranota <pyra@duck.com>

* nits

Signed-off-by: pyranota <pyra@duck.com>

* remove todos

Signed-off-by: pyranota <pyra@duck.com>

* fix cli

Signed-off-by: pyranota <pyra@duck.com>

* add debug flag

Signed-off-by: pyranota <pyra@duck.com>

* cli: remove noise

Signed-off-by: pyranota <pyra@duck.com>

* fix cli

Signed-off-by: pyranota <pyra@duck.com>

* remove todos

Signed-off-by: pyranota <pyra@duck.com>

* trigger deps correctly

Signed-off-by: pyranota <pyra@duck.com>

* fix frontend

Signed-off-by: pyranota <pyra@duck.com>

* fix frontend again

Signed-off-by: pyranota <pyra@duck.com>

* finally fix frontend

Signed-off-by: pyranota <pyra@duck.com>

* ee repo ref

Signed-off-by: pyranota <pyra@duck.com>

* fix all

Signed-off-by: pyranota <pyra@duck.com>

* more fixes...

Signed-off-by: pyranota <pyra@duck.com>

* remove test

Signed-off-by: pyranota <pyra@duck.com>

* Update backend-test.yml

* comment out legacy test

Signed-off-by: pyranota <pyra@duck.com>

* fix ci

Signed-off-by: pyranota <pyra@duck.com>

* fix ci?

Signed-off-by: pyranota <pyra@duck.com>

* comment out thing

Signed-off-by: pyranota <pyra@duck.com>

* ignore test

Signed-off-by: pyranota <pyra@duck.com>

* ci

Signed-off-by: pyranota <pyra@duck.com>

* base fixture

Signed-off-by: pyranota <pyra@duck.com>

* fix regression

Signed-off-by: pyranota <pyra@duck.com>

* fix docs links

Signed-off-by: pyranota <pyra@duck.com>

* update min version

Signed-off-by: pyranota <pyra@duck.com>

* simplify

* implement cache for get_latest

Signed-off-by: pyranota <pyra@duck.com>

* move to workspace settings

Signed-off-by: pyranota <pyra@duck.com>

* sqlx + migration

Signed-off-by: pyranota <pyra@duck.com>

* more migrations

Signed-off-by: pyranota <pyra@duck.com>

* use box pin

Signed-off-by: pyranota <pyra@duck.com>

* nit

Signed-off-by: pyranota <pyra@duck.com>

---------

Signed-off-by: pyranota <pyra@duck.com>
Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
2025-11-28 16:00:11 +00:00

100 lines
3.2 KiB
Svelte

<script lang="ts">
import Drawer from './common/drawer/Drawer.svelte'
import DrawerContent from './common/drawer/DrawerContent.svelte'
import HighlightCode from './HighlightCode.svelte'
import { Button } from './common'
import WorkspaceDependenciesEditor from './WorkspaceDependenciesEditor.svelte'
import type { ScriptLang } from '$lib/gen'
import { Code2, Edit, FileText } from 'lucide-svelte'
import { canWrite } from '$lib/utils'
import { userStore } from '$lib/stores'
// Component state
let drawer: Drawer | undefined = $state()
let workspaceDependenciesEditor: WorkspaceDependenciesEditor | undefined = $state()
// Content state
let viewContent: string = $state('')
let viewLanguage: ScriptLang = $state('python3')
let viewPath: string = $state('')
let viewDescription: string = $state('')
let viewDepsId: number | undefined = $state(undefined)
let viewDepsName: string | undefined = $state(undefined)
let canWriteDeps: boolean = $state(false)
// Export methods for external control
export function openViewer(path: string, content?: string, language?: ScriptLang, description?: string, depsId?: number, depsName?: string) {
viewPath = path
viewContent = content || ''
viewLanguage = language || 'python3'
viewDescription = description || ''
viewDepsId = depsId
viewDepsName = depsName
// TODO: Replace with actual API call to check permissions
// For now, mock the permission check
canWriteDeps = canWrite(path, {}, $userStore)
drawer?.openDrawer()
}
export function closeViewer() {
drawer?.closeDrawer()
}
function editWorkspaceDependencies() {
if (viewDepsId) {
workspaceDependenciesEditor?.editWorkspaceDependencies(viewDepsId, viewDepsName, viewLanguage)
}
closeViewer()
}
function onWorkspaceDependenciesUpdated() {
// TODO: Reload workspace dependencies data
console.log('Workspace dependencies updated, should reload data')
}
</script>
<WorkspaceDependenciesEditor bind:this={workspaceDependenciesEditor} on:create={onWorkspaceDependenciesUpdated} />
<Drawer bind:this={drawer} size="900px">
<DrawerContent title="Workspace Dependencies from {viewPath}" on:close={closeViewer}>
{#snippet actions()}
<div class="flex items-center gap-4">
<div class="flex items-center gap-2">
<Code2 size={16} class="text-secondary" />
<span class="text-sm font-mono text-secondary">{viewLanguage}</span>
</div>
{#if canWriteDeps}
<Button
size="xs"
variant="border"
color="light"
startIcon={{ icon: Edit }}
on:click={editWorkspaceDependencies}
>
Edit
</Button>
{/if}
</div>
{/snippet}
<div class="space-y-4">
{#if viewDescription}
<div class="bg-surface-secondary rounded-md p-3">
<p class="text-sm text-secondary">{viewDescription}</p>
</div>
{/if}
{#if viewContent}
<HighlightCode language={viewLanguage} code={viewContent} />
{:else}
<div class="text-center text-secondary py-8">
<FileText size={48} class="mx-auto mb-4 opacity-50" />
<p>No workspace dependencies found for this path</p>
<p class="text-xs mt-2">Create workspace dependencies to define dependencies for scripts in this directory</p>
</div>
{/if}
</div>
</DrawerContent>
</Drawer>