mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
fix(editor): Fix hard-coded parameter names for code editors (#6372)
* fix(editor): Fix hard-coded parameter names for code editors * ⚡ Adding computed property for editor content * 👌 Refactoring based on the code review comments
This commit is contained in:
parent
968b733fd6
commit
f61b776bea
|
@ -87,7 +87,7 @@
|
||||||
<code-node-editor
|
<code-node-editor
|
||||||
v-if="editorType === 'codeNodeEditor' && isCodeNode(node)"
|
v-if="editorType === 'codeNodeEditor' && isCodeNode(node)"
|
||||||
:mode="node.parameters.mode"
|
:mode="node.parameters.mode"
|
||||||
:value="node.parameters.jsCode"
|
:value="editorContent"
|
||||||
:defaultValue="parameter.default"
|
:defaultValue="parameter.default"
|
||||||
:language="editorLanguage"
|
:language="editorLanguage"
|
||||||
:isReadOnly="isReadOnly"
|
:isReadOnly="isReadOnly"
|
||||||
|
@ -97,7 +97,7 @@
|
||||||
|
|
||||||
<html-editor
|
<html-editor
|
||||||
v-else-if="editorType === 'htmlEditor'"
|
v-else-if="editorType === 'htmlEditor'"
|
||||||
:html="node.parameters.html"
|
:html="editorContent"
|
||||||
:isReadOnly="isReadOnly"
|
:isReadOnly="isReadOnly"
|
||||||
:rows="getArgument('rows')"
|
:rows="getArgument('rows')"
|
||||||
:disableExpressionColoring="!isHtmlNode(node)"
|
:disableExpressionColoring="!isHtmlNode(node)"
|
||||||
|
@ -107,7 +107,7 @@
|
||||||
|
|
||||||
<sql-editor
|
<sql-editor
|
||||||
v-else-if="editorType === 'sqlEditor'"
|
v-else-if="editorType === 'sqlEditor'"
|
||||||
:query="node.parameters.query"
|
:query="editorContent"
|
||||||
:dialect="getArgument('sqlDialect')"
|
:dialect="getArgument('sqlDialect')"
|
||||||
:isReadOnly="isReadOnly"
|
:isReadOnly="isReadOnly"
|
||||||
@valueChanged="valueChangedDebounced"
|
@valueChanged="valueChangedDebounced"
|
||||||
|
@ -365,6 +365,7 @@ import type {
|
||||||
IParameterLabel,
|
IParameterLabel,
|
||||||
EditorType,
|
EditorType,
|
||||||
CodeNodeEditorLanguage,
|
CodeNodeEditorLanguage,
|
||||||
|
INodeTypeDescription,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
import { NodeHelpers } from 'n8n-workflow';
|
import { NodeHelpers } from 'n8n-workflow';
|
||||||
|
|
||||||
|
@ -820,6 +821,22 @@ export default defineComponent({
|
||||||
remoteParameterOptionsKeys(): string[] {
|
remoteParameterOptionsKeys(): string[] {
|
||||||
return (this.remoteParameterOptions || []).map((o) => o.name);
|
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: {
|
methods: {
|
||||||
isRemoteParameterOption(option: INodePropertyOptions) {
|
isRemoteParameterOption(option: INodePropertyOptions) {
|
||||||
|
|
Loading…
Reference in a new issue