feat(Jira Software Node): Use resource locator component (#5090)

* ️Issue -> Create -> parameter Project RLC

* 🔥removed unused loadOptions getProjects

* ️Issue -> Create -> parameter Issue Type RLC

* 🔥removed unused loadOptions getIssueTypes

* ️Issue -> Create/Update -> parameter Assignee RLC

* ️Issue -> Create/Update -> parameter Reporter RLC

* ️Issue -> Create/Update -> parameter Priority RLC

* 🔥removed unused loadOptions getPriorities

* ️Issue -> Update -> parameter Status RLC

* 🔥removed unused loadOptions getTransitions

* 🎨 fix typos

* ️Issue -> Create/Update -> Custom Fields parameter Field RLC

* 🔥removed unused loadOptions getCustomFields

* 🥅 throw custom error for "Field priority cannot be set"

* 🚨 fix linter error

*  removed ts-ignore

*  removed ts-ignore

Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
Marcus
2023-01-24 17:42:38 +01:00
committed by GitHub
parent 2b776f39f1
commit 237b1d8614
4 changed files with 654 additions and 275 deletions

View File

@@ -7,13 +7,12 @@ import {
ILoadOptionsFunctions,
} from 'n8n-core';
import { IDataObject } from 'n8n-workflow';
import { IDataObject, INodeListSearchItems, NodeApiError } from 'n8n-workflow';
export async function jiraSoftwareCloudApiRequest(
this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions,
endpoint: string,
method: string,
body: any = {},
query?: IDataObject,
uri?: string,
@@ -56,8 +55,20 @@ export async function jiraSoftwareCloudApiRequest(
if (Object.keys(query || {}).length === 0) {
delete options.qs;
}
return this.helpers.requestWithAuthentication.call(this, credentialType, options);
try {
return await this.helpers.requestWithAuthentication.call(this, credentialType, options);
} catch (error) {
if (
error.description?.includes &&
error.description.includes("Field 'priority' cannot be set")
) {
throw new NodeApiError(this.getNode(), error, {
message:
"Field 'priority' cannot be set. You need to add the Priority field to your Jira Project's Issue Types.",
});
}
throw error;
}
}
export async function jiraSoftwareCloudApiRequestAllItems(
@@ -65,7 +76,6 @@ export async function jiraSoftwareCloudApiRequestAllItems(
propertyName: string,
endpoint: string,
method: string,
body: any = {},
query: IDataObject = {},
): Promise<any> {
@@ -198,3 +208,22 @@ export const allEvents = [
'worklog_updated',
'worklog_deleted',
];
export function filterSortSearchListItems(items: INodeListSearchItems[], filter?: string) {
return items
.filter(
(item) =>
!filter ||
item.name.toLowerCase().includes(filter.toLowerCase()) ||
item.value.toString().toLowerCase().includes(filter.toLowerCase()),
)
.sort((a, b) => {
if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) {
return -1;
}
if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) {
return 1;
}
return 0;
});
}