mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-12-03 16:10:37 +00:00
fix: one tool list per connection, fold the workspaces that connect on their own
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
aa1fa8f6d2
commit
fc23165c33
@@ -43,6 +43,8 @@
|
||||
import { sendUserToast } from '$lib/toast'
|
||||
import { copyToClipboard } from '$lib/utils'
|
||||
import Pencil from 'lucide-svelte/icons/pencil'
|
||||
import ChevronDown from 'lucide-svelte/icons/chevron-down'
|
||||
import ChevronRight from 'lucide-svelte/icons/chevron-right'
|
||||
import Copy from 'lucide-svelte/icons/copy'
|
||||
import Check from 'lucide-svelte/icons/check'
|
||||
|
||||
@@ -184,7 +186,7 @@
|
||||
isGateway && !toolsOnly && !allWorkspaces && covered.length === 1 && isTools(covered[0])
|
||||
)
|
||||
const leftOut = $derived(
|
||||
isGateway && !toolsOnly && access !== 'selected' && access !== 'read'
|
||||
isGateway && access !== 'selected' && access !== 'read'
|
||||
? workspaceAccess.filter((w) => isTools(w) && !served.includes(w))
|
||||
: []
|
||||
)
|
||||
@@ -198,18 +200,15 @@
|
||||
return [...byLabel].map(([key, ws]) => {
|
||||
const label = accessLabel(ws[0], access)
|
||||
const level = toolsetLevel(ws[0], access)
|
||||
const hint =
|
||||
!givesAnything(ws[0], access)
|
||||
? 'Nothing the client can use there with this access.'
|
||||
: isTools(ws[0])
|
||||
? 'The scripts and flows your role offers, each as its own tool, and nothing else.'
|
||||
: ACCESS_HINTS[level ?? access]
|
||||
const hint = !givesAnything(ws[0], access)
|
||||
? 'Nothing the client can use there with this access.'
|
||||
: isTools(ws[0])
|
||||
? 'The scripts and flows your role offers, each as its own tool, and nothing else.'
|
||||
: ACCESS_HINTS[level ?? access]
|
||||
return {
|
||||
key,
|
||||
label,
|
||||
ws,
|
||||
// One list per connection: the picked level's, or what a bound workspace leaves.
|
||||
tools: givesAnything(ws[0], access) ? connectionToolset(access, bound) : undefined,
|
||||
restricted: restriction(ws[0], access),
|
||||
hint: ws.every((w) => w.limited) ? `${hint} Set by your role.` : hint
|
||||
}
|
||||
@@ -217,8 +216,12 @@
|
||||
})
|
||||
// A role limit settles the access; a narrower one the client asked for stays editable.
|
||||
const editable = $derived(served.every((w) => !w.limited) || access !== 'full')
|
||||
let shownTools = $state<string[]>([])
|
||||
let showUrls = $state(false)
|
||||
// One tool list per connection: the picked level's, or what a bound workspace leaves.
|
||||
const connectionTools = $derived(
|
||||
served.some((w) => givesAnything(w, access)) ? connectionToolset(access, bound) : undefined
|
||||
)
|
||||
let toolsOpen = $state(false)
|
||||
let leftOutOpen = $state(false)
|
||||
function coverDefault() {
|
||||
const initial = defaultConnection(workspaceAccess)
|
||||
allWorkspaces = initial.all
|
||||
@@ -514,23 +517,8 @@
|
||||
placeholder="Choose a workspace"
|
||||
/>
|
||||
<p class="text-2xs text-secondary">
|
||||
Your role gives scripts and flows as tools, one workspace per connection. For another,
|
||||
sign in again and choose it here, or add its URL to your client.
|
||||
Your role gives scripts and flows as tools, one workspace per connection.
|
||||
</p>
|
||||
<Button
|
||||
variant="subtle"
|
||||
unifiedSize="xs"
|
||||
btnClasses="w-fit"
|
||||
aria-expanded={showUrls}
|
||||
onClick={() => (showUrls = !showUrls)}
|
||||
>
|
||||
{showUrls ? 'Hide workspace URLs' : 'Show workspace URLs'}
|
||||
</Button>
|
||||
{#if showUrls}
|
||||
{#each workspaceAccess.filter((w) => isTools(w) && !pickedWorkspaces.includes(w.id)) as w (w.id)}
|
||||
<ClipboardPanel title={w.name} content={workspaceMcpUrl(w.id)} size="sm" />
|
||||
{/each}
|
||||
{/if}
|
||||
{:else if toolsAlone}
|
||||
<p class="text-xs text-primary">{covered[0].name} only</p>
|
||||
<Button variant="subtle" unifiedSize="xs" btnClasses="w-fit" onClick={coverDefault}>
|
||||
@@ -605,8 +593,19 @@
|
||||
/>
|
||||
{/if}
|
||||
{/snippet}
|
||||
{#snippet toolsToggle()}
|
||||
{#if connectionTools}
|
||||
<Button
|
||||
variant="subtle"
|
||||
unifiedSize="xs"
|
||||
aria-expanded={toolsOpen}
|
||||
onClick={() => (toolsOpen = !toolsOpen)}
|
||||
>
|
||||
{toolsOpen ? 'Hide tools' : 'Show tools'}
|
||||
</Button>
|
||||
{/if}
|
||||
{/snippet}
|
||||
{#snippet accessRow(group: (typeof groups)[number], named: boolean)}
|
||||
{@const open = shownTools.includes(group.key)}
|
||||
<div class="flex flex-col gap-1">
|
||||
<div class="flex flex-wrap items-center gap-x-1.5">
|
||||
<span class="text-xs text-primary">
|
||||
@@ -626,24 +625,9 @@
|
||||
</Popover>
|
||||
{/if}
|
||||
<Tooltip small>{group.hint}</Tooltip>
|
||||
{#if !named}{@render pen()}{/if}
|
||||
{#if group.tools}
|
||||
{@const tools = open ? toolset(group.tools) : undefined}
|
||||
<Button
|
||||
variant="subtle"
|
||||
unifiedSize="xs"
|
||||
btnClasses="ml-auto"
|
||||
aria-expanded={open}
|
||||
onClick={() =>
|
||||
(shownTools = open
|
||||
? shownTools.filter((l) => l !== group.key)
|
||||
: [...shownTools, group.key])}
|
||||
>
|
||||
{open ? 'Hide tools' : 'Show tools'}
|
||||
</Button>
|
||||
{#if open}
|
||||
<div class="basis-full"><McpToolList {tools} /></div>
|
||||
{/if}
|
||||
{#if !named}
|
||||
{@render pen()}
|
||||
{@render toolsToggle()}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
@@ -653,7 +637,10 @@
|
||||
<div class="mb-6 flex flex-col gap-1">
|
||||
<div class="flex items-center gap-1.5">
|
||||
<p class="text-xs font-semibold text-emphasis">Access</p>
|
||||
{#if groups.length !== 1}{@render pen()}{/if}
|
||||
{#if groups.length !== 1}
|
||||
{@render pen()}
|
||||
{@render toolsToggle()}
|
||||
{/if}
|
||||
</div>
|
||||
{#if groups.length === 1}
|
||||
{@render accessRow(groups[0], false)}
|
||||
@@ -668,42 +655,54 @@
|
||||
Scripts and flows as tools. Choose the workspace and its scripts and flows.
|
||||
</p>
|
||||
{/if}
|
||||
{#if toolsOpen && connectionTools}
|
||||
<McpToolList tools={toolset(connectionTools)} />
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if leftOut.length > 0}
|
||||
{@const one = leftOut.length === 1}
|
||||
<div class="mb-6 flex flex-col gap-2 rounded-md border bg-surface-secondary p-3">
|
||||
<p class="text-xs font-semibold text-emphasis">
|
||||
<Button
|
||||
variant="subtle"
|
||||
unifiedSize="xs"
|
||||
btnClasses="-m-1 w-fit font-semibold text-emphasis"
|
||||
startIcon={{ icon: leftOutOpen ? ChevronDown : ChevronRight }}
|
||||
aria-expanded={leftOutOpen}
|
||||
onClick={() => (leftOutOpen = !leftOutOpen)}
|
||||
>
|
||||
{one ? 'Workspace' : 'Workspaces'}
|
||||
{leftOut.map((w) => w.name).join(', ')}
|
||||
{one ? 'connects on its own' : 'connect on their own'}
|
||||
</p>
|
||||
<p class="text-xs text-primary">
|
||||
Scripts and flows as tools need a connection of their own.
|
||||
</p>
|
||||
{#each leftOut as w (w.id)}
|
||||
<div class="flex flex-col gap-3">
|
||||
<div class="flex flex-col gap-1">
|
||||
<p class="text-xs font-semibold text-emphasis">
|
||||
Add {one ? 'its' : `${w.name}'s`} URL to your AI client
|
||||
</p>
|
||||
<ClipboardPanel content={workspaceMcpUrl(w.id)} size="sm" />
|
||||
</Button>
|
||||
{#if leftOutOpen}
|
||||
<p class="text-xs text-primary">
|
||||
Scripts and flows as tools need a connection of their own.
|
||||
</p>
|
||||
{#each leftOut as w (w.id)}
|
||||
<div class="flex flex-col gap-3">
|
||||
<div class="flex flex-col gap-1">
|
||||
<p class="text-xs font-semibold text-emphasis">
|
||||
Add {one ? 'its' : `${w.name}'s`} URL to your AI client
|
||||
</p>
|
||||
<ClipboardPanel content={workspaceMcpUrl(w.id)} size="sm" />
|
||||
</div>
|
||||
<div class="flex flex-col gap-1">
|
||||
<p class="text-xs font-semibold text-emphasis">Or connect only {w.name} here</p>
|
||||
<p class="text-2xs text-secondary">In place of the other workspaces.</p>
|
||||
<Button
|
||||
variant="default"
|
||||
unifiedSize="sm"
|
||||
btnClasses="w-fit"
|
||||
onClick={() => connectOnly(w.id)}
|
||||
>
|
||||
Connect {w.name} only
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1">
|
||||
<p class="text-xs font-semibold text-emphasis">Or connect only {w.name} here</p>
|
||||
<p class="text-2xs text-secondary">In place of the other workspaces.</p>
|
||||
<Button
|
||||
variant="default"
|
||||
unifiedSize="sm"
|
||||
btnClasses="w-fit"
|
||||
onClick={() => connectOnly(w.id)}
|
||||
>
|
||||
Connect {w.name} only
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
{/each}
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user