From 9f451cb3fb66e618e48278de7104e204b8695ef1 Mon Sep 17 00:00:00 2001 From: Léo Geoffroy Date: Mon, 6 Nov 2023 14:18:31 +0100 Subject: SONAR-20877 Update naming to issueStatus --- .../main/js/apps/issues/__tests__/IssueApp-it.tsx | 10 +- .../issues/__tests__/IssuesApp-Filtering-it.tsx | 4 +- .../main/js/apps/issues/__tests__/utils-test.ts | 81 +++++++-------- .../ComponentSourceSnippetGroupViewer.tsx | 4 +- .../CrossComponentSourceViewer.tsx | 4 +- .../js/apps/issues/sidebar/IssueStatusFacet.tsx | 108 ++++++++++++++++++++ .../src/main/js/apps/issues/sidebar/Sidebar.tsx | 12 +-- .../js/apps/issues/sidebar/SimpleStatusFacet.tsx | 109 --------------------- .../apps/issues/sidebar/__tests__/Sidebar-it.tsx | 6 +- .../src/main/js/apps/issues/test-utils.tsx | 8 +- server/sonar-web/src/main/js/apps/issues/utils.ts | 67 ++++++------- 11 files changed, 202 insertions(+), 211 deletions(-) create mode 100644 server/sonar-web/src/main/js/apps/issues/sidebar/IssueStatusFacet.tsx delete mode 100644 server/sonar-web/src/main/js/apps/issues/sidebar/SimpleStatusFacet.tsx (limited to 'server/sonar-web/src/main/js/apps/issues') diff --git a/server/sonar-web/src/main/js/apps/issues/__tests__/IssueApp-it.tsx b/server/sonar-web/src/main/js/apps/issues/__tests__/IssueApp-it.tsx index d333b922e69..cb66cd3775f 100644 --- a/server/sonar-web/src/main/js/apps/issues/__tests__/IssueApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/issues/__tests__/IssueApp-it.tsx @@ -154,10 +154,10 @@ describe('issue app', () => { // Get a specific issue list item const listItem = within(await screen.findByRole('region', { name: 'Fix that' })); - expect(listItem.getByText('issue.simple_status.OPEN')).toBeInTheDocument(); + expect(listItem.getByText('issue.issue_status.OPEN')).toBeInTheDocument(); await act(async () => { - await user.click(listItem.getByText('issue.simple_status.OPEN')); + await user.click(listItem.getByText('issue.issue_status.OPEN')); }); expect(listItem.getByText('issue.transition.accept')).toBeInTheDocument(); expect(listItem.getByText('issue.transition.confirm')).toBeInTheDocument(); @@ -175,20 +175,20 @@ describe('issue app', () => { expect( listItem.getByLabelText( - 'issue.transition.status_x_click_to_change.issue.simple_status.CONFIRMED', + 'issue.transition.status_x_click_to_change.issue.issue_status.CONFIRMED', ), ).toBeInTheDocument(); // Change status again await act(async () => { - await user.click(listItem.getByText('issue.simple_status.CONFIRMED')); + await user.click(listItem.getByText('issue.issue_status.CONFIRMED')); await user.click(listItem.getByText('issue.transition.accept')); await user.click(listItem.getByText('resolve')); }); expect( listItem.getByLabelText( - 'issue.transition.status_x_click_to_change.issue.simple_status.ACCEPTED', + 'issue.transition.status_x_click_to_change.issue.issue_status.ACCEPTED', ), ).toBeInTheDocument(); diff --git a/server/sonar-web/src/main/js/apps/issues/__tests__/IssuesApp-Filtering-it.tsx b/server/sonar-web/src/main/js/apps/issues/__tests__/IssuesApp-Filtering-it.tsx index ce0e9931252..2e2320f6f0b 100644 --- a/server/sonar-web/src/main/js/apps/issues/__tests__/IssuesApp-Filtering-it.tsx +++ b/server/sonar-web/src/main/js/apps/issues/__tests__/IssuesApp-Filtering-it.tsx @@ -90,7 +90,7 @@ describe('issues app filtering', () => { expect(ui.issueItem6.get()).toBeInTheDocument(); // Status - await user.click(ui.simpleStatusFacet.get()); + await user.click(ui.issueStatusFacet.get()); await user.click(ui.openStatusFilter.get()); expect(ui.issueItem6.query()).not.toBeInTheDocument(); // Issue 6 should vanish @@ -350,7 +350,7 @@ describe('issues app when reindexing', () => { expect(ui.resolutionFacet.query()).not.toBeInTheDocument(); expect(ui.ruleFacet.query()).not.toBeInTheDocument(); expect(ui.scopeFacet.query()).not.toBeInTheDocument(); - expect(ui.simpleStatusFacet.query()).not.toBeInTheDocument(); + expect(ui.issueStatusFacet.query()).not.toBeInTheDocument(); expect(ui.tagFacet.query()).not.toBeInTheDocument(); // Indexation message diff --git a/server/sonar-web/src/main/js/apps/issues/__tests__/utils-test.ts b/server/sonar-web/src/main/js/apps/issues/__tests__/utils-test.ts index 7f55fb9c1e2..0be574f9806 100644 --- a/server/sonar-web/src/main/js/apps/issues/__tests__/utils-test.ts +++ b/server/sonar-web/src/main/js/apps/issues/__tests__/utils-test.ts @@ -22,7 +22,7 @@ import { SoftwareImpactSeverity, SoftwareQuality, } from '../../../types/clean-code-taxonomy'; -import { IssueSimpleStatus } from '../../../types/issues'; +import { IssueStatus } from '../../../types/issues'; import { SecurityStandard } from '../../../types/security'; import { parseQuery, @@ -69,7 +69,7 @@ describe('serialize/deserialize', () => { severities: ['a', 'b'], inNewCodePeriod: true, sonarsourceSecurity: ['a', 'b'], - simpleStatuses: [IssueSimpleStatus.Accepted, IssueSimpleStatus.Confirmed], + issueStatuses: [IssueStatus.Accepted, IssueStatus.Confirmed], tags: ['a', 'b'], types: ['a', 'b'], }), @@ -102,7 +102,7 @@ describe('serialize/deserialize', () => { inNewCodePeriod: 'true', severities: 'a,b', sonarsourceSecurity: 'a,b', - simpleStatuses: 'ACCEPTED,CONFIRMED', + issueStatuses: 'ACCEPTED,CONFIRMED', tags: 'a,b', types: 'a,b', }); @@ -149,73 +149,64 @@ describe('serialize/deserialize', () => { severities: ['CRITICAL', 'MAJOR'], sonarsourceSecurity: [], sort: '', - simpleStatuses: [], + issueStatuses: [], tags: [], types: [], }); }); - it('should map deprecated status and resolution query to new simple statuses', () => { - expect(parseQuery({ statuses: 'OPEN' }).simpleStatuses).toEqual([IssueSimpleStatus.Open]); - expect(parseQuery({ statuses: 'REOPENED' }).simpleStatuses).toEqual([IssueSimpleStatus.Open]); - expect(parseQuery({ statuses: 'CONFIRMED' }).simpleStatuses).toEqual([ - IssueSimpleStatus.Confirmed, + it('should map deprecated status and resolution query to new issue statuses', () => { + expect(parseQuery({ statuses: 'OPEN' }).issueStatuses).toEqual([IssueStatus.Open]); + expect(parseQuery({ statuses: 'REOPENED' }).issueStatuses).toEqual([IssueStatus.Open]); + expect(parseQuery({ statuses: 'CONFIRMED' }).issueStatuses).toEqual([IssueStatus.Confirmed]); + expect(parseQuery({ statuses: 'RESOLVED' }).issueStatuses).toEqual([ + IssueStatus.Fixed, + IssueStatus.Accepted, + IssueStatus.FalsePositive, ]); - expect(parseQuery({ statuses: 'RESOLVED' }).simpleStatuses).toEqual([ - IssueSimpleStatus.Fixed, - IssueSimpleStatus.Accepted, - IssueSimpleStatus.FalsePositive, - ]); - expect(parseQuery({ statuses: 'OPEN,REOPENED' }).simpleStatuses).toEqual([ - IssueSimpleStatus.Open, - ]); - expect(parseQuery({ statuses: 'OPEN,CONFIRMED' }).simpleStatuses).toEqual([ - IssueSimpleStatus.Open, - IssueSimpleStatus.Confirmed, + expect(parseQuery({ statuses: 'OPEN,REOPENED' }).issueStatuses).toEqual([IssueStatus.Open]); + expect(parseQuery({ statuses: 'OPEN,CONFIRMED' }).issueStatuses).toEqual([ + IssueStatus.Open, + IssueStatus.Confirmed, ]); // Resolutions - expect(parseQuery({ resolutions: 'FALSE-POSITIVE' }).simpleStatuses).toEqual([ - IssueSimpleStatus.FalsePositive, - ]); - expect(parseQuery({ resolutions: 'WONTFIX' }).simpleStatuses).toEqual([ - IssueSimpleStatus.Accepted, - ]); - expect(parseQuery({ resolutions: 'REMOVED' }).simpleStatuses).toEqual([ - IssueSimpleStatus.Fixed, + expect(parseQuery({ resolutions: 'FALSE-POSITIVE' }).issueStatuses).toEqual([ + IssueStatus.FalsePositive, ]); - expect(parseQuery({ resolutions: 'REMOVED,WONTFIX,FALSE-POSITIVE' }).simpleStatuses).toEqual([ - IssueSimpleStatus.Fixed, - IssueSimpleStatus.Accepted, - IssueSimpleStatus.FalsePositive, + expect(parseQuery({ resolutions: 'WONTFIX' }).issueStatuses).toEqual([IssueStatus.Accepted]); + expect(parseQuery({ resolutions: 'REMOVED' }).issueStatuses).toEqual([IssueStatus.Fixed]); + expect(parseQuery({ resolutions: 'REMOVED,WONTFIX,FALSE-POSITIVE' }).issueStatuses).toEqual([ + IssueStatus.Fixed, + IssueStatus.Accepted, + IssueStatus.FalsePositive, ]); // Both statuses and resolutions expect( - parseQuery({ resolutions: 'FALSE-POSITIVE', statuses: 'RESOLVED' }).simpleStatuses, - ).toEqual([IssueSimpleStatus.FalsePositive]); - expect(parseQuery({ resolutions: 'WONTFIX', statuses: 'RESOLVED' }).simpleStatuses).toEqual([ - IssueSimpleStatus.Accepted, + parseQuery({ resolutions: 'FALSE-POSITIVE', statuses: 'RESOLVED' }).issueStatuses, + ).toEqual([IssueStatus.FalsePositive]); + expect(parseQuery({ resolutions: 'WONTFIX', statuses: 'RESOLVED' }).issueStatuses).toEqual([ + IssueStatus.Accepted, ]); // With resolved=false expect( - parseQuery({ resolutions: 'WONTFIX', statuses: 'RESOLVED', resolved: 'false' }) - .simpleStatuses, - ).toEqual([IssueSimpleStatus.Accepted, IssueSimpleStatus.Open, IssueSimpleStatus.Confirmed]); - expect(parseQuery({ statuses: 'OPEN', resolved: 'false' }).simpleStatuses).toEqual([ - IssueSimpleStatus.Open, + parseQuery({ resolutions: 'WONTFIX', statuses: 'RESOLVED', resolved: 'false' }).issueStatuses, + ).toEqual([IssueStatus.Accepted, IssueStatus.Open, IssueStatus.Confirmed]); + expect(parseQuery({ statuses: 'OPEN', resolved: 'false' }).issueStatuses).toEqual([ + IssueStatus.Open, ]); - // With simple status + // With new status expect( parseQuery({ resolutions: 'WONTFIX', statuses: 'RESOLVED', resolved: 'false', - simpleStatuses: 'FIXED', - }).simpleStatuses, - ).toEqual([IssueSimpleStatus.Fixed]); + issueStatuses: 'FIXED', + }).issueStatuses, + ).toEqual([IssueStatus.Fixed]); }); }); diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetGroupViewer.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetGroupViewer.tsx index 6505066761a..d409919df58 100644 --- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetGroupViewer.tsx +++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetGroupViewer.tsx @@ -29,7 +29,7 @@ import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { translate } from '../../../helpers/l10n'; import { BranchLike } from '../../../types/branch-like'; import { isFile } from '../../../types/component'; -import { IssueStatus } from '../../../types/issues'; +import { IssueDeprecatedStatus } from '../../../types/issues'; import { Dict, Duplication, @@ -272,7 +272,7 @@ export default class ComponentSourceSnippetGroupViewer extends React.PureCompone ...additionalLines, }); - const issueIsClosed = issue.status === IssueStatus.Closed; + const issueIsClosed = issue.status === IssueDeprecatedStatus.Closed; const issueIsFileLevel = isFile(issue.componentQualifier) && issue.componentEnabled; const closedIssueMessageKey = issueIsFileLevel ? 'issue.closed.file_level' diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewer.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewer.tsx index c5c2dfcb4f7..12817ba7163 100644 --- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewer.tsx +++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/CrossComponentSourceViewer.tsx @@ -41,7 +41,7 @@ import { translate } from '../../../helpers/l10n'; import { HttpStatus } from '../../../helpers/request'; import { BranchLike } from '../../../types/branch-like'; import { isFile } from '../../../types/component'; -import { IssueStatus } from '../../../types/issues'; +import { IssueDeprecatedStatus } from '../../../types/issues'; import { Dict, DuplicatedFile, @@ -124,7 +124,7 @@ export default class CrossComponentSourceViewer extends React.PureComponent; +} + +const property = 'issueStatuses'; +const headerId = `facet_${property}`; + +const defaultStatuses = DEFAULT_ISSUES_QUERY.issueStatuses.split(',') as IssueStatus[]; + +export function IssueStatusFacet(props: Readonly) { + const { issueStatuses = [], stats = {}, fetching, open, help, needIssueSync } = props; + const intl = useIntl(); + + const nbSelectableItems = ISSUE_STATUSES.filter( + (item) => !defaultStatuses.includes(item) && stats[item], + ).length; + const hasDefaultSelection = isEqual(sortBy(issueStatuses), sortBy(defaultStatuses)); + const nbSelectedItems = hasDefaultSelection ? 0 : issueStatuses.length; + + return ( + + props.onChange({ + [property]: defaultStatuses, + }) + } + onClick={() => props.onToggle(property)} + open={open} + help={help} + > + + {ISSUE_STATUSES.map((item) => { + const active = issueStatuses.includes(item); + const stat = stats[item]; + + return ( + { + if (multiple) { + props.onChange({ + [property]: active + ? without(issueStatuses, itemValue) + : [...issueStatuses, itemValue], + }); + } else { + props.onChange({ + [property]: active && issueStatuses.length === 1 ? [] : [itemValue], + }); + } + }} + stat={(!needIssueSync && formatFacetStat(stat)) ?? 0} + value={item} + /> + ); + })} + + + + + ); +} diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx index 141cb21fe1b..54c8082ca81 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx @@ -49,13 +49,13 @@ import { AuthorFacet } from './AuthorFacet'; import { CreationDateFacet } from './CreationDateFacet'; import { DirectoryFacet } from './DirectoryFacet'; import { FileFacet } from './FileFacet'; +import { IssueStatusFacet } from './IssueStatusFacet'; import { LanguageFacet } from './LanguageFacet'; import { PeriodFilter } from './PeriodFilter'; import { ProjectFacet } from './ProjectFacet'; import { RuleFacet } from './RuleFacet'; import { ScopeFacet } from './ScopeFacet'; import { SeverityFacet } from './SeverityFacet'; -import { SimpleStatusFacet } from './SimpleStatusFacet'; import { SoftwareQualityFacet } from './SoftwareQualityFacet'; import { StandardFacet } from './StandardFacet'; import { TagFacet } from './TagFacet'; @@ -245,13 +245,13 @@ export class SidebarClass extends React.PureComponent { - diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/SimpleStatusFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/SimpleStatusFacet.tsx deleted file mode 100644 index 5889d9fc2c2..00000000000 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/SimpleStatusFacet.tsx +++ /dev/null @@ -1,109 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2023 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 { FacetBox, FacetItem } from 'design-system'; -import { FacetItemsList } from './FacetItemsList'; - -import { isEqual, sortBy, without } from 'lodash'; -import * as React from 'react'; -import { useIntl } from 'react-intl'; -import { DEFAULT_ISSUES_QUERY } from '../../../components/shared/utils'; -import { SIMPLE_STATUSES } from '../../../helpers/constants'; -import { IssueSimpleStatus } from '../../../types/issues'; -import { formatFacetStat } from '../utils'; -import { MultipleSelectionHint } from './MultipleSelectionHint'; -import { CommonProps } from './SimpleListStyleFacet'; - -interface Props extends CommonProps { - simpleStatuses: Array; -} - -const property = 'simpleStatuses'; -const headerId = `facet_${property}`; - -const defaultStatuses = DEFAULT_ISSUES_QUERY.simpleStatuses.split(',') as IssueSimpleStatus[]; - -export function SimpleStatusFacet(props: Readonly) { - const { simpleStatuses = [], stats = {}, fetching, open, help, needIssueSync } = props; - const intl = useIntl(); - - const nbSelectableItems = SIMPLE_STATUSES.filter( - (item) => !defaultStatuses.includes(item) && stats[item], - ).length; - const hasDefaultSelection = isEqual(sortBy(simpleStatuses), sortBy(defaultStatuses)); - const nbSelectedItems = hasDefaultSelection ? 0 : simpleStatuses.length; - - return ( - - props.onChange({ - [property]: defaultStatuses, - }) - } - onClick={() => props.onToggle(property)} - open={open} - help={help} - > - - {SIMPLE_STATUSES.map((item) => { - const active = simpleStatuses.includes(item); - const stat = stats[item]; - - return ( - { - if (multiple) { - props.onChange({ - [property]: active - ? without(simpleStatuses, itemValue) - : [...simpleStatuses, itemValue], - }); - } else { - props.onChange({ - [property]: active && simpleStatuses.length === 1 ? [] : [itemValue], - }); - } - }} - stat={(!needIssueSync && formatFacetStat(stat)) ?? 0} - value={item} - /> - ); - })} - - - - - ); -} diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/Sidebar-it.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/Sidebar-it.tsx index cd19d2908bb..58a518e30ec 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/Sidebar-it.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/Sidebar-it.tsx @@ -51,7 +51,7 @@ it('should render correct facets for Application', () => { 'issues.facet.impactSeverities', 'issues.facet.types', 'issues.facet.scopes', - 'issues.facet.simpleStatuses', + 'issues.facet.issueStatuses', 'issues.facet.standards', 'issues.facet.createdAt', 'issues.facet.languages', @@ -73,7 +73,7 @@ it('should render correct facets for Portfolio', () => { 'issues.facet.impactSeverities', 'issues.facet.types', 'issues.facet.scopes', - 'issues.facet.simpleStatuses', + 'issues.facet.issueStatuses', 'issues.facet.standards', 'issues.facet.createdAt', 'issues.facet.languages', @@ -95,7 +95,7 @@ it('should render correct facets for SubPortfolio', () => { 'issues.facet.impactSeverities', 'issues.facet.types', 'issues.facet.scopes', - 'issues.facet.simpleStatuses', + 'issues.facet.issueStatuses', 'issues.facet.standards', 'issues.facet.createdAt', 'issues.facet.languages', diff --git a/server/sonar-web/src/main/js/apps/issues/test-utils.tsx b/server/sonar-web/src/main/js/apps/issues/test-utils.tsx index 5079125b95f..20514054359 100644 --- a/server/sonar-web/src/main/js/apps/issues/test-utils.tsx +++ b/server/sonar-web/src/main/js/apps/issues/test-utils.tsx @@ -74,7 +74,7 @@ export const ui = { resolutionFacet: byRole('button', { name: 'issues.facet.resolutions' }), ruleFacet: byRole('button', { name: 'issues.facet.rules' }), scopeFacet: byRole('button', { name: 'issues.facet.scopes' }), - simpleStatusFacet: byRole('button', { name: 'issues.facet.simpleStatuses' }), + issueStatusFacet: byRole('button', { name: 'issues.facet.issueStatuses' }), tagFacet: byRole('button', { name: 'issues.facet.tags' }), typeFacet: byRole('button', { name: 'issues.facet.types' }), cleanCodeAttributeCategoryFacet: byRole('button', { @@ -97,7 +97,7 @@ export const ui = { clearRuleFacet: byTestId('clear-issues.facet.rules'), clearScopeFacet: byTestId('clear-issues.facet.scopes'), clearSeverityFacet: byTestId('clear-issues.facet.impactSeverities'), - clearSimpleStatusFacet: byTestId('clear-issues.facet.simpleStatuses'), + clearIssueStatusFacet: byTestId('clear-issues.facet.issueStatuses'), clearTagFacet: byTestId('clear-issues.facet.tags'), responsibleCategoryFilter: byRole('checkbox', { @@ -110,11 +110,11 @@ export const ui = { name: `software_quality.${SoftwareQuality.Maintainability}`, }), codeSmellIssueTypeFilter: byRole('checkbox', { name: 'issue.type.CODE_SMELL' }), - confirmedStatusFilter: byRole('checkbox', { name: 'issue.simple_status.CONFIRMED' }), + confirmedStatusFilter: byRole('checkbox', { name: 'issue.issue_status.CONFIRMED' }), fixedResolutionFilter: byRole('checkbox', { name: 'issue.resolution.FIXED' }), mainScopeFilter: byRole('checkbox', { name: 'issue.scope.MAIN' }), mediumSeverityFilter: byRole('checkbox', { name: `severity.${SoftwareImpactSeverity.Medium}` }), - openStatusFilter: byRole('checkbox', { name: 'issue.simple_status.OPEN' }), + openStatusFilter: byRole('checkbox', { name: 'issue.issue_status.OPEN' }), vulnerabilityIssueTypeFilter: byRole('checkbox', { name: 'issue.type.VULNERABILITY' }), bulkChangeComment: byRole('textbox', { name: /issue_bulk_change.resolution_comment/ }), diff --git a/server/sonar-web/src/main/js/apps/issues/utils.ts b/server/sonar-web/src/main/js/apps/issues/utils.ts index 85ebc2f8d99..664a01d2515 100644 --- a/server/sonar-web/src/main/js/apps/issues/utils.ts +++ b/server/sonar-web/src/main/js/apps/issues/utils.ts @@ -41,8 +41,8 @@ import { } from '../../types/clean-code-taxonomy'; import { Facet, + IssueDeprecatedStatus, IssueResolution, - IssueSimpleStatus, IssueStatus, RawFacet, } from '../../types/issues'; @@ -83,7 +83,7 @@ export interface Query { inNewCodePeriod: boolean; sonarsourceSecurity: string[]; sort: string; - simpleStatuses: IssueSimpleStatus[]; + issueStatuses: IssueStatus[]; tags: string[]; types: string[]; } @@ -130,44 +130,47 @@ export function parseQuery(query: RawQuery): Query { severities: parseAsArray(query.severities, parseAsString), sonarsourceSecurity: parseAsArray(query.sonarsourceSecurity, parseAsString), sort: parseAsSort(query.s), - simpleStatuses: parseSimpleStatuses(query), + issueStatuses: parseIssueStatuses(query), tags: parseAsArray(query.tags, parseAsString), types: parseAsArray(query.types, parseAsString), codeVariants: parseAsArray(query.codeVariants, parseAsString), }; } -function parseSimpleStatuses(query: RawQuery) { - let result: Array = []; +function parseIssueStatuses(query: RawQuery) { + let result: Array = []; - if (query.simpleStatuses) { - return parseAsArray(query.simpleStatuses, parseAsString); + if (query.issueStatuses) { + return parseAsArray(query.issueStatuses, parseAsString); } const deprecatedStatusesMap = { - [IssueStatus.Open]: [IssueSimpleStatus.Open], - [IssueStatus.Confirmed]: [IssueSimpleStatus.Confirmed], - [IssueStatus.Reopened]: [IssueSimpleStatus.Open], - [IssueStatus.Resolved]: [ - IssueSimpleStatus.Fixed, - IssueSimpleStatus.Accepted, - IssueSimpleStatus.FalsePositive, + [IssueDeprecatedStatus.Open]: [IssueStatus.Open], + [IssueDeprecatedStatus.Confirmed]: [IssueStatus.Confirmed], + [IssueDeprecatedStatus.Reopened]: [IssueStatus.Open], + [IssueDeprecatedStatus.Resolved]: [ + IssueStatus.Fixed, + IssueStatus.Accepted, + IssueStatus.FalsePositive, ], - [IssueStatus.Closed]: [IssueSimpleStatus.Fixed], + [IssueDeprecatedStatus.Closed]: [IssueStatus.Fixed], }; const deprecatedResolutionsMap = { - [IssueResolution.FalsePositive]: [IssueSimpleStatus.FalsePositive], - [IssueResolution.WontFix]: [IssueSimpleStatus.Accepted], - [IssueResolution.Fixed]: [IssueSimpleStatus.Fixed], - [IssueResolution.Removed]: [IssueSimpleStatus.Fixed], - [IssueResolution.Unresolved]: [IssueSimpleStatus.Open, IssueSimpleStatus.Confirmed], + [IssueResolution.FalsePositive]: [IssueStatus.FalsePositive], + [IssueResolution.WontFix]: [IssueStatus.Accepted], + [IssueResolution.Fixed]: [IssueStatus.Fixed], + [IssueResolution.Removed]: [IssueStatus.Fixed], + [IssueResolution.Unresolved]: [IssueStatus.Open, IssueStatus.Confirmed], }; - const simpleStatusesFromStatuses = parseAsArray(query.statuses, parseAsString) + const issuesStatusesFromDeprecatedStatuses = parseAsArray( + query.statuses, + parseAsString, + ) .map((status) => deprecatedStatusesMap[status]) .filter(Boolean) .flat(); - const simpleStatusesFromResolutions = parseAsArray( + const issueStatusesFromResolutions = parseAsArray( query.resolutions, parseAsString, ) @@ -175,22 +178,20 @@ function parseSimpleStatuses(query: RawQuery) { .filter(Boolean) .flat(); - const intesectedSimpleStatuses = intersection( - simpleStatusesFromStatuses, - simpleStatusesFromResolutions, + const intesectedIssueStatuses = intersection( + issuesStatusesFromDeprecatedStatuses, + issueStatusesFromResolutions, ); - result = intesectedSimpleStatuses.length - ? intesectedSimpleStatuses - : simpleStatusesFromResolutions.concat(simpleStatusesFromStatuses); + result = intesectedIssueStatuses.length + ? intesectedIssueStatuses + : issueStatusesFromResolutions.concat(issuesStatusesFromDeprecatedStatuses); if ( query.resolved === 'false' && - [IssueSimpleStatus.Open, IssueSimpleStatus.Confirmed].every( - (status) => !result.includes(status), - ) + [IssueStatus.Open, IssueStatus.Confirmed].every((status) => !result.includes(status)) ) { result = result.concat( - parseAsArray(DEFAULT_ISSUES_QUERY.simpleStatuses, parseAsString), + parseAsArray(DEFAULT_ISSUES_QUERY.issueStatuses, parseAsString), ); } @@ -238,7 +239,7 @@ export function serializeQuery(query: Query): RawQuery { impactSoftwareQualities: serializeStringArray(query.impactSoftwareQualities), inNewCodePeriod: query.inNewCodePeriod ? 'true' : undefined, sonarsourceSecurity: serializeStringArray(query.sonarsourceSecurity), - simpleStatuses: serializeStringArray(query.simpleStatuses), + issueStatuses: serializeStringArray(query.issueStatuses), tags: serializeStringArray(query.tags), types: serializeStringArray(query.types), codeVariants: serializeStringArray(query.codeVariants), -- cgit v1.2.3