From 456e368cf3064d6d1cbbd6a6041836661afc68ed Mon Sep 17 00:00:00 2001 From: kshitij katiyar Date: Tue, 5 Nov 2024 13:22:14 +0530 Subject: [PATCH 1/3] [MM-1121]: Fixed issue of create issue modal's epic selector not showing options if epic field is renamed in jira project configuration --- .../jira_epic_selector/jira_epic_selector.tsx | 51 +++++++++++++------ 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/webapp/src/components/data_selectors/jira_epic_selector/jira_epic_selector.tsx b/webapp/src/components/data_selectors/jira_epic_selector/jira_epic_selector.tsx index 20ec1e7e1..a752e3e4c 100644 --- a/webapp/src/components/data_selectors/jira_epic_selector/jira_epic_selector.tsx +++ b/webapp/src/components/data_selectors/jira_epic_selector/jira_epic_selector.tsx @@ -3,7 +3,7 @@ import React from 'react'; -import {isEpicIssueType, isEpicNameField} from 'utils/jira_issue_metadata'; +import {isEpicNameField} from 'utils/jira_issue_metadata'; import {IssueMetadata, JiraIssue, ReactSelectOption} from 'types/model'; import BackendSelector, {Props as BackendSelectorProps} from '../backend_selector'; @@ -43,18 +43,26 @@ export default class JiraEpicSelector extends React.PureComponent { }; searchIssues = async (userInput: string): Promise => { - const epicIssueType = this.props.issueMetadata.projects[0].issuetypes.find(isEpicIssueType); - if (!epicIssueType) { - return []; + let epicNameTypeId: string | undefined; + let epicNameTypeName: string | undefined; + + for (const project of this.props.issueMetadata.projects) { + for (const issueType of project.issuetypes) { + epicNameTypeId = Object.keys(issueType.fields).find((key) => isEpicNameField(issueType.fields[key])); + if (epicNameTypeId) { + epicNameTypeName = issueType.fields[epicNameTypeId].name; + break; + } + } + if (epicNameTypeId) { + break; + } } - - const epicNameTypeId = Object.keys(epicIssueType.fields).find((key) => isEpicNameField(epicIssueType.fields[key])); - if (!epicNameTypeId) { + + if (!epicNameTypeId || !epicNameTypeName) { return []; } - const epicNameTypeName = epicIssueType.fields[epicNameTypeId].name; - let searchStr = ''; if (userInput) { const cleanedInput = userInput.trim().replace(/"/g, '\\"'); @@ -65,18 +73,29 @@ export default class JiraEpicSelector extends React.PureComponent { }; fetchEpicsFromJql = async (jqlSearch: string, userInput: string): Promise => { - const epicIssueType = this.props.issueMetadata.projects[0].issuetypes.find(isEpicIssueType); - if (!epicIssueType) { - return []; + let epicIssueTypeId: string | undefined; + let epicNameTypeId: string | undefined; + let projectKey: string | undefined; + + for (const project of this.props.issueMetadata.projects) { + for (const issueType of project.issuetypes) { + epicNameTypeId = Object.keys(issueType.fields).find((key) => isEpicNameField(issueType.fields[key])); + if (epicNameTypeId) { + epicIssueTypeId = issueType.id; + projectKey = project.key; + break; + } + } + if (epicNameTypeId) { + break; + } } - const epicNameTypeId = Object.keys(epicIssueType.fields).find((key) => isEpicNameField(epicIssueType.fields[key])); - if (!epicNameTypeId) { + if (!epicNameTypeId || !projectKey || !epicIssueTypeId) { return []; } - const projectKey = this.props.issueMetadata.projects[0].key; - const fullJql = `project=${projectKey} and issuetype=${epicIssueType.id} ${jqlSearch} ${searchDefaults}`; + const fullJql = `project=${projectKey} and issuetype=${epicIssueTypeId} ${jqlSearch} ${searchDefaults}`; const params = { jql: fullJql, From bc5440df996e77368d83143e8cf1d0eb536c1f7b Mon Sep 17 00:00:00 2001 From: kshitij katiyar Date: Tue, 5 Nov 2024 13:37:01 +0530 Subject: [PATCH 2/3] [MM-1121]: Removed extra lines --- .../jira_epic_selector/jira_epic_selector.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webapp/src/components/data_selectors/jira_epic_selector/jira_epic_selector.tsx b/webapp/src/components/data_selectors/jira_epic_selector/jira_epic_selector.tsx index a752e3e4c..1f6989c97 100644 --- a/webapp/src/components/data_selectors/jira_epic_selector/jira_epic_selector.tsx +++ b/webapp/src/components/data_selectors/jira_epic_selector/jira_epic_selector.tsx @@ -45,7 +45,7 @@ export default class JiraEpicSelector extends React.PureComponent { searchIssues = async (userInput: string): Promise => { let epicNameTypeId: string | undefined; let epicNameTypeName: string | undefined; - + for (const project of this.props.issueMetadata.projects) { for (const issueType of project.issuetypes) { epicNameTypeId = Object.keys(issueType.fields).find((key) => isEpicNameField(issueType.fields[key])); @@ -58,7 +58,7 @@ export default class JiraEpicSelector extends React.PureComponent { break; } } - + if (!epicNameTypeId || !epicNameTypeName) { return []; } @@ -76,7 +76,7 @@ export default class JiraEpicSelector extends React.PureComponent { let epicIssueTypeId: string | undefined; let epicNameTypeId: string | undefined; let projectKey: string | undefined; - + for (const project of this.props.issueMetadata.projects) { for (const issueType of project.issuetypes) { epicNameTypeId = Object.keys(issueType.fields).find((key) => isEpicNameField(issueType.fields[key])); From 1a26ef10b6b6b4f278e15e993bd6c4d5de1d26ad Mon Sep 17 00:00:00 2001 From: kshitij katiyar Date: Thu, 16 Jan 2025 20:01:29 +0530 Subject: [PATCH 3/3] review fixes --- .../jira_epic_selector/jira_epic_selector.tsx | 6 ------ 1 file changed, 6 deletions(-) diff --git a/webapp/src/components/data_selectors/jira_epic_selector/jira_epic_selector.tsx b/webapp/src/components/data_selectors/jira_epic_selector/jira_epic_selector.tsx index 1f6989c97..0ead689b3 100644 --- a/webapp/src/components/data_selectors/jira_epic_selector/jira_epic_selector.tsx +++ b/webapp/src/components/data_selectors/jira_epic_selector/jira_epic_selector.tsx @@ -54,9 +54,6 @@ export default class JiraEpicSelector extends React.PureComponent { break; } } - if (epicNameTypeId) { - break; - } } if (!epicNameTypeId || !epicNameTypeName) { @@ -86,9 +83,6 @@ export default class JiraEpicSelector extends React.PureComponent { break; } } - if (epicNameTypeId) { - break; - } } if (!epicNameTypeId || !projectKey || !epicIssueTypeId) {