fix(editor): limiting columns in table view to prevent unresponsive UI when opening NDV (#4480)

* fix(editor): limiting columns in table view

* fix(editor): adding ghost table column with tooltip to table view

* fix(editor): limit columns to 40

* fix(editor): show table columns if it doesn't exceed the limit

* fix(editor): rolling back globalLinkActions changes

* fix(editor): using i18n tag for having cleaner event handling

* fix(editor): emphasizing magic variable

* fix(editor): removing unused prop
This commit is contained in:
Csaba Tuncsik 2022-11-02 09:23:09 +01:00 committed by GitHub
parent dcec5e9e82
commit 41e6489b75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 10 deletions

View file

@ -229,6 +229,7 @@
:hasDefaultHoverState="paneType === 'input'" :hasDefaultHoverState="paneType === 'input'"
@mounted="$emit('tableMounted', $event)" @mounted="$emit('tableMounted', $event)"
@activeRowChanged="onItemHover" @activeRowChanged="onItemHover"
@displayModeChange="onDisplayModeChange"
/> />
<run-data-json <run-data-json

View file

@ -66,6 +66,19 @@
</draggable> </draggable>
</n8n-tooltip> </n8n-tooltip>
</th> </th>
<th v-if="columnLimitExceeded" :class="$style.header">
<n8n-tooltip placement="bottom-end">
<div slot="content">
<i18n path="dataMapping.tableView.tableColumnsExceeded.tooltip">
<a @click="switchToJsonView">{{ $locale.baseText('dataMapping.tableView.tableColumnsExceeded.tooltip.link') }}</a>
</i18n>
</div>
<span>
<font-awesome-icon :class="$style['warningTooltip']" icon="exclamation-triangle"></font-awesome-icon>
{{ $locale.baseText('dataMapping.tableView.tableColumnsExceeded') }}
</span>
</n8n-tooltip>
</th>
<th :class="$style.tableRightMargin"></th> <th :class="$style.tableRightMargin"></th>
</tr> </tr>
</thead> </thead>
@ -129,6 +142,7 @@
</template> </template>
</n8n-tree> </n8n-tree>
</td> </td>
<td v-if="columnLimitExceeded"></td>
<td :class="$style.tableRightMargin"></td> <td :class="$style.tableRightMargin"></td>
</tr> </tr>
</template> </template>
@ -138,16 +152,16 @@
</template> </template>
<script lang="ts"> <script lang="ts">
/* eslint-disable prefer-spread */ import { INodeUi, IRootState, ITableData, NDVState } from '@/Interface';
import { INodeUi, IRootState, ITableData, IUiState, NDVState } from '@/Interface';
import { getPairedItemId } from '@/pairedItemUtils'; import { getPairedItemId } from '@/pairedItemUtils';
import Vue, { PropType } from 'vue'; import Vue, { PropType } from 'vue';
import mixins from 'vue-typed-mixins'; import mixins from 'vue-typed-mixins';
import { GenericValue, IDataObject, INodeExecutionData } from 'n8n-workflow'; import { GenericValue, IDataObject, INodeExecutionData } from 'n8n-workflow';
import Draggable from './Draggable.vue'; import Draggable from '@/components/Draggable.vue';
import { shorten } from './helpers'; import { shorten } from '@/components/helpers';
import { externalHooks } from './mixins/externalHooks'; import { externalHooks } from '@/components/mixins/externalHooks';
const MAX_COLUMNS_LIMIT = 40;
export default mixins(externalHooks).extend({ export default mixins(externalHooks).extend({
name: 'run-data-table', name: 'run-data-table',
@ -189,6 +203,7 @@ export default mixins(externalHooks).extend({
hoveringPath: null as null | string, hoveringPath: null as null | string,
mappingHintVisible: false, mappingHintVisible: false,
activeRow: null as number | null, activeRow: null as number | null,
columnLimitExceeded: false,
}; };
}, },
mounted() { mounted() {
@ -202,7 +217,7 @@ export default mixins(externalHooks).extend({
} }
}, },
computed: { computed: {
hoveringItem(): NDVState['ndv']['hoveringItem'] { hoveringItem(): NDVState['hoveringItem'] {
return this.$store.getters['ndv/hoveringItem']; return this.$store.getters['ndv/hoveringItem'];
}, },
pairedItemMappings(): IRootState['workflowExecutionPairedItemMappings'] { pairedItemMappings(): IRootState['workflowExecutionPairedItemMappings'] {
@ -411,7 +426,14 @@ export default mixins(externalHooks).extend({
// Go over all keys of entry // Go over all keys of entry
entryRows = []; entryRows = [];
leftEntryColumns = Object.keys(entry || {}); const entryColumns = Object.keys(entry || {});
if(entryColumns.length > MAX_COLUMNS_LIMIT) {
this.columnLimitExceeded = true;
leftEntryColumns = entryColumns.slice(0, MAX_COLUMNS_LIMIT);
} else {
leftEntryColumns = entryColumns;
}
// Go over all the already existing column-keys // Go over all the already existing column-keys
tableColumns.forEach((key) => { tableColumns.forEach((key) => {
@ -450,8 +472,8 @@ export default mixins(externalHooks).extend({
// Make sure that all entry-rows have the same length // Make sure that all entry-rows have the same length
tableData.forEach((entryRows) => { tableData.forEach((entryRows) => {
if (tableColumns.length > entryRows.length) { if (tableColumns.length > entryRows.length) {
// Has to less entries so add the missing ones // Has fewer entries so add the missing ones
entryRows.push.apply(entryRows, new Array(tableColumns.length - entryRows.length)); entryRows.push(...new Array(tableColumns.length - entryRows.length));
} }
}); });
@ -461,6 +483,9 @@ export default mixins(externalHooks).extend({
data: tableData, data: tableData,
}; };
}, },
switchToJsonView(){
this.$emit('displayModeChange', 'json');
},
}, },
}); });
</script> </script>
@ -654,4 +679,9 @@ export default mixins(externalHooks).extend({
background-color: var(--color-secondary); background-color: var(--color-secondary);
} }
} }
.warningTooltip {
color: var(--color-warning);
}
</style> </style>

View file

@ -361,6 +361,9 @@
"dataMapping.jsonHint": "<img src='/static/json-mapping-gif.gif'/> Drag a JSON key onto <b>{name}</b> to map data", "dataMapping.jsonHint": "<img src='/static/json-mapping-gif.gif'/> Drag a JSON key onto <b>{name}</b> to map data",
"dataMapping.mapKeyToField": "Map '{name}' to a field", "dataMapping.mapKeyToField": "Map '{name}' to a field",
"dataMapping.mapAllKeysToField": "Map every '{name}' to a field", "dataMapping.mapAllKeysToField": "Map every '{name}' to a field",
"dataMapping.tableView.tableColumnsExceeded": "Some columns are hidden.",
"dataMapping.tableView.tableColumnsExceeded.tooltip": "Your data has more than {columnLimit} columns so some are hidden. Switch to {0} to see all data.",
"dataMapping.tableView.tableColumnsExceeded.tooltip.link": "JSON view",
"displayWithChange.cancelEdit": "Cancel Edit", "displayWithChange.cancelEdit": "Cancel Edit",
"displayWithChange.clickToChange": "Click to Change", "displayWithChange.clickToChange": "Click to Change",
"displayWithChange.setValue": "Set Value", "displayWithChange.setValue": "Set Value",