From a9a15ab6a63ba4e544bc52334847e57ca76f33bc Mon Sep 17 00:00:00 2001 From: kshitij katiyar <90389917+Kshitij-Katiyar@users.noreply.github.com> Date: Wed, 19 Oct 2022 14:00:37 +0530 Subject: [PATCH 1/5] [MI-2228]:Fixed Jira Issue 819 (Create issue modal crashes when assignee is selected before switching projects) (#8) * iterim pr for qa * updated changes that fixes crash * this is a hotfix that fixes the crash * fixes line issue * updated logic to reset fields * spacing * updated types for datatypes * fixed linting * fixed linting issues * [MI-2228]:Fixed jira issue 819 * [MI-2228]:Fixed review fixes Co-authored-by: raju Co-authored-by: sibasankarnayak --- .../jira_user_selector/jira_user_selector.tsx | 2 +- .../components/modals/create_issue/create_issue_form.tsx | 7 +++++-- webapp/src/types/model.ts | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/webapp/src/components/data_selectors/jira_user_selector/jira_user_selector.tsx b/webapp/src/components/data_selectors/jira_user_selector/jira_user_selector.tsx index db0dbd357..78cff4dd6 100644 --- a/webapp/src/components/data_selectors/jira_user_selector/jira_user_selector.tsx +++ b/webapp/src/components/data_selectors/jira_user_selector/jira_user_selector.tsx @@ -9,7 +9,7 @@ import BackendSelector, {Props as BackendSelectorProps} from '../backend_selecto type Props = BackendSelectorProps & { projectKey: string; - searchUsers: (params: {project: string; q: string}) => Promise<{data: JiraUser[]; error?: Error}>; + searchUsers: (params: {project: string; q: string}) => Promise<{data: {label: string; value: JiraUser[]}; error?: Error}>; }; export default class JiraUserSelector extends React.PureComponent { diff --git a/webapp/src/components/modals/create_issue/create_issue_form.tsx b/webapp/src/components/modals/create_issue/create_issue_form.tsx index f855b4877..78465475b 100644 --- a/webapp/src/components/modals/create_issue/create_issue_form.tsx +++ b/webapp/src/components/modals/create_issue/create_issue_form.tsx @@ -136,7 +136,8 @@ export default class CreateIssueForm extends React.PureComponent { }); let fields = { - ...this.state.fields, + summary: this.state.fields.summary, + description: this.state.fields.description, project: {key: projectKey}, } as CreateIssueFields; @@ -160,7 +161,9 @@ export default class CreateIssueForm extends React.PureComponent { handleIssueTypeChange = (_: string, issueType: string) => { let fields = { - ...this.state.fields, + summary: this.state.fields.summary, + description: this.state.fields.description, + project: {key: this.state.projectKey}, issuetype: {id: issueType}, } as CreateIssueFields; diff --git a/webapp/src/types/model.ts b/webapp/src/types/model.ts index fca984f1a..9f8b4bb8d 100644 --- a/webapp/src/types/model.ts +++ b/webapp/src/types/model.ts @@ -212,6 +212,7 @@ export type AllProjectMetadata = { export type CreateIssueFields = { description: string; + summary?: string; project: {key: string}; issuetype: {id: string}; } & {[key: string]: JiraField}; From 3ec1f87601030f93ab83a4945931ab9be76a81c5 Mon Sep 17 00:00:00 2001 From: Kshitij Katiyar Date: Tue, 1 Nov 2022 15:19:40 +0530 Subject: [PATCH 2/5] remove filter function --- .../modals/create_issue/create_issue_form.tsx | 28 ++----------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/webapp/src/components/modals/create_issue/create_issue_form.tsx b/webapp/src/components/modals/create_issue/create_issue_form.tsx index 78465475b..749372678 100644 --- a/webapp/src/components/modals/create_issue/create_issue_form.tsx +++ b/webapp/src/components/modals/create_issue/create_issue_form.tsx @@ -128,14 +128,13 @@ export default class CreateIssueForm extends React.PureComponent { if (error) { state.error = error.message; } else { - const fields = this.filterInvalidFields(this.state.projectKey, this.state.issueType, this.state.fields); state.fields = fields; } this.setState(state); }); - let fields = { + const fields = { summary: this.state.fields.summary, description: this.state.fields.description, project: {key: projectKey}, @@ -147,7 +146,6 @@ export default class CreateIssueForm extends React.PureComponent { id: issueType, }; - fields = this.filterInvalidFields(projectKey, issueType, fields); this.setState({ projectKey, issueType, @@ -160,14 +158,13 @@ export default class CreateIssueForm extends React.PureComponent { } handleIssueTypeChange = (_: string, issueType: string) => { - let fields = { + const fields = { summary: this.state.fields.summary, description: this.state.fields.description, project: {key: this.state.projectKey}, issuetype: {id: issueType}, } as CreateIssueFields; - fields = this.filterInvalidFields(this.state.projectKey, issueType, fields); this.setState({ issueType, fields, @@ -213,27 +210,6 @@ export default class CreateIssueForm extends React.PureComponent { return fieldsNotCovered; } - filterInvalidFields = (projectKey: string | null, issueType: string | null, fields: CreateIssueFields) => { - if (!projectKey || !issueType || !this.state.jiraIssueMetadata) { - return fields; - } - - const available = getFields(this.state.jiraIssueMetadata, projectKey, issueType); - - if (Object.keys(available).length === 0) { - return fields; - } - - const result = {} as CreateIssueFields; - for (const key of Object.keys(fields)) { - if (available[key] || key === 'project' || key === 'issuetype') { - result[key] = fields[key]; - } - } - - return result; - } - handleSubmit = (e?: React.FormEvent) => { if (e && e.preventDefault) { e.preventDefault(); From 0eec99e80c40eac566e6660401e7a80e172fe043 Mon Sep 17 00:00:00 2001 From: Kshitij Katiyar Date: Tue, 13 Dec 2022 21:58:33 +0530 Subject: [PATCH 3/5] [MM-819]:remove states.field --- webapp/src/components/modals/create_issue/create_issue_form.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/webapp/src/components/modals/create_issue/create_issue_form.tsx b/webapp/src/components/modals/create_issue/create_issue_form.tsx index 749372678..ac097b86d 100644 --- a/webapp/src/components/modals/create_issue/create_issue_form.tsx +++ b/webapp/src/components/modals/create_issue/create_issue_form.tsx @@ -127,8 +127,6 @@ export default class CreateIssueForm extends React.PureComponent { if (error) { state.error = error.message; - } else { - state.fields = fields; } this.setState(state); From 071c9df58dfeb2f47cfe453710b2fbd9ed364e40 Mon Sep 17 00:00:00 2001 From: Kshitij Katiyar Date: Thu, 15 Dec 2022 12:40:12 +0530 Subject: [PATCH 4/5] [MM-819]:Fixed lint errors --- webapp/src/components/modals/create_issue/create_issue_form.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/src/components/modals/create_issue/create_issue_form.tsx b/webapp/src/components/modals/create_issue/create_issue_form.tsx index ac097b86d..cdf2c6479 100644 --- a/webapp/src/components/modals/create_issue/create_issue_form.tsx +++ b/webapp/src/components/modals/create_issue/create_issue_form.tsx @@ -162,7 +162,7 @@ export default class CreateIssueForm extends React.PureComponent { project: {key: this.state.projectKey}, issuetype: {id: issueType}, } as CreateIssueFields; - + this.setState({ issueType, fields, From efceb995d46f4821a5c25ab1dfebba112a4d0451 Mon Sep 17 00:00:00 2001 From: Kshitij Katiyar Date: Thu, 15 Dec 2022 12:41:30 +0530 Subject: [PATCH 5/5] [MM-819]:Fixed lint errors --- webapp/src/components/modals/create_issue/create_issue_form.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/src/components/modals/create_issue/create_issue_form.tsx b/webapp/src/components/modals/create_issue/create_issue_form.tsx index cdf2c6479..ac097b86d 100644 --- a/webapp/src/components/modals/create_issue/create_issue_form.tsx +++ b/webapp/src/components/modals/create_issue/create_issue_form.tsx @@ -162,7 +162,7 @@ export default class CreateIssueForm extends React.PureComponent { project: {key: this.state.projectKey}, issuetype: {id: issueType}, } as CreateIssueFields; - + this.setState({ issueType, fields,