fix(editor): Workflow diff UX improvements (#19047)

This commit is contained in:
Raúl Gómez Morales
2025-09-03 16:48:10 +02:00
committed by GitHub
parent fc094518d6
commit 277685e9e5
6 changed files with 46 additions and 15 deletions

View File

@@ -3438,6 +3438,7 @@
"workflowDiff.changes": "Changes",
"workflowDiff.nodes": "Nodes",
"workflowDiff.connectors": "Connectors",
"workflowDiff.compare": "Compare versions",
"workflowDiff.settings": "Settings",
"workflowDiff.local": "Local",
"workflowDiff.remote": "Remote ({branchName})",

View File

@@ -15,7 +15,15 @@ import {
notifyUserAboutPullWorkFolderOutcome,
} from '@/utils/sourceControlUtils';
import { type SourceControlledFile, SOURCE_CONTROL_FILE_TYPE } from '@n8n/api-types';
import { N8nBadge, N8nButton, N8nHeading, N8nInfoTip, N8nLink, N8nText } from '@n8n/design-system';
import {
N8nBadge,
N8nButton,
N8nHeading,
N8nInfoTip,
N8nLink,
N8nText,
N8nTooltip,
} from '@n8n/design-system';
import { useI18n } from '@n8n/i18n';
import type { EventBus } from '@n8n/utils/event-bus';
import dateformat from 'dateformat';
@@ -355,12 +363,17 @@ onMounted(() => {
{{ getStatusText(file.status) }}
</N8nBadge>
<template v-if="isWorkflowDiffsEnabled">
<N8nIconButton
<N8nTooltip
v-if="file.type === SOURCE_CONTROL_FILE_TYPE.workflow"
:content="i18n.baseText('workflowDiff.compare')"
placement="top"
>
<N8nIconButton
icon="file-diff"
type="secondary"
@click="openDiffModal(file.id)"
/>
</N8nTooltip>
</template>
</span>
</div>

View File

@@ -33,6 +33,7 @@ import {
N8nPopover,
N8nSelect,
N8nText,
N8nTooltip,
} from '@n8n/design-system';
import { useI18n } from '@n8n/i18n';
import type { EventBus } from '@n8n/utils/event-bus';
@@ -889,12 +890,17 @@ onMounted(async () => {
{{ getStatusText(file.status) }}
</N8nBadge>
<template v-if="isWorkflowDiffsEnabled">
<N8nIconButton
<N8nTooltip
v-if="file.type === SOURCE_CONTROL_FILE_TYPE.workflow"
:content="i18n.baseText('workflowDiff.compare')"
placement="top"
>
<N8nIconButton
icon="file-diff"
type="secondary"
@click="openDiffModal(file.id)"
/>
</N8nTooltip>
</template>
</span>
</N8nCheckbox>

View File

@@ -40,6 +40,10 @@ const props = withDefaults(
border: none;
border-radius: 0;
:global(.blob-num) {
display: none;
}
&:global([theme='dark']) {
--fgColor-default: var(--color-text-dark);
--bgColor-default: var(--color-background-light);

View File

@@ -133,7 +133,7 @@ describe('WorkflowDiffModal', () => {
// Component should render with the basic structure
expect(container.querySelector('.header')).toBeInTheDocument();
expect(container.querySelector('h1')).toBeInTheDocument();
expect(container.querySelector('h4')).toBeInTheDocument();
});
it('should initialize with correct props', () => {

View File

@@ -267,9 +267,16 @@ const nodeDiffs = computed(() => {
const targetNode = targetWorkFlow.value?.state.value?.workflow?.nodes.find(
(node) => node.id === selectedDetailId.value,
);
function replacer(key: string, value: unknown) {
if (key === 'position') {
return undefined; // exclude this property
}
return value;
}
return {
oldString: JSON.stringify(sourceNode, null, 2) ?? '',
newString: JSON.stringify(targetNode, null, 2) ?? '',
oldString: JSON.stringify(sourceNode, replacer, 2) ?? '',
newString: JSON.stringify(targetNode, replacer, 2) ?? '',
};
});
@@ -399,7 +406,7 @@ const modifiers = [
icon-size="large"
@click="handleBeforeClose"
></N8nIconButton>
<N8nHeading tag="h1" size="xlarge">
<N8nHeading tag="h4" size="medium">
{{
sourceWorkFlow.state.value?.workflow?.name ||
targetWorkFlow.state.value?.workflow?.name