From fe02ece46458e9c17a506643c6dee8ada7fcd358 Mon Sep 17 00:00:00 2001 From: kshitij katiyar <90389917+Kshitij-Katiyar@users.noreply.github.com> Date: Thu, 25 Jul 2024 13:48:09 +0530 Subject: [PATCH] [GH-993]: added support for subtasks in subscriptions (#1095) * [GH-993]: added support for subtasks in subscriptions * [GH-993]: updated an additional condition of getting issueTypes * [GH-993]: Added types for the subtask parameter in getIssueType function --- .../edit_channel_subscription.test.tsx.snap | 40 + .../edit_channel_subscription.tsx | 2 +- .../create_issue_form.test.tsx.snap | 2950 ++++++----------- .../modals/create_issue/create_issue_form.tsx | 4 +- webapp/src/utils/jira_issue_metadata.tsx | 17 +- 5 files changed, 993 insertions(+), 2020 deletions(-) diff --git a/webapp/src/components/modals/channel_subscriptions/__snapshots__/edit_channel_subscription.test.tsx.snap b/webapp/src/components/modals/channel_subscriptions/__snapshots__/edit_channel_subscription.test.tsx.snap index 495fed31e..5a7731a9d 100644 --- a/webapp/src/components/modals/channel_subscriptions/__snapshots__/edit_channel_subscription.test.tsx.snap +++ b/webapp/src/components/modals/channel_subscriptions/__snapshots__/edit_channel_subscription.test.tsx.snap @@ -432,6 +432,10 @@ exports[`components/EditChannelSubscription should match snapshot after fetching "label": "Task", "value": "10002", }, + Object { + "label": "Sub-task", + "value": "10003", + }, Object { "label": "Story", "value": "10001", @@ -522,6 +526,10 @@ exports[`components/EditChannelSubscription should match snapshot after fetching "id": "10002", "name": "Task", }, + Object { + "id": "10003", + "name": "Sub-task", + }, Object { "id": "10001", "name": "Story", @@ -550,6 +558,10 @@ exports[`components/EditChannelSubscription should match snapshot after fetching "id": "10002", "name": "Task", }, + Object { + "id": "10003", + "name": "Sub-task", + }, Object { "id": "10001", "name": "Story", @@ -583,6 +595,10 @@ exports[`components/EditChannelSubscription should match snapshot after fetching "id": "10002", "name": "Task", }, + Object { + "id": "10003", + "name": "Sub-task", + }, Object { "id": "10001", "name": "Story", @@ -611,6 +627,10 @@ exports[`components/EditChannelSubscription should match snapshot after fetching "id": "10002", "name": "Task", }, + Object { + "id": "10003", + "name": "Sub-task", + }, Object { "id": "10001", "name": "Story", @@ -649,6 +669,10 @@ exports[`components/EditChannelSubscription should match snapshot after fetching "id": "10002", "name": "Task", }, + Object { + "id": "10003", + "name": "Sub-task", + }, Object { "id": "10001", "name": "Story", @@ -678,6 +702,10 @@ exports[`components/EditChannelSubscription should match snapshot after fetching "id": "10002", "name": "Task", }, + Object { + "id": "10003", + "name": "Sub-task", + }, Object { "id": "10001", "name": "Story", @@ -715,6 +743,10 @@ exports[`components/EditChannelSubscription should match snapshot after fetching "id": "10002", "name": "Task", }, + Object { + "id": "10003", + "name": "Sub-task", + }, Object { "id": "10001", "name": "Story", @@ -753,6 +785,10 @@ exports[`components/EditChannelSubscription should match snapshot after fetching "id": "10002", "name": "Task", }, + Object { + "id": "10003", + "name": "Sub-task", + }, Object { "id": "10001", "name": "Story", @@ -790,6 +826,10 @@ exports[`components/EditChannelSubscription should match snapshot after fetching "id": "10002", "name": "Task", }, + Object { + "id": "10003", + "name": "Sub-task", + }, Object { "id": "10001", "name": "Story", diff --git a/webapp/src/components/modals/channel_subscriptions/edit_channel_subscription.tsx b/webapp/src/components/modals/channel_subscriptions/edit_channel_subscription.tsx index 6db51dbc4..1edc90f60 100644 --- a/webapp/src/components/modals/channel_subscriptions/edit_channel_subscription.tsx +++ b/webapp/src/components/modals/channel_subscriptions/edit_channel_subscription.tsx @@ -349,7 +349,7 @@ export default class EditChannelSubscription extends PureComponent render(): JSX.Element { const style = getModalStyles(this.props.theme); - const issueTypes = getIssueTypes(this.state.jiraIssueMetadata, this.state.filters.projects[0]); + const issueTypes = getIssueTypes(this.state.jiraIssueMetadata, this.state.filters.projects[0], {includeSubtasks: true}); const issueOptions = issueTypes.map((it) => ({label: it.name, value: it.id})); const customFields = getCustomFieldValuesForEvents(this.state.jiraIssueMetadata, this.state.filters.projects); diff --git a/webapp/src/components/modals/create_issue/__snapshots__/create_issue_form.test.tsx.snap b/webapp/src/components/modals/create_issue/__snapshots__/create_issue_form.test.tsx.snap index 087bc53be..6709ead88 100644 --- a/webapp/src/components/modals/create_issue/__snapshots__/create_issue_form.test.tsx.snap +++ b/webapp/src/components/modals/create_issue/__snapshots__/create_issue_form.test.tsx.snap @@ -1377,7 +1377,7 @@ exports[`components/CreateIssue should match snapshot with error 1`] = ` "self": "https://mmtest.atlassian.net/rest/api/2/issuetype/10002", }, Object { - "description": "The sub-task of the issue", + "description": "Stories track functionality or features expressed as user goals.", "expand": "fields", "fields": Object { "assignee": Object { @@ -1765,13 +1765,13 @@ exports[`components/CreateIssue should match snapshot with error 1`] = ` "issuetype": Object { "allowedValues": Array [ Object { - "avatarId": 10316, - "description": "The sub-task of the issue", - "iconUrl": "https://mmtest.atlassian.net/secure/viewavatar?size=medium&avatarId=10316&avatarType=issuetype", - "id": "10003", - "name": "Sub-task", - "self": "https://mmtest.atlassian.net/rest/api/2/issuetype/10003", - "subtask": true, + "avatarId": 10315, + "description": "Stories track functionality or features expressed as user goals.", + "iconUrl": "https://mmtest.atlassian.net/secure/viewavatar?size=medium&avatarId=10315&avatarType=issuetype", + "id": "10001", + "name": "Story", + "self": "https://mmtest.atlassian.net/rest/api/2/issuetype/10001", + "subtask": false, }, ], "hasDefaultValue": false, @@ -1801,19 +1801,6 @@ exports[`components/CreateIssue should match snapshot with error 1`] = ` "type": "array", }, }, - "parent": Object { - "hasDefaultValue": false, - "key": "parent", - "name": "Parent", - "operations": Array [ - "set", - ], - "required": true, - "schema": Object { - "system": "parent", - "type": "issuelink", - }, - }, "priority": Object { "allowedValues": Array [ Object { @@ -1908,14 +1895,13 @@ exports[`components/CreateIssue should match snapshot with error 1`] = ` }, }, }, - "iconurl": "https://mmtest.atlassian.net/secure/viewavatar?size=medium&avatarId=10316&avatarType=issuetype", - "id": "10003", - "name": "Sub-task", - "self": "https://mmtest.atlassian.net/rest/api/2/issuetype/10003", - "subtask": true, + "iconurl": "https://mmtest.atlassian.net/secure/viewavatar?size=medium&avatarId=10315&avatarType=issuetype", + "id": "10001", + "name": "Story", + "self": "https://mmtest.atlassian.net/rest/api/2/issuetype/10001", }, Object { - "description": "Stories track functionality or features expressed as user goals.", + "description": "jira.translation.issuetype.bug.name.desc", "expand": "fields", "fields": Object { "assignee": Object { @@ -2259,6 +2245,19 @@ exports[`components/CreateIssue should match snapshot with error 1`] = ` "type": "string", }, }, + "environment": Object { + "hasDefaultValue": false, + "key": "environment", + "name": "Environment", + "operations": Array [ + "set", + ], + "required": false, + "schema": Object { + "system": "environment", + "type": "string", + }, + }, "fixVersions": Object { "allowedValues": Array [ Object { @@ -2303,12 +2302,12 @@ exports[`components/CreateIssue should match snapshot with error 1`] = ` "issuetype": Object { "allowedValues": Array [ Object { - "avatarId": 10315, - "description": "Stories track functionality or features expressed as user goals.", - "iconUrl": "https://mmtest.atlassian.net/secure/viewavatar?size=medium&avatarId=10315&avatarType=issuetype", - "id": "10001", - "name": "Story", - "self": "https://mmtest.atlassian.net/rest/api/2/issuetype/10001", + "avatarId": 10303, + "description": "jira.translation.issuetype.bug.name.desc", + "iconUrl": "https://mmtest.atlassian.net/secure/viewavatar?size=medium&avatarId=10303&avatarType=issuetype", + "id": "10004", + "name": "Bug", + "self": "https://mmtest.atlassian.net/rest/api/2/issuetype/10004", "subtask": false, }, ], @@ -2432,14 +2431,40 @@ exports[`components/CreateIssue should match snapshot with error 1`] = ` "type": "string", }, }, + "versions": Object { + "allowedValues": Array [ + Object { + "archived": false, + "id": "10000", + "name": "d", + "projectId": 10008, + "released": false, + "self": "https://mmtest.atlassian.net/rest/api/2/version/10000", + }, + ], + "hasDefaultValue": false, + "key": "versions", + "name": "Affects versions", + "operations": Array [ + "set", + "add", + "remove", + ], + "required": false, + "schema": Object { + "items": "version", + "system": "versions", + "type": "array", + }, + }, }, - "iconurl": "https://mmtest.atlassian.net/secure/viewavatar?size=medium&avatarId=10315&avatarType=issuetype", - "id": "10001", - "name": "Story", - "self": "https://mmtest.atlassian.net/rest/api/2/issuetype/10001", + "iconurl": "https://mmtest.atlassian.net/secure/viewavatar?size=medium&avatarId=10303&avatarType=issuetype", + "id": "10004", + "name": "Bug", + "self": "https://mmtest.atlassian.net/rest/api/2/issuetype/10004", }, Object { - "description": "jira.translation.issuetype.bug.name.desc", + "description": "A big user story that needs to be broken down. Created by Jira Software - do not edit or delete.", "expand": "fields", "fields": Object { "assignee": Object { @@ -2485,6 +2510,20 @@ exports[`components/CreateIssue should match snapshot with error 1`] = ` "type": "array", }, }, + "customfield_10011": Object { + "hasDefaultValue": false, + "key": "customfield_10011", + "name": "Epic Name", + "operations": Array [ + "set", + ], + "required": true, + "schema": Object { + "custom": "com.pyxis.greenhopper.jira:gh-epic-label", + "customId": 10011, + "type": "string", + }, + }, "customfield_10014": Object { "hasDefaultValue": false, "key": "customfield_10014", @@ -2783,19 +2822,6 @@ exports[`components/CreateIssue should match snapshot with error 1`] = ` "type": "string", }, }, - "environment": Object { - "hasDefaultValue": false, - "key": "environment", - "name": "Environment", - "operations": Array [ - "set", - ], - "required": false, - "schema": Object { - "system": "environment", - "type": "string", - }, - }, "fixVersions": Object { "allowedValues": Array [ Object { @@ -2840,12 +2866,11 @@ exports[`components/CreateIssue should match snapshot with error 1`] = ` "issuetype": Object { "allowedValues": Array [ Object { - "avatarId": 10303, - "description": "jira.translation.issuetype.bug.name.desc", - "iconUrl": "https://mmtest.atlassian.net/secure/viewavatar?size=medium&avatarId=10303&avatarType=issuetype", - "id": "10004", - "name": "Bug", - "self": "https://mmtest.atlassian.net/rest/api/2/issuetype/10004", + "description": "A big user story that needs to be broken down. Created by Jira Software - do not edit or delete.", + "iconUrl": "https://mmtest.atlassian.net/images/icons/issuetypes/epic.svg", + "id": "10000", + "name": "Epic", + "self": "https://mmtest.atlassian.net/rest/api/2/issuetype/10000", "subtask": false, }, ], @@ -2969,1941 +2994,854 @@ exports[`components/CreateIssue should match snapshot with error 1`] = ` "type": "string", }, }, - "versions": Object { - "allowedValues": Array [ - Object { - "archived": false, - "id": "10000", - "name": "d", - "projectId": 10008, - "released": false, - "self": "https://mmtest.atlassian.net/rest/api/2/version/10000", - }, - ], - "hasDefaultValue": false, - "key": "versions", - "name": "Affects versions", - "operations": Array [ - "set", - "add", - "remove", - ], - "required": false, - "schema": Object { - "items": "version", - "system": "versions", - "type": "array", - }, - }, }, - "iconurl": "https://mmtest.atlassian.net/secure/viewavatar?size=medium&avatarId=10303&avatarType=issuetype", - "id": "10004", - "name": "Bug", - "self": "https://mmtest.atlassian.net/rest/api/2/issuetype/10004", + "iconurl": "https://mmtest.atlassian.net/images/icons/issuetypes/epic.svg", + "id": "10000", + "name": "Epic", + "self": "https://mmtest.atlassian.net/rest/api/2/issuetype/10000", }, - Object { - "description": "A big user story that needs to be broken down. Created by Jira Software - do not edit or delete.", - "expand": "fields", - "fields": Object { - "assignee": Object { - "autoCompleteUrl": "https://mmtest.atlassian.net/rest/api/2/user/assignable/search?project=KT&query=", - "hasDefaultValue": false, - "key": "assignee", - "name": "Assignee", - "operations": Array [ - "set", - ], - "required": false, - "schema": Object { - "system": "assignee", - "type": "user", - }, - }, - "attachment": Object { - "hasDefaultValue": false, - "key": "attachment", - "name": "Attachment", - "operations": Array [], - "required": false, - "schema": Object { - "items": "attachment", - "system": "attachment", - "type": "array", - }, - }, - "components": Object { - "allowedValues": Array [], - "hasDefaultValue": false, - "key": "components", - "name": "Components", - "operations": Array [ - "add", - "set", - "remove", - ], - "required": false, - "schema": Object { - "items": "component", - "system": "components", - "type": "array", - }, - }, - "customfield_10011": Object { - "hasDefaultValue": false, - "key": "customfield_10011", - "name": "Epic Name", - "operations": Array [ - "set", - ], - "required": true, - "schema": Object { - "custom": "com.pyxis.greenhopper.jira:gh-epic-label", - "customId": 10011, - "type": "string", - }, - }, - "customfield_10014": Object { - "hasDefaultValue": false, - "key": "customfield_10014", - "name": "Epic Link", - "operations": Array [ - "set", - ], - "required": false, - "schema": Object { - "custom": "com.pyxis.greenhopper.jira:gh-epic-link", - "customId": 10014, - "type": "any", - }, - }, - "customfield_10021": Object { - "hasDefaultValue": false, - "key": "customfield_10021", - "name": "Sprint", - "operations": Array [ - "set", - ], - "required": false, - "schema": Object { - "custom": "com.pyxis.greenhopper.jira:gh-sprint", - "customId": 10021, - "items": "string", - "type": "array", - }, - }, - "customfield_10067": Object { - "hasDefaultValue": false, - "key": "customfield_10067", - "name": "Favorite Food", - "operations": Array [ - "set", - ], - "required": false, - "schema": Object { - "custom": "com.atlassian.jira.plugin.system.customfieldtypes:textfield", - "customId": 10067, - "type": "string", - }, - }, - "customfield_10068": Object { - "allowedValues": Array [ - Object { - "id": "10033", - "self": "https://mmtest.atlassian.net/rest/api/2/customFieldOption/10033", - "value": "1", - }, - Object { - "id": "10034", - "self": "https://mmtest.atlassian.net/rest/api/2/customFieldOption/10034", - "value": "2", - }, - ], - "hasDefaultValue": false, - "key": "customfield_10068", - "name": "MJK - Checkbox", - "operations": Array [ - "add", - "set", - "remove", - ], - "required": false, - "schema": Object { - "custom": "com.atlassian.jira.plugin.system.customfieldtypes:multicheckboxes", - "customId": 10068, - "items": "option", - "type": "array", - }, - }, - "customfield_10069": Object { - "hasDefaultValue": false, - "key": "customfield_10069", - "name": "MJK - Date Picker", - "operations": Array [ - "set", - ], - "required": false, - "schema": Object { - "custom": "com.atlassian.jira.plugin.system.customfieldtypes:datepicker", - "customId": 10069, - "type": "date", - }, - }, - "customfield_10070": Object { - "hasDefaultValue": false, - "key": "customfield_10070", - "name": "MJK - Date Time Picker", - "operations": Array [ - "set", - ], - "required": false, - "schema": Object { - "custom": "com.atlassian.jira.plugin.system.customfieldtypes:datetime", - "customId": 10070, - "type": "datetime", - }, - }, - "customfield_10071": Object { - "autoCompleteUrl": "https://mmtest.atlassian.net/rest/api/1.0/labels/suggest?customFieldId=10071&query=", - "hasDefaultValue": false, - "key": "customfield_10071", - "name": "MJK - Labels", - "operations": Array [ - "add", - "set", - "remove", - ], - "required": false, - "schema": Object { - "custom": "com.atlassian.jira.plugin.system.customfieldtypes:labels", - "customId": 10071, - "items": "string", - "type": "array", - }, - }, - "customfield_10072": Object { - "hasDefaultValue": false, - "key": "customfield_10072", - "name": "MJK - Number Field", - "operations": Array [ - "set", - ], - "required": false, - "schema": Object { - "custom": "com.atlassian.jira.plugin.system.customfieldtypes:float", - "customId": 10072, - "type": "number", - }, - }, - "customfield_10073": Object { - "allowedValues": Array [ - Object { - "id": "10035", - "self": "https://mmtest.atlassian.net/rest/api/2/customFieldOption/10035", - "value": "1", - }, - Object { - "id": "10036", - "self": "https://mmtest.atlassian.net/rest/api/2/customFieldOption/10036", - "value": "2", - }, - ], - "hasDefaultValue": false, - "key": "customfield_10073", - "name": "MJK - Radio Buttons", - "operations": Array [ - "set", - ], - "required": false, - "schema": Object { - "custom": "com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons", - "customId": 10073, - "type": "option", - }, - }, - "customfield_10074": Object { - "allowedValues": Array [], - "hasDefaultValue": false, - "key": "customfield_10074", - "name": "MJK - Select List 1", - "operations": Array [ - "set", - ], - "required": false, - "schema": Object { - "custom": "com.atlassian.jira.plugin.system.customfieldtypes:cascadingselect", - "customId": 10074, - "type": "option-with-child", - }, - }, - "customfield_10075": Object { - "allowedValues": Array [ - Object { - "id": "10037", - "self": "https://mmtest.atlassian.net/rest/api/2/customFieldOption/10037", - "value": "1", - }, - Object { - "id": "10038", - "self": "https://mmtest.atlassian.net/rest/api/2/customFieldOption/10038", - "value": "2", - }, - ], - "hasDefaultValue": false, - "key": "customfield_10075", - "name": "MJK - Select List 2", - "operations": Array [ - "add", - "set", - "remove", - ], - "required": false, - "schema": Object { - "custom": "com.atlassian.jira.plugin.system.customfieldtypes:multiselect", - "customId": 10075, - "items": "option", - "type": "array", - }, - }, - "customfield_10076": Object { - "allowedValues": Array [ - Object { - "id": "10039", - "self": "https://mmtest.atlassian.net/rest/api/2/customFieldOption/10039", - "value": "1", - }, - Object { - "id": "10040", - "self": "https://mmtest.atlassian.net/rest/api/2/customFieldOption/10040", - "value": "2", - }, - ], - "hasDefaultValue": false, - "key": "customfield_10076", - "name": "MJK - Select List 3", - "operations": Array [ - "set", - ], - "required": false, - "schema": Object { - "custom": "com.atlassian.jira.plugin.system.customfieldtypes:select", - "customId": 10076, - "type": "option", - }, - }, - "customfield_10077": Object { - "hasDefaultValue": false, - "key": "customfield_10077", - "name": "Text Field 1", - "operations": Array [ - "set", - ], - "required": false, - "schema": Object { - "custom": "com.atlassian.jira.plugin.system.customfieldtypes:textarea", - "customId": 10077, - "type": "string", - }, - }, - "customfield_10078": Object { - "hasDefaultValue": false, - "key": "customfield_10078", - "name": "Text Field 2", - "operations": Array [ - "set", - ], - "required": false, - "schema": Object { - "custom": "com.atlassian.jira.plugin.system.customfieldtypes:textfield", - "customId": 10078, - "type": "string", - }, - }, - "customfield_10079": Object { - "hasDefaultValue": false, - "key": "customfield_10079", - "name": "MJK - URL Field", - "operations": Array [ - "set", - ], - "required": false, - "schema": Object { - "custom": "com.atlassian.jira.plugin.system.customfieldtypes:url", - "customId": 10079, - "type": "string", - }, - }, - "customfield_10080": Object { - "autoCompleteUrl": "https://mmtest.atlassian.net/rest/api/1.0/users/picker?fieldName=customfield_10080&fieldConfigId=10187&projectId=10008&showAvatar=true&query=", - "hasDefaultValue": false, - "key": "customfield_10080", - "name": "MJK - User Picker", - "operations": Array [ - "set", - ], - "required": false, - "schema": Object { - "custom": "com.atlassian.jira.plugin.system.customfieldtypes:userpicker", - "customId": 10080, - "type": "user", - }, - }, - "description": Object { - "hasDefaultValue": false, - "key": "description", - "name": "Description", - "operations": Array [ - "set", - ], - "required": true, - "schema": Object { - "system": "description", - "type": "string", - }, - }, - "fixVersions": Object { - "allowedValues": Array [ - Object { - "archived": false, - "id": "10000", - "name": "d", - "projectId": 10008, - "released": false, - "self": "https://mmtest.atlassian.net/rest/api/2/version/10000", - }, - ], - "hasDefaultValue": false, - "key": "fixVersions", - "name": "Fix versions", - "operations": Array [ - "set", - "add", - "remove", - ], - "required": false, - "schema": Object { - "items": "version", - "system": "fixVersions", - "type": "array", - }, - }, - "issuelinks": Object { - "autoCompleteUrl": "https://mmtest.atlassian.net/rest/api/2/issue/picker?currentProjectId=&showSubTaskParent=true&showSubTasks=true¤tIssueKey=null&query=", - "hasDefaultValue": false, - "key": "issuelinks", - "name": "Linked Issues", - "operations": Array [ - "add", - ], - "required": false, - "schema": Object { - "items": "issuelinks", - "system": "issuelinks", - "type": "array", - }, - }, - "issuetype": Object { - "allowedValues": Array [ - Object { - "description": "A big user story that needs to be broken down. Created by Jira Software - do not edit or delete.", - "iconUrl": "https://mmtest.atlassian.net/images/icons/issuetypes/epic.svg", - "id": "10000", - "name": "Epic", - "self": "https://mmtest.atlassian.net/rest/api/2/issuetype/10000", - "subtask": false, - }, - ], - "hasDefaultValue": false, - "key": "issuetype", - "name": "Issue Type", - "operations": Array [], - "required": true, - "schema": Object { - "system": "issuetype", - "type": "issuetype", - }, - }, - "labels": Object { - "autoCompleteUrl": "https://mmtest.atlassian.net/rest/api/1.0/labels/suggest?query=", - "hasDefaultValue": false, - "key": "labels", - "name": "Labels", - "operations": Array [ - "add", - "set", - "remove", - ], - "required": false, - "schema": Object { - "items": "string", - "system": "labels", - "type": "array", - }, - }, - "priority": Object { - "allowedValues": Array [ - Object { - "iconUrl": "https://mmtest.atlassian.net/images/icons/priorities/highest.svg", - "id": "1", - "name": "Highest", - "self": "https://mmtest.atlassian.net/rest/api/2/priority/1", - }, - Object { - "iconUrl": "https://mmtest.atlassian.net/images/icons/priorities/high.svg", - "id": "2", - "name": "High", - "self": "https://mmtest.atlassian.net/rest/api/2/priority/2", - }, - Object { - "iconUrl": "https://mmtest.atlassian.net/images/icons/priorities/medium.svg", - "id": "3", - "name": "Medium", - "self": "https://mmtest.atlassian.net/rest/api/2/priority/3", - }, - Object { - "iconUrl": "https://mmtest.atlassian.net/images/icons/priorities/low.svg", - "id": "4", - "name": "Low", - "self": "https://mmtest.atlassian.net/rest/api/2/priority/4", - }, - Object { - "iconUrl": "https://mmtest.atlassian.net/images/icons/priorities/lowest.svg", - "id": "5", - "name": "Lowest", - "self": "https://mmtest.atlassian.net/rest/api/2/priority/5", - }, - ], - "defaultValue": Object { - "iconUrl": "https://mmtest.atlassian.net/images/icons/priorities/medium.svg", - "id": "3", - "name": "Medium", - "self": "https://mmtest.atlassian.net/rest/api/2/priority/3", - }, - "hasDefaultValue": true, - "key": "priority", - "name": "Priority", - "operations": Array [ - "set", - ], - "required": true, - "schema": Object { - "system": "priority", - "type": "priority", - }, - }, - "project": Object { - "allowedValues": Array [ - Object { - "avatarUrls": Object { - "16x16": "https://mmtest.atlassian.net/secure/projectavatar?size=xsmall&s=xsmall&pid=10008&avatarId=10417", - "24x24": "https://mmtest.atlassian.net/secure/projectavatar?size=small&s=small&pid=10008&avatarId=10417", - "32x32": "https://mmtest.atlassian.net/secure/projectavatar?size=medium&s=medium&pid=10008&avatarId=10417", - "48x48": "https://mmtest.atlassian.net/secure/projectavatar?pid=10008&avatarId=10417", - }, - "id": "10008", - "key": "KT", - "name": "Koch Testing", - "projectTypeKey": "software", - "self": "https://mmtest.atlassian.net/rest/api/2/project/10008", - "simplified": false, - }, - ], - "hasDefaultValue": false, - "key": "project", - "name": "Project", - "operations": Array [ - "set", - ], - "required": true, - "schema": Object { - "system": "project", - "type": "project", - }, - }, - "summary": Object { - "hasDefaultValue": false, - "key": "summary", - "name": "Summary", - "operations": Array [ - "set", - ], - "required": true, - "schema": Object { - "system": "summary", - "type": "string", - }, - }, - }, - "iconurl": "https://mmtest.atlassian.net/images/icons/issuetypes/epic.svg", - "id": "10000", - "name": "Epic", - "self": "https://mmtest.atlassian.net/rest/api/2/issuetype/10000", - }, - ], - "key": "KT", - "name": "Koch Testing", - "self": "https://mmtest.atlassian.net/rest/api/2/project/10008", - }, - ], - } - } - onChange={[Function]} - removeValidate={[Function]} - theme={ - Object { - "awayIndicator": "#ffbc42", - "buttonBg": "#166de0", - "buttonColor": "#ffffff", - "centerChannelBg": "#ffffff", - "centerChannelColor": "#3d3c40", - "codeTheme": "github", - "dndIndicator": "#f74343", - "errorTextColor": "#fd5960", - "linkColor": "#2389d7", - "mentionBg": "#ffffff", - "mentionBj": "#ffffff", - "mentionColor": "#145dbf", - "mentionHighlightBg": "#ffe577", - "mentionHighlightLink": "#166de0", - "newMessageSeparator": "#ff8800", - "onlineIndicator": "#06d6a0", - "sidebarBg": "#145dbf", - "sidebarHeaderBg": "#1153ab", - "sidebarHeaderTextColor": "#ffffff", - "sidebarText": "#ffffff", - "sidebarTextActiveBorder": "#579eff", - "sidebarTextActiveColor": "#ffffff", - "sidebarTextHoverBg": "#4578bf", - "sidebarUnreadText": "#ffffff", - "type": "Mattermost", - } - } - values={ - Object { - "description": "some description", - "issuetype": Object { - "id": "10001", - }, - "priority": Object { - "id": 1, - }, - "project": Object { - "key": "KT", - }, - "summary": "", - } - } - /> - - - - - - Create - - - -`; - -exports[`components/CreateIssue should match snapshot with form filled 1`] = ` -
- - -
- - +
+
+ + + + Create + + +
+`; + +exports[`components/CreateIssue should match snapshot with form filled 1`] = ` +
+ + +
+ + { id: fieldValues.issue_type, }; } else { - const issueTypes = getIssueTypes(this.state.jiraIssueMetadata, projectKey); + const issueTypes = getIssueTypes(this.state.jiraIssueMetadata, projectKey, {includeSubtasks: false}); const issueType = issueTypes.length ? issueTypes[0].id : ''; fields.issuetype = { id: issueType, @@ -267,7 +267,7 @@ export default class CreateIssueForm extends React.PureComponent { }; renderForm = () => { - const issueTypes = getIssueTypes(this.state.jiraIssueMetadata, this.state.projectKey); + const issueTypes = getIssueTypes(this.state.jiraIssueMetadata, this.state.projectKey, {includeSubtasks: false}); const issueOptions = issueTypes.map((it) => ({label: it.name, value: it.id})); return ( diff --git a/webapp/src/utils/jira_issue_metadata.tsx b/webapp/src/utils/jira_issue_metadata.tsx index be0c23fcd..afe2833c8 100644 --- a/webapp/src/utils/jira_issue_metadata.tsx +++ b/webapp/src/utils/jira_issue_metadata.tsx @@ -27,6 +27,10 @@ type FieldWithInfo = JiraField & { issueTypeMeta: IssueTypeIdentifier; } +type GetIssueTypesOptions = { + includeSubtasks: boolean; +} + export const FIELD_KEY_STATUS = 'status'; // This is a replacement for the Array.flat() function which will be polyfilled by Babel @@ -55,7 +59,7 @@ export function getProjectValues(metadata: ProjectMetadata | null): ReactSelectO return metadata.projects; } -export function getIssueTypes(metadata: IssueMetadata | null, projectKey: string | null): IssueType[] { +export function getIssueTypes(metadata: IssueMetadata | null, projectKey: string | null, options: GetIssueTypesOptions): IssueType[] { if (!metadata || !metadata.projects) { return []; } @@ -64,7 +68,12 @@ export function getIssueTypes(metadata: IssueMetadata | null, projectKey: string if (!project) { return []; } - return project.issuetypes.filter((i) => !i.subtask); + + if (!options.includeSubtasks) { + project.issuetypes = project.issuetypes.filter((i) => !i.subtask); + } + + return project.issuetypes; } export function getIssueValues(metadata: ProjectMetadata, projectKey: string): ReactSelectOption[] { @@ -95,7 +104,7 @@ export function getFields(metadata: IssueMetadata | null, projectKey: string | n return {}; } - const issueType = getIssueTypes(metadata, projectKey).find((it) => it.id === issueTypeId); + const issueType = getIssueTypes(metadata, projectKey, {includeSubtasks: false}).find((it) => it.id === issueTypeId); if (issueType) { return issueType.fields; } @@ -126,7 +135,7 @@ export function getCustomFieldsForProjects(metadata: IssueMetadata | null, proje return []; } - const issueTypes = flatten(projectKeys.map((key) => getIssueTypes(metadata, key))) as IssueType[]; + const issueTypes = flatten(projectKeys.map((key) => getIssueTypes(metadata, key, {includeSubtasks: true}))) as IssueType[]; const customFieldHash: {[key: string]: FieldWithInfo} = {}; const fields = flatten(issueTypes.map((issueType) =>