Skip to content

Commit

Permalink
fix(editor): Render backticks as code segments in error view (#9352)
Browse files Browse the repository at this point in the history
  • Loading branch information
elsmr committed May 10, 2024
1 parent a00467c commit 4ed5850
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions packages/editor-ui/src/components/Error/NodeErrorView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,8 @@ function nodeVersionTag(nodeType: NodeError['node']): string {
});
}
function replacePlaceholders(parameter: string, message: string): string {
const parameterName = parameterDisplayName(parameter, false);
const parameterFullName = parameterDisplayName(parameter, true);
return message
.replace(/%%PARAMETER%%/g, parameterName)
.replace(/%%PARAMETER_FULL%%/g, parameterFullName);
function prepareDescription(description: string): string {
return sanitizeHtml(description.replace(/`(.*?)`/g, '<code>$1</code>'));
}
function getErrorDescription(): string {
Expand All @@ -136,7 +132,7 @@ function getErrorDescription(): string {
(props.error as NodeOperationError).functionality === 'configuration-node';
if (isSubNodeError) {
return sanitizeHtml(
return prepareDescription(
props.error.description +
i18n.baseText('pushConnection.executionError.openNode', {
interpolate: { node: props.error.node.name },
Expand All @@ -150,7 +146,7 @@ function getErrorDescription(): string {
runIndex: (props.error.context.runIndex as string) ?? '0',
itemIndex: (props.error.context.itemIndex as string) ?? '0',
};
return sanitizeHtml(
return prepareDescription(
i18n.baseText(
`nodeErrorView.description.${props.error.context.descriptionKey as string}` as BaseTextKey,
{ interpolate },
Expand All @@ -159,11 +155,11 @@ function getErrorDescription(): string {
}
if (!props.error.context?.descriptionTemplate) {
return sanitizeHtml(props.error.description ?? '');
return prepareDescription(props.error.description ?? '');
}
const parameterName = parameterDisplayName(props.error.context.parameter as string);
return sanitizeHtml(
return prepareDescription(
(props.error.context.descriptionTemplate as string).replace(/%%PARAMETER%%/g, parameterName),
);
}
Expand Down Expand Up @@ -214,7 +210,7 @@ function getErrorMessage(): string {
function parameterDisplayName(path: string, fullPath = true) {
try {
const params = parameterName(parameters.value, path.split('.'));
const params = getParameterName(parameters.value, path.split('.'));
if (!params.length) {
throw new Error();
}
Expand All @@ -228,7 +224,7 @@ function parameterDisplayName(path: string, fullPath = true) {
}
}
function parameterName(
function getParameterName(
params: Array<INodePropertyOptions | INodeProperties | INodePropertyCollection>,
pathParts: string[],
): Array<INodeProperties | INodePropertyCollection> {
Expand Down Expand Up @@ -257,14 +253,14 @@ function parameterName(
if (currentParameter.hasOwnProperty('options')) {
return [
currentParameter,
...parameterName((currentParameter as INodeProperties).options!, pathParts),
...getParameterName((currentParameter as INodeProperties).options!, pathParts),
];
}
if (currentParameter.hasOwnProperty('values')) {
return [
currentParameter,
...parameterName((currentParameter as INodePropertyCollection).values, pathParts),
...getParameterName((currentParameter as INodePropertyCollection).values, pathParts),
];
}
Expand Down

0 comments on commit 4ed5850

Please sign in to comment.