mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-12-03 16:10:37 +00:00
fix: shorten the run-and-edit access label, list the edits in its tooltip
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
168412b04b
commit
72db21f599
@@ -4,6 +4,7 @@ import {
|
||||
accessLabel,
|
||||
connectsSeparately,
|
||||
defaultConnection,
|
||||
editsHint,
|
||||
servedOn,
|
||||
toolsetLevel
|
||||
} from './workspaceAccess'
|
||||
@@ -36,12 +37,11 @@ it('names the lower of the picked access and the workspace one', () => {
|
||||
expect(accessLabel({ ...ws('a', 'runnables'), runnables: 12 }, 'full')).toBe(
|
||||
'12 scripts and flows as tools'
|
||||
)
|
||||
expect(
|
||||
accessLabel(
|
||||
{ ...ws('a', 'run_and_edit'), edits: ['variables', 'schedules', 'triggers'] },
|
||||
'full'
|
||||
)
|
||||
).toBe('Read and run, edit variables, schedules and triggers')
|
||||
const edits = { ...ws('a', 'run_and_edit'), edits: ['variables', 'schedules', 'triggers'] }
|
||||
expect(accessLabel(edits, 'full')).toBe('Read, run and edit')
|
||||
expect(editsHint(edits)).toBe(
|
||||
'Explore, run deployed scripts, flows and agents, and edit variables, schedules and triggers.'
|
||||
)
|
||||
expect(accessLabel(ws('a', 'run_and_edit'), 'read_run')).toBe('Read and run')
|
||||
expect(accessLabel(ws('a', 'read_only'), 'read_run')).toBe('Read only')
|
||||
expect(accessLabel(ws('a', 'read_only'), 'selected')).toBe('Not available')
|
||||
|
||||
@@ -7,7 +7,7 @@ export type WorkspaceAccess = McpWorkspaceAccess['access']
|
||||
|
||||
const LABELS: Record<WorkspaceAccess, string> = {
|
||||
build_and_run: 'Build and run',
|
||||
run_and_edit: 'Read and run',
|
||||
run_and_edit: 'Read, run and edit',
|
||||
read_and_run: 'Read and run',
|
||||
read_only: 'Read only',
|
||||
runnables: 'Scripts and flows as tools',
|
||||
@@ -40,15 +40,18 @@ export function accessLabel(workspace: McpWorkspaceAccess, picked: McpAccess): s
|
||||
return `${runnables} ${runnables === 1 ? 'script or flow' : 'scripts and flows'} as tools`
|
||||
}
|
||||
if (picked === 'read_run' && access !== 'read_only') return LABELS.read_and_run
|
||||
if (access === 'run_and_edit') {
|
||||
const edits = workspace.edits ?? []
|
||||
const last = edits.at(-1)
|
||||
const listed = edits.length > 1 ? `${edits.slice(0, -1).join(', ')} and ${last}` : last
|
||||
return listed ? `${LABELS.run_and_edit}, edit ${listed}` : LABELS.run_and_edit
|
||||
}
|
||||
return LABELS[access]
|
||||
}
|
||||
|
||||
/** What a role that edits only some kinds lets the client do; the label stays short. */
|
||||
export function editsHint(workspace: McpWorkspaceAccess): string | undefined {
|
||||
const edits = workspace.edits ?? []
|
||||
if (workspace.access !== 'run_and_edit' || edits.length === 0) return undefined
|
||||
const last = edits.at(-1)
|
||||
const listed = edits.length > 1 ? `${edits.slice(0, -1).join(', ')} and ${last}` : last
|
||||
return `Explore, run deployed scripts, flows and agents, and edit ${listed}.`
|
||||
}
|
||||
|
||||
/** The covered workspaces a connection serves. One set to scripts and flows as tools is served
|
||||
* only to a connection covering it alone; a read-only one lists it as giving nothing. */
|
||||
export function servedOn(
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
import {
|
||||
accessLabel,
|
||||
defaultConnection,
|
||||
editsHint,
|
||||
givesAnything,
|
||||
servedOn,
|
||||
toolsetLevel,
|
||||
@@ -198,7 +199,7 @@
|
||||
? '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]
|
||||
: ((level === 'full' && editsHint(ws[0])) || ACCESS_HINTS[level ?? access])
|
||||
return {
|
||||
label,
|
||||
ws,
|
||||
|
||||
Reference in New Issue
Block a user