Skip to content

Commit f03737d

Browse files
committed
[ACTIONS] JIRA - Create Task - the Organizations field is not applying
1 parent cd0d7f7 commit f03737d

File tree

5 files changed

+57
-16
lines changed

5 files changed

+57
-16
lines changed

components/jira/actions/common/issue.mjs

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,20 @@ export default {
118118
async getDynamicFields({
119119
fields, predicate = (field) => field,
120120
} = {}) {
121-
const schemaTypes = Object.keys(constants.SCHEMA);
122-
123121
const keysForResourceRequest = [
124122
constants.FIELD_KEY.PARENT,
125123
constants.FIELD_KEY.LABELS,
126124
constants.FIELD_KEY.ISSUETYPE,
127125
];
126+
const keysForAutoCompleteRequest = [
127+
constants.FIELD_KEY.ASSIGNEE,
128+
constants.FIELD_KEY.ISSUELINKS,
129+
];
128130

129131
return Object.values(fields)
130132
.filter(predicate)
131133
.reduce(async (props, {
132-
schema, name: label, key, autoCompleteUrl, required,
134+
schema, name: label, key, autoCompleteUrl, required, allowedValues,
133135
}) => {
134136
const reduction = await props;
135137

@@ -150,24 +152,42 @@ export default {
150152
optional: !required,
151153
};
152154

155+
if (schemaType === "array" && Array.isArray(allowedValues)) {
156+
return Promise.resolve({
157+
...reduction,
158+
[newKey]: {
159+
...value,
160+
options: allowedValues.map(({
161+
value: label, id: value,
162+
}) => ({
163+
label,
164+
value,
165+
})),
166+
},
167+
});
168+
}
169+
153170
// Requests by URL
154-
if (schemaTypes.includes(schemaType)) {
171+
if (keysForAutoCompleteRequest.includes(key)) {
155172
try {
156-
const resources = await this.app._makeRequest({
173+
const response = await this.app._makeRequest({
157174
url: autoCompleteUrl,
158175
});
159176

160177
return Promise.resolve({
161178
...reduction,
162179
[newKey]: {
163180
...value,
164-
options: resources.map(constants.SCHEMA[schemaType].mapping),
181+
options: constants.AUTOCOMPLETE_KEY[key].getOptions(response),
165182
},
166183
});
167184

168185
} catch (error) {
169-
console.log("Error fetching resources requested by URL", autoCompleteUrl, error);
170-
return Promise.resolve(reduction);
186+
console.log("Error fetching resources requested by URL", autoCompleteUrl);
187+
return Promise.resolve({
188+
...reduction,
189+
[newKey]: value,
190+
});
171191
}
172192
}
173193

components/jira/actions/create-issue/create-issue.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
key: "jira-create-issue",
88
name: "Create Issue",
99
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)",
10-
version: "0.1.21",
10+
version: "0.1.22",
1111
type: "action",
1212
props: {
1313
...common.props,

components/jira/common/constants.mjs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,30 @@ const FIELD_KEY = {
1717
ASSIGNEE: "assignee",
1818
PARENT: "parent",
1919
LABELS: "labels",
20+
ISSUELINKS: "issuelinks",
21+
};
22+
23+
const AUTOCOMPLETE_KEY = {
24+
assignee: {
25+
getOptions: (response) => {
26+
return response.map(({
27+
displayName: label, accountId: value,
28+
}) => ({
29+
label,
30+
value,
31+
}));
32+
},
33+
},
34+
issuelinks: {
35+
getOptions: (response) => {
36+
return response.sections.flatMap(({ issues }) => issues.map(({
37+
summary: label, key: value,
38+
}) => ({
39+
label,
40+
value,
41+
})));
42+
},
43+
},
2044
};
2145

2246
const FIELD_TYPE = {
@@ -42,4 +66,5 @@ export default {
4266
FIELD_TYPE,
4367
SCHEMA,
4468
DEFAULT_LIMIT,
69+
AUTOCOMPLETE_KEY,
4570
};

components/jira/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/jira",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "Pipedream Jira Components",
55
"main": "jira.app.mjs",
66
"keywords": [

pnpm-lock.yaml

Lines changed: 2 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)