diff --git a/packages/editor-ui/src/components/WorkflowHistory/WorkflowHistoryContent.vue b/packages/editor-ui/src/components/WorkflowHistory/WorkflowHistoryContent.vue index 2437ae5a29..4a86873121 100644 --- a/packages/editor-ui/src/components/WorkflowHistory/WorkflowHistoryContent.vue +++ b/packages/editor-ui/src/components/WorkflowHistory/WorkflowHistoryContent.vue @@ -10,6 +10,7 @@ import WorkflowPreview from '@/components/WorkflowPreview.vue'; import WorkflowHistoryListItem from '@/components/WorkflowHistory/WorkflowHistoryListItem.vue'; import { useI18n } from '@/composables/useI18n'; import { compareWorkflows } from '@/utils/workflowDiff'; +import { WORKFLOW_HISTORY_ACTIONS } from '@/constants'; const i18n = useI18n(); @@ -27,7 +28,7 @@ const emit = defineEmits<{ value: { action: WorkflowHistoryActionType; id: WorkflowVersionId; - data: { formattedCreatedAt: string }; + data?: { formattedCreatedAt: string }; }, ]; }>(); @@ -83,67 +84,120 @@ const onAction = ({ }) => { emit('action', { action, id, data }); }; + +function onClickCloseDiff() { + emit('action', { + action: WORKFLOW_HISTORY_ACTIONS.CLOSEDIFF, + id: props.workflowVersion?.versionId ?? '', + }); +} @@ -164,8 +218,15 @@ const onAction = ({ width: 100%; height: 100%; - > *:first-child { - border-right: 1px double var(--color-foreground-base); + .splitViewPanel { + flex: 1 0 50%; + display: flex; + flex-direction: column; + position: relative; + + &:first-child { + border-right: 1px double var(--color-foreground-base); + } } } diff --git a/packages/editor-ui/src/components/WorkflowHistory/WorkflowHistoryListItem.vue b/packages/editor-ui/src/components/WorkflowHistory/WorkflowHistoryListItem.vue index 5e4c0f98b9..f2ea086626 100644 --- a/packages/editor-ui/src/components/WorkflowHistory/WorkflowHistoryListItem.vue +++ b/packages/editor-ui/src/components/WorkflowHistory/WorkflowHistoryListItem.vue @@ -12,7 +12,7 @@ import { useI18n } from '@/composables/useI18n'; const props = defineProps<{ item: WorkflowHistory; index: number; - actions: UserAction[]; + actions?: UserAction[]; isActive: boolean; }>(); const emit = defineEmits<{ @@ -116,6 +116,7 @@ onMounted(() => { {{ i18n.baseText('workflowHistory.item.latest') }} { > + diff --git a/packages/editor-ui/src/components/WorkflowPreview.vue b/packages/editor-ui/src/components/WorkflowPreview.vue index 3b94c91be4..4738a494ee 100644 --- a/packages/editor-ui/src/components/WorkflowPreview.vue +++ b/packages/editor-ui/src/components/WorkflowPreview.vue @@ -78,15 +78,7 @@ const loadWorkflow = () => { '*', ); - if (props.diff) { - iframeRef.value?.contentWindow?.postMessage?.( - JSON.stringify({ - command: 'setDiff', - diff: props.diff, - }), - '*', - ); - } + loadDiff(); } catch (error) { toast.showError( error, @@ -96,6 +88,45 @@ const loadWorkflow = () => { } }; +const loadDiff = () => { + if (props.diff) { + iframeRef.value?.contentWindow?.postMessage?.( + JSON.stringify({ + command: 'setDiff', + diff: props.diff, + }), + '*', + ); + + fitView(); + } +}; + +const unloadDiff = () => { + iframeRef.value?.contentWindow?.postMessage?.( + JSON.stringify({ + command: 'setDiff', + diff: {}, + }), + '*', + ); + + fitView(); +}; + +const fitView = () => { + if (!ready.value) { + return; + } + + iframeRef.value?.contentWindow?.postMessage?.( + JSON.stringify({ + command: 'fitView', + }), + '*', + ); +}; + const loadExecution = () => { try { if (!props.executionId) { @@ -203,6 +234,17 @@ watch( } }, ); + +watch( + () => props.diff, + (value) => { + if (value) { + loadDiff(); + } else { + unloadDiff(); + } + }, +);