Skip to content

Commit

Permalink
⚡ item index suffix to error message if provifded and many input items
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-radency committed Apr 5, 2024
1 parent ba986fb commit 662a6bb
Showing 1 changed file with 33 additions and 14 deletions.
47 changes: 33 additions & 14 deletions packages/editor-ui/src/components/Error/NodeErrorView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ const n8nVersion = computed(() => {
return rootStore.versionCli + ` (${instanceType})`;
});
const hasManyInputItems = computed(() => {
return ndvStore.ndvInputData.length > 1;
});
const nodeDefaultName = computed(() => {
const node = props.error?.node;
if (!node) {
Expand Down Expand Up @@ -214,33 +218,48 @@ function getErrorDescription(): string {
);
}
function addItemIndexSuffix(message: string): string {
let itemIndexSuffix = '';
const ITEM_INDEX_SUFFIX_TEXT = '[item ';
if (
hasManyInputItems.value &&
!message.includes(ITEM_INDEX_SUFFIX_TEXT) &&
props.error?.context?.itemIndex !== undefined
) {
itemIndexSuffix = ` [item ${props.error.context.itemIndex}]`;
}
return message + itemIndexSuffix;
}
function getErrorMessage(): string {
const baseErrorMessage = '';
let message = '';
const isSubNodeError =
props.error.name === 'NodeOperationError' &&
(props.error as NodeOperationError).functionality === 'configuration-node';
if (isSubNodeError) {
const baseErrorMessageSubNode = i18n.baseText('nodeErrorView.errorSubNode', {
message = i18n.baseText('nodeErrorView.errorSubNode', {
interpolate: { node: props.error.node.name },
});
return baseErrorMessageSubNode;
}
} else if (
props.error.message === props.error.description ||
!props.error.context?.messageTemplate
) {
message = baseErrorMessage + props.error.message;
} else {
const parameterName = parameterDisplayName(props.error.context.parameter as string);
if (props.error.message === props.error.description) {
return baseErrorMessage;
}
if (!props.error.context?.messageTemplate) {
return baseErrorMessage + props.error.message;
message =
baseErrorMessage +
(props.error.context.messageTemplate as string).replace(/%%PARAMETER%%/g, parameterName);
}
const parameterName = parameterDisplayName(props.error.context.parameter as string);
return (
baseErrorMessage +
(props.error.context.messageTemplate as string).replace(/%%PARAMETER%%/g, parameterName)
);
return addItemIndexSuffix(message);
}
function parameterDisplayName(path: string, fullPath = true) {
Expand Down

0 comments on commit 662a6bb

Please sign in to comment.