Skip to content

Commit

Permalink
fix(editor): Fix hard-coded parameter names for code editors (#6372)
Browse files Browse the repository at this point in the history
* fix(editor): Fix hard-coded parameter names for code editors
* ⚡ Adding computed property for editor content
* 👌 Refactoring based on the code review comments
  • Loading branch information
MiloradFilipovic authored Jun 2, 2023
1 parent 968b733 commit f61b776
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions packages/editor-ui/src/components/ParameterInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<code-node-editor
v-if="editorType === 'codeNodeEditor' && isCodeNode(node)"
:mode="node.parameters.mode"
:value="node.parameters.jsCode"
:value="editorContent"
:defaultValue="parameter.default"
:language="editorLanguage"
:isReadOnly="isReadOnly"
Expand All @@ -97,7 +97,7 @@

<html-editor
v-else-if="editorType === 'htmlEditor'"
:html="node.parameters.html"
:html="editorContent"
:isReadOnly="isReadOnly"
:rows="getArgument('rows')"
:disableExpressionColoring="!isHtmlNode(node)"
Expand All @@ -107,7 +107,7 @@

<sql-editor
v-else-if="editorType === 'sqlEditor'"
:query="node.parameters.query"
:query="editorContent"
:dialect="getArgument('sqlDialect')"
:isReadOnly="isReadOnly"
@valueChanged="valueChangedDebounced"
Expand Down Expand Up @@ -365,6 +365,7 @@ import type {
IParameterLabel,
EditorType,
CodeNodeEditorLanguage,
INodeTypeDescription,
} from 'n8n-workflow';
import { NodeHelpers } from 'n8n-workflow';
Expand Down Expand Up @@ -820,6 +821,22 @@ export default defineComponent({
remoteParameterOptionsKeys(): string[] {
return (this.remoteParameterOptions || []).map((o) => o.name);
},
nodeType(): INodeTypeDescription | null {
if (!this.node) return null;
return this.nodeTypesStore.getNodeType(this.node.type, this.node.typeVersion);
},
editorContent(): string | undefined {
if (!this.nodeType) {
return;
}
const editorProp = this.nodeType.properties.find(
(p) => p.typeOptions?.editor === (this.editorType as string),
);
if (!editorProp) {
return;
}
return this.node.parameters[editorProp.name] as string;
},
},
methods: {
isRemoteParameterOption(option: INodePropertyOptions) {
Expand Down

0 comments on commit f61b776

Please sign in to comment.