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 --- .../src/main/js/api/mocks/IssuesServiceMock.ts | 41 ++++---- .../sonar-web/src/main/js/api/mocks/data/issues.ts | 10 +- .../src/main/js/api/mocks/data/measures.ts | 10 +- .../__tests__/ComponentContainer-test.tsx | 4 +- .../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 ++++++------- .../components/__tests__/BranchQualityGate-it.tsx | 4 +- .../__snapshots__/loadIssues-test.ts.snap | 4 +- .../main/js/components/icons/IssueStatusIcon.tsx | 62 ++++++++++++ .../main/js/components/icons/SimpleStatusIcon.tsx | 62 ------------ .../js/components/issue/__tests__/Issue-it.tsx | 14 +-- .../issue/components/IssueTransition.tsx | 8 +- .../src/main/js/components/shared/StatusHelper.tsx | 10 +- .../js/components/shared/__tests__/utils-test.ts | 4 +- .../src/main/js/components/shared/utils.ts | 12 +-- server/sonar-web/src/main/js/helpers/constants.ts | 14 +-- server/sonar-web/src/main/js/helpers/issues.ts | 18 ++-- .../sonar-web/src/main/js/helpers/mocks/issues.ts | 2 +- server/sonar-web/src/main/js/helpers/testMocks.ts | 10 +- server/sonar-web/src/main/js/types/issues.ts | 6 +- server/sonar-web/src/main/js/types/types.ts | 4 +- 30 files changed, 352 insertions(+), 360 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 create mode 100644 server/sonar-web/src/main/js/components/icons/IssueStatusIcon.tsx delete mode 100644 server/sonar-web/src/main/js/components/icons/SimpleStatusIcon.tsx (limited to 'server/sonar-web/src') 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 48027575795..35ad8e2f3a3 100644 --- a/server/sonar-web/src/main/js/api/mocks/IssuesServiceMock.ts +++ b/server/sonar-web/src/main/js/api/mocks/IssuesServiceMock.ts @@ -20,7 +20,7 @@ import { cloneDeep, uniqueId } from 'lodash'; import { RuleDescriptionSections } from '../../apps/coding-rules/rule'; -import { ISSUE_TYPES, SEVERITIES, SIMPLE_STATUSES, SOURCE_SCOPES } from '../../helpers/constants'; +import { ISSUE_STATUSES, ISSUE_TYPES, SEVERITIES, SOURCE_SCOPES } from '../../helpers/constants'; import { mockIssueAuthors, mockIssueChangelog } from '../../helpers/mocks/issues'; import { RequestData } from '../../helpers/request'; import { getStandards } from '../../helpers/security-standard'; @@ -33,7 +33,7 @@ import { import { SearchRulesResponse } from '../../types/coding-rules'; import { ASSIGNEE_ME, - IssueSimpleStatus, + IssueDeprecatedStatus, IssueStatus, IssueTransition, IssueType, @@ -331,7 +331,7 @@ export default class IssuesServiceMock { values: ( { severities: SEVERITIES, - simpleStatuses: SIMPLE_STATUSES, + issueStatuses: ISSUE_STATUSES, types: ISSUE_TYPES, scopes: SOURCE_SCOPES.map(({ scope }) => scope), projects: ['org.project1', 'org.project2'], @@ -384,8 +384,7 @@ export default class IssuesServiceMock { const filteredList = this.list .filter( (item) => - !query.simpleStatuses || - query.simpleStatuses.split(',').includes(item.issue.simpleStatus), + !query.issueStatuses || query.issueStatuses.split(',').includes(item.issue.issueStatus), ) .filter((item) => { if (!query.cleanCodeAttributeCategories) { @@ -518,39 +517,39 @@ export default class IssuesServiceMock { }; handleSetIssueTransition = (data: { issue: string; transition: string }) => { - const simpleStatusMap: { [key: string]: IssueSimpleStatus } = { - [IssueTransition.Accept]: IssueSimpleStatus.Accepted, - [IssueTransition.Confirm]: IssueSimpleStatus.Confirmed, - [IssueTransition.UnConfirm]: IssueSimpleStatus.Open, - [IssueTransition.Resolve]: IssueSimpleStatus.Fixed, - [IssueTransition.WontFix]: IssueSimpleStatus.Accepted, - [IssueTransition.FalsePositive]: IssueSimpleStatus.FalsePositive, + const issueStatusMap: { [key: string]: IssueStatus } = { + [IssueTransition.Accept]: IssueStatus.Accepted, + [IssueTransition.Confirm]: IssueStatus.Confirmed, + [IssueTransition.UnConfirm]: IssueStatus.Open, + [IssueTransition.Resolve]: IssueStatus.Fixed, + [IssueTransition.WontFix]: IssueStatus.Accepted, + [IssueTransition.FalsePositive]: IssueStatus.FalsePositive, }; const transitionMap: Dict = { - [IssueSimpleStatus.Open]: [ + [IssueStatus.Open]: [ IssueTransition.Accept, IssueTransition.Confirm, IssueTransition.Resolve, IssueTransition.FalsePositive, IssueTransition.WontFix, ], - [IssueSimpleStatus.Confirmed]: [ + [IssueStatus.Confirmed]: [ IssueTransition.Accept, IssueTransition.Resolve, IssueTransition.UnConfirm, IssueTransition.FalsePositive, IssueTransition.WontFix, ], - [IssueSimpleStatus.FalsePositive]: [IssueTransition.Reopen], - [IssueSimpleStatus.Accepted]: [IssueTransition.Reopen], - [IssueSimpleStatus.Fixed]: [IssueTransition.Reopen], + [IssueStatus.FalsePositive]: [IssueTransition.Reopen], + [IssueStatus.Accepted]: [IssueTransition.Reopen], + [IssueStatus.Fixed]: [IssueTransition.Reopen], }; return this.getActionsResponse( { - simpleStatus: simpleStatusMap[data.transition], - transitions: transitionMap[simpleStatusMap[data.transition]], + issueStatus: issueStatusMap[data.transition], + transitions: transitionMap[issueStatusMap[data.transition]], }, data.issue, ); @@ -639,8 +638,8 @@ export default class IssuesServiceMock { diffs: [ { key: 'status', - newValue: IssueStatus.Reopened, - oldValue: IssueStatus.Confirmed, + newValue: IssueDeprecatedStatus.Reopened, + oldValue: IssueDeprecatedStatus.Confirmed, }, ], }), diff --git a/server/sonar-web/src/main/js/api/mocks/data/issues.ts b/server/sonar-web/src/main/js/api/mocks/data/issues.ts index 116e77c6771..d2634d338e8 100644 --- a/server/sonar-web/src/main/js/api/mocks/data/issues.ts +++ b/server/sonar-web/src/main/js/api/mocks/data/issues.ts @@ -28,10 +28,10 @@ import { } from '../../../types/clean-code-taxonomy'; import { IssueActions, + IssueDeprecatedStatus, IssueResolution, IssueScope, IssueSeverity, - IssueSimpleStatus, IssueStatus, IssueTransition, IssueType, @@ -318,8 +318,8 @@ export function mockIssuesList(baseComponentKey = PARENT_COMPONENT_KEY): IssueDa { softwareQuality: SoftwareQuality.Security, severity: SoftwareImpactSeverity.High }, ], resolution: IssueResolution.Unresolved, - status: IssueStatus.Open, - simpleStatus: IssueSimpleStatus.Open, + status: IssueDeprecatedStatus.Open, + issueStatus: IssueStatus.Open, ruleDescriptionContextKey: 'spring', }), snippets: keyBy( @@ -346,8 +346,8 @@ export function mockIssuesList(baseComponentKey = PARENT_COMPONENT_KEY): IssueDa endOffset: 1, }, resolution: IssueResolution.Fixed, - status: IssueStatus.Confirmed, - simpleStatus: IssueSimpleStatus.Confirmed, + status: IssueDeprecatedStatus.Confirmed, + issueStatus: IssueStatus.Confirmed, }), snippets: keyBy( [ diff --git a/server/sonar-web/src/main/js/api/mocks/data/measures.ts b/server/sonar-web/src/main/js/api/mocks/data/measures.ts index de6dabf1daa..5e019ff7e08 100644 --- a/server/sonar-web/src/main/js/api/mocks/data/measures.ts +++ b/server/sonar-web/src/main/js/api/mocks/data/measures.ts @@ -21,7 +21,7 @@ import { keyBy } from 'lodash'; import { isDiffMetric } from '../../../helpers/measures'; import { mockMeasure } from '../../../helpers/testMocks'; -import { IssueStatus, IssueType, RawIssue } from '../../../types/issues'; +import { IssueDeprecatedStatus, IssueType, RawIssue } from '../../../types/issues'; import { MetricKey } from '../../../types/metrics'; import { Measure } from '../../../types/types'; import { ComponentTree } from './components'; @@ -62,9 +62,11 @@ function mockComponentMeasure(tree: ComponentTree, issueList: IssueData[], metri .map(({ issue }) => issue) .filter(({ component }) => componentKeys.includes(component)) .filter(({ status }) => - [IssueStatus.Open, IssueStatus.Reopened, IssueStatus.Confirmed].includes( - status as IssueStatus, - ), + [ + IssueDeprecatedStatus.Open, + IssueDeprecatedStatus.Reopened, + IssueDeprecatedStatus.Confirmed, + ].includes(status as IssueDeprecatedStatus), ); if (isIssueType(metricKey)) { diff --git a/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx b/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx index c9c1f352fc2..76e98ef85d0 100644 --- a/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx +++ b/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx @@ -87,7 +87,7 @@ it('should render the component nav correctly for portfolio', async () => { expect(await ui.portfolioTitle.find()).toHaveAttribute('href', '/portfolio?id=portfolioKey'); expect(ui.issuesPageLink.get()).toHaveAttribute( 'href', - '/project/issues?id=portfolioKey&simpleStatuses=OPEN%2CCONFIRMED', + '/project/issues?id=portfolioKey&issueStatuses=OPEN%2CCONFIRMED', ); expect(ui.measuresPageLink.get()).toHaveAttribute('href', '/component_measures?id=portfolioKey'); expect(ui.activityPageLink.get()).toHaveAttribute('href', '/project/activity?id=portfolioKey'); @@ -119,7 +119,7 @@ it('should render the component nav correctly for projects', async () => { expect(ui.overviewPageLink.get()).toHaveAttribute('href', '/dashboard?id=project-key'); expect(ui.issuesPageLink.get()).toHaveAttribute( 'href', - '/project/issues?id=project-key&simpleStatuses=OPEN%2CCONFIRMED', + '/project/issues?id=project-key&issueStatuses=OPEN%2CCONFIRMED', ); expect(ui.hotspotsPageLink.get()).toHaveAttribute('href', '/security_hotspots?id=project-key'); expect(ui.measuresPageLink.get()).toHaveAttribute('href', '/component_measures?id=project-key'); 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), diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/BranchQualityGate-it.tsx b/server/sonar-web/src/main/js/apps/overview/components/__tests__/BranchQualityGate-it.tsx index a38af0f8da2..1731d8793db 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/__tests__/BranchQualityGate-it.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/BranchQualityGate-it.tsx @@ -39,7 +39,7 @@ it('renders failed QG', () => { expect(maintainabilityRatingLink).toBeInTheDocument(); expect(maintainabilityRatingLink).toHaveAttribute( 'href', - '/project/issues?simpleStatuses=OPEN%2CCONFIRMED&types=CODE_SMELL&pullRequest=1001&sinceLeakPeriod=true&id=my-project', + '/project/issues?issueStatuses=OPEN%2CCONFIRMED&types=CODE_SMELL&pullRequest=1001&sinceLeakPeriod=true&id=my-project', ); // Security Hotspots rating condition @@ -59,7 +59,7 @@ it('renders failed QG', () => { expect(codeSmellsLink).toBeInTheDocument(); expect(codeSmellsLink).toHaveAttribute( 'href', - '/project/issues?simpleStatuses=OPEN%2CCONFIRMED&types=CODE_SMELL&pullRequest=1001&id=my-project', + '/project/issues?issueStatuses=OPEN%2CCONFIRMED&types=CODE_SMELL&pullRequest=1001&id=my-project', ); // Conditions to cover diff --git a/server/sonar-web/src/main/js/components/SourceViewer/helpers/__tests__/__snapshots__/loadIssues-test.ts.snap b/server/sonar-web/src/main/js/components/SourceViewer/helpers/__tests__/__snapshots__/loadIssues-test.ts.snap index 2aba8958d02..d1ec2c58c33 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/helpers/__tests__/__snapshots__/loadIssues-test.ts.snap +++ b/server/sonar-web/src/main/js/components/SourceViewer/helpers/__tests__/__snapshots__/loadIssues-test.ts.snap @@ -22,6 +22,7 @@ exports[`loadIssues should load issues with listIssues if re-indexing 1`] = ` "flows": [], "flowsWithType": [], "hash": "78417dcee7ba927b7e7c9161e29e02b8", + "issueStatus": "OPEN", "key": "AWaqVGl3tut9VbnJvk6M", "line": 62, "message": "Make sure this file handling is safe here.", @@ -33,7 +34,6 @@ exports[`loadIssues should load issues with listIssues if re-indexing 1`] = ` "projectQualifier": "TRK", "rule": "squid:S4797", "secondaryLocations": [], - "simpleStatus": "OPEN", "status": "OPEN", "tags": [ "cert", @@ -80,6 +80,7 @@ exports[`loadIssues should load issues with searchIssues if not re-indexing 1`] "flows": [], "flowsWithType": [], "hash": "78417dcee7ba927b7e7c9161e29e02b8", + "issueStatus": "OPEN", "key": "AWaqVGl3tut9VbnJvk6M", "line": 62, "message": "Make sure this file handling is safe here.", @@ -96,7 +97,6 @@ exports[`loadIssues should load issues with searchIssues if not re-indexing 1`] "ruleName": "Handling files is security-sensitive", "ruleStatus": "READY", "secondaryLocations": [], - "simpleStatus": "OPEN", "status": "OPEN", "tags": [ "cert", diff --git a/server/sonar-web/src/main/js/components/icons/IssueStatusIcon.tsx b/server/sonar-web/src/main/js/components/icons/IssueStatusIcon.tsx new file mode 100644 index 00000000000..ef2a2dbfdf8 --- /dev/null +++ b/server/sonar-web/src/main/js/components/icons/IssueStatusIcon.tsx @@ -0,0 +1,62 @@ +/* + * 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 { + StatusConfirmedIcon, + StatusOpenIcon, + StatusReopenedIcon, + StatusResolvedIcon, +} from 'design-system'; +import * as React from 'react'; +import { IssueStatus } from '../../types/issues'; +import { Dict } from '../../types/types'; +import { IconProps } from './Icon'; + +interface Props extends IconProps { + issueStatus: IssueStatus; +} + +const statusIcons: Dict<(props: IconProps) => React.ReactElement> = { + [IssueStatus.Accepted]: StatusConfirmedIcon, + [IssueStatus.Confirmed]: StatusConfirmedIcon, + [IssueStatus.FalsePositive]: StatusResolvedIcon, + [IssueStatus.Fixed]: StatusResolvedIcon, + [IssueStatus.Open]: StatusOpenIcon, + closed: StatusResolvedIcon, + confirm: StatusConfirmedIcon, + confirmed: StatusConfirmedIcon, + falsepositive: StatusResolvedIcon, + in_review: StatusConfirmedIcon, + open: StatusOpenIcon, + reopened: StatusReopenedIcon, + reopen: StatusReopenedIcon, + unconfirm: StatusReopenedIcon, + resolve: StatusResolvedIcon, + resolved: StatusResolvedIcon, + reviewed: StatusResolvedIcon, + to_review: StatusOpenIcon, + wontfix: StatusResolvedIcon, +}; + +export default function IssueStatusIcon({ issueStatus, ...iconProps }: Props) { + const DesiredStatusIcon = statusIcons[issueStatus.toLowerCase()]; + + return DesiredStatusIcon ? : null; +} diff --git a/server/sonar-web/src/main/js/components/icons/SimpleStatusIcon.tsx b/server/sonar-web/src/main/js/components/icons/SimpleStatusIcon.tsx deleted file mode 100644 index 6e25c4f2b49..00000000000 --- a/server/sonar-web/src/main/js/components/icons/SimpleStatusIcon.tsx +++ /dev/null @@ -1,62 +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 { - StatusConfirmedIcon, - StatusOpenIcon, - StatusReopenedIcon, - StatusResolvedIcon, -} from 'design-system'; -import * as React from 'react'; -import { IssueSimpleStatus } from '../../types/issues'; -import { Dict } from '../../types/types'; -import { IconProps } from './Icon'; - -interface Props extends IconProps { - simpleStatus: IssueSimpleStatus; -} - -const statusIcons: Dict<(props: IconProps) => React.ReactElement> = { - [IssueSimpleStatus.Accepted]: StatusConfirmedIcon, - [IssueSimpleStatus.Confirmed]: StatusConfirmedIcon, - [IssueSimpleStatus.FalsePositive]: StatusResolvedIcon, - [IssueSimpleStatus.Fixed]: StatusResolvedIcon, - [IssueSimpleStatus.Open]: StatusOpenIcon, - closed: StatusResolvedIcon, - confirm: StatusConfirmedIcon, - confirmed: StatusConfirmedIcon, - falsepositive: StatusResolvedIcon, - in_review: StatusConfirmedIcon, - open: StatusOpenIcon, - reopened: StatusReopenedIcon, - reopen: StatusReopenedIcon, - unconfirm: StatusReopenedIcon, - resolve: StatusResolvedIcon, - resolved: StatusResolvedIcon, - reviewed: StatusResolvedIcon, - to_review: StatusOpenIcon, - wontfix: StatusResolvedIcon, -}; - -export default function SimpleStatusIcon({ simpleStatus, ...iconProps }: Props) { - const DesiredStatusIcon = statusIcons[simpleStatus.toLowerCase()]; - - return DesiredStatusIcon ? : null; -} diff --git a/server/sonar-web/src/main/js/components/issue/__tests__/Issue-it.tsx b/server/sonar-web/src/main/js/components/issue/__tests__/Issue-it.tsx index eb9c9880faa..b0584d15771 100644 --- a/server/sonar-web/src/main/js/components/issue/__tests__/Issue-it.tsx +++ b/server/sonar-web/src/main/js/components/issue/__tests__/Issue-it.tsx @@ -32,7 +32,7 @@ import { ComponentPropsType } from '../../../helpers/testUtils'; import { IssueActions, IssueSeverity, - IssueSimpleStatus, + IssueStatus, IssueTransition, IssueType, } from '../../../types/issues'; @@ -97,7 +97,7 @@ describe('updating', () => { it('should allow updating the status', async () => { const { ui } = getPageObject(); const issue = mockRawIssue(false, { - simpleStatus: IssueSimpleStatus.Open, + issueStatus: IssueStatus.Open, transitions: [IssueTransition.Confirm, IssueTransition.UnConfirm], }); issuesHandler.setIssueList([{ issue, snippets: {} }]); @@ -105,8 +105,8 @@ describe('updating', () => { issue: mockIssue(false, { ...pick(issue, 'key', 'status', 'transitions') }), }); - await ui.updateStatus(IssueSimpleStatus.Open, IssueTransition.Confirm); - expect(ui.updateStatusBtn(IssueSimpleStatus.Confirmed).get()).toBeInTheDocument(); + await ui.updateStatus(IssueStatus.Open, IssueTransition.Confirm); + expect(ui.updateStatusBtn(IssueStatus.Confirmed).get()).toBeInTheDocument(); }); it('should allow assigning', async () => { @@ -244,8 +244,8 @@ function getPageObject() { setSeverityBtn: (severity: IssueSeverity) => byText(`severity.${severity}`), // Status - updateStatusBtn: (currentStatus: IssueSimpleStatus) => - byLabelText(`issue.transition.status_x_click_to_change.issue.simple_status.${currentStatus}`), + updateStatusBtn: (currentStatus: IssueStatus) => + byLabelText(`issue.transition.status_x_click_to_change.issue.issue_status.${currentStatus}`), setStatusBtn: (transition: IssueTransition) => byText(`issue.transition.${transition}`), // Assignee @@ -297,7 +297,7 @@ function getPageObject() { await user.click(selectors.setSeverityBtn(newSeverity).get()); }); }, - async updateStatus(currentStatus: IssueSimpleStatus, transition: IssueTransition) { + async updateStatus(currentStatus: IssueStatus, transition: IssueTransition) { await user.click(selectors.updateStatusBtn(currentStatus).get()); await act(async () => { await user.click(selectors.setStatusBtn(transition).get()); diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueTransition.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueTransition.tsx index 5f0fab73147..31a44cdadb8 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueTransition.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueTransition.tsx @@ -29,7 +29,7 @@ import { IssueTransitionOverlay } from './IssueTransitionOverlay'; interface Props { isOpen: boolean; - issue: Pick; + issue: Pick; onChange: (issue: Issue) => void; togglePopup: (popup: string, show?: boolean) => void; } @@ -91,11 +91,11 @@ export default function IssueTransition(props: Readonly) { isDiscreet className="it__issue-transition sw-px-1" label={ - + } ariaLabel={translateWithParameters( 'issue.transition.status_x_click_to_change', - translate('issue.simple_status', issue.simpleStatus), + translate('issue.issue_status', issue.issueStatus), )} /> )} @@ -103,5 +103,5 @@ export default function IssueTransition(props: Readonly) { ); } - return ; + return ; } diff --git a/server/sonar-web/src/main/js/components/shared/StatusHelper.tsx b/server/sonar-web/src/main/js/components/shared/StatusHelper.tsx index 90ea9cf83b2..f3724cb8510 100644 --- a/server/sonar-web/src/main/js/components/shared/StatusHelper.tsx +++ b/server/sonar-web/src/main/js/components/shared/StatusHelper.tsx @@ -19,19 +19,19 @@ */ import * as React from 'react'; import { translate } from '../../helpers/l10n'; -import { IssueSimpleStatus } from '../../types/issues'; -import SimpleStatusIcon from '../icons/SimpleStatusIcon'; +import { IssueStatus } from '../../types/issues'; +import IssueStatusIcon from '../icons/IssueStatusIcon'; interface Props { className?: string; - simpleStatus: IssueSimpleStatus; + issueStatus: IssueStatus; } export default function StatusHelper(props: Props) { return ( - - {translate('issue.simple_status', props.simpleStatus)} + + {translate('issue.issue_status', props.issueStatus)} ); } diff --git a/server/sonar-web/src/main/js/components/shared/__tests__/utils-test.ts b/server/sonar-web/src/main/js/components/shared/__tests__/utils-test.ts index f83c2dfa817..dcb4062988e 100644 --- a/server/sonar-web/src/main/js/components/shared/__tests__/utils-test.ts +++ b/server/sonar-web/src/main/js/components/shared/__tests__/utils-test.ts @@ -23,13 +23,13 @@ import { propsToIssueParams } from '../utils'; describe('propsToIssueParams', () => { it('should render correct default parameters', () => { - expect(propsToIssueParams('other')).toEqual({ simpleStatuses: 'OPEN,CONFIRMED' }); + expect(propsToIssueParams('other')).toEqual({ issueStatuses: 'OPEN,CONFIRMED' }); }); it(`should render correct params`, () => { expect(propsToIssueParams(MetricKey.false_positive_issues, true)).toEqual({ inNewCodePeriod: true, - simpleStatuses: 'FALSE_POSITIVE', + issueStatuses: 'FALSE_POSITIVE', }); }); }); diff --git a/server/sonar-web/src/main/js/components/shared/utils.ts b/server/sonar-web/src/main/js/components/shared/utils.ts index 12358551c9e..bcfc4123e71 100644 --- a/server/sonar-web/src/main/js/components/shared/utils.ts +++ b/server/sonar-web/src/main/js/components/shared/utils.ts @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { IssueSimpleStatus } from '../../types/issues'; +import { IssueStatus } from '../../types/issues'; import { MetricKey } from '../../types/metrics'; import { Dict } from '../../types/types'; @@ -47,7 +47,7 @@ const ISSUE_MEASURES = [ ]; export const DEFAULT_ISSUES_QUERY = { - simpleStatuses: `${IssueSimpleStatus.Open},${IssueSimpleStatus.Confirmed}`, + issueStatuses: `${IssueStatus.Open},${IssueStatus.Confirmed}`, }; const issueParamsPerMetric: Dict> = { @@ -61,10 +61,10 @@ const issueParamsPerMetric: Dict> = { [MetricKey.new_minor_violations]: { severities: 'MINOR' }, [MetricKey.info_violations]: { severities: 'INFO' }, [MetricKey.new_info_violations]: { severities: 'INFO' }, - [MetricKey.open_issues]: { simpleStatuses: IssueSimpleStatus.Open }, - [MetricKey.reopened_issues]: { simpleStatuses: IssueSimpleStatus.Open }, - [MetricKey.confirmed_issues]: { simpleStatuses: IssueSimpleStatus.Confirmed }, - [MetricKey.false_positive_issues]: { simpleStatuses: IssueSimpleStatus.FalsePositive }, + [MetricKey.open_issues]: { issueStatuses: IssueStatus.Open }, + [MetricKey.reopened_issues]: { issueStatuses: IssueStatus.Open }, + [MetricKey.confirmed_issues]: { issueStatuses: IssueStatus.Confirmed }, + [MetricKey.false_positive_issues]: { issueStatuses: IssueStatus.FalsePositive }, [MetricKey.code_smells]: { types: 'CODE_SMELL' }, [MetricKey.new_code_smells]: { types: 'CODE_SMELL' }, [MetricKey.bugs]: { types: 'BUG' }, diff --git a/server/sonar-web/src/main/js/helpers/constants.ts b/server/sonar-web/src/main/js/helpers/constants.ts index 20d4cab5b02..5dd32be9e4e 100644 --- a/server/sonar-web/src/main/js/helpers/constants.ts +++ b/server/sonar-web/src/main/js/helpers/constants.ts @@ -29,7 +29,7 @@ import { IssueResolution, IssueScope, IssueSeverity, - IssueSimpleStatus, + IssueStatus, IssueType, } from '../types/issues'; import { RuleType } from '../types/types'; @@ -44,12 +44,12 @@ export const SOFTWARE_QUALITIES = Object.values(SoftwareQuality); export const STATUSES = ['OPEN', 'CONFIRMED', 'REOPENED', 'RESOLVED', 'CLOSED']; -export const SIMPLE_STATUSES = [ - IssueSimpleStatus.Open, - IssueSimpleStatus.Accepted, - IssueSimpleStatus.FalsePositive, - IssueSimpleStatus.Confirmed, - IssueSimpleStatus.Fixed, +export const ISSUE_STATUSES = [ + IssueStatus.Open, + IssueStatus.Accepted, + IssueStatus.FalsePositive, + IssueStatus.Confirmed, + IssueStatus.Fixed, ]; export const ISSUE_TYPES: IssueType[] = [ diff --git a/server/sonar-web/src/main/js/helpers/issues.ts b/server/sonar-web/src/main/js/helpers/issues.ts index 54db9489922..10cb28acc07 100644 --- a/server/sonar-web/src/main/js/helpers/issues.ts +++ b/server/sonar-web/src/main/js/helpers/issues.ts @@ -19,7 +19,7 @@ */ import { BugIcon, CodeSmellIcon, SecurityHotspotIcon, VulnerabilityIcon } from 'design-system'; import { flatten, sortBy } from 'lodash'; -import { IssueSimpleStatus, IssueStatus, IssueType, RawIssue } from '../types/issues'; +import { IssueDeprecatedStatus, IssueStatus, IssueType, RawIssue } from '../types/issues'; import { MetricKey } from '../types/metrics'; import { Dict, Flow, FlowLocation, FlowType, Issue, TextRange } from '../types/types'; import { UserBase } from '../types/users'; @@ -160,16 +160,16 @@ export function parseIssueFromResponse( ...splitFlows(issue, components), ...prepareClosed(issue), ...ensureTextRange(issue), - simpleStatus: - issue.simpleStatus ?? + issueStatus: + issue.issueStatus ?? { - [IssueStatus.Open]: IssueSimpleStatus.Open, - [IssueStatus.Reopened]: IssueSimpleStatus.Open, - [IssueStatus.Closed]: IssueSimpleStatus.Fixed, - [IssueStatus.Resolved]: IssueSimpleStatus.Fixed, - [IssueStatus.Confirmed]: IssueSimpleStatus.Confirmed, + [IssueDeprecatedStatus.Open]: IssueStatus.Open, + [IssueDeprecatedStatus.Reopened]: IssueStatus.Open, + [IssueDeprecatedStatus.Closed]: IssueStatus.Fixed, + [IssueDeprecatedStatus.Resolved]: IssueStatus.Fixed, + [IssueDeprecatedStatus.Confirmed]: IssueStatus.Confirmed, }[issue.status] ?? - IssueSimpleStatus.Open, + IssueStatus.Open, } as Issue; } diff --git a/server/sonar-web/src/main/js/helpers/mocks/issues.ts b/server/sonar-web/src/main/js/helpers/mocks/issues.ts index dedc2f1ff1d..6bb8f194838 100644 --- a/server/sonar-web/src/main/js/helpers/mocks/issues.ts +++ b/server/sonar-web/src/main/js/helpers/mocks/issues.ts @@ -82,7 +82,7 @@ export function mockQuery(overrides: Partial = {}): Query { impactSoftwareQualities: [], inNewCodePeriod: false, sonarsourceSecurity: [], - simpleStatuses: [], + issueStatuses: [], sort: '', tags: [], types: [], diff --git a/server/sonar-web/src/main/js/helpers/testMocks.ts b/server/sonar-web/src/main/js/helpers/testMocks.ts index 44c433f0bd6..a815fac07a0 100644 --- a/server/sonar-web/src/main/js/helpers/testMocks.ts +++ b/server/sonar-web/src/main/js/helpers/testMocks.ts @@ -33,9 +33,9 @@ import { import { RuleRepository } from '../types/coding-rules'; import { EditionKey } from '../types/editions'; import { + IssueDeprecatedStatus, IssueScope, IssueSeverity, - IssueSimpleStatus, IssueStatus, IssueType, RawIssue, @@ -312,8 +312,8 @@ export function mockRawIssue(withLocations = false, overrides: Partial severity: IssueSeverity.Major, textRange: { startLine: 25, endLine: 26, startOffset: 0, endOffset: 15 }, type: IssueType.CodeSmell, - status: IssueStatus.Open, - simpleStatus: IssueSimpleStatus.Open, + status: IssueDeprecatedStatus.Open, + issueStatus: IssueStatus.Open, transitions: [], scope: IssueScope.Main, cleanCodeAttributeCategory: CleanCodeAttributeCategory.Responsible, @@ -365,8 +365,8 @@ export function mockIssue(withLocations = false, overrides: Partial = {}) scope: IssueScope.Main, secondaryLocations: [], severity: IssueSeverity.Major, - status: IssueStatus.Open, - simpleStatus: IssueSimpleStatus.Open, + status: IssueDeprecatedStatus.Open, + issueStatus: IssueStatus.Open, textRange: { startLine: 25, endLine: 26, startOffset: 0, endOffset: 15 }, transitions: [], type: 'BUG', diff --git a/server/sonar-web/src/main/js/types/issues.ts b/server/sonar-web/src/main/js/types/issues.ts index 6dcba48dc6f..223164569e9 100644 --- a/server/sonar-web/src/main/js/types/issues.ts +++ b/server/sonar-web/src/main/js/types/issues.ts @@ -58,7 +58,7 @@ export enum IssueResolution { WontFix = 'WONTFIX', } -export enum IssueStatus { +export enum IssueDeprecatedStatus { Open = 'OPEN', Confirmed = 'CONFIRMED', Reopened = 'REOPENED', @@ -66,7 +66,7 @@ export enum IssueStatus { Closed = 'CLOSED', } -export enum IssueSimpleStatus { +export enum IssueStatus { Open = 'OPEN', Fixed = 'FIXED', Confirmed = 'CONFIRMED', @@ -149,7 +149,7 @@ export interface RawIssue { message?: string; severity: string; status: string; - simpleStatus: IssueSimpleStatus; + issueStatus: IssueStatus; textRange?: TextRange; type: IssueType; scope: string; diff --git a/server/sonar-web/src/main/js/types/types.ts b/server/sonar-web/src/main/js/types/types.ts index c0d8973b325..910fb3147be 100644 --- a/server/sonar-web/src/main/js/types/types.ts +++ b/server/sonar-web/src/main/js/types/types.ts @@ -25,7 +25,7 @@ import { SoftwareQuality, } from './clean-code-taxonomy'; import { ComponentQualifier, Visibility } from './component'; -import { IssueSimpleStatus, IssueTransition, MessageFormatting } from './issues'; +import { IssueStatus, IssueTransition, MessageFormatting } from './issues'; import { NewCodeDefinitionType } from './new-code-definition'; import { UserActive, UserBase } from './users'; @@ -291,7 +291,7 @@ export interface Issue { secondaryLocations: FlowLocation[]; severity: string; status: string; - simpleStatus: IssueSimpleStatus; + issueStatus: IssueStatus; tags?: string[]; textRange?: TextRange; transitions: IssueTransition[]; -- cgit v1.2.3