Feature/asana improvements (#920)

*  Improvements to Asana-Node

* Minor change to comment strings

helpful when filtering the code based on indentation

* Minor rephrasing of description in search action

* Add loadOption to get all projects

* Add loadOption to get all sections in a project

* Add UI fields to move task to a specific section

* Add execution for moveToSection operation

* Add loadOptions helper to get all teams

* Add UI fields to get projects

* Add execution methods for projects getter

* Add loadOptions helper to get all users

* Add loadOptions helper to get all tags

* Add UI fields for adding a tag to a task

* Add execution method to add a tag to a task

* Add functionality to remove Tag from Task

* Add option to set 'Assignee' and 'Assignee Status' on a task

to unset an assignee 'null' has to be send. Unfortunately this gives a warning in the UI.

* a few fixes

* Only show existing task tags when removing a tag

* few more fixes

*  Improvements to #855

Co-authored-by: Silvio <silvio@sintuity.com>
This commit is contained in:
Ricardo Espinoza 2020-09-08 08:00:54 -04:00 committed by GitHub
parent f32e63acfa
commit dc583bd81b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 1007 additions and 91 deletions

File diff suppressed because it is too large Load diff

View file

@ -4,8 +4,17 @@ import {
ILoadOptionsFunctions,
} from 'n8n-core';
import { OptionsWithUri } from 'request';
import {
OptionsWithUri,
} from 'request';
import {
IDataObject,
} from 'n8n-workflow';
import {
get,
} from 'lodash';
/**
* Make an API request to Asana
@ -16,7 +25,7 @@ import { OptionsWithUri } from 'request';
* @param {object} body
* @returns {Promise<any>}
*/
export async function asanaApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: object, query?: object): Promise<any> { // tslint:disable-line:no-any
export async function asanaApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: object, query?: object, uri?: string | undefined): Promise<any> { // tslint:disable-line:no-any
const credentials = this.getCredentials('asanaApi');
if (credentials === undefined) {
@ -30,7 +39,7 @@ export async function asanaApiRequest(this: IHookFunctions | IExecuteFunctions |
method,
body: { data: body },
qs: query,
uri: `https://app.asana.com/api/1.0/${endpoint}`,
uri: uri || `https://app.asana.com/api/1.0${endpoint}`,
json: true,
};
@ -54,3 +63,22 @@ export async function asanaApiRequest(this: IHookFunctions | IExecuteFunctions |
throw error;
}
}
export async function asanaApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions ,method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const returnData: IDataObject[] = [];
let responseData;
let uri: string | undefined;
query.limit = 100;
do {
responseData = await asanaApiRequest.call(this, method, endpoint, body, query, uri);
uri = get(responseData, 'next_page.uri');
returnData.push.apply(returnData, responseData['data']);
} while (
responseData['next_page'] !== null
);
return returnData;
}