mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-02 07:01:30 -08:00
Recursively parse layouts inside folders
Sort layouts by name Fix credentials
This commit is contained in:
parent
c9b26000c8
commit
1a0bcc0dc9
|
@ -5,8 +5,8 @@ import {
|
||||||
|
|
||||||
|
|
||||||
export class FileMaker implements ICredentialType {
|
export class FileMaker implements ICredentialType {
|
||||||
name = 'FileMaker';
|
name = 'fileMaker';
|
||||||
displayName = 'fileMaker';
|
displayName = 'FileMaker API';
|
||||||
properties = [
|
properties = [
|
||||||
{
|
{
|
||||||
displayName: 'Host',
|
displayName: 'Host',
|
||||||
|
|
|
@ -38,7 +38,7 @@ export class FileMaker implements INodeType {
|
||||||
outputs: ['main'],
|
outputs: ['main'],
|
||||||
credentials: [
|
credentials: [
|
||||||
{
|
{
|
||||||
name: 'FileMaker',
|
name: 'fileMaker',
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -676,20 +676,14 @@ export class FileMaker implements INodeType {
|
||||||
// Get all the available topics to display them to user so that he can
|
// Get all the available topics to display them to user so that he can
|
||||||
// select them easily
|
// select them easily
|
||||||
async getLayouts(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
async getLayouts(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||||
const returnData: INodePropertyOptions[] = [];
|
let returnData: INodePropertyOptions[];
|
||||||
|
|
||||||
let layouts;
|
|
||||||
try {
|
try {
|
||||||
layouts = await layoutsApiRequest.call(this);
|
returnData = await layoutsApiRequest.call(this);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new Error(`FileMaker Error: ${err}`);
|
throw new Error(`FileMaker Error: ${err}`);
|
||||||
}
|
}
|
||||||
for (const layout of layouts) {
|
|
||||||
returnData.push({
|
|
||||||
name: layout.name,
|
|
||||||
value: layout.name,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return returnData;
|
return returnData;
|
||||||
},
|
},
|
||||||
async getResponseLayouts(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
async getResponseLayouts(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {
|
||||||
} from 'n8n-core';
|
} from 'n8n-core';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IDataObject,
|
IDataObject, INodePropertyOptions,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
import {OptionsWithUri} from 'request';
|
import {OptionsWithUri} from 'request';
|
||||||
|
@ -19,6 +19,11 @@ interface ScriptsOptions {
|
||||||
'script.presort'?: any; //tslint:disable-line:no-any
|
'script.presort'?: any; //tslint:disable-line:no-any
|
||||||
'script.presort.param'?: any; //tslint:disable-line:no-any
|
'script.presort.param'?: any; //tslint:disable-line:no-any
|
||||||
}
|
}
|
||||||
|
interface LayoutObject {
|
||||||
|
name: string;
|
||||||
|
isFolder?: boolean;
|
||||||
|
folderLayoutNames?:LayoutObject[];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make an API request to ActiveCampaign
|
* Make an API request to ActiveCampaign
|
||||||
|
@ -27,7 +32,7 @@ interface ScriptsOptions {
|
||||||
* @param {string} method
|
* @param {string} method
|
||||||
* @returns {Promise<any>}
|
* @returns {Promise<any>}
|
||||||
*/
|
*/
|
||||||
export async function layoutsApiRequest(this: ILoadOptionsFunctions | IExecuteFunctions | IExecuteSingleFunctions): Promise<any> { // tslint:disable-line:no-any
|
export async function layoutsApiRequest(this: ILoadOptionsFunctions | IExecuteFunctions | IExecuteSingleFunctions): Promise<INodePropertyOptions[]> { // tslint:disable-line:no-any
|
||||||
const token = await getToken.call(this);
|
const token = await getToken.call(this);
|
||||||
const credentials = this.getCredentials('fileMaker');
|
const credentials = this.getCredentials('fileMaker');
|
||||||
|
|
||||||
|
@ -49,14 +54,30 @@ export async function layoutsApiRequest(this: ILoadOptionsFunctions | IExecuteFu
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const responseData = await this.helpers.request!(options);
|
const responseData = await this.helpers.request!(options);
|
||||||
return responseData.response.layouts;
|
const items = parseLayouts(responseData.response.layouts);
|
||||||
|
items.sort((a, b) => a.name > b.name ? 0 : 1);
|
||||||
|
return items;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// If that data does not exist for some reason return the actual error
|
// If that data does not exist for some reason return the actual error
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseLayouts(layouts: LayoutObject[]): INodePropertyOptions[] {
|
||||||
|
const returnData: INodePropertyOptions[] = [];
|
||||||
|
for (const layout of layouts) {
|
||||||
|
if (layout.isFolder!) {
|
||||||
|
returnData.push(...parseLayouts(layout.folderLayoutNames!));
|
||||||
|
} else {
|
||||||
|
returnData.push({
|
||||||
|
name: layout.name,
|
||||||
|
value: layout.name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnData;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make an API request to ActiveCampaign
|
* Make an API request to ActiveCampaign
|
||||||
*
|
*
|
||||||
|
@ -138,7 +159,6 @@ export async function getPortals(this: ILoadOptionsFunctions): Promise<any> { //
|
||||||
export async function getScripts(this: ILoadOptionsFunctions): Promise<any> { // tslint:disable-line:no-any
|
export async function getScripts(this: ILoadOptionsFunctions): Promise<any> { // tslint:disable-line:no-any
|
||||||
const token = await getToken.call(this);
|
const token = await getToken.call(this);
|
||||||
const credentials = this.getCredentials('fileMaker');
|
const credentials = this.getCredentials('fileMaker');
|
||||||
const layout = this.getCurrentNodeParameter('layout') as string;
|
|
||||||
|
|
||||||
if (credentials === undefined) {
|
if (credentials === undefined) {
|
||||||
throw new Error('No credentials got returned!');
|
throw new Error('No credentials got returned!');
|
||||||
|
|
Loading…
Reference in a new issue