mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-10-28 08:02:43 +00:00
* feat: edit variables, resources and triggers in their own session tab Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: take a trigger's flow kind from its config and name the written trigger Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * refactor: one operating-workspace context for editors acting on a session's workspace Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: reload page item tabs only in sessions acting on the tool's workspace Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: resolve open in workspace for every preview tab kind in one place Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: guard every component under a session editor against the navigation workspace Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: show a page item tab whose item is gone instead of mounting its editor Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: follow a saved page item in the tab's own workspace and restore in-frame rows Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * feat: close a page item tab from its editor header Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: judge trigger permissions by the user acting in the session workspace Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: judge every session-editor permission by the user acting in that workspace Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: keep session permissions reactive to the acting role and restore tabs as last seen Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: default Path's owner controls to the user acting in its workspace Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
120 lines
3.4 KiB
Svelte
120 lines
3.4 KiB
Svelte
<script lang="ts">
|
|
import { ResourceService, VariableService } from '$lib/gen'
|
|
import { copyToClipboard, truncate } from '$lib/utils'
|
|
import { ClipboardCopy, Expand } from 'lucide-svelte'
|
|
import Drawer from './common/drawer/Drawer.svelte'
|
|
import ObjectViewer from './propertyPicker/ObjectViewer.svelte'
|
|
import Tooltip from './Tooltip.svelte'
|
|
import { Button, DrawerContent } from './common'
|
|
import { useOperatingWorkspace } from '$lib/components/operatingWorkspace.svelte'
|
|
|
|
const operatingWorkspace = useOperatingWorkspace()
|
|
|
|
interface Props {
|
|
value: any
|
|
}
|
|
|
|
let { value }: Props = $props()
|
|
let jsonViewer: Drawer | undefined = $state()
|
|
let jsonViewerContent: any | undefined = $state()
|
|
|
|
function isString(value: any) {
|
|
return typeof value === 'string' || value instanceof String
|
|
}
|
|
|
|
async function getResource(path: string) {
|
|
jsonViewerContent = await ResourceService.getResourceValue({
|
|
workspace: $operatingWorkspace!,
|
|
path
|
|
})
|
|
}
|
|
|
|
async function getVariable(path: string) {
|
|
jsonViewerContent = await VariableService.getVariableValue({
|
|
workspace: $operatingWorkspace!,
|
|
path
|
|
})
|
|
}
|
|
</script>
|
|
|
|
<Drawer bind:this={jsonViewer} size="800px">
|
|
<DrawerContent title="Argument Details" on:close={jsonViewer.closeDrawer}>
|
|
{#snippet actions()}
|
|
<Button
|
|
on:click={() => copyToClipboard(JSON.stringify(jsonViewerContent, null, 4))}
|
|
variant="subtle"
|
|
unifiedSize="md"
|
|
startIcon={{ icon: ClipboardCopy }}
|
|
>
|
|
Copy
|
|
</Button>
|
|
{/snippet}
|
|
{#if isString(jsonViewerContent)}
|
|
<pre class="text-xs whitespace-pre-wrap">{jsonViewerContent}</pre>
|
|
{:else}
|
|
<ObjectViewer pureViewer json={jsonViewerContent} />
|
|
{/if}
|
|
</DrawerContent>
|
|
</Drawer>
|
|
|
|
{#if value == undefined || value == null}
|
|
<span class="text-primary">null</span>
|
|
{:else if value === '<function call>'}
|
|
{'<function call>'}<Tooltip
|
|
>The arg was none and the default argument of the script is a function call, hence the actual
|
|
value used for this arg was the output of the script's function call for this arg</Tooltip
|
|
>
|
|
{:else if isString(value) && value.startsWith('$res:')}
|
|
<button
|
|
class="text-xs text-accent"
|
|
onclick={async () => {
|
|
await getResource(value.substring('$res:'.length))
|
|
jsonViewer?.toggleDrawer()
|
|
}}>{value}</button
|
|
>
|
|
{:else if isString(value) && value.startsWith('$var:')}
|
|
<button
|
|
class="text-xs text-accent"
|
|
onclick={async () => {
|
|
await getVariable(value.substring('$var:'.length))
|
|
jsonViewer?.toggleDrawer()
|
|
}}>{value}</button
|
|
>
|
|
{:else if isString(value) && value.startsWith('$jsonvar:')}
|
|
<button
|
|
class="text-xs text-accent"
|
|
onclick={async () => {
|
|
await getVariable(value.substring('$jsonvar:'.length))
|
|
jsonViewer?.toggleDrawer()
|
|
}}>{value}</button
|
|
>
|
|
{:else if typeof value !== 'object'}
|
|
<span>
|
|
{truncate(JSON.stringify(value), 80)}
|
|
{#if JSON.stringify(value).length > 80}
|
|
<button
|
|
class="text-xs text-accent"
|
|
onclick={() => {
|
|
jsonViewerContent = value
|
|
jsonViewer?.toggleDrawer()
|
|
}}>See expanded</button
|
|
>
|
|
{/if}
|
|
</span>
|
|
{:else}
|
|
<div class="relative">
|
|
{#if JSON.stringify(value).length > 120}
|
|
<button
|
|
class="text-xs absolute top-0 right-8 text-primary"
|
|
onclick={() => {
|
|
jsonViewerContent = value
|
|
jsonViewer?.toggleDrawer()
|
|
}}><Expand size={18} /></button
|
|
>
|
|
{/if}
|
|
<div class="max-h-60 overflow-auto" style="scrollbar-gutter: stable">
|
|
<ObjectViewer collapsed={false} topBrackets={true} pureViewer={true} json={value} />
|
|
</div>
|
|
</div>
|
|
{/if}
|