mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-10-13 08:02:47 +00:00
revert: clicking an unbuilt asset opens the asset again, not its script
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
8c6a660059
commit
5bc516c4fe
@@ -70,11 +70,7 @@
|
||||
interface Props {
|
||||
graph: AssetGraphResponse
|
||||
selection?: AssetGraphSelection | undefined
|
||||
/** `soleScript`: assets-only, the one script folded into a clicked asset. */
|
||||
onselect?: (
|
||||
selection: AssetGraphSelection | undefined,
|
||||
opts?: { soleScript?: string }
|
||||
) => void
|
||||
onselect?: (selection: AssetGraphSelection | undefined) => void
|
||||
// Called when the user clicks the per-asset + button (consumer-script
|
||||
// entry). Kept optional so the canvas stays usable outside the
|
||||
// pipeline editor.
|
||||
@@ -2009,11 +2005,7 @@
|
||||
if (!onselect) return
|
||||
const data = node.data as any
|
||||
if (node.type === 'asset') {
|
||||
const scripts = ((data.foldedIds ?? []) as string[]).filter((id) => id.startsWith('script:'))
|
||||
onselect(
|
||||
{ kind: 'asset', asset_kind: data.asset_kind, path: data.path },
|
||||
scripts.length === 1 ? { soleScript: scripts[0].slice('script:'.length) } : undefined
|
||||
)
|
||||
onselect({ kind: 'asset', asset_kind: data.asset_kind, path: data.path })
|
||||
} else if (node.type === 'runnable') {
|
||||
onselect({ kind: 'runnable', runnable_kind: data.runnable_kind, path: data.path })
|
||||
} else if (node.type === 'data-test') {
|
||||
|
||||
@@ -159,10 +159,7 @@
|
||||
onDeleteTrigger?: (...args: any[]) => void
|
||||
onOpenWebhook?: (...args: any[]) => void
|
||||
onOpenDataUpload?: (...args: any[]) => void
|
||||
onSelect: (
|
||||
selection: AssetGraphSelection | undefined,
|
||||
opts?: { soleScript?: string }
|
||||
) => void
|
||||
onSelect: (selection: AssetGraphSelection | undefined) => void
|
||||
onAddScriptForAsset?: (
|
||||
asset: { kind: AssetKind; path: string },
|
||||
language: ScriptLang,
|
||||
|
||||
@@ -1205,44 +1205,7 @@
|
||||
return false
|
||||
}
|
||||
}
|
||||
// Assets a job has written, by `kind:path`. Only grows: once built, an asset
|
||||
// stays built for this page's purposes.
|
||||
const materialized = new Set<string>()
|
||||
async function isMaterialized(asset: { kind: AssetKind; path: string }): Promise<boolean> {
|
||||
const key = `${asset.kind}:${asset.path}`
|
||||
if (materialized.has(key) || !$workspaceStore) return true
|
||||
try {
|
||||
const res = await AssetService.listAssets({
|
||||
workspace: $workspaceStore,
|
||||
path: asset.path,
|
||||
assetKinds: asset.kind
|
||||
})
|
||||
const built = res.assets.some((a) =>
|
||||
a.usages.some((u) => u.kind === 'job' && (u.access_type === 'w' || u.access_type === 'rw'))
|
||||
)
|
||||
if (built) materialized.add(key)
|
||||
return built
|
||||
} catch {
|
||||
return true
|
||||
}
|
||||
}
|
||||
// An asset nothing has built yet has no data to show: in the assets-only view,
|
||||
// where its one script has no node of its own, the click opens that script.
|
||||
async function handleCanvasSelect(
|
||||
s: AssetGraphSelection | undefined,
|
||||
opts?: { soleScript?: string }
|
||||
) {
|
||||
if (s?.kind === 'asset' && opts?.soleScript) {
|
||||
const asset = s
|
||||
if (!(await isMaterialized({ kind: asset.asset_kind, path: asset.path }))) {
|
||||
s = { kind: 'runnable', runnable_kind: 'script', path: opts.soleScript }
|
||||
// Job history expires, so "no write on record" may be an asset built long
|
||||
// ago: its own pane stays one click away.
|
||||
sendUserToast(`No build of ${asset.path} on record: opened its script.`, false, [
|
||||
{ label: 'Show the asset', callback: () => void handleCanvasSelect(asset) }
|
||||
])
|
||||
}
|
||||
}
|
||||
function handleCanvasSelect(s: AssetGraphSelection | undefined) {
|
||||
// Clicking a node while the pane is explicitly hidden is a request
|
||||
// to see that node — unhide. Background clicks (s == undefined)
|
||||
// keep the hidden state.
|
||||
|
||||
Reference in New Issue
Block a user