fix(editor): Properly set colors for connections and labels on nodes with pinned data (#8209)

Co-authored-by: Alex Grozav <alex@grozav.com>
This commit is contained in:
Csaba Tuncsik
2024-01-11 14:03:23 +01:00
committed by GitHub
parent 884396ea0d
commit 3b8ccb9fb9
5 changed files with 518 additions and 16 deletions

View File

@@ -1179,17 +1179,6 @@ export default defineComponent({
.drop-add-node-label {
z-index: 10;
}
.jtk-connector.success:not(.jtk-hover) {
path:not(.jtk-connector-outline) {
stroke: var(--color-success-light);
}
path[jtk-overlay-id='reverse-arrow'],
path[jtk-overlay-id='endpoint-arrow'],
path[jtk-overlay-id='midpoint-arrow'] {
fill: var(--color-success-light);
}
}
</style>
<style lang="scss">
@@ -1262,7 +1251,6 @@ export default defineComponent({
white-space: nowrap;
font-size: var(--font-size-s);
font-weight: var(--font-weight-regular);
color: var(--color-success);
margin-top: -15px;
&.floating {

View File

@@ -755,9 +755,15 @@ export const getRunItemsLabel = (output: { total: number; iterations: number }):
export const addConnectionOutputSuccess = (
connection: Connection,
output: { total: number; iterations: number },
output: { total: number; iterations: number; classNames?: string[] },
) => {
connection.addClass('success');
const classNames: string[] = ['success'];
if (output.classNames) {
classNames.push(...output.classNames);
}
connection.addClass(classNames.join(' '));
if (getOverlay(connection, OVERLAY_RUN_ITEMS_ID)) {
connection.removeOverlay(OVERLAY_RUN_ITEMS_ID);
}
@@ -771,7 +777,7 @@ export const addConnectionOutputSuccess = (
const container = document.createElement('div');
const span = document.createElement('span');
container.classList.add('connection-run-items-label');
container.classList.add(...['connection-run-items-label', ...classNames]);
span.classList.add('floating');
span.innerHTML = getRunItemsLabel(output);
container.appendChild(span);
@@ -791,6 +797,27 @@ export const addConnectionOutputSuccess = (
});
};
export const addClassesToOverlays = ({
connection,
overlayIds,
classNames,
includeConnector,
}: {
connection: Connection;
overlayIds: string[];
classNames: string[];
includeConnector?: boolean;
}) => {
overlayIds.forEach((overlayId) => {
const overlay = getOverlay(connection, overlayId);
overlay?.canvas?.classList.add(...classNames);
if (includeConnector) {
connection.connector.canvas?.classList.add(...classNames);
}
});
};
const getContentDimensions = (): { editorWidth: number; editorHeight: number } => {
let contentWidth = window.innerWidth;
let contentHeight = window.innerHeight;

View File

@@ -2157,6 +2157,9 @@ export default defineComponent({
}, []);
this.workflowsStore.addWorkflowTagIds(tagIds);
setTimeout(() => {
this.addPinDataConnections(this.workflowsStore.pinnedWorkflowData || ({} as IPinData));
});
}
} catch (error) {
this.showError(error, this.$locale.baseText('nodeView.showError.importWorkflowData.title'));
@@ -3803,7 +3806,22 @@ export default defineComponent({
}) {
const pinData = this.workflowsStore.pinnedWorkflowData;
if (pinData?.[name]) return;
if (pinData?.[name]) {
const { outgoing } = this.getIncomingOutgoingConnections(name);
outgoing.forEach((connection: Connection) => {
if (connection.__meta?.sourceNodeName === name) {
const hasRun = this.workflowsStore.getWorkflowResultDataByNodeName(name) !== null;
NodeViewUtils.addClassesToOverlays({
connection,
overlayIds: [NodeViewUtils.OVERLAY_RUN_ITEMS_ID],
classNames: hasRun ? ['has-run'] : [],
includeConnector: true,
});
}
});
return;
}
const sourceNodeName = name;
const sourceNode = this.workflowsStore.getNodeByName(sourceNodeName);
@@ -4690,6 +4708,7 @@ export default defineComponent({
NodeViewUtils.addConnectionOutputSuccess(connection, {
total: pinData[nodeName].length,
iterations: 0,
classNames: ['pinned'],
});
});
});
@@ -5209,3 +5228,36 @@ export default defineComponent({
top: var(--spacing-l);
}
</style>
<style lang="scss" scoped>
@mixin applyColorToConnection($partialSelector, $cssColorVarName, $labelCssColorVarName) {
.jtk-connector#{$partialSelector}:not(.jtk-hover) {
path:not(.jtk-connector-outline) {
stroke: var(#{$cssColorVarName});
}
path[jtk-overlay-id='reverse-arrow'],
path[jtk-overlay-id='endpoint-arrow'],
path[jtk-overlay-id='midpoint-arrow'] {
fill: var(#{$cssColorVarName});
}
}
.connection-run-items-label#{$partialSelector} {
color: var(#{$labelCssColorVarName});
}
}
:deep(.node-view) {
@include applyColorToConnection('.success', '--color-success-light', '--color-success');
@include applyColorToConnection(
'.success.pinned',
'--color-foreground-xdark',
'--color-foreground-xdark'
);
@include applyColorToConnection(
'.success.pinned.has-run',
'--color-secondary',
'--color-secondary'
);
}
</style>