Skip to content

Commit

Permalink
fix(editor): Handle disabled nodes in schema view (#10052)
Browse files Browse the repository at this point in the history
Co-authored-by: Shireen Missi <94372015+ShireenMissi@users.noreply.github.com>
  • Loading branch information
elsmr and ShireenMissi authored Jul 17, 2024
1 parent 9cbbb63 commit ab5688c
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 9 deletions.
7 changes: 5 additions & 2 deletions packages/editor-ui/src/components/RunData.vue
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,14 @@
<NodeErrorView :error="subworkflowExecutionError" :class="$style.errorDisplay" />
</div>

<div v-else-if="!hasNodeRun" :class="$style.center">
<div v-else-if="!hasNodeRun && !(isInputSchemaView && node?.disabled)" :class="$style.center">
<slot name="node-not-run"></slot>
</div>

<div v-else-if="paneType === 'input' && node?.disabled" :class="$style.center">
<div
v-else-if="paneType === 'input' && !isInputSchemaView && node?.disabled"
:class="$style.center"
>
<n8n-text>
{{ $locale.baseText('ndv.input.disabled', { interpolate: { nodeName: node.name } }) }}
<n8n-link @click="enableNode">
Expand Down
17 changes: 13 additions & 4 deletions packages/editor-ui/src/components/RunDataSchema.vue
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ watch(

<div :class="$style.title">
{{ currentNode.node.name }}
<span v-if="currentNode.node.disabled">({{ $locale.baseText('node.disabled') }})</span>
</div>
<font-awesome-icon
v-if="currentNode.nodeType.group.includes('trigger')"
Expand Down Expand Up @@ -329,8 +330,16 @@ watch(
>
<div :class="$style.innerSchema" @transitionstart.stop>
<div
v-if="isDataEmpty(currentNode.schema)"
:class="$style.empty"
v-if="currentNode.node.disabled"
:class="$style.notice"
data-test-id="run-data-schema-disabled"
>
{{ i18n.baseText('dataMapping.schemaView.disabled') }}
</div>

<div
v-else-if="isDataEmpty(currentNode.schema)"
:class="$style.notice"
data-test-id="run-data-schema-empty"
>
{{ i18n.baseText('dataMapping.schemaView.emptyData') }}
Expand Down Expand Up @@ -421,7 +430,7 @@ watch(
scroll-margin-top: var(--header-height);
}
.empty {
.notice {
padding-left: var(--spacing-l);
}
}
Expand All @@ -443,7 +452,7 @@ watch(
}
}
.empty {
.notice {
font-size: var(--font-size-2xs);
color: var(--color-text-light);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,21 @@ const mockNode1 = createTestNode({
name: 'Set1',
type: SET_NODE_TYPE,
typeVersion: 1,
disabled: false,
});

const mockNode2 = createTestNode({
name: 'Set2',
type: SET_NODE_TYPE,
typeVersion: 1,
disabled: false,
});

const disabledNode = createTestNode({
name: 'Disabled Node',
type: SET_NODE_TYPE,
typeVersion: 1,
disabled: true,
});

async function setupStore() {
Expand All @@ -28,7 +37,7 @@ async function setupStore() {
name: 'Test Workflow',
connections: {},
active: true,
nodes: [mockNode1, mockNode2],
nodes: [mockNode1, mockNode2, disabledNode],
});

const pinia = createPinia();
Expand Down Expand Up @@ -162,6 +171,18 @@ describe('RunDataSchema.vue', () => {
expect(getAllByTestId('run-data-schema-empty').length).toBe(1);
});

it('renders disabled nodes correctly', () => {
const { getByTestId } = renderComponent({
props: {
nodes: [{ name: disabledNode.name, indicies: [], depth: 1 }],
},
});
expect(getByTestId('run-data-schema-disabled')).toBeInTheDocument();
expect(getByTestId('run-data-schema-node-name')).toHaveTextContent(
`${disabledNode.name} (Deactivated)`,
);
});

test.each([[[{ tx: false }, { tx: false }]], [[{ tx: '' }, { tx: '' }]], [[{ tx: [] }]]])(
'renders schema instead of showing no data for %o',
(data) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,8 @@ exports[`RunDataSchema.vue > renders schema with spaces and dots 1`] = `
class="title"
data-v-46dade00=""
>
Set1
Set1
<!--v-if-->
</div>
<!--v-if-->
</div>
Expand Down Expand Up @@ -1932,7 +1933,8 @@ exports[`RunDataSchema.vue > renders schema with spaces and dots 1`] = `
class="title"
data-v-46dade00=""
>
Set2
Set2
<!--v-if-->
</div>
<!--v-if-->
</div>
Expand Down
1 change: 1 addition & 0 deletions packages/editor-ui/src/plugins/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@
"dataMapping.tableView.tableColumnsExceeded.tooltip": "Your data has more than {columnLimit} columns so some are hidden. Switch to {link} to see all data.",
"dataMapping.tableView.tableColumnsExceeded.tooltip.link": "JSON view",
"dataMapping.schemaView.emptyData": "No fields - item(s) exist, but they're empty",
"dataMapping.schemaView.disabled": "This node is disabled and will just pass data through",
"dataMapping.schemaView.noMatches": "No results for '{search}'",
"displayWithChange.cancelEdit": "Cancel Edit",
"displayWithChange.clickToChange": "Click to Change",
Expand Down

0 comments on commit ab5688c

Please sign in to comment.