From 0776b019cd2e044441a6cc8c0f2fb61405264a19 Mon Sep 17 00:00:00 2001 From: stanislavh Date: Tue, 18 Apr 2023 14:29:18 +0200 Subject: [PATCH] SONAR-19069 Disable the option to change an issue type in issues list and issue view --- .../main/js/api/mocks/IssuesServiceMock.ts | 6 +- .../js/apps/issues/__tests__/IssuesApp-it.tsx | 28 +----- .../issues/components/BulkChangeModal.tsx | 63 +----------- .../__tests__/BulkChangeModal-it.tsx | 12 +-- .../__tests__/SourceViewer-it.tsx | 6 -- .../src/main/js/components/issue/Issue.css | 4 + .../components/issue/__tests__/Issue-it.tsx | 13 --- .../issue/components/IssueActionsBar.tsx | 14 +-- .../components/issue/components/IssueType.tsx | 97 ------------------- server/sonar-web/src/main/js/types/issues.ts | 1 - 10 files changed, 18 insertions(+), 226 deletions(-) delete mode 100644 server/sonar-web/src/main/js/components/issue/components/IssueType.tsx diff --git a/server/sonar-web/src/main/js/api/mocks/IssuesServiceMock.ts b/server/sonar-web/src/main/js/api/mocks/IssuesServiceMock.ts index 46bedfce13d..73e33083b28 100644 --- a/server/sonar-web/src/main/js/api/mocks/IssuesServiceMock.ts +++ b/server/sonar-web/src/main/js/api/mocks/IssuesServiceMock.ts @@ -62,8 +62,8 @@ import { editIssueComment, getIssueChangelog, getIssueFlowSnippets, - searchIssueTags, searchIssues, + searchIssueTags, setIssueAssignee, setIssueSeverity, setIssueTags, @@ -528,11 +528,11 @@ export default class IssuesServiceMock { } handleBulkChangeIssues = (issueKeys: string[], query: RequestData) => { - //For now we only check for issue type change. + //For now we only check for issue severity change. this.list .filter((i) => issueKeys.includes(i.issue.key)) .forEach((data) => { - data.issue.type = query.set_type; + data.issue.severity = query.set_severity; }); return this.reply({}); }; diff --git a/server/sonar-web/src/main/js/apps/issues/__tests__/IssuesApp-it.tsx b/server/sonar-web/src/main/js/apps/issues/__tests__/IssuesApp-it.tsx index e90b41b0a4e..d90c6b6f4f8 100644 --- a/server/sonar-web/src/main/js/apps/issues/__tests__/IssuesApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/issues/__tests__/IssuesApp-it.tsx @@ -246,12 +246,6 @@ describe('issues app', () => { // Check that we bulk change the selected issue const issueBoxFixThat = within(screen.getByRole('region', { name: 'Fix that' })); - expect( - issueBoxFixThat.getByRole('button', { - name: 'issue.type.type_x_click_to_change.issue.type.CODE_SMELL', - }) - ).toBeInTheDocument(); - await user.click( screen.getByRole('checkbox', { name: 'issues.action_select.label.Fix that' }) ); @@ -261,14 +255,14 @@ describe('issues app', () => { await user.keyboard('New Comment'); expect(screen.getByRole('button', { name: 'apply' })).toBeDisabled(); - await selectEvent.select(screen.getByRole('combobox', { name: 'issue.set_type' }), [ - 'issue.type.BUG', + await selectEvent.select(screen.getByRole('combobox', { name: 'issue.set_severity' }), [ + 'severity.BLOCKER', ]); await user.click(screen.getByRole('button', { name: 'apply' })); expect( issueBoxFixThat.getByRole('button', { - name: 'issue.type.type_x_click_to_change.issue.type.BUG', + name: 'issue.severity.severity_x_click_to_change.severity.BLOCKER', }) ).toBeInTheDocument(); }); @@ -613,22 +607,6 @@ describe('issues item', () => { // Get a specific issue list item const listItem = within(await screen.findByRole('region', { name: 'Fix that' })); - // Change issue type - await user.click( - listItem.getByRole('button', { - name: `issue.type.type_x_click_to_change.issue.type.CODE_SMELL`, - }) - ); - expect(listItem.getByText('issue.type.BUG')).toBeInTheDocument(); - expect(listItem.getByText('issue.type.VULNERABILITY')).toBeInTheDocument(); - - await user.click(listItem.getByText('issue.type.VULNERABILITY')); - expect( - listItem.getByRole('button', { - name: `issue.type.type_x_click_to_change.issue.type.VULNERABILITY`, - }) - ).toBeInTheDocument(); - // Change issue severity expect(listItem.getByText('severity.MAJOR')).toBeInTheDocument(); diff --git a/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx b/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx index 1a31ccfb7ff..fb3e941c7bd 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/BulkChangeModal.tsx @@ -33,14 +33,13 @@ import Select, { LabelValueSelectOption, SearchSelect, } from '../../../components/controls/Select'; -import IssueTypeIcon from '../../../components/icons/IssueTypeIcon'; import SeverityHelper from '../../../components/shared/SeverityHelper'; import { Alert } from '../../../components/ui/Alert'; import DeferredSpinner from '../../../components/ui/DeferredSpinner'; import { SEVERITIES } from '../../../helpers/constants'; import { throwGlobalError } from '../../../helpers/error'; import { translate, translateWithParameters } from '../../../helpers/l10n'; -import { Component, Dict, Issue, IssueType, Paging } from '../../../types/types'; +import { Component, Dict, Issue, Paging } from '../../../types/types'; import { CurrentUser } from '../../../types/users'; import AssigneeSelect, { AssigneeOption } from './AssigneeSelect'; @@ -67,7 +66,6 @@ interface FormFields { removeTags?: Array<{ label: string; value: string }>; severity?: string; transition?: string; - type?: string; } interface State extends FormFields { @@ -85,30 +83,10 @@ enum InputField { assignee = 'assignee', removeTags = 'removeTags', severity = 'severity', - type = 'type', } export const MAX_PAGE_SIZE = 500; -function typeFieldTypeRenderer(option: LabelValueSelectOption) { - return ( -
- - {option.label} -
- ); -} - -function TypeFieldOptionComponent(props: OptionProps) { - return {typeFieldTypeRenderer(props.data)}; -} - -function TypeFieldSingleValueComponent(props: SingleValueProps) { - return ( - {typeFieldTypeRenderer(props.data)} - ); -} - function SeverityFieldOptionComponent(props: OptionProps) { return ( @@ -218,7 +196,6 @@ export default class BulkChangeModal extends React.PureComponent { remove_tags: this.state.removeTags && this.state.removeTags.map((t) => t.value).join(), sendNotifications: this.state.notifications, set_severity: this.state.severity, - set_type: this.state.type, }, (x) => x !== undefined ); @@ -258,15 +235,14 @@ export default class BulkChangeModal extends React.PureComponent { } canSubmit = () => { - const { addTags, assignee, removeTags, severity, transition, type } = this.state; + const { addTags, assignee, removeTags, severity, transition } = this.state; return Boolean( (addTags && addTags.length > 0) || (removeTags && removeTags.length > 0) || assignee || severity || - transition || - type + transition ); }; @@ -331,38 +307,6 @@ export default class BulkChangeModal extends React.PureComponent { return this.renderField(field, 'issue.assign.formlink', affected, input); }; - renderTypeField = () => { - const affected = this.state.issues.filter(hasAction('set_type')).length; - const field = InputField.type; - - if (affected === 0) { - return null; - } - - const types: IssueType[] = ['BUG', 'VULNERABILITY', 'CODE_SMELL']; - const options: LabelValueSelectOption[] = types.map((type) => ({ - label: translate('issue.type', type), - value: type, - })); - - const input = ( -