diff options
author | Viktor Vorona <viktor.vorona@sonarsource.com> | 2024-09-30 13:19:32 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-10-03 20:02:51 +0000 |
commit | 4b6cae980fe81ca8e6368785873159a868832426 (patch) | |
tree | 11c993e9b18bf5ea2960ce17dba49418cf1f4247 /server | |
parent | 2c51259de09747163b5c1f15e376263c2d10408c (diff) | |
download | sonarqube-4b6cae980fe81ca8e6368785873159a868832426.tar.gz sonarqube-4b6cae980fe81ca8e6368785873159a868832426.zip |
Revert "SONAR-23076 Hide ratings"
This reverts commit 11de475367bb8e3b1ffff53b8ef50e8c235584e0.
Diffstat (limited to 'server')
15 files changed, 74 insertions, 80 deletions
diff --git a/server/sonar-web/src/main/js/app/components/ChangeInCalculationPill.tsx b/server/sonar-web/src/main/js/app/components/ChangeInCalculationPill.tsx index b5c520e172d..deb82e402fe 100644 --- a/server/sonar-web/src/main/js/app/components/ChangeInCalculationPill.tsx +++ b/server/sonar-web/src/main/js/app/components/ChangeInCalculationPill.tsx @@ -23,6 +23,7 @@ import * as React from 'react'; import DocumentationLink from '../../components/common/DocumentationLink'; import { DocLink } from '../../helpers/doc-links'; import { translate } from '../../helpers/l10n'; +import { useIsLegacyCCTMode } from '../../queries/settings'; import { ComponentQualifier } from '../../sonar-aligned/types/component'; interface Props { @@ -31,11 +32,11 @@ interface Props { export default function ChangeInCalculation({ qualifier }: Readonly<Props>) { const [isPopoverOpen, setIsPopoverOpen] = React.useState(false); - // const { data: isLegacy, isLoading } = useIsLegacyCCTMode(); + const { data: isLegacy, isLoading } = useIsLegacyCCTMode(); - // if (isLegacy || isLoading) { - // return null; - // } + if (isLegacy || isLoading) { + return null; + } return ( <Popover diff --git a/server/sonar-web/src/main/js/apps/code/components/CodeAppRenderer.tsx b/server/sonar-web/src/main/js/apps/code/components/CodeAppRenderer.tsx index 806f2912122..39188e22ddf 100644 --- a/server/sonar-web/src/main/js/apps/code/components/CodeAppRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/CodeAppRenderer.tsx @@ -124,7 +124,7 @@ export default function CodeAppRenderer(props: Readonly<Props>) { ); const filteredMetrics = difference(metricKeys, [ - ...(allComponentsHaveSoftwareQualityMeasures + ...(allComponentsHaveSoftwareQualityMeasures && !isLegacy ? OLD_TAXONOMY_METRICS : CCT_SOFTWARE_QUALITY_METRICS), ...(allComponentsHaveRatings && !isLegacy diff --git a/server/sonar-web/src/main/js/apps/component-measures/__tests__/ComponentMeasures-it.tsx b/server/sonar-web/src/main/js/apps/component-measures/__tests__/ComponentMeasures-it.tsx index c43001836f6..01043b60288 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/__tests__/ComponentMeasures-it.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/__tests__/ComponentMeasures-it.tsx @@ -92,21 +92,20 @@ describe('rendering', () => { await user.click(ui.maintainabilityDomainBtn.get()); [ 'component_measures.metric.new_maintainability_issues.name 5', - 'Added Technical Debt work_duration.x_minutes.1', - 'Technical Debt Ratio on New Code 1.0%', - 'Maintainability Rating on New Code metric.has_rating_X.E metric.sqale_rating.tooltip.E.0.0%', + 'Software Quality Maintainability Remediation Effort on new code work_duration.x_minutes.1', + 'Software Quality Technical Debt Ratio on New Code 1.0%', + 'Software Quality Maintainability Rating on New Code metric.has_rating_X.D metric.software_quality_maintainability_rating.tooltip.D.0.0%', 'component_measures.metric.maintainability_issues.name 2', - 'Technical Debt work_duration.x_minutes.1', - 'Technical Debt Ratio 1.0%', - 'Maintainability Rating metric.has_rating_X.E metric.sqale_rating.tooltip.E.0.0%', - 'Effort to Reach Maintainability Rating A work_duration.x_minutes.1', + 'Software Quality Maintainability Remediation Effort work_duration.x_minutes.1', + 'Software Quality Technical Debt Ratio 1.0%', + 'Software Quality Maintainability Rating metric.has_rating_X.D metric.software_quality_maintainability_rating.tooltip.D.0.0%', + 'Software Quality Effort to Reach Maintainability Rating A work_duration.x_minutes.1', ].forEach((measure) => { expect(ui.measureLink(measure).get()).toBeInTheDocument(); }); }); - // eslint-disable-next-line jest/no-disabled-tests - it.skip('should correctly render the default overview and navigation in legacy mode', async () => { + it('should correctly render the default overview and navigation in legacy mode', async () => { settingsHandler.set(SettingsKey.LegacyMode, 'true'); const { ui, user } = getPageObject(); renderMeasuresApp(); @@ -209,11 +208,10 @@ describe('rendering', () => { ].forEach((measure) => { expect(ui.measureLink(measure).get()).toBeInTheDocument(); }); - // expect(screen.getByText('overview.missing_project_dataTRK')).toBeInTheDocument(); + expect(screen.getByText('overview.missing_project_dataTRK')).toBeInTheDocument(); }); - // eslint-disable-next-line jest/no-disabled-tests - it.skip('should show old measures and no flag message if no rating measures and legacy mode', async () => { + it('should show old measures and no flag message if no rating measures and legacy mode', async () => { settingsHandler.set(SettingsKey.LegacyMode, 'true'); measuresHandler.deleteComponentMeasure( 'foo', @@ -519,7 +517,7 @@ describe('navigation', () => { await user.click( ui .measureLink( - 'Maintainability Rating on New Code metric.has_rating_X.E metric.sqale_rating.tooltip.E.0.0%', + 'Software Quality Maintainability Rating metric.has_rating_X.D metric.software_quality_maintainability_rating.tooltip.D.0.0%', ) .get(), ); diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx index a3395ea2989..f12e7111e68 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx @@ -44,7 +44,10 @@ import { enhanceMeasure } from '../../../components/measure/utils'; import '../../../components/search-navigator.css'; import AnalysisMissingInfoMessage from '../../../components/shared/AnalysisMissingInfoMessage'; import { translate } from '../../../helpers/l10n'; -import { areCCTMeasuresComputed } from '../../../helpers/measures'; +import { + areCCTMeasuresComputed, + areSoftwareQualityRatingsComputed, +} from '../../../helpers/measures'; import { useCurrentBranchQuery } from '../../../queries/branch'; import { useMeasuresComponentQuery } from '../../../queries/measures'; @@ -223,7 +226,8 @@ export default function ComponentMeasuresApp() { /> </FlagMessage> )} - {!areCCTMeasuresComputed(measures) && ( + {(!areCCTMeasuresComputed(measures) || + !areSoftwareQualityRatingsComputed(measures)) && ( <AnalysisMissingInfoMessage className="sw-mb-4" qualifier={component?.qualifier as ComponentQualifier} diff --git a/server/sonar-web/src/main/js/apps/component-measures/utils.ts b/server/sonar-web/src/main/js/apps/component-measures/utils.ts index 3e1e38a7849..e47f720209e 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/utils.ts +++ b/server/sonar-web/src/main/js/apps/component-measures/utils.ts @@ -118,7 +118,7 @@ export const populateDomainsFromMeasures = memoize( }; }); - if (areLeakCCTMeasuresComputed(measures)) { + if (!isLegacy && areLeakCCTMeasuresComputed(measures)) { populatedMeasures = populatedMeasures.filter( (measure) => !LEAK_OLD_TAXONOMY_METRICS.includes(measure.metric.key as MetricKey), ); @@ -141,7 +141,7 @@ export const populateDomainsFromMeasures = memoize( ); } - if (areCCTMeasuresComputed(measures)) { + if (!isLegacy && areCCTMeasuresComputed(measures)) { populatedMeasures = populatedMeasures.filter( (measure) => !OLD_TAXONOMY_METRICS.includes(measure.metric.key as MetricKey), ); diff --git a/server/sonar-web/src/main/js/apps/overview/branches/BranchOverviewRenderer.tsx b/server/sonar-web/src/main/js/apps/overview/branches/BranchOverviewRenderer.tsx index a2004e6a902..6333d82a4ff 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/BranchOverviewRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/BranchOverviewRenderer.tsx @@ -29,7 +29,11 @@ import { CurrentUserContext } from '../../../app/components/current-user/Current import AnalysisMissingInfoMessage from '../../../components/shared/AnalysisMissingInfoMessage'; import { parseDate } from '../../../helpers/dates'; import { translate } from '../../../helpers/l10n'; -import { areCCTMeasuresComputed, isDiffMetric } from '../../../helpers/measures'; +import { + areCCTMeasuresComputed, + areSoftwareQualityRatingsComputed, + isDiffMetric, +} from '../../../helpers/measures'; import { CodeScope } from '../../../helpers/urls'; import { useProjectAiCodeAssuredQuery } from '../../../queries/ai-code-assurance'; import { useDismissNoticeMutation } from '../../../queries/users'; @@ -131,9 +135,8 @@ export default function BranchOverviewRenderer(props: BranchOverviewRendererProp ); // Check if any potentially missing uncomputed measure is not present - // const isMissingMeasures = - // !areCCTMeasuresComputed(measures) || !areSoftwareQualityRatingsComputed(measures); - const isMissingMeasures = !areCCTMeasuresComputed(measures); + const isMissingMeasures = + !areCCTMeasuresComputed(measures) || !areSoftwareQualityRatingsComputed(measures); const selectTab = (tab: CodeScope) => { router.replace({ query: { ...query, codeScope: tab } }); diff --git a/server/sonar-web/src/main/js/apps/overview/branches/SoftwareImpactMeasureCard.tsx b/server/sonar-web/src/main/js/apps/overview/branches/SoftwareImpactMeasureCard.tsx index a742f8365d0..0f4f9c97e80 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/SoftwareImpactMeasureCard.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/SoftwareImpactMeasureCard.tsx @@ -31,6 +31,7 @@ import { getIssueTypeBySoftwareQuality, } from '../../../helpers/issues'; import { isDefined } from '../../../helpers/types'; +import { useIsLegacyCCTMode } from '../../../queries/settings'; import { Branch } from '../../../types/branch-like'; import { SoftwareImpactMeasureData, SoftwareQuality } from '../../../types/clean-code-taxonomy'; import { QualityGateStatusConditionEnhanced } from '../../../types/quality-gates'; @@ -51,12 +52,14 @@ export function SoftwareImpactMeasureCard(props: Readonly<SoftwareImpactBreakdow const { component, conditions, softwareQuality, ratingMetricKey, measures, branch } = props; const intl = useIntl(); - // const { data: isLegacy } = useIsLegacyCCTMode(); + const { data: isLegacy } = useIsLegacyCCTMode(); // Find measure for this software quality const metricKey = softwareQualityToMeasure(softwareQuality); const measureRaw = measures.find((m) => m.metric.key === metricKey); - const measure = JSON.parse(measureRaw?.value ?? 'null') as SoftwareImpactMeasureData; + const measure = isLegacy + ? undefined + : (JSON.parse(measureRaw?.value ?? 'null') as SoftwareImpactMeasureData); const alternativeMeasure = measures.find( (m) => m.metric.key === SOFTWARE_QUALITIES_METRIC_KEYS_MAP[softwareQuality].deprecatedMetric, ); diff --git a/server/sonar-web/src/main/js/apps/overview/branches/__tests__/BranchOverview-it.tsx b/server/sonar-web/src/main/js/apps/overview/branches/__tests__/BranchOverview-it.tsx index af9c4331e63..4979f7546be 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/__tests__/BranchOverview-it.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/__tests__/BranchOverview-it.tsx @@ -322,11 +322,11 @@ describe('project overview', () => { 'overview.measures.software_impact.improve_rating_tooltip.A.software_quality.RELIABILITY.software_quality.reliability.A.overview.measures.software_impact.severity.LOW.improve_tooltip', ); - ui.expectSoftwareImpactMeasureCard(SoftwareQuality.Maintainability, 'E', 2); + ui.expectSoftwareImpactMeasureCard(SoftwareQuality.Maintainability, 'D', 2); await ui.expectSoftwareImpactMeasureCardRatingTooltip( SoftwareQuality.Maintainability, - 'E', - 'overview.measures.software_impact.improve_rating_tooltip.MAINTAINABILITY.software_quality.MAINTAINABILITY.software_quality.maintainability.E.overview.measures.software_impact.severity.HIGH.improve_tooltip', + 'D', + 'overview.measures.software_impact.improve_rating_tooltip.MAINTAINABILITY.software_quality.MAINTAINABILITY.software_quality.maintainability.D.overview.measures.software_impact.severity.HIGH.improve_tooltip', ); }); @@ -346,7 +346,7 @@ describe('project overview', () => { await user.click(await ui.overallCodeButton.find()); - ui.expectSoftwareImpactMeasureCard(SoftwareQuality.Maintainability, 'E', 2, ''); + ui.expectSoftwareImpactMeasureCard(SoftwareQuality.Maintainability, 'D', 2, ''); }); it('should render old measures if software impact are missing', async () => { @@ -453,8 +453,7 @@ describe('project overview', () => { }, ); - // eslint-disable-next-line jest/no-disabled-tests - it.skip('should display info about missing analysis if a project did not compute ratings', async () => { + it('should display info about missing analysis if a project did not compute ratings', async () => { measuresHandler.deleteComponentMeasure('foo', MetricKey.software_quality_security_rating); measuresHandler.deleteComponentMeasure( 'foo', @@ -487,8 +486,7 @@ describe('project overview', () => { ).toBeInTheDocument(); }); - // eslint-disable-next-line jest/no-disabled-tests - it.skip('should display old measures if in legacy mode', async () => { + it('should display old measures if in legacy mode', async () => { settingsHandler.set(SettingsKey.LegacyMode, 'true'); const { user, ui } = getPageObjects(); renderBranchOverview(); diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityApp-it.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityApp-it.tsx index 84b3223f85b..e8132d76bef 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityApp-it.tsx @@ -553,8 +553,7 @@ describe('graph interactions', () => { }); describe('ratings', () => { - // eslint-disable-next-line jest/no-disabled-tests - it.skip('should combine old and new rating + gaps', async () => { + it('should combine old and new rating + gaps', async () => { timeMachineHandler.setMeasureHistory([ mockMeasureHistory({ metric: MetricKey.reliability_rating, @@ -612,8 +611,7 @@ describe('ratings', () => { expect(ui.gapInfoMessage.get()).toBeInTheDocument(); }); - // eslint-disable-next-line jest/no-disabled-tests - it.skip('should not show old rating if new one was always there', async () => { + it('should not show old rating if new one was always there', async () => { timeMachineHandler.setMeasureHistory([ mockMeasureHistory({ metric: MetricKey.reliability_rating, diff --git a/server/sonar-web/src/main/js/apps/projects/components/__tests__/PageSidebar-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/__tests__/PageSidebar-test.tsx index 0e65b820444..927df18e7aa 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/__tests__/PageSidebar-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/__tests__/PageSidebar-test.tsx @@ -95,8 +95,7 @@ it('should show legacy filters', async () => { ).toBeInTheDocument(); }); -// eslint-disable-next-line jest/no-disabled-tests -it.skip('should show non legacy filters', async () => { +it('should show non legacy filters', async () => { settingsHandler.set(SettingsKey.LegacyMode, 'false'); renderPageSidebar(); diff --git a/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx b/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx index 8d28bd2d911..0dab91e1db1 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx @@ -73,13 +73,13 @@ function renderFirstLine( MetricKey.maintainability_issues, MetricKey.security_issues, ].every((key) => measures[key] === undefined); - // const noRatingMetrics = [ - // MetricKey.software_quality_reliability_rating, - // MetricKey.software_quality_maintainability_rating, - // MetricKey.software_quality_security_rating, - // ].every((key) => measures[key] === undefined); + const noRatingMetrics = [ + MetricKey.software_quality_reliability_rating, + MetricKey.software_quality_maintainability_rating, + MetricKey.software_quality_security_rating, + ].every((key) => measures[key] === undefined); const awaitingScan = - noSoftwareQualityMetrics && + (noSoftwareQualityMetrics || noRatingMetrics) && !isNewCode && !isEmpty(analysisDate) && measures.ncloc !== undefined; diff --git a/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCardMeasures.tsx b/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCardMeasures.tsx index 30b3e2c55b2..3b7ac673094 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCardMeasures.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCardMeasures.tsx @@ -31,6 +31,7 @@ import RatingComponent from '../../../../app/components/metrics/RatingComponent' import { duplicationRatingConverter } from '../../../../components/measure/utils'; import { translate } from '../../../../helpers/l10n'; import { isDefined } from '../../../../helpers/types'; +import { useIsLegacyCCTMode } from '../../../../queries/settings'; import { Dict } from '../../../../types/types'; import ProjectCardMeasure from './ProjectCardMeasure'; @@ -115,7 +116,7 @@ function renderDuplication(props: ProjectCardMeasuresProps) { ); } -function renderRatings(props: ProjectCardMeasuresProps) { +function renderRatings(props: ProjectCardMeasuresProps, isLegacy: boolean) { const { isNewCode, measures, componentKey } = props; const measuresByCodeLeak = isNewCode @@ -125,7 +126,7 @@ function renderRatings(props: ProjectCardMeasuresProps) { iconLabel: translate(`metric.${MetricKey.security_issues}.short_name`), noShrink: true, metricKey: - measures[MetricKey.security_issues] === undefined + isLegacy || measures[MetricKey.security_issues] === undefined ? MetricKey.vulnerabilities : MetricKey.security_issues, metricRatingKey: MetricKey.security_rating, @@ -134,7 +135,7 @@ function renderRatings(props: ProjectCardMeasuresProps) { { iconLabel: translate(`metric.${MetricKey.reliability_issues}.short_name`), metricKey: - measures[MetricKey.reliability_issues] === undefined + isLegacy || measures[MetricKey.reliability_issues] === undefined ? MetricKey.bugs : MetricKey.reliability_issues, metricRatingKey: MetricKey.reliability_rating, @@ -143,7 +144,7 @@ function renderRatings(props: ProjectCardMeasuresProps) { { iconLabel: translate(`metric.${MetricKey.maintainability_issues}.short_name`), metricKey: - measures[MetricKey.maintainability_issues] === undefined + isLegacy || measures[MetricKey.maintainability_issues] === undefined ? MetricKey.code_smells : MetricKey.maintainability_issues, metricRatingKey: MetricKey.sqale_rating, @@ -195,7 +196,7 @@ function renderRatings(props: ProjectCardMeasuresProps) { export default function ProjectCardMeasures(props: ProjectCardMeasuresProps) { const { isNewCode, measures, componentQualifier } = props; - // const { data: isLegacy } = useIsLegacyCCTMode(); + const { data: isLegacy } = useIsLegacyCCTMode(); const { ncloc } = measures; @@ -211,7 +212,7 @@ export default function ProjectCardMeasures(props: ProjectCardMeasuresProps) { const measureList = [ renderNewIssues(props), - ...renderRatings(props), + ...renderRatings(props, !!isLegacy), renderCoverage(props), renderDuplication(props), ].filter(isDefined); diff --git a/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCard-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCard-test.tsx index 768fe93f295..f2754c4aeaf 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCard-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCard-test.tsx @@ -170,7 +170,6 @@ describe('upgrade scenario (awaiting scan)', () => { value: '3', }), }; - beforeEach(() => { measuresHandler.setComponents({ component: mockComponent({ key: PROJECT.key }), @@ -181,13 +180,9 @@ describe('upgrade scenario (awaiting scan)', () => { [PROJECT.key]: oldRatings, }); }); - it('should not display awaiting analysis badge and do not display old measures', async () => { measuresHandler.registerComponentMeasures({ - [PROJECT.key]: { - ...newRatings, - ...oldRatings, - }, + [PROJECT.key]: newRatings, }); renderProjectCard({ ...PROJECT, @@ -212,13 +207,13 @@ describe('upgrade scenario (awaiting scan)', () => { expect(screen.getByText('1')).toBeInTheDocument(); expect(screen.getByText('2')).toBeInTheDocument(); expect(screen.getByText('3')).toBeInTheDocument(); - await waitFor(() => expect(screen.getAllByText('A')).toHaveLength(3)); + await waitFor(() => expect(screen.getAllByText('B')).toHaveLength(3)); await waitFor(() => expect(screen.getAllByText('C')).toHaveLength(1)); expect(screen.queryByText('projects.awaiting_scan')).not.toBeInTheDocument(); expect(screen.queryByText('4')).not.toBeInTheDocument(); expect(screen.queryByText('5')).not.toBeInTheDocument(); expect(screen.queryByText('6')).not.toBeInTheDocument(); - expect(screen.queryByText('B')).not.toBeInTheDocument(); + expect(screen.queryByText('A')).not.toBeInTheDocument(); }); it('should display awaiting analysis badge and show the old measures', async () => { @@ -260,9 +255,8 @@ describe('upgrade scenario (awaiting scan)', () => { [MetricKey.vulnerabilities]: '6', }, }); - expect(await screen.findByText('1')).toBeInTheDocument(); - expect(screen.queryByText('projects.awaiting_scan')).not.toBeInTheDocument(); - + expect(await screen.findByText('projects.awaiting_scan')).toBeInTheDocument(); + expect(screen.getByText('1')).toBeInTheDocument(); expect(screen.getByText('2')).toBeInTheDocument(); expect(screen.getByText('3')).toBeInTheDocument(); expect(screen.queryByText('4')).not.toBeInTheDocument(); @@ -315,8 +309,7 @@ describe('upgrade scenario (awaiting scan)', () => { expect(screen.queryByText('projects.awaiting_scan')).not.toBeInTheDocument(); }); - // eslint-disable-next-line jest/no-disabled-tests - it.skip('should not display awaiting analysis badge if legacy mode is enabled', async () => { + it('should not display awaiting analysis badge if legacy mode is enabled', async () => { settingsHandler.set(SettingsKey.LegacyMode, 'true'); renderProjectCard({ ...PROJECT, @@ -335,8 +328,7 @@ describe('upgrade scenario (awaiting scan)', () => { expect(screen.queryByText('projects.awaiting_scan')).not.toBeInTheDocument(); }); - // eslint-disable-next-line jest/no-disabled-tests - it.skip('should not display new values if legacy mode is enabled', async () => { + it('should not display new values if legacy mode is enabled', async () => { settingsHandler.set(SettingsKey.LegacyMode, 'true'); measuresHandler.registerComponentMeasures({ [PROJECT.key]: { diff --git a/server/sonar-web/src/main/js/components/shared/AnalysisMissingInfoMessage.tsx b/server/sonar-web/src/main/js/components/shared/AnalysisMissingInfoMessage.tsx index a3a39f3620c..b0bb17d6cbf 100644 --- a/server/sonar-web/src/main/js/components/shared/AnalysisMissingInfoMessage.tsx +++ b/server/sonar-web/src/main/js/components/shared/AnalysisMissingInfoMessage.tsx @@ -22,6 +22,7 @@ import { FlagMessage } from 'design-system'; import * as React from 'react'; import { FormattedMessage, useIntl } from 'react-intl'; import { DocLink } from '../../helpers/doc-links'; +import { useIsLegacyCCTMode } from '../../queries/settings'; import DocumentationLink from '../common/DocumentationLink'; interface AnalysisMissingInfoMessageProps { @@ -35,10 +36,10 @@ export default function AnalysisMissingInfoMessage({ qualifier, className, }: Readonly<AnalysisMissingInfoMessageProps>) { + const { data: isLegacy, isLoading } = useIsLegacyCCTMode(); const intl = useIntl(); - // const { data: isLegacy, isLoading } = useIsLegacyCCTMode(); - if (hide) { + if (hide || isLoading || isLegacy) { return null; } diff --git a/server/sonar-web/src/main/js/queries/settings.ts b/server/sonar-web/src/main/js/queries/settings.ts index 0f25e391be9..89c77ea30d7 100644 --- a/server/sonar-web/src/main/js/queries/settings.ts +++ b/server/sonar-web/src/main/js/queries/settings.ts @@ -27,7 +27,7 @@ import { setSimpleSettingValue, } from '../api/settings'; import { translate } from '../helpers/l10n'; -import { ExtendedSettingDefinition } from '../types/settings'; +import { ExtendedSettingDefinition, SettingsKey } from '../types/settings'; import { createQueryHook } from './common'; import { invalidateAllMeasures } from './measures'; @@ -58,14 +58,10 @@ export const useGetValueQuery = createQueryHook( ); export const useIsLegacyCCTMode = () => { - return useQuery({ - queryKey: ['mocked-legacy-mode'], - queryFn: () => Promise.resolve(true), - }); - // return useGetValueQuery( - // { key: SettingsKey.LegacyMode }, - // { staleTime: Infinity, select: (data) => data?.value === 'true' }, - // ); + return useGetValueQuery( + { key: SettingsKey.LegacyMode }, + { staleTime: Infinity, select: (data) => data?.value === 'true' }, + ); }; export function useResetSettingsMutation() { |