mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 21:07:28 -08:00
🐛 Fix script list parsing on Filemaker Node(#1342)
Scripts in sub folders where not detected
This commit is contained in:
parent
58c9a92e38
commit
2d8fe3a4a5
|
@ -24,6 +24,12 @@ interface LayoutObject {
|
|||
folderLayoutNames?:LayoutObject[];
|
||||
}
|
||||
|
||||
interface ScriptObject {
|
||||
name: string;
|
||||
isFolder?: boolean;
|
||||
folderScriptNames?:LayoutObject[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Make an API request to ActiveCampaign
|
||||
*
|
||||
|
@ -106,7 +112,6 @@ export async function getFields(this: ILoadOptionsFunctions): Promise<any> { //
|
|||
try {
|
||||
const responseData = await this.helpers.request!(options);
|
||||
return responseData.response.fieldMetaData;
|
||||
|
||||
} catch (error) {
|
||||
// If that data does not exist for some reason return the actual error
|
||||
throw error;
|
||||
|
@ -177,7 +182,9 @@ export async function getScripts(this: ILoadOptionsFunctions): Promise<any> { //
|
|||
|
||||
try {
|
||||
const responseData = await this.helpers.request!(options);
|
||||
return responseData.response.scripts;
|
||||
const items = parseScriptsList(responseData.response.scripts);
|
||||
items.sort((a, b) => a.name > b.name ? 0 : 1);
|
||||
return items;
|
||||
|
||||
} catch (error) {
|
||||
// If that data does not exist for some reason return the actual error
|
||||
|
@ -185,6 +192,21 @@ export async function getScripts(this: ILoadOptionsFunctions): Promise<any> { //
|
|||
}
|
||||
}
|
||||
|
||||
function parseScriptsList(scripts: ScriptObject[]): INodePropertyOptions[] {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
for (const script of scripts) {
|
||||
if (script.isFolder!) {
|
||||
returnData.push(...parseScriptsList(script.folderScriptNames!));
|
||||
} else if (script.name !== '-') {
|
||||
returnData.push({
|
||||
name: script.name,
|
||||
value: script.name,
|
||||
});
|
||||
}
|
||||
}
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export async function getToken(this: ILoadOptionsFunctions | IExecuteFunctions | IExecuteSingleFunctions): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = this.getCredentials('fileMaker');
|
||||
if (credentials === undefined) {
|
||||
|
|
Loading…
Reference in a new issue