Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(editor): Restrict [empty] in parameter input hint to zero-length string #6003

Merged
merged 19 commits into from
May 3, 2023
Merged
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cypress/e2e/14-mapping.cy.ts
Original file line number Diff line number Diff line change
@@ -205,7 +205,7 @@ describe('Data mapping', () => {
'have.text',
`{{ $node['${SCHEDULE_TRIGGER_NODE_NAME}'].json.input[0].count }} {{ $node['${SCHEDULE_TRIGGER_NODE_NAME}'].json.input }}`,
);
ndv.getters.parameterExpressionPreview('value').should('include.text', '[empty]');
ndv.getters.parameterExpressionPreview('value').should('include.text', ' ');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe have.text would be better here for this test


ndv.actions.selectInputNode('Set');

19 changes: 13 additions & 6 deletions packages/editor-ui/src/components/ParameterInputHint.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<template>
<n8n-text size="small" color="text-base" tag="div" v-if="hint">
<div
v-if="!renderHTML"
:class="{ [$style.singleline]: singleLine, [$style.highlight]: highlight }"
>
{{ hint }}
</div>
<div v-if="!renderHTML" :class="classes">{{ hint }}</div>
<div
v-else
ref="hint"
@@ -39,6 +34,15 @@ export default defineComponent({
methods: {
sanitizeHtml,
},
computed: {
classes() {
return {
[this.$style.singleline]: this.singleLine,
[this.$style.highlight]: this.highlight,
[this.$style['preserve-whitespace']]: true,
};
},
},
mounted() {
if (this.$refs.hint) {
(this.$refs.hint as Element).querySelectorAll('a').forEach((a) => (a.target = '_blank'));
@@ -56,4 +60,7 @@ export default defineComponent({
.highlight {
color: var(--color-secondary);
}
.preserve-whitespace {
white-space: pre;
}
</style>
4 changes: 2 additions & 2 deletions packages/editor-ui/src/components/ParameterInputWrapper.vue
Original file line number Diff line number Diff line change
@@ -182,8 +182,8 @@ export default mixins(showMessage, workflowHelpers).extend({
return null;
}

if (typeof computedValue === 'string' && computedValue.trim().length === 0) {
computedValue = this.$locale.baseText('parameterInput.emptyString');
if (typeof computedValue === 'string' && computedValue.length === 0) {
mutdmour marked this conversation as resolved.
Show resolved Hide resolved
return this.$locale.baseText('parameterInput.emptyString');
}
} catch (error) {
computedValue = `[${this.$locale.baseText('parameterInput.error')}: ${error.message}]`;