From 1dd12c14d03e7703ec35c45e92777933cf7c3e93 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Aubert?= Date: Tue, 15 Oct 2019 11:33:25 +0200 Subject: [PATCH] SONAR-12594 Udpate issue type icons --- .../coding-rules/components/RuleListItem.tsx | 16 ++- .../components/SimilarRulesFilter.tsx | 48 ++++--- .../__tests__/SimilarRulesFilter-test.tsx | 67 ++++++++++ .../__snapshots__/RuleListItem-test.tsx.snap | 11 +- .../SimilarRulesFilter-test.tsx.snap | 125 ++++++++++++++++++ .../issues/components/BulkChangeModal.tsx | 8 +- .../SourceViewer/components/Line.css | 9 +- .../js/components/common/SelectListItem.tsx | 6 +- .../components/issue/components/IssueType.tsx | 7 +- .../__snapshots__/IssueType-test.tsx.snap | 2 + .../issue/popups/SetSeverityPopup.tsx | 2 +- .../components/issue/popups/SetTypePopup.tsx | 2 +- .../issue/popups/SimilarIssuesPopup.tsx | 10 +- .../SetSeverityPopup-test.tsx.snap | 5 + .../__snapshots__/SetTypePopup-test.tsx.snap | 3 + .../SimilarIssuesPopup-test.tsx.snap | 3 + 16 files changed, 281 insertions(+), 43 deletions(-) create mode 100644 server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/SimilarRulesFilter-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/SimilarRulesFilter-test.tsx.snap diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleListItem.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleListItem.tsx index 4bed1a8943b..dfa86f63668 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleListItem.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleListItem.tsx @@ -228,15 +228,23 @@ export default class RuleListItem extends React.PureComponent { {translate('rules.status', rule.status)} )} - {rule.langName} + + {rule.langName} + - - {translate('issue.type', rule.type)} + + + {translate('issue.type', rule.type)} + {allTags.length > 0 && ( - + )} diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/SimilarRulesFilter.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/SimilarRulesFilter.tsx index 83e73cdd632..8215db4f307 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/SimilarRulesFilter.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/SimilarRulesFilter.tsx @@ -21,6 +21,7 @@ import * as React from 'react'; import Dropdown from 'sonar-ui-common/components/controls/Dropdown'; import DropdownIcon from 'sonar-ui-common/components/icons/DropdownIcon'; import FilterIcon from 'sonar-ui-common/components/icons/FilterIcon'; +import IssueTypeIcon from 'sonar-ui-common/components/icons/IssueTypeIcon'; import TagsIcon from 'sonar-ui-common/components/icons/TagsIcon'; import { translate } from 'sonar-ui-common/helpers/l10n'; import SeverityHelper from '../../../components/shared/SeverityHelper'; @@ -76,38 +77,49 @@ export default class SimilarRulesFilter extends React.PureComponent { }> diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/SimilarRulesFilter-test.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/SimilarRulesFilter-test.tsx new file mode 100644 index 00000000000..27c9b779961 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/SimilarRulesFilter-test.tsx @@ -0,0 +1,67 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import { mount, shallow } from 'enzyme'; +import * as React from 'react'; +import { click } from 'sonar-ui-common/helpers/testUtils'; +import { mockRule } from '../../../../helpers/testMocks'; +import SimilarRulesFilter from '../SimilarRulesFilter'; + +it('should render correctly', () => { + expect( + shallow() + ).toMatchSnapshot(); +}); + +it('should filter by similar language', () => { + const onFilterChange = jest.fn(); + const wrapper = mountRenderAction('language', { onFilterChange }); + click(wrapper); + expect(onFilterChange).toBeCalledWith({ languages: ['js'] }); +}); + +it('should filter by similar type', () => { + const onFilterChange = jest.fn(); + const wrapper = mountRenderAction('type', { onFilterChange }); + click(wrapper); + expect(onFilterChange).toBeCalledWith({ types: ['CODE_SMELL'] }); +}); + +it('should filter by similar severity', () => { + const onFilterChange = jest.fn(); + const wrapper = mountRenderAction('severity', { onFilterChange }); + click(wrapper); + expect(onFilterChange).toBeCalledWith({ severities: ['MAJOR'] }); +}); + +it('should filter by similar tag', () => { + const onFilterChange = jest.fn(); + const wrapper = mountRenderAction('tag', { onFilterChange }); + click(wrapper); + expect(onFilterChange).toBeCalledWith({ tags: ['x'] }); +}); + +function mountRenderAction(actionName: string, props: Partial = {}) { + const wrapper = mount( + + ); + return mount(wrapper.find('Dropdown').prop('overlay')) + .find(`a[data-test="coding-rules__similar-${actionName}"]`) + .first(); +} diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleListItem-test.tsx.snap b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleListItem-test.tsx.snap index 279ddfd36e6..a48a11f7ef0 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleListItem-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/RuleListItem-test.tsx.snap @@ -127,7 +127,7 @@ exports[`should render 1`] = ` className="display-flex-center coding-rule-meta" > JavaScript @@ -138,15 +138,18 @@ exports[`should render 1`] = ` className="display-inline-flex-center spacer-left note" > - issue.type.CODE_SMELL + + issue.type.CODE_SMELL + + + + } +> + + + + + +`; 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 7e16ba09c35..b8385c54db2 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 @@ -344,10 +344,10 @@ export default class BulkChangeModal extends React.PureComponent { const options = types.map(type => ({ label: translate('issue.type', type), value: type })); const optionRenderer = (option: { label: string; value: string }) => ( - - - {option.label} - + <> + + {option.label} + ); const input = ( diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/Line.css b/server/sonar-web/src/main/js/components/SourceViewer/components/Line.css index 8052467813b..4858d14b49b 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/Line.css +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/Line.css @@ -140,10 +140,6 @@ cursor: pointer; } -.source-meta + .source-meta { - border-left: 1px solid var(--barBackgroundColor); -} - .source-line-number { min-width: 18px; padding: 0 10px; @@ -163,8 +159,9 @@ white-space: nowrap; } -.source-line-with-issues { - padding-right: 4px; +.source-line-with-issues svg { + padding-right: 2px; + vertical-align: middle; } .source-line-issues-counter { diff --git a/server/sonar-web/src/main/js/components/common/SelectListItem.tsx b/server/sonar-web/src/main/js/components/common/SelectListItem.tsx index 17236942c19..e70ef01ba38 100644 --- a/server/sonar-web/src/main/js/components/common/SelectListItem.tsx +++ b/server/sonar-web/src/main/js/components/common/SelectListItem.tsx @@ -23,6 +23,7 @@ import Tooltip from 'sonar-ui-common/components/controls/Tooltip'; interface Props { active?: string; + className?: string; item: string; onHover?: (item: string) => void; onSelect?: (item: string) => void; @@ -48,7 +49,10 @@ export default class SelectListItem extends React.PureComponent { return (
  • { - + {translate('issue.type', issue.type)} diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueType-test.tsx.snap b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueType-test.tsx.snap index 6af3b059348..ecd72edd310 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueType-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueType-test.tsx.snap @@ -33,6 +33,7 @@ exports[`should open the popup when the button is clicked 2`] = ` > issue.type.BUG @@ -68,6 +69,7 @@ exports[`should render with the action 1`] = ` > issue.type.BUG diff --git a/server/sonar-web/src/main/js/components/issue/popups/SetSeverityPopup.tsx b/server/sonar-web/src/main/js/components/issue/popups/SetSeverityPopup.tsx index 10ffa22cb49..2e8f1a489d4 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/SetSeverityPopup.tsx +++ b/server/sonar-web/src/main/js/components/issue/popups/SetSeverityPopup.tsx @@ -36,7 +36,7 @@ export default function SetSeverityPopup({ issue, onSelect }: Props) { {SEVERITY.map(severity => ( - + {translate('severity', severity)} diff --git a/server/sonar-web/src/main/js/components/issue/popups/SetTypePopup.tsx b/server/sonar-web/src/main/js/components/issue/popups/SetTypePopup.tsx index 070f01b0271..7f13d002a7b 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/SetTypePopup.tsx +++ b/server/sonar-web/src/main/js/components/issue/popups/SetTypePopup.tsx @@ -36,7 +36,7 @@ export default function SetTypePopup({ issue, onSelect }: Props) { {TYPES.map(type => ( - + {translate('issue.type', type)} diff --git a/server/sonar-web/src/main/js/components/issue/popups/SimilarIssuesPopup.tsx b/server/sonar-web/src/main/js/components/issue/popups/SimilarIssuesPopup.tsx index b2d34c5a29e..0309b679764 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/SimilarIssuesPopup.tsx +++ b/server/sonar-web/src/main/js/components/issue/popups/SimilarIssuesPopup.tsx @@ -69,17 +69,21 @@ export default class SimilarIssuesPopup extends React.PureComponent { currentItem={items[0]} items={items} onSelect={this.handleSelect}> - + {translate('issue.type', issue.type)} - + - + diff --git a/server/sonar-web/src/main/js/components/issue/popups/__tests__/__snapshots__/SetSeverityPopup-test.tsx.snap b/server/sonar-web/src/main/js/components/issue/popups/__tests__/__snapshots__/SetSeverityPopup-test.tsx.snap index f8818f53cab..405a967b10d 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/__tests__/__snapshots__/SetSeverityPopup-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/issue/popups/__tests__/__snapshots__/SetSeverityPopup-test.tsx.snap @@ -16,6 +16,7 @@ exports[`should render tags popup correctly 1`] = ` onSelect={[MockFunction]} > @@ -26,6 +27,7 @@ exports[`should render tags popup correctly 1`] = ` severity.BLOCKER @@ -36,6 +38,7 @@ exports[`should render tags popup correctly 1`] = ` severity.CRITICAL @@ -46,6 +49,7 @@ exports[`should render tags popup correctly 1`] = ` severity.MAJOR @@ -56,6 +60,7 @@ exports[`should render tags popup correctly 1`] = ` severity.MINOR diff --git a/server/sonar-web/src/main/js/components/issue/popups/__tests__/__snapshots__/SetTypePopup-test.tsx.snap b/server/sonar-web/src/main/js/components/issue/popups/__tests__/__snapshots__/SetTypePopup-test.tsx.snap index 5055d807449..1073a5fd23c 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/__tests__/__snapshots__/SetTypePopup-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/issue/popups/__tests__/__snapshots__/SetTypePopup-test.tsx.snap @@ -14,6 +14,7 @@ exports[`should render tags popup correctly 1`] = ` onSelect={[MockFunction]} > @@ -24,6 +25,7 @@ exports[`should render tags popup correctly 1`] = ` issue.type.BUG @@ -34,6 +36,7 @@ exports[`should render tags popup correctly 1`] = ` issue.type.VULNERABILITY diff --git a/server/sonar-web/src/main/js/components/issue/popups/__tests__/__snapshots__/SimilarIssuesPopup-test.tsx.snap b/server/sonar-web/src/main/js/components/issue/popups/__tests__/__snapshots__/SimilarIssuesPopup-test.tsx.snap index 59070654247..595727bceb6 100644 --- a/server/sonar-web/src/main/js/components/issue/popups/__tests__/__snapshots__/SimilarIssuesPopup-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/issue/popups/__tests__/__snapshots__/SimilarIssuesPopup-test.tsx.snap @@ -31,6 +31,7 @@ exports[`should render correctly 1`] = ` onSelect={[Function]} > @@ -50,6 +52,7 @@ exports[`should render correctly 1`] = ` item="status" > -- 2.39.5