mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(Jira Software Node): Get all users in dropdown/RLC (#7322)
Github issue / Community forum post (link here to close automatically): fixes #2670 --------- Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import type {
|
||||
IHookFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
INodeListSearchItems,
|
||||
INodePropertyOptions,
|
||||
JsonObject,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeApiError } from 'n8n-workflow';
|
||||
@@ -228,3 +229,40 @@ export function filterSortSearchListItems(items: INodeListSearchItems[], filter?
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
export async function getUsers(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const jiraVersion = this.getCurrentNodeParameter('jiraVersion') as string;
|
||||
const maxResults = 1000;
|
||||
const query: IDataObject = { maxResults };
|
||||
let endpoint = '/api/2/users/search';
|
||||
|
||||
if (jiraVersion === 'server') {
|
||||
endpoint = '/api/2/user/search';
|
||||
query.username = "'";
|
||||
}
|
||||
|
||||
const users = [];
|
||||
let hasNextPage: boolean;
|
||||
|
||||
do {
|
||||
const usersPage = (await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
endpoint,
|
||||
'GET',
|
||||
{},
|
||||
{ ...query, startAt: users.length },
|
||||
)) as IDataObject[];
|
||||
users.push(...usersPage);
|
||||
hasNextPage = usersPage.length === maxResults;
|
||||
} while (hasNextPage);
|
||||
|
||||
return users
|
||||
.filter((user) => user.active)
|
||||
.map((user) => ({
|
||||
name: user.displayName as string,
|
||||
value: (user.accountId ?? user.name) as string,
|
||||
}))
|
||||
.sort((a: INodePropertyOptions, b: INodePropertyOptions) => {
|
||||
return a.name.toLowerCase() > b.name.toLowerCase() ? 1 : -1;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user