Skip to content

Commit

Permalink
fix(editor): show null value in table view (n8n-io#4346)
Browse files Browse the repository at this point in the history
* fix(editor): remove code that never runs from table view

* fix(editor): show null in table view

* fix(editor): handle nil values properly

* fix(editor): add double quotes around strings

* fix(editor): remove unused function

* Revert "fix(editor): remove code that never runs from table view"

This reverts commit 167312d.

* fix(editor): applying Max's review
  • Loading branch information
cstuncsik authored Oct 18, 2022
1 parent d2c8ca3 commit 013c497
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions packages/editor-ui/src/components/RunDataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@
@mouseleave="onMouseLeaveCell"
:class="hasJsonInColumn(index2) ? $style.minColWidth : $style.limitColWidth"
>
<span v-if="isSimple(data)" :class="$style.value">{{
[null, undefined].includes(data) ? '&nbsp;' : data
}}</span>
<span v-if="isSimple(data)" :class="{[$style.value]: true, [$style.empty]: isEmpty(data)}">{{ getValueToRender(data) }}</span>
<n8n-tree :nodeClass="$style.nodeClass" v-else :value="data">
<template v-slot:label="{ label, path }">
<span
Expand Down Expand Up @@ -315,11 +313,12 @@ export default mixins(externalHooks).extend({
return `{{ $node["${this.node.name}"].json["${column}"]${expr} }}`;
},
isEmpty(value: unknown) {
isEmpty(value: unknown): boolean {
return (
value === '' ||
(Array.isArray(value) && value.length === 0) ||
(typeof value === 'object' && value !== null && Object.keys(value).length === 0)
(typeof value === 'object' && value !== null && Object.keys(value).length === 0) ||
(value === null || value === undefined)
);
},
getValueToRender(value: unknown) {
Expand All @@ -338,6 +337,10 @@ export default mixins(externalHooks).extend({
return this.$locale.baseText('runData.emptyObject');
}
if (value === null || value === undefined) {
return `[${value}]`;
}
return value;
},
onDragStart() {
Expand Down Expand Up @@ -386,7 +389,9 @@ export default mixins(externalHooks).extend({
}, 1000); // ensure dest data gets set if drop
},
isSimple(data: unknown): boolean {
return typeof data !== 'object';
return (typeof data !== 'object' || data === null) ||
(Array.isArray(data) && data.length === 0) ||
(typeof data === 'object' && Object.keys(data).length === 0);
},
hasJsonInColumn(colIndex: number): boolean {
return this.tableData.hasJson[this.tableData.columns[colIndex]];
Expand Down

0 comments on commit 013c497

Please sign in to comment.