mirror of
https://github.com/n8n-io/n8n.git
synced 2026-08-28 17:22:01 +08:00
fix(editor): Group output panel warnings to keep it usable (#36619)
This commit is contained in:
@@ -14,7 +14,7 @@ import {
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { addBinariesToItem } from './utils';
|
||||
import { prepareFieldsArray } from '../utils/utils';
|
||||
import { fieldNotFoundHint, prepareFieldsArray } from '../utils/utils';
|
||||
|
||||
export class Aggregate implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -439,10 +439,7 @@ export class Aggregate implements INodeType {
|
||||
|
||||
for (const [field, values] of Object.entries(notFoundedFields)) {
|
||||
if (values.every((value) => !value)) {
|
||||
hints.push({
|
||||
message: `The field '${field}' wasn't found in any input item`,
|
||||
location: 'outputPane',
|
||||
});
|
||||
hints.push(fieldNotFoundHint(field));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,11 @@ describe('FieldsTracker', () => {
|
||||
{
|
||||
message: "The field 'missingField' wasn't found in any input item",
|
||||
location: 'outputPane',
|
||||
group: {
|
||||
key: 'fieldNotFound',
|
||||
summary: "{count} fields weren't found in your input items",
|
||||
label: 'missingField',
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import type { NodeExecutionHint } from 'n8n-workflow';
|
||||
|
||||
import { fieldNotFoundHint } from '../utils/utils';
|
||||
|
||||
export class FieldsTracker {
|
||||
fields: { [key: string]: boolean } = {};
|
||||
|
||||
@@ -20,10 +22,7 @@ export class FieldsTracker {
|
||||
|
||||
for (const [field, value] of Object.entries(this.fields)) {
|
||||
if (!value) {
|
||||
hints.push({
|
||||
message: `The field '${field}' wasn't found in any input item`,
|
||||
location: 'outputPane',
|
||||
});
|
||||
hints.push(fieldNotFoundHint(field));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
import type { NodeExecutionHint } from 'n8n-workflow';
|
||||
import { UserError } from 'n8n-workflow';
|
||||
|
||||
/**
|
||||
* Nodes that take a list of field names report one hint per field they couldn't
|
||||
* find. Use the same group key so the UI can collapse them under one summary.
|
||||
*/
|
||||
export const fieldNotFoundHint = (field: string): NodeExecutionHint => ({
|
||||
message: `The field '${field}' wasn't found in any input item`,
|
||||
location: 'outputPane',
|
||||
group: {
|
||||
key: 'fieldNotFound',
|
||||
summary: "{count} fields weren't found in your input items",
|
||||
label: field,
|
||||
},
|
||||
});
|
||||
|
||||
export const prepareFieldsArray = (fields: string | string[], fieldName = 'Fields') => {
|
||||
if (typeof fields === 'string') {
|
||||
return fields
|
||||
|
||||
Reference in New Issue
Block a user