feat(editor): Create separate components for JS and JSON editors (no-changelog) (#8156)

## Summary
This is part-1 of refactoring our code editors to extract different type
of editors into their own components.
In part-2 we'll
1. delete a of unused or duplicate code
2. switch to a `useEditor` composable to bring more UX consistency
across all the code editors.

## Review / Merge checklist
- [x] PR title and summary are descriptive
- [x] Tests included
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-12-29 10:49:27 +01:00
committed by GitHub
parent 1286d6583c
commit 216ec079c9
31 changed files with 290 additions and 91 deletions

View File

@@ -55,14 +55,14 @@ const versionDescription: INodeTypeDescription = {
displayName: 'Allowed Mentions',
name: 'allowedMentions',
type: 'json',
typeOptions: { alwaysOpenEditWindow: true, editor: 'code' },
typeOptions: { alwaysOpenEditWindow: true },
default: '',
},
{
displayName: 'Attachments',
name: 'attachments',
type: 'json',
typeOptions: { alwaysOpenEditWindow: true, editor: 'code' },
typeOptions: { alwaysOpenEditWindow: true },
default: '',
},
{
@@ -75,14 +75,14 @@ const versionDescription: INodeTypeDescription = {
displayName: 'Components',
name: 'components',
type: 'json',
typeOptions: { alwaysOpenEditWindow: true, editor: 'code' },
typeOptions: { alwaysOpenEditWindow: true },
default: '',
},
{
displayName: 'Embeds',
name: 'embeds',
type: 'json',
typeOptions: { alwaysOpenEditWindow: true, editor: 'code' },
typeOptions: { alwaysOpenEditWindow: true },
default: '',
},
{
@@ -95,7 +95,7 @@ const versionDescription: INodeTypeDescription = {
displayName: 'JSON Payload',
name: 'payloadJson',
type: 'json',
typeOptions: { alwaysOpenEditWindow: true, editor: 'code' },
typeOptions: { alwaysOpenEditWindow: true },
default: '',
},
{

View File

@@ -416,11 +416,9 @@ export const embedsFixedCollection: INodeProperties = {
{
displayName: 'Value',
name: 'json',
type: 'string',
type: 'json',
default: '={}',
typeOptions: {
editor: 'json',
editorLanguage: 'json',
rows: 2,
},
displayOptions: {

View File

@@ -111,9 +111,8 @@ export class ExecuteWorkflow implements INodeType {
{
displayName: 'Workflow JSON',
name: 'workflowJson',
type: 'string',
type: 'json',
typeOptions: {
editor: 'json',
rows: 10,
},
displayOptions: {

View File

@@ -1,10 +1,6 @@
import { readFile as fsReadFile } from 'fs/promises';
import {
NodeOperationError,
type IExecuteFunctions,
type IExecuteWorkflowInfo,
jsonParse,
} from 'n8n-workflow';
import { NodeOperationError, jsonParse } from 'n8n-workflow';
import type { IWorkflowBase, IExecuteFunctions, IExecuteWorkflowInfo } from 'n8n-workflow';
export async function getWorkflowInfo(this: IExecuteFunctions, source: string, itemIndex = 0) {
const workflowInfo: IExecuteWorkflowInfo = {};
@@ -33,8 +29,7 @@ export async function getWorkflowInfo(this: IExecuteFunctions, source: string, i
workflowInfo.code = jsonParse(workflowJson);
} else if (source === 'parameter') {
// Read workflow from parameter
const workflowJson = this.getNodeParameter('workflowJson', itemIndex) as string;
workflowInfo.code = jsonParse(workflowJson);
workflowInfo.code = this.getNodeParameter('workflowJson', itemIndex) as IWorkflowBase;
} else if (source === 'url') {
// Read workflow from url
const workflowUrl = this.getNodeParameter('workflowUrl', itemIndex) as string;

View File

@@ -40,7 +40,7 @@ export class Function implements INodeType {
typeOptions: {
alwaysOpenEditWindow: true,
codeAutocomplete: 'function',
editor: 'code',
editor: 'jsEditor',
rows: 10,
},
type: 'string',

View File

@@ -40,7 +40,7 @@ export class FunctionItem implements INodeType {
typeOptions: {
alwaysOpenEditWindow: true,
codeAutocomplete: 'functionItem',
editor: 'code',
editor: 'jsEditor',
rows: 10,
},
type: 'string',

View File

@@ -596,7 +596,7 @@ export class ItemListsV1 implements INodeType {
type: 'string',
typeOptions: {
alwaysOpenEditWindow: true,
editor: 'code',
editor: 'jsEditor',
rows: 10,
},
default: `// The two items to compare are in the variables a and b

View File

@@ -598,7 +598,7 @@ export class ItemListsV2 implements INodeType {
type: 'string',
typeOptions: {
alwaysOpenEditWindow: true,
editor: 'code',
editor: 'jsEditor',
rows: 10,
},
default: `// The two items to compare are in the variables a and b

View File

@@ -96,7 +96,7 @@ const properties: INodeProperties[] = [
type: 'string',
typeOptions: {
alwaysOpenEditWindow: true,
editor: 'code',
editor: 'jsEditor',
rows: 10,
},
default: `// The two items to compare are in the variables a and b

View File

@@ -115,8 +115,6 @@ export class RespondToWebhook implements INodeType {
},
default: '{\n "myField": "value"\n}',
typeOptions: {
editor: 'json',
editorLanguage: 'json',
rows: 4,
},
description: 'The HTTP response JSON data',

View File

@@ -139,11 +139,9 @@ const properties: INodeProperties[] = [
{
displayName: 'Value',
name: 'objectValue',
type: 'string',
type: 'json',
default: '={}',
typeOptions: {
editor: 'json',
editorLanguage: 'json',
rows: 2,
},
displayOptions: {

View File

@@ -15,10 +15,8 @@ const properties: INodeProperties[] = [
{
displayName: 'JSON Output',
name: 'jsonOutput',
type: 'string',
type: 'json',
typeOptions: {
editor: 'json',
editorLanguage: 'json',
rows: 5,
},
default: '{\n "my_field_1": "value",\n "my_field_2": 1\n}',

View File

@@ -13,13 +13,12 @@ const properties: INodeProperties[] = [
{
displayName: 'Query',
name: 'queryJson',
type: 'string',
type: 'json',
required: true,
default: '=[\n {\n "_name": "listOrganisation"\n }\n]',
description: 'Search for objects with filtering and sorting capabilities',
hint: 'The query should be an array of operations with the required selection and optional filtering, sorting, and pagination. See <a href="https://docs.strangebee.com/thehive/api-docs/#operation/Query%20API" target="_blank">Query API</a> for more information.',
typeOptions: {
editor: 'json',
rows: 10,
},
},

View File

@@ -106,7 +106,7 @@ export class Sort implements INodeType {
type: 'string',
typeOptions: {
alwaysOpenEditWindow: true,
editor: 'code',
editor: 'jsEditor',
rows: 10,
},
default: `// The two items to compare are in the variables a and b