From 36c93541ba64e24851da4ee51a5ae4140978b515 Mon Sep 17 00:00:00 2001 From: Brandon Jordan Date: Sun, 19 Nov 2023 22:44:21 -0500 Subject: [PATCH] Implement connections between actions --- src/render.ts | 38 ++++++++++++++++++++++++++++++++++++++ src/style.css | 9 +++++++++ 2 files changed, 47 insertions(+) diff --git a/src/render.ts b/src/render.ts index 7bd2313..1cb5c2e 100644 --- a/src/render.ts +++ b/src/render.ts @@ -47,6 +47,8 @@ function renderAction(identifier: string, action: ActionData): Node { const ul = document.createElement('ul'); + renderActionConnection(card, action); + let actionData = null; if (actions[identifier]) { console.log('Found definition.'); @@ -82,6 +84,42 @@ function renderAction(identifier: string, action: ActionData): Node { return card; } +let lastAction: ActionData; + +function renderActionConnection(card: HTMLElement, action: ActionData) { + if (lastAction && lastAction.WFWorkflowActionParameters) { + let outputUUID = null; + for (let i in action.WFWorkflowActionParameters) { + // @ts-ignore + const paramValue = action.WFWorkflowActionParameters[i]; + if (!paramValue.hasOwnProperty("Value")) { + continue; + } + if (!paramValue.Value.hasOwnProperty("OutputUUID")) { + continue; + } + outputUUID = paramValue.Value.OutputUUID; + } + if (outputUUID !== null) { + // @ts-ignore + for (let j in lastAction.WFWorkflowActionParameters) { + if (j !== "UUID") { + continue; + } + // @ts-ignore + const UUID = lastAction.WFWorkflowActionParameters[j]; + if (outputUUID !== UUID) { + continue; + } + + console.log('link actions', [action, lastAction]); + card.classList.add('sp-linked-action'); + } + } + } + lastAction = action; +} + export function renderActionIcon(icon: string = 'gear', color?: string, background?: string): string { const actionIcon = document.createElement('div'); actionIcon.className = 'sp-action-icon'; diff --git a/src/style.css b/src/style.css index e0a0234..3a5919f 100644 --- a/src/style.css +++ b/src/style.css @@ -172,6 +172,15 @@ color: #ffbf00; } +.sp-container .card.sp-linked-action:before { + content: " "; + background: #6f7178; + width: 0.2rem; + height: 0.9rem; + top: -1rem; + position: absolute; +} + .sp-container .sp-action-icon { display: flex; place-content: center;