Skip to content

Commit

Permalink
Jira: Add pagination to labels async options
Browse files Browse the repository at this point in the history
  • Loading branch information
jcortes committed Sep 10, 2024
1 parent fdbb71c commit 8191527
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 47 deletions.
80 changes: 46 additions & 34 deletions components/jira/actions/common/issue.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,56 +43,76 @@ export default {
...args,
});
},
getResourcesInfo(key) {
const {
app,
cloudId,
} = this;
getOptions(key) {
switch (key) {
case constants.FIELD_KEY.PARENT:
return {
fn: app.getIssues,
args: {
return async ({ prevContext: { startAt = 0 } }) => {
const {
app,
cloudId,
} = this;
const maxResults = 50;
const { issues } = await app.getIssues({
cloudId,
params: {
maxResults: 100,
maxResults,
startAt,
},
},
map: ({ issues }) =>
issues?.map(({
});
return {
options: issues.map(({
id: value, key: label,
}) => ({
value,
label,
})),
context: {
startAt: startAt + maxResults,
},
};
};
case constants.FIELD_KEY.LABELS:
return {
fn: app.getLabels,
args: {
return async ({ prevContext: { startAt = 0 } }) => {
const {
app,
cloudId,
} = this;
const maxResults = 50;
const { values } = await app.getLabels({
cloudId,
params: {
maxResults: 100,
maxResults,
startAt,
},
},
map: ({ values }) => values,
});
return {
options: values,
context: {
startAt: startAt + maxResults,
},
};
};
case constants.FIELD_KEY.ISSUETYPE:
return {
fn: this.getIssueTypes,
args: {
return async () => {
const {
getIssueTypes,
cloudId,
},
map: (issueTypes) =>
issueTypes?.map(({
} = this;

const issueTypes = await getIssueTypes({
cloudId,
});
return {
options: issueTypes.map(({
id: value, name: label,
}) => ({
value,
label,
})),
};
};
default:
return {};
return [];
}
},
async getDynamicFields({
Expand Down Expand Up @@ -153,19 +173,11 @@ export default {

// Requests by Resource
if (keysForResourceRequest.includes(key)) {
const {
fn: resourcesFn,
args: resourcesFnArgs,
map: resourcesFnMap,
} = this.getResourcesInfo(key);

const response = await resourcesFn(resourcesFnArgs);

return Promise.resolve({
...reduction,
[newKey]: {
...value,
options: resourcesFnMap(response),
options: this.getOptions(key),
},
});
}
Expand Down
2 changes: 1 addition & 1 deletion components/jira/actions/create-issue/create-issue.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
key: "jira-create-issue",
name: "Create Issue",
description: "Creates an issue or, where the option to create subtasks is enabled in Jira, a subtask, [See the docs](https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-rest-api-3-issue-post)",
version: "0.1.17",
version: "0.1.18",
type: "action",
props: {
...common.props,
Expand Down
14 changes: 7 additions & 7 deletions components/jira/actions/update-issue/update-issue.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@ export default {
key: "jira-update-issue",
name: "Update Issue",
description: "Updates an issue. A transition may be applied and issue properties updated as part of the edit, [See the docs](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-put)",
version: "0.2.11",
version: "0.2.12",
type: "action",
props: {
...common.props,
issueIdOrKey: {
reloadProps: true,
projectId: {
propDefinition: [
common.props.app,
"issueIdOrKey",
"projectID",
({ cloudId }) => ({
cloudId,
}),
],
optional: true,
},
projectId: {
issueIdOrKey: {
reloadProps: true,
propDefinition: [
common.props.app,
"projectID",
"issueIdOrKey",
({ cloudId }) => ({
cloudId,
}),
],
optional: true,
},
issueTypeId: {
reloadProps: true,
Expand Down
4 changes: 2 additions & 2 deletions components/jira/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/jira",
"version": "0.1.0",
"version": "0.1.1",
"description": "Pipedream Jira Components",
"main": "jira.app.mjs",
"keywords": [
Expand All @@ -10,7 +10,7 @@
"homepage": "https://pipedream.com/apps/jira",
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"dependencies": {
"@pipedream/platform": "^0.10.0",
"@pipedream/platform": "^3.0.1",
"form-data": "^4.0.0"
},
"publishConfig": {
Expand Down
26 changes: 23 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8191527

Please sign in to comment.