diff options
author | Ismail Cherri <ismail.cherri@sonarsource.com> | 2024-10-15 17:57:26 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-10-16 20:03:00 +0000 |
commit | 4a9e9a5d98c5e3d0c938ef3be2027e08182b958c (patch) | |
tree | e9b3575dc86d23b22401c50890da478b2692d2fa /server/sonar-web/src/main/js/apps | |
parent | 8073032868b6763891a12f4a4b4d4cb2507a179d (diff) | |
download | sonarqube-4a9e9a5d98c5e3d0c938ef3be2027e08182b958c.tar.gz sonarqube-4a9e9a5d98c5e3d0c938ef3be2027e08182b958c.zip |
SONAR-23188 Rename isLegacy into isStandardMode and useLegacyCCTMode into useStandardExperienceMode
Diffstat (limited to 'server/sonar-web/src/main/js/apps')
29 files changed, 204 insertions, 182 deletions
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 c180e6fe1a7..03c701c5cb5 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 @@ -42,7 +42,7 @@ import { areCCTMeasuresComputed, areSoftwareQualityRatingsComputed, } from '../../../helpers/measures'; -import { useIsLegacyCCTMode } from '../../../queries/settings'; +import { useStandardExperienceMode } from '../../../queries/settings'; import { BranchLike } from '../../../types/branch-like'; import { isApplication } from '../../../types/component'; import { Component, ComponentMeasure, Dict, Metric } from '../../../types/types'; @@ -102,7 +102,7 @@ export default function CodeAppRenderer(props: Readonly<Props>) { const showComponentList = sourceViewer === undefined && components.length > 0 && !showSearch; - const { data: isLegacy, isLoading: isLoadingLegacy } = useIsLegacyCCTMode(); + const { data: isStandardMode, isLoading: isLoadingStandardMode } = useStandardExperienceMode(); const metricKeys = intersection( getCodeMetrics(component.qualifier, branchLike, { newCode: newCodeSelected }), @@ -117,10 +117,10 @@ export default function CodeAppRenderer(props: Readonly<Props>) { ); const filteredMetrics = difference(metricKeys, [ - ...(allComponentsHaveSoftwareQualityMeasures && !isLegacy + ...(allComponentsHaveSoftwareQualityMeasures && !isStandardMode ? OLD_TAXONOMY_METRICS : CCT_SOFTWARE_QUALITY_METRICS), - ...(allComponentsHaveRatings && !isLegacy + ...(allComponentsHaveRatings && !isStandardMode ? [...OLD_TAXONOMY_RATINGS, ...LEAK_OLD_TAXONOMY_RATINGS] : SOFTWARE_QUALITY_RATING_METRICS), ]).map((key) => metrics[key]); @@ -150,7 +150,7 @@ export default function CodeAppRenderer(props: Readonly<Props>) { </FlagMessage> )} - <Spinner isLoading={loading || isLoadingLegacy}> + <Spinner isLoading={loading || isLoadingStandardMode}> {!allComponentsHaveSoftwareQualityMeasures && ( <AnalysisMissingInfoMessage qualifier={component.qualifier} diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentMeasure.tsx b/server/sonar-web/src/main/js/apps/code/components/ComponentMeasure.tsx index 7f77c3dda31..30d46001e75 100644 --- a/server/sonar-web/src/main/js/apps/code/components/ComponentMeasure.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/ComponentMeasure.tsx @@ -34,7 +34,7 @@ import { areCCTMeasuresComputed as areCCTMeasuresComputedFn, isDiffMetric, } from '../../../helpers/measures'; -import { useIsLegacyCCTMode } from '../../../queries/settings'; +import { useStandardExperienceMode } from '../../../queries/settings'; import { BranchLike } from '../../../types/branch-like'; import { isApplication, isProject } from '../../../types/component'; import { Metric, ComponentMeasure as TypeComponentMeasure } from '../../../types/types'; @@ -48,13 +48,13 @@ interface Props { export default function ComponentMeasure(props: Props) { const { component, metric, branchLike } = props; const isProjectLike = isProject(component.qualifier) || isApplication(component.qualifier); - const { data: isLegacy } = useIsLegacyCCTMode(); + const { data: isStandardMode } = useStandardExperienceMode(); const isReleasability = metric.key === MetricKey.releasability_rating; let finalMetricKey = isProjectLike && isReleasability ? MetricKey.alert_status : metric.key; const finalMetricType = isProjectLike && isReleasability ? MetricType.Level : metric.type; - const areCCTMeasuresComputed = !isLegacy && areCCTMeasuresComputedFn(component.measures); + const areCCTMeasuresComputed = !isStandardMode && areCCTMeasuresComputedFn(component.measures); finalMetricKey = areCCTMeasuresComputed ? (OLD_TO_NEW_TAXONOMY_METRICS_MAP[finalMetricKey as MetricKey] ?? finalMetricKey) : finalMetricKey; diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentsHeader.tsx b/server/sonar-web/src/main/js/apps/code/components/ComponentsHeader.tsx index b1ee5f40500..4ee73fd725e 100644 --- a/server/sonar-web/src/main/js/apps/code/components/ComponentsHeader.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/ComponentsHeader.tsx @@ -26,7 +26,7 @@ import { OLD_TO_NEW_TAXONOMY_METRICS_MAP, } from '../../../helpers/constants'; import { translate } from '../../../helpers/l10n'; -import { useIsLegacyCCTMode } from '../../../queries/settings'; +import { useStandardExperienceMode } from '../../../queries/settings'; import { ComponentMeasure } from '../../../types/types'; interface ComponentsHeaderProps { @@ -47,7 +47,7 @@ const SHORT_NAME_METRICS = [ export default function ComponentsHeader(props: ComponentsHeaderProps) { const { baseComponent, canBePinned = true, metrics, rootComponent, showAnalysisDate } = props; - const { data: isLegacy = false } = useIsLegacyCCTMode(); + const { data: isStandardMode = false } = useStandardExperienceMode(); const isPortfolio = isPortfolioLike(rootComponent.qualifier); let columns: string[] = []; let Cell: typeof NumericalCell; @@ -68,7 +68,7 @@ export default function ComponentsHeader(props: ComponentsHeaderProps) { Cell = RatingCell; } else { columns = metrics.map((m: MetricKey) => { - const metric = isLegacy ? m : (OLD_TO_NEW_TAXONOMY_METRICS_MAP[m] ?? m); + const metric = isStandardMode ? m : (OLD_TO_NEW_TAXONOMY_METRICS_MAP[m] ?? m); return translate( 'metric', diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/FacetsList.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/FacetsList.tsx index e29d4e44913..ec284499b1d 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/FacetsList.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/FacetsList.tsx @@ -24,7 +24,7 @@ import { useAvailableFeatures } from '../../../app/components/available-features import SeverityFacet from '../../../components/facets/SeverityFacet'; import StandardSeverityFacet from '../../../components/facets/StandardSeverityFacet'; import { translate } from '../../../helpers/l10n'; -import { useIsLegacyCCTMode } from '../../../queries/settings'; +import { useStandardExperienceMode } from '../../../queries/settings'; import { Feature } from '../../../types/features'; import { Dict } from '../../../types/types'; import { LanguageFacet } from '../../issues/sidebar/LanguageFacet'; @@ -59,7 +59,7 @@ const MAX_INITIAL_LANGUAGES = 5; export default function FacetsList(props: FacetsListProps) { const { hasFeature } = useAvailableFeatures(); - const { data: isLegacy } = useIsLegacyCCTMode(); + const { data: isStandardMode } = useStandardExperienceMode(); const languageDisabled = !props.hideProfileFacet && props.query.profile !== undefined; const inheritanceDisabled = @@ -82,7 +82,7 @@ export default function FacetsList(props: FacetsListProps) { disabledHelper={translate('coding_rules.filters.language.inactive')} /> - {isLegacy && ( + {isStandardMode && ( <> <BasicSeparator className="sw-my-4" /> @@ -96,7 +96,7 @@ export default function FacetsList(props: FacetsListProps) { </> )} - {!isLegacy && ( + {!isStandardMode && ( <> <BasicSeparator className="sw-my-4" /> @@ -110,7 +110,7 @@ export default function FacetsList(props: FacetsListProps) { </> )} - {!isLegacy && ( + {!isStandardMode && ( <> <BasicSeparator className="sw-my-4" /> @@ -124,7 +124,7 @@ export default function FacetsList(props: FacetsListProps) { </> )} - {!isLegacy && ( + {!isStandardMode && ( <> <BasicSeparator className="sw-my-4" /> @@ -138,7 +138,7 @@ export default function FacetsList(props: FacetsListProps) { </> )} - {isLegacy && ( + {isStandardMode && ( <> <BasicSeparator className="sw-my-4" /> @@ -152,7 +152,7 @@ export default function FacetsList(props: FacetsListProps) { </> )} - {!isLegacy && ( + {!isStandardMode && ( <> <BasicSeparator className="sw-my-4" /> diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsHeaderSide.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsHeaderSide.tsx index 8731166166f..25b8bc60b9b 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsHeaderSide.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsHeaderSide.tsx @@ -23,7 +23,7 @@ import React from 'react'; import { CleanCodeAttributePill } from '../../../components/shared/CleanCodeAttributePill'; import SoftwareImpactPillList from '../../../components/shared/SoftwareImpactPillList'; import { translate } from '../../../helpers/l10n'; -import { useIsLegacyCCTMode } from '../../../queries/settings'; +import { useStandardExperienceMode } from '../../../queries/settings'; import { IssueSeverity } from '../../../types/issues'; import { RuleDetails } from '../../../types/types'; @@ -35,7 +35,7 @@ export default function RuleDetailsHeaderSide({ ruleDetails }: Readonly<Props>) const hasCleanCodeAttribute = ruleDetails.cleanCodeAttributeCategory && ruleDetails.cleanCodeAttribute; const hasSoftwareImpact = ruleDetails.impacts.length > 0; - const { data: isLegacy } = useIsLegacyCCTMode(); + const { data: isStandardMode } = useStandardExperienceMode(); if (!hasCleanCodeAttribute && !hasSoftwareImpact) { return null; @@ -45,7 +45,9 @@ export default function RuleDetailsHeaderSide({ ruleDetails }: Readonly<Props>) <StyledSection className="sw-flex sw-flex-col sw-pl-4 sw-gap-6 sw-max-w-[250px]"> {hasSoftwareImpact && ( <RuleHeaderInfo - title={isLegacy ? translate('type') : translate('coding_rules.software_qualities.label')} + title={ + isStandardMode ? translate('type') : translate('coding_rules.software_qualities.label') + } > <SoftwareImpactPillList className="sw-flex-wrap" @@ -57,15 +59,17 @@ export default function RuleDetailsHeaderSide({ ruleDetails }: Readonly<Props>) </RuleHeaderInfo> )} - {ruleDetails.cleanCodeAttributeCategory && ruleDetails.cleanCodeAttribute && !isLegacy && ( - <RuleHeaderInfo title={translate('coding_rules.cct_attribute.label')}> - <CleanCodeAttributePill - cleanCodeAttributeCategory={ruleDetails.cleanCodeAttributeCategory} - cleanCodeAttribute={ruleDetails.cleanCodeAttribute} - type="rule" - /> - </RuleHeaderInfo> - )} + {ruleDetails.cleanCodeAttributeCategory && + ruleDetails.cleanCodeAttribute && + !isStandardMode && ( + <RuleHeaderInfo title={translate('coding_rules.cct_attribute.label')}> + <CleanCodeAttributePill + cleanCodeAttributeCategory={ruleDetails.cleanCodeAttributeCategory} + cleanCodeAttribute={ruleDetails.cleanCodeAttribute} + type="rule" + /> + </RuleHeaderInfo> + )} </StyledSection> ); } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleListItem.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleListItem.tsx index 8d26d829b47..607c206990d 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/RuleListItem.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/RuleListItem.tsx @@ -42,7 +42,7 @@ import { useDeactivateRuleMutation, } from '../../../queries/quality-profiles'; import { useRuleDetailsQuery } from '../../../queries/rules'; -import { useIsLegacyCCTMode } from '../../../queries/settings'; +import { useStandardExperienceMode } from '../../../queries/settings'; import { IssueSeverity } from '../../../types/issues'; import { Rule, RuleActivation } from '../../../types/types'; import ActivatedRuleActions from './ActivatedRuleActions'; @@ -85,7 +85,7 @@ export default function RuleListItem(props: Readonly<Props>) { const { mutate: deactivateRule } = useDeactivateRuleMutation((data) => onDeactivate(data.key, data.rule), ); - const { data: isLegacy } = useIsLegacyCCTMode(); + const { data: isStandardMode } = useStandardExperienceMode(); const activation = data && ruleIsChanged @@ -249,7 +249,7 @@ export default function RuleListItem(props: Readonly<Props>) { </div> <div> - {rule.cleanCodeAttributeCategory !== undefined && !isLegacy && ( + {rule.cleanCodeAttributeCategory !== undefined && !isStandardMode && ( <CleanCodeAttributePill cleanCodeAttributeCategory={rule.cleanCodeAttributeCategory} type="rule" diff --git a/server/sonar-web/src/main/js/apps/component-measures/hooks.ts b/server/sonar-web/src/main/js/apps/component-measures/hooks.ts index d0fa433ba1f..984ad1ab377 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/hooks.ts +++ b/server/sonar-web/src/main/js/apps/component-measures/hooks.ts @@ -19,7 +19,7 @@ */ import { areCCTMeasuresComputed, areSoftwareQualityRatingsComputed } from '../../helpers/measures'; -import { useIsLegacyCCTMode } from '../../queries/settings'; +import { useStandardExperienceMode } from '../../queries/settings'; import { MeasureEnhanced } from '../../types/types'; import { legacyBubbles, @@ -28,9 +28,9 @@ import { } from './config/bubbles'; export function useBubbleChartMetrics(measures: MeasureEnhanced[]) { - const { data: isLegacy } = useIsLegacyCCTMode(); + const { data: isStandardMode } = useStandardExperienceMode(); - if (isLegacy || !areCCTMeasuresComputed(measures)) { + if (isStandardMode || !areCCTMeasuresComputed(measures)) { return legacyBubbles; } diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/DomainSubnavigation.tsx b/server/sonar-web/src/main/js/apps/component-measures/sidebar/DomainSubnavigation.tsx index 1271c05af55..ef1702f1db3 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/sidebar/DomainSubnavigation.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/sidebar/DomainSubnavigation.tsx @@ -32,7 +32,7 @@ import { hasMessage, translate, } from '../../../helpers/l10n'; -import { useIsLegacyCCTMode } from '../../../queries/settings'; +import { useStandardExperienceMode } from '../../../queries/settings'; import { MeasureEnhanced } from '../../../types/types'; import { useBubbleChartMetrics } from '../hooks'; import { @@ -55,7 +55,7 @@ interface Props { export default function DomainSubnavigation(props: Readonly<Props>) { const { componentKey, domain, onChange, open, selected, showFullMeasures, measures } = props; - const { data: isLegacy = false } = useIsLegacyCCTMode(); + const { data: isStandardMode = false } = useStandardExperienceMode(); const helperMessageKey = `component_measures.domain_subnavigation.${domain.name}.help`; const helper = hasMessage(helperMessageKey) ? translate(helperMessageKey) : undefined; const items = addMeasureCategories(domain.name, domain.measures); @@ -114,7 +114,7 @@ export default function DomainSubnavigation(props: Readonly<Props>) { key={item.metric.key} componentKey={componentKey} measure={item} - name={getMetricSubnavigationName(item.metric, translateMetric, false, isLegacy)} + name={getMetricSubnavigationName(item.metric, translateMetric, false, isStandardMode)} onChange={onChange} selected={selected} /> diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.tsx b/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.tsx index ea39cb9d6d4..618c42a30d3 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.tsx @@ -32,7 +32,7 @@ import * as React from 'react'; import A11ySkipTarget from '~sonar-aligned/components/a11y/A11ySkipTarget'; import { translate } from '../../../helpers/l10n'; import useFollowScroll from '../../../hooks/useFollowScroll'; -import { useIsLegacyCCTMode } from '../../../queries/settings'; +import { useStandardExperienceMode } from '../../../queries/settings'; import { Domain } from '../../../types/measures'; import { MeasureEnhanced } from '../../../types/types'; import { PROJECT_OVERVEW, Query, isProjectOverview, populateDomainsFromMeasures } from '../utils'; @@ -49,8 +49,8 @@ interface Props { export default function Sidebar(props: Readonly<Props>) { const { showFullMeasures, updateQuery, componentKey, selectedMetric, measures } = props; const { top: topScroll, scrolledOnce } = useFollowScroll(); - const { data: isLegacy } = useIsLegacyCCTMode(); - const domains = populateDomainsFromMeasures(measures, isLegacy); + const { data: isStandardMode } = useStandardExperienceMode(); + const domains = populateDomainsFromMeasures(measures, isStandardMode); const handleChangeMetric = React.useCallback( (metric: string) => { 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 8a70d05b716..f277a75fd35 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 @@ -102,7 +102,7 @@ const ISSUES_METRICS = [ ]; export const populateDomainsFromMeasures = memoize( - (measures: MeasureEnhanced[], isLegacy = false): Domain[] => { + (measures: MeasureEnhanced[], isStandardMode = false): Domain[] => { let populatedMeasures = measures .filter((measure) => !DEPRECATED_METRICS.includes(measure.metric.key as MetricKey)) .map((measure) => { @@ -118,7 +118,7 @@ export const populateDomainsFromMeasures = memoize( }; }); - if (!isLegacy && areLeakCCTMeasuresComputed(measures)) { + if (!isStandardMode && areLeakCCTMeasuresComputed(measures)) { populatedMeasures = populatedMeasures.filter( (measure) => !LEAK_OLD_TAXONOMY_METRICS.includes(measure.metric.key as MetricKey), ); @@ -129,7 +129,7 @@ export const populateDomainsFromMeasures = memoize( } // Both new and overall code will exist after next analysis - if (!isLegacy && areSoftwareQualityRatingsComputed(measures)) { + if (!isStandardMode && areSoftwareQualityRatingsComputed(measures)) { populatedMeasures = populatedMeasures.filter( (measure) => !OLD_TAXONOMY_RATINGS.includes(measure.metric.key as MetricKey) && @@ -141,7 +141,7 @@ export const populateDomainsFromMeasures = memoize( ); } - if (!isLegacy && areCCTMeasuresComputed(measures)) { + if (!isStandardMode && areCCTMeasuresComputed(measures)) { populatedMeasures = populatedMeasures.filter( (measure) => !OLD_TAXONOMY_METRICS.includes(measure.metric.key as MetricKey), ); @@ -159,13 +159,13 @@ export function getMetricSubnavigationName( metric: Metric, translateFn: (metric: Metric) => string, isDiff = false, - isLegacy = false, + isStandardMode = false, ) { // MQR mode and old taxonomy metrics, we return "Issues" for them anyway - if (!isLegacy && OLD_TAXONOMY_METRICS.includes(metric.key as MetricKey)) { + if (!isStandardMode && OLD_TAXONOMY_METRICS.includes(metric.key as MetricKey)) { return translate('component_measures.awaiting_analysis.name'); } - if (!isLegacy && LEAK_OLD_TAXONOMY_METRICS.includes(metric.key as MetricKey)) { + if (!isStandardMode && LEAK_OLD_TAXONOMY_METRICS.includes(metric.key as MetricKey)) { return translate('component_measures.leak_awaiting_analysis.name'); } diff --git a/server/sonar-web/src/main/js/apps/issues/components/IssueHeaderSide.tsx b/server/sonar-web/src/main/js/apps/issues/components/IssueHeaderSide.tsx index b30eb641b1f..81a093dabee 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/IssueHeaderSide.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/IssueHeaderSide.tsx @@ -24,7 +24,7 @@ import React from 'react'; import { CleanCodeAttributePill } from '../../../components/shared/CleanCodeAttributePill'; import SoftwareImpactPillList from '../../../components/shared/SoftwareImpactPillList'; import { translate } from '../../../helpers/l10n'; -import { useIsLegacyCCTMode } from '../../../queries/settings'; +import { useStandardExperienceMode } from '../../../queries/settings'; import { IssueSeverity } from '../../../types/issues'; import { Issue } from '../../../types/types'; @@ -33,14 +33,14 @@ interface Props { } export default function IssueHeaderSide({ issue }: Readonly<Props>) { - const { data: isLegacy, isLoading } = useIsLegacyCCTMode(); + const { data: isStandardMode, isLoading } = useStandardExperienceMode(); return ( <StyledSection className="sw-flex sw-flex-col sw-pl-4 sw-max-w-[250px]"> <Spinner isLoading={isLoading}> <IssueHeaderInfo className="sw-mb-6" data-guiding-id="issue-2" - title={isLegacy ? translate('type') : translate('issue.software_qualities.label')} + title={isStandardMode ? translate('type') : translate('issue.software_qualities.label')} > <SoftwareImpactPillList className="sw-flex-wrap" @@ -50,7 +50,7 @@ export default function IssueHeaderSide({ issue }: Readonly<Props>) { /> </IssueHeaderInfo> - {!isLegacy && ( + {!isStandardMode && ( <IssueHeaderInfo title={translate('issue.cct_attribute.label')}> <CleanCodeAttributePill cleanCodeAttributeCategory={issue.cleanCodeAttributeCategory} 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 a41e9a851ee..f8930f85993 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 @@ -28,7 +28,7 @@ import { useAvailableFeatures } from '../../../app/components/available-features import SeverityFacet from '../../../components/facets/SeverityFacet'; import StandardSeverityFacet from '../../../components/facets/StandardSeverityFacet'; import { translate } from '../../../helpers/l10n'; -import { useIsLegacyCCTMode } from '../../../queries/settings'; +import { useStandardExperienceMode } from '../../../queries/settings'; import { BranchLike } from '../../../types/branch-like'; import { isApplication, isProject, isView } from '../../../types/component'; import { Feature } from '../../../types/features'; @@ -94,7 +94,7 @@ export function Sidebar(props: Readonly<Props>) { } = props; const { settings } = useAppState(); const { hasFeature } = useAvailableFeatures(); - const { data: isLegacy } = useIsLegacyCCTMode(); + const { data: isStandardMode } = useStandardExperienceMode(); const renderComponentFacets = () => { const hasFileOrDirectory = @@ -176,7 +176,7 @@ export function Sidebar(props: Readonly<Props>) { <PeriodFilter onChange={props.onFilterChange} newCodeSelected={query.inNewCodePeriod} /> )} - {!isLegacy && !needIssueSync && ( + {!isStandardMode && !needIssueSync && ( <> <SoftwareQualityFacet fetching={props.loadingFacets.impactSoftwareQualities === true} @@ -215,7 +215,7 @@ export function Sidebar(props: Readonly<Props>) { </> )} - {isLegacy && ( + {isStandardMode && ( <> <TypeFacet fetching={props.loadingFacets.types === true} diff --git a/server/sonar-web/src/main/js/apps/overview/branches/ActivityPanel.tsx b/server/sonar-web/src/main/js/apps/overview/branches/ActivityPanel.tsx index 92c9bd59815..6bbf5eaf39a 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/ActivityPanel.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/ActivityPanel.tsx @@ -33,7 +33,7 @@ import ActivityLink from '../../../components/common/ActivityLink'; import { parseDate } from '../../../helpers/dates'; import { translate, translateWithParameters } from '../../../helpers/l10n'; import { localizeMetric } from '../../../helpers/measures'; -import { useIsLegacyCCTMode } from '../../../queries/settings'; +import { useStandardExperienceMode } from '../../../queries/settings'; import { BranchLike } from '../../../types/branch-like'; import { Analysis as AnalysisType, @@ -72,8 +72,8 @@ export function ActivityPanel(props: ActivityPanelProps) { metrics, } = props; - const { data: isLegacy = false } = useIsLegacyCCTMode(); - const displayedMetrics = getDisplayedHistoryMetrics(graph, [], isLegacy); + const { data: isStandardMode = false } = useStandardExperienceMode(); + const displayedMetrics = getDisplayedHistoryMetrics(graph, [], isStandardMode); const series = generateSeries(measuresHistory, graph, metrics, displayedMetrics); const graphs = splitSeriesInGraphs(series, MAX_GRAPH_NB, MAX_SERIES_PER_GRAPH); let shownLeakPeriodDate; diff --git a/server/sonar-web/src/main/js/apps/overview/branches/BranchOverview.tsx b/server/sonar-web/src/main/js/apps/overview/branches/BranchOverview.tsx index 3a159842e5f..ddf4d2ec60b 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/BranchOverview.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/BranchOverview.tsx @@ -45,7 +45,7 @@ import { useApplicationQualityGateStatus, useProjectQualityGateStatus, } from '../../../queries/quality-gates'; -import { useIsLegacyCCTMode } from '../../../queries/settings'; +import { useStandardExperienceMode } from '../../../queries/settings'; import { ApplicationPeriod } from '../../../types/application'; import { Branch, BranchLike } from '../../../types/branch-like'; import { Analysis, GraphType, MeasureHistory } from '../../../types/project-activity'; @@ -69,7 +69,7 @@ const FROM_DATE = toISO8601WithOffsetString(new Date().setFullYear(new Date().ge export default function BranchOverview(props: Readonly<Props>) { const { component, branch, branchesEnabled } = props; - const { data: isLegacy = false } = useIsLegacyCCTMode(); + const { data: isStandardMode = false } = useStandardExperienceMode(); const { graph: initialGraph } = getActivityGraph( BRANCH_OVERVIEW_ACTIVITY_GRAPH, props.component.key, @@ -283,7 +283,7 @@ export default function BranchOverview(props: Readonly<Props>) { }; const loadHistoryMeasures = React.useCallback(() => { - const graphMetrics = getHistoryMetrics(graph, [], isLegacy); + const graphMetrics = getHistoryMetrics(graph, [], isStandardMode); const metrics = uniq([...HISTORY_METRICS_LIST, ...graphMetrics]); return getAllTimeMachineData({ 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 3d381c9a414..3f3cb6f1dc1 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,7 +31,7 @@ import { getIssueTypeBySoftwareQuality, } from '../../../helpers/issues'; import { isDefined } from '../../../helpers/types'; -import { useIsLegacyCCTMode } from '../../../queries/settings'; +import { useStandardExperienceMode } from '../../../queries/settings'; import { Branch } from '../../../types/branch-like'; import { SoftwareImpactMeasureData, SoftwareQuality } from '../../../types/clean-code-taxonomy'; import { QualityGateStatusConditionEnhanced } from '../../../types/quality-gates'; @@ -52,12 +52,12 @@ export function SoftwareImpactMeasureCard(props: Readonly<SoftwareImpactBreakdow const { component, conditions, softwareQuality, ratingMetricKey, measures, branch } = props; const intl = useIntl(); - const { data: isLegacy } = useIsLegacyCCTMode(); + const { data: isStandardMode } = useStandardExperienceMode(); // Find measure for this software quality const metricKey = softwareQualityToMeasure(softwareQuality); const measureRaw = measures.find((m) => m.metric.key === metricKey); - const measure = isLegacy + const measure = isStandardMode ? undefined : (JSON.parse(measureRaw?.value ?? 'null') as SoftwareImpactMeasureData); const alternativeMeasure = measures.find( @@ -87,8 +87,8 @@ export function SoftwareImpactMeasureCard(props: Readonly<SoftwareImpactBreakdow > <div className="sw-flex sw-items-center"> <ColorBold className="sw-typo-semibold"> - {!isLegacy && intl.formatMessage({ id: `software_quality.${softwareQuality}` })} - {alternativeMeasure && isLegacy && alternativeMeasure.metric.name} + {!isStandardMode && intl.formatMessage({ id: `software_quality.${softwareQuality}` })} + {alternativeMeasure && isStandardMode && alternativeMeasure.metric.name} </ColorBold> {failed && ( <Badge className="sw-h-fit sw-ml-2" variant="deleted"> @@ -100,7 +100,7 @@ export function SoftwareImpactMeasureCard(props: Readonly<SoftwareImpactBreakdow <div className="sw-flex sw-mt-4"> <div className="sw-flex sw-gap-1 sw-items-center"> {count ? ( - <Tooltip content={countTooltipOverlay} isOpen={isLegacy ? false : undefined}> + <Tooltip content={countTooltipOverlay} isOpen={isStandardMode ? false : undefined}> <LinkStandalone data-testid={`overview__software-impact-${softwareQuality}`} aria-label={intl.formatMessage( diff --git a/server/sonar-web/src/main/js/apps/overview/branches/SoftwareImpactMeasureRating.tsx b/server/sonar-web/src/main/js/apps/overview/branches/SoftwareImpactMeasureRating.tsx index c58ff188d11..c990b5f26ac 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/SoftwareImpactMeasureRating.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/SoftwareImpactMeasureRating.tsx @@ -24,7 +24,7 @@ import { useIntl } from 'react-intl'; import { MetricKey } from '~sonar-aligned/types/metrics'; import RatingComponent from '../../../app/components/metrics/RatingComponent'; import RatingTooltipContent from '../../../components/measure/RatingTooltipContent'; -import { useIsLegacyCCTMode } from '../../../queries/settings'; +import { useStandardExperienceMode } from '../../../queries/settings'; import { Branch } from '../../../types/branch-like'; import { SoftwareImpactSeverity, SoftwareQuality } from '../../../types/clean-code-taxonomy'; @@ -37,7 +37,7 @@ export interface SoftwareImpactMeasureRatingProps { export function SoftwareImpactMeasureRating(props: Readonly<SoftwareImpactMeasureRatingProps>) { const { ratingMetricKey, componentKey, softwareQuality, branch } = props; - const { data: isLegacy = false } = useIsLegacyCCTMode(); + const { data: isStandardMode = false } = useStandardExperienceMode(); const intl = useIntl(); @@ -47,7 +47,7 @@ export function SoftwareImpactMeasureRating(props: Readonly<SoftwareImpactMeasur return null; } - if (isLegacy && value !== undefined) { + if (isStandardMode && value !== undefined) { return <RatingTooltipContent metricKey={ratingMetricKey} value={value} />; } diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx index 21cc693dd84..b51a8650651 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx @@ -38,7 +38,7 @@ import useApplicationLeakQuery from '../../../queries/applications'; import { useCurrentBranchQuery } from '../../../queries/branch'; import { useAllMeasuresHistoryQuery } from '../../../queries/measures'; import { useAllProjectAnalysesQuery } from '../../../queries/project-analyses'; -import { useIsLegacyCCTMode } from '../../../queries/settings'; +import { useStandardExperienceMode } from '../../../queries/settings'; import { isApplication, isProject } from '../../../types/component'; import { MeasureHistory, ParsedAnalysis } from '../../../types/project-activity'; import { Query, parseQuery, serializeUrlQuery } from '../utils'; @@ -73,7 +73,7 @@ export function ProjectActivityApp() { ); const { data: analysesData, isLoading: isLoadingAnalyses } = useAllProjectAnalysesQuery(enabled); - const { data: isLegacy, isLoading: isLoadingLegacy } = useIsLegacyCCTMode(); + const { data: isStandardMode, isLoading: isLoadingStandardMode } = useStandardExperienceMode(); const { data: historyData, isLoading: isLoadingHistory } = useAllMeasuresHistoryQuery( { @@ -87,8 +87,11 @@ export function ProjectActivityApp() { const analyses = React.useMemo(() => analysesData ?? [], [analysesData]); const measuresHistory = React.useMemo( - () => (isLoadingLegacy ? [] : mergeRatingMeasureHistory(historyData, parseDate, isLegacy)), - [historyData, isLegacy, isLoadingLegacy], + () => + isLoadingStandardMode + ? [] + : mergeRatingMeasureHistory(historyData, parseDate, isStandardMode), + [historyData, isStandardMode, isLoadingStandardMode], ); const leakPeriodDate = React.useMemo(() => { @@ -139,11 +142,11 @@ export function ProjectActivityApp() { return ( component && ( - <Spinner isLoading={isLoadingLegacy}> + <Spinner isLoading={isLoadingStandardMode}> <ProjectActivityAppRenderer analyses={analyses} - isLegacy={ - isLegacy || + isStandardMode={ + isStandardMode || !firstSoftwareQualityRatingMetric || firstSoftwareQualityRatingMetric.history.every((h) => h.value === undefined) } diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppRenderer.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppRenderer.tsx index f52fbbd5b72..de667ada90b 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppRenderer.tsx @@ -42,7 +42,7 @@ interface Props { analysesLoading: boolean; graphLoading: boolean; initializing: boolean; - isLegacy?: boolean; + isStandardMode?: boolean; leakPeriodDate?: Date; measuresHistory: MeasureHistory[]; metrics: Metric[]; @@ -62,7 +62,7 @@ export default function ProjectActivityAppRenderer(props: Props) { graphLoading, metrics, project, - isLegacy, + isStandardMode, } = props; const { configuration, qualifier } = props.project; const canAdmin = @@ -103,7 +103,7 @@ export default function ProjectActivityAppRenderer(props: Props) { analyses={analyses} leakPeriodDate={leakPeriodDate} loading={graphLoading} - isLegacy={isLegacy} + isStandardMode={isStandardMode} measuresHistory={measuresHistory} metrics={metrics} project={project.key} diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphs.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphs.tsx index f059e203627..fa05b8f0303 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphs.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphs.tsx @@ -55,7 +55,7 @@ import { PROJECT_ACTIVITY_GRAPH } from './ProjectActivityApp'; interface Props { analyses: ParsedAnalysis[]; - isLegacy?: boolean; + isStandardMode?: boolean; leakPeriodDate?: Date; loading: boolean; measuresHistory: MeasureHistory[]; @@ -219,7 +219,7 @@ export default class ProjectActivityGraphs extends React.PureComponent<Props, St }; renderQualitiesMetricInfoMessage = () => { - const { measuresHistory, isLegacy } = this.props; + const { measuresHistory, isStandardMode } = this.props; const qualityMeasuresHistory = measuresHistory.find((history) => CCT_SOFTWARE_QUALITY_METRICS.includes(history.metric), @@ -230,7 +230,7 @@ export default class ProjectActivityGraphs extends React.PureComponent<Props, St if ( this.hasGaps(qualityMeasuresHistory) || - (!isLegacy && this.hasGaps(ratingQualityMeasuresHistory)) + (!isStandardMode && this.hasGaps(ratingQualityMeasuresHistory)) ) { return ( <FlagMessage variant="info"> diff --git a/server/sonar-web/src/main/js/apps/projects/__tests__/utils-test.ts b/server/sonar-web/src/main/js/apps/projects/__tests__/utils-test.ts index f245ee977fe..ce5aedb63bd 100644 --- a/server/sonar-web/src/main/js/apps/projects/__tests__/utils-test.ts +++ b/server/sonar-web/src/main/js/apps/projects/__tests__/utils-test.ts @@ -84,7 +84,7 @@ describe('formatDuration', () => { describe('fetchProjects', () => { it('correctly converts the passed arguments to the desired query format', async () => { - await utils.fetchProjects({ isFavorite: true, query: {}, isLegacy: true }); + await utils.fetchProjects({ isFavorite: true, query: {}, isStandardMode: true }); expect(searchProjects).toHaveBeenCalledWith({ f: 'analysisDate,leakPeriodDate', @@ -103,7 +103,7 @@ describe('fetchProjects', () => { incorrect_property: 'should not appear in post data', search: 'foo', }, - isLegacy: true, + isStandardMode: true, }); expect(searchProjects).toHaveBeenCalledWith({ @@ -116,7 +116,7 @@ describe('fetchProjects', () => { }); it('correctly converts the passed arguments to the desired query format for non legacy', async () => { - await utils.fetchProjects({ isFavorite: true, query: {}, isLegacy: false }); + await utils.fetchProjects({ isFavorite: true, query: {}, isStandardMode: false }); expect(searchProjects).toHaveBeenCalledWith({ f: 'analysisDate,leakPeriodDate', @@ -135,7 +135,7 @@ describe('fetchProjects', () => { incorrect_property: 'should not appear in post data', search: 'foo', }, - isLegacy: false, + isStandardMode: false, }); expect(searchProjects).toHaveBeenCalledWith({ @@ -165,7 +165,7 @@ describe('fetchProjects', () => { paging: { total: 2 }, }); - await utils.fetchProjects({ isFavorite: true, query: {}, isLegacy: true }).then((r) => { + await utils.fetchProjects({ isFavorite: true, query: {}, isStandardMode: true }).then((r) => { expect(r).toEqual({ facets: { new_coverage: { NO_DATA: 0 }, diff --git a/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx b/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx index 3d9eeead93c..d08bc398621 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/AllProjects.tsx @@ -44,7 +44,7 @@ import handleRequiredAuthentication from '../../../helpers/handleRequiredAuthent import { translate } from '../../../helpers/l10n'; import { get, save } from '../../../helpers/storage'; import { isDefined } from '../../../helpers/types'; -import { useIsLegacyCCTMode } from '../../../queries/settings'; +import { useStandardExperienceMode } from '../../../queries/settings'; import { AppState } from '../../../types/appstate'; import { CurrentUser, isLoggedIn } from '../../../types/users'; import { Query, hasFilterParams, parseUrlQuery } from '../query'; @@ -59,7 +59,7 @@ interface Props { appState: AppState; currentUser: CurrentUser; isFavorite: boolean; - isLegacy: boolean; + isStandardMode: boolean; location: Location; router: Router; } @@ -106,21 +106,24 @@ export class AllProjects extends React.PureComponent<Props, State> { } fetchMoreProjects = () => { - const { isFavorite, isLegacy } = this.props; + const { isFavorite, isStandardMode } = this.props; const { pageIndex, projects, query } = this.state; if (isDefined(pageIndex) && pageIndex !== 0 && projects && Object.keys(query).length !== 0) { this.setState({ loading: true }); - fetchProjects({ isFavorite, query, pageIndex: pageIndex + 1, isLegacy }).then((response) => { - if (this.mounted) { - this.setState({ - loading: false, - pageIndex: pageIndex + 1, - projects: [...projects, ...response.projects], - }); - } - }, this.stopLoading); + fetchProjects({ isFavorite, query, pageIndex: pageIndex + 1, isStandardMode }).then( + (response) => { + if (this.mounted) { + this.setState({ + loading: false, + pageIndex: pageIndex + 1, + projects: [...projects, ...response.projects], + }); + } + }, + this.stopLoading, + ); } }; @@ -175,14 +178,14 @@ export class AllProjects extends React.PureComponent<Props, State> { }; handleQueryChange() { - const { isFavorite, isLegacy } = this.props; + const { isFavorite, isStandardMode } = this.props; const queryRaw = this.props.location.query; const query = parseUrlQuery(queryRaw); this.setState({ loading: true, query }); - fetchProjects({ isFavorite, query, isLegacy }).then((response) => { + fetchProjects({ isFavorite, query, isStandardMode }).then((response) => { // We ignore the request if the query changed since the time it was initiated // If that happened, another query will be initiated anyway if (this.mounted && queryRaw === this.props.location.query) { @@ -204,10 +207,10 @@ export class AllProjects extends React.PureComponent<Props, State> { }; loadSearchResultCount = (property: string, values: string[]) => { - const { isFavorite, isLegacy } = this.props; + const { isFavorite, isStandardMode } = this.props; const { query = {} } = this.state; - const data = convertToQueryData({ ...query, [property]: values }, isFavorite, isLegacy, { + const data = convertToQueryData({ ...query, [property]: values }, isFavorite, isStandardMode, { ps: 1, facets: property, }); @@ -352,10 +355,10 @@ function getStorageOptions() { return options; } -function AllProjectsWrapper(props: Readonly<Omit<Props, 'isLegacy'>>) { +function AllProjectsWrapper(props: Readonly<Omit<Props, 'isStandardMode'>>) { const [searchParams, setSearchParams] = useSearchParams(); const savedOptions = getStorageOptions(); - const { data: isLegacy, isLoading } = useIsLegacyCCTMode(); + const { data: isStandardMode, isLoading } = useStandardExperienceMode(); React.useEffect( () => { @@ -374,7 +377,7 @@ function AllProjectsWrapper(props: Readonly<Omit<Props, 'isLegacy'>>) { return ( <Spinner isLoading={isLoading}> - <AllProjects {...props} isLegacy={isLegacy ?? false} /> + <AllProjects {...props} isStandardMode={isStandardMode ?? false} /> </Spinner> ); } 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 19dfe38e4dc..179b9b1bb6f 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,7 +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 { useStandardExperienceMode } from '../../../../queries/settings'; import { Dict } from '../../../../types/types'; import ProjectCardMeasure from './ProjectCardMeasure'; @@ -116,7 +116,7 @@ function renderDuplication(props: ProjectCardMeasuresProps) { ); } -function renderRatings(props: ProjectCardMeasuresProps, isLegacy: boolean) { +function renderRatings(props: ProjectCardMeasuresProps, isStandardMode: boolean) { const { isNewCode, measures, componentKey } = props; const measuresByCodeLeak = isNewCode @@ -124,11 +124,11 @@ function renderRatings(props: ProjectCardMeasuresProps, isLegacy: boolean) { : [ { iconLabel: translate( - `metric.${isLegacy ? MetricKey.vulnerabilities : MetricKey.security_issues}.short_name`, + `metric.${isStandardMode ? MetricKey.vulnerabilities : MetricKey.security_issues}.short_name`, ), noShrink: true, metricKey: - isLegacy || measures[MetricKey.security_issues] === undefined + isStandardMode || measures[MetricKey.security_issues] === undefined ? MetricKey.vulnerabilities : MetricKey.security_issues, metricRatingKey: MetricKey.security_rating, @@ -136,10 +136,10 @@ function renderRatings(props: ProjectCardMeasuresProps, isLegacy: boolean) { }, { iconLabel: translate( - `metric.${isLegacy ? MetricKey.bugs : MetricKey.reliability_issues}.short_name`, + `metric.${isStandardMode ? MetricKey.bugs : MetricKey.reliability_issues}.short_name`, ), metricKey: - isLegacy || measures[MetricKey.reliability_issues] === undefined + isStandardMode || measures[MetricKey.reliability_issues] === undefined ? MetricKey.bugs : MetricKey.reliability_issues, metricRatingKey: MetricKey.reliability_rating, @@ -147,10 +147,10 @@ function renderRatings(props: ProjectCardMeasuresProps, isLegacy: boolean) { }, { iconLabel: translate( - `metric.${isLegacy ? MetricKey.code_smells : MetricKey.maintainability_issues}.short_name`, + `metric.${isStandardMode ? MetricKey.code_smells : MetricKey.maintainability_issues}.short_name`, ), metricKey: - isLegacy || measures[MetricKey.maintainability_issues] === undefined + isStandardMode || measures[MetricKey.maintainability_issues] === undefined ? MetricKey.code_smells : MetricKey.maintainability_issues, metricRatingKey: MetricKey.sqale_rating, @@ -202,7 +202,7 @@ function renderRatings(props: ProjectCardMeasuresProps, isLegacy: boolean) { export default function ProjectCardMeasures(props: ProjectCardMeasuresProps) { const { isNewCode, measures, componentQualifier } = props; - const { data: isLegacy } = useIsLegacyCCTMode(); + const { data: isStandardMode } = useStandardExperienceMode(); const { ncloc } = measures; @@ -218,7 +218,7 @@ export default function ProjectCardMeasures(props: ProjectCardMeasuresProps) { const measureList = [ renderNewIssues(props), - ...renderRatings(props, !!isLegacy), + ...renderRatings(props, !!isStandardMode), renderCoverage(props), renderDuplication(props), ].filter(isDefined); diff --git a/server/sonar-web/src/main/js/apps/projects/filters/RatingFacet.tsx b/server/sonar-web/src/main/js/apps/projects/filters/RatingFacet.tsx index 5a0b704345b..a756bb4e0c3 100644 --- a/server/sonar-web/src/main/js/apps/projects/filters/RatingFacet.tsx +++ b/server/sonar-web/src/main/js/apps/projects/filters/RatingFacet.tsx @@ -25,7 +25,7 @@ import { formatMeasure } from '~sonar-aligned/helpers/measures'; import { MetricType } from '~sonar-aligned/types/metrics'; import { RawQuery } from '~sonar-aligned/types/router'; import { translate, translateWithParameters } from '../../../helpers/l10n'; -import { useIsLegacyCCTMode } from '../../../queries/settings'; +import { useStandardExperienceMode } from '../../../queries/settings'; import { Facet } from '../types'; import RangeFacetBase from './RangeFacetBase'; @@ -40,7 +40,7 @@ interface Props { export default function RatingFacet(props: Readonly<Props>) { const { facet, maxFacetValue, name, property, value } = props; - const { data: isLegacy } = useIsLegacyCCTMode(); + const { data: isStandardMode } = useStandardExperienceMode(); const renderAccessibleLabel = React.useCallback( (option: number) => { @@ -66,7 +66,7 @@ export default function RatingFacet(props: Readonly<Props>) { facet={facet} header={translate('metric_domain', name)} description={ - hasDescription(property, isLegacy) + hasDescription(property, isStandardMode) ? translate(`projects.facets.${property.replace('new_', '')}.description`) : undefined } @@ -82,12 +82,12 @@ export default function RatingFacet(props: Readonly<Props>) { ); } -const hasDescription = (property: string, isLegacy = false) => { +const hasDescription = (property: string, isStandardMode = false) => { return [ 'maintainability', 'new_maintainability', 'security_review', - ...(isLegacy ? ['security', 'new_security', 'reliability', 'new_reliability'] : []), + ...(isStandardMode ? ['security', 'new_security', 'reliability', 'new_reliability'] : []), ].includes(property); }; @@ -99,7 +99,7 @@ function RatingOption({ option, property, }: Readonly<{ option: string | number; property: string }>) { - const { data: isLegacy, isLoading } = useIsLegacyCCTMode(); + const { data: isStandardMode, isLoading } = useStandardExperienceMode(); const intl = useIntl(); const ratingFormatted = formatMeasure(option, MetricType.Rating); @@ -114,7 +114,7 @@ function RatingOption({ /> <span className="sw-ml-2"> {intl.formatMessage({ - id: `projects.facets.rating_option.${propertyWithoutPrefix}${isLegacy && isSecurityOrReliability ? '.legacy' : ''}.${option}`, + id: `projects.facets.rating_option.${propertyWithoutPrefix}${isStandardMode && isSecurityOrReliability ? '.legacy' : ''}.${option}`, })} </span> </Spinner> diff --git a/server/sonar-web/src/main/js/apps/projects/query.ts b/server/sonar-web/src/main/js/apps/projects/query.ts index 0a6edbb1563..cef18e8f55b 100644 --- a/server/sonar-web/src/main/js/apps/projects/query.ts +++ b/server/sonar-web/src/main/js/apps/projects/query.ts @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { ComponentQualifier } from '~sonar-aligned/types/component'; +import { MetricKey } from '~sonar-aligned/types/metrics'; import { RawQuery } from '~sonar-aligned/types/router'; import { propertyToMetricMap, propertyToMetricMapLegacy } from './utils'; @@ -59,12 +60,12 @@ export function parseUrlQuery(urlQuery: RawQuery): Query { new_security_review: getAsNumericRating(urlQuery['new_security_review']), maintainability: getAsNumericRating(urlQuery['maintainability']), new_maintainability: getAsNumericRating(urlQuery['new_maintainability']), - coverage: getAsNumericRating(urlQuery['coverage']), - new_coverage: getAsNumericRating(urlQuery['new_coverage']), + coverage: getAsNumericRating(urlQuery[MetricKey.coverage]), + new_coverage: getAsNumericRating(urlQuery[MetricKey.new_coverage]), duplications: getAsNumericRating(urlQuery['duplications']), new_duplications: getAsNumericRating(urlQuery['new_duplications']), size: getAsNumericRating(urlQuery['size']), - new_lines: getAsNumericRating(urlQuery['new_lines']), + new_lines: getAsNumericRating(urlQuery[MetricKey.new_lines]), languages: getAsStringArray(urlQuery['languages']), tags: getAsStringArray(urlQuery['tags']), qualifier: getAsQualifier(urlQuery['qualifier']), @@ -74,7 +75,11 @@ export function parseUrlQuery(urlQuery: RawQuery): Query { }; } -export function convertToFilter(query: Query, isFavorite: boolean, isLegacy: boolean): string { +export function convertToFilter( + query: Query, + isFavorite: boolean, + isStandardMode: boolean, +): string { const conditions: string[] = []; if (isFavorite) { @@ -82,19 +87,19 @@ export function convertToFilter(query: Query, isFavorite: boolean, isLegacy: boo } if (query['gate'] != null) { - conditions.push(mapPropertyToMetric('gate', isLegacy) + ' = ' + query['gate']); + conditions.push(`${mapPropertyToMetric('gate', isStandardMode)}=${query['gate']}`); } - ['coverage', 'new_coverage'].forEach((property) => - pushMetricToArray(query, property, conditions, convertCoverage, isLegacy), + [MetricKey.coverage, MetricKey.new_coverage].forEach((property) => + pushMetricToArray(query, property, conditions, convertCoverage, isStandardMode), ); ['duplications', 'new_duplications'].forEach((property) => - pushMetricToArray(query, property, conditions, convertDuplications, isLegacy), + pushMetricToArray(query, property, conditions, convertDuplications, isStandardMode), ); ['size', 'new_lines'].forEach((property) => - pushMetricToArray(query, property, conditions, convertSize, isLegacy), + pushMetricToArray(query, property, conditions, convertSize, isStandardMode), ); [ @@ -107,15 +112,15 @@ export function convertToFilter(query: Query, isFavorite: boolean, isLegacy: boo 'new_security_review', 'new_maintainability', ].forEach((property) => - pushMetricToArray(query, property, conditions, convertIssuesRating, isLegacy), + pushMetricToArray(query, property, conditions, convertIssuesRating, isStandardMode), ); ['languages', 'tags', 'qualifier'].forEach((property) => - pushMetricToArray(query, property, conditions, convertArrayMetric, isLegacy), + pushMetricToArray(query, property, conditions, convertArrayMetric, isStandardMode), ); if (query['search'] != null) { - conditions.push(`${mapPropertyToMetric('search', isLegacy)} = "${query['search']}"`); + conditions.push(`${mapPropertyToMetric('search', isStandardMode)} = "${query['search']}"`); } return conditions.join(' and '); @@ -235,8 +240,11 @@ function convertSize(metric: string, size: number): string { } } -function mapPropertyToMetric(property?: string, isLegacy = false): string | undefined { - return property && (isLegacy ? propertyToMetricMapLegacy : propertyToMetricMap)[property]; +function mapPropertyToMetric(property?: string, isStandardMode = false): string | undefined { + if (property === undefined) { + return; + } + return (isStandardMode ? propertyToMetricMapLegacy : propertyToMetricMap)[property]; } function pushMetricToArray( @@ -244,9 +252,9 @@ function pushMetricToArray( property: string, conditionsArray: string[], convertFunction: (metric: string, value: Query[string]) => string, - isLegacy: boolean, + isStandardMode: boolean, ): void { - const metric = mapPropertyToMetric(property, isLegacy); + const metric = mapPropertyToMetric(property, isStandardMode); if (query[property] !== undefined && metric !== undefined) { conditionsArray.push(convertFunction(metric, query[property])); } diff --git a/server/sonar-web/src/main/js/apps/projects/utils.ts b/server/sonar-web/src/main/js/apps/projects/utils.ts index 709e2626f52..b32e4ca015d 100644 --- a/server/sonar-web/src/main/js/apps/projects/utils.ts +++ b/server/sonar-web/src/main/js/apps/projects/utils.ts @@ -206,19 +206,19 @@ export function fetchProjects({ isFavorite, query, pageIndex = 1, - isLegacy, + isStandardMode, }: { isFavorite: boolean; - isLegacy: boolean; + isStandardMode: boolean; pageIndex?: number; query: Query; }) { const ps = PAGE_SIZE; - const data = convertToQueryData(query, isFavorite, isLegacy, { + const data = convertToQueryData(query, isFavorite, isStandardMode, { p: pageIndex > 1 ? pageIndex : undefined, ps, - facets: defineFacets(query, isLegacy).join(), + facets: defineFacets(query, isStandardMode).join(), f: 'analysisDate,leakPeriodDate', }); @@ -226,7 +226,7 @@ export function fetchProjects({ .then((response) => Promise.all([Promise.resolve(response), fetchScannableProjects()])) .then(([{ components, facets, paging }, { scannableProjects }]) => { return { - facets: getFacetsMap(facets, isLegacy), + facets: getFacetsMap(facets, isStandardMode), projects: components.map((component) => ({ ...component, isScannable: scannableProjects.find((p) => p.key === component.key) !== undefined, @@ -244,23 +244,23 @@ export function defineMetrics(query: Query): string[] { return METRICS; } -function defineFacets(query: Query, isLegacy: boolean): string[] { +function defineFacets(query: Query, isStandardMode: boolean): string[] { if (query.view === 'leak') { - return isLegacy ? LEGACY_LEAK_FACETS : LEAK_FACETS; + return isStandardMode ? LEGACY_LEAK_FACETS : LEAK_FACETS; } - return isLegacy ? LEGACY_FACETS : FACETS; + return isStandardMode ? LEGACY_FACETS : FACETS; } export function convertToQueryData( query: Query, isFavorite: boolean, - isLegacy: boolean, + isStandardMode: boolean, defaultData = {}, ) { const data: RequestData = { ...defaultData }; - const filter = convertToFilter(query, isFavorite, isLegacy); - const sort = convertToSorting(query, isLegacy); + const filter = convertToFilter(query, isFavorite, isStandardMode); + const sort = convertToSorting(query, isStandardMode); if (filter) { data.filter = filter; @@ -321,11 +321,11 @@ export const propertyToMetricMap: Dict<string | undefined> = { new_maintainability: 'new_software_quality_maintainability_rating', }; -function getFacetsMap(facets: Facet[], isLegacy: boolean) { +function getFacetsMap(facets: Facet[], isStandardMode: boolean) { const map: Dict<Dict<number>> = {}; facets.forEach((facet) => { - const property = invert(isLegacy ? propertyToMetricMapLegacy : propertyToMetricMap)[ + const property = invert(isStandardMode ? propertyToMetricMapLegacy : propertyToMetricMap)[ facet.property ]; const { values } = facet; @@ -342,16 +342,16 @@ function getFacetsMap(facets: Facet[], isLegacy: boolean) { export function convertToSorting( { sort }: Query, - isLegacy: boolean, + isStandardMode: boolean, ): { asc?: boolean; s?: string } { if (sort?.startsWith('-')) { return { - s: (isLegacy ? propertyToMetricMapLegacy : propertyToMetricMap)[sort.substring(1)], + s: (isStandardMode ? propertyToMetricMapLegacy : propertyToMetricMap)[sort.substring(1)], asc: false, }; } - return { s: (isLegacy ? propertyToMetricMapLegacy : propertyToMetricMap)[sort ?? ''] }; + return { s: (isStandardMode ? propertyToMetricMapLegacy : propertyToMetricMap)[sort ?? ''] }; } const ONE_MINUTE = 60000; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.tsx index 5ace834dc30..9af91ac5e32 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/compare/ComparisonResults.tsx @@ -27,7 +27,7 @@ import IssueSeverityIcon from '../../../components/icon-mappers/IssueSeverityIco import { CleanCodeAttributePill } from '../../../components/shared/CleanCodeAttributePill'; import SoftwareImpactPillList from '../../../components/shared/SoftwareImpactPillList'; import { getRulesUrl } from '../../../helpers/urls'; -import { useIsLegacyCCTMode } from '../../../queries/settings'; +import { useStandardExperienceMode } from '../../../queries/settings'; import { IssueSeverity } from '../../../types/issues'; import { Dict } from '../../../types/types'; import ComparisonResultActivation from './ComparisonResultActivation'; @@ -224,9 +224,9 @@ export default function ComparisonResults(props: Readonly<Props>) { } function RuleCell({ rule, severity }: Readonly<{ rule: RuleCompare; severity?: string }>) { - const { data: isLegacy } = useIsLegacyCCTMode(); + const { data: isStandardMode } = useStandardExperienceMode(); const shouldRenderSeverity = - isLegacy && + isStandardMode && Boolean(severity) && rule.left && rule.right && @@ -238,7 +238,7 @@ function RuleCell({ rule, severity }: Readonly<{ rule: RuleCompare; severity?: s <LinkStandalone className="sw-ml-1" to={getRulesUrl({ rule_key: rule.key, open: rule.key })}> {rule.name} </LinkStandalone> - {!isLegacy && (rule.cleanCodeAttributeCategory || rule.impacts.length > 0) && ( + {!isStandardMode && (rule.cleanCodeAttributeCategory || rule.impacts.length > 0) && ( <ul className="sw-mt-3 sw-flex sw-items-center"> {rule.cleanCodeAttributeCategory && ( <li> diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRules.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRules.tsx index eebcabef175..039fc4a7afe 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRules.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileRules.tsx @@ -33,9 +33,10 @@ import DocHelpTooltip from '~sonar-aligned/components/controls/DocHelpTooltip'; import { translate } from '../../../helpers/l10n'; import { isDefined } from '../../../helpers/types'; import { getRulesUrl } from '../../../helpers/urls'; +import { StaleTime } from '../../../queries/common'; import { useGetQualityProfile } from '../../../queries/quality-profiles'; import { useSearchRulesQuery } from '../../../queries/rules'; -import { useIsLegacyCCTMode } from '../../../queries/settings'; +import { useStandardExperienceMode } from '../../../queries/settings'; import { CleanCodeAttributeCategory, SoftwareQuality } from '../../../types/clean-code-taxonomy'; import { SearchRulesResponse } from '../../../types/coding-rules'; import { RulesFacetName } from '../../../types/rules'; @@ -55,28 +56,31 @@ interface ByType { } export default function ProfileRules({ profile }: Readonly<Props>) { - const { data: isLegacy } = useIsLegacyCCTMode(); + const { data: isStandardMode } = useStandardExperienceMode(); const activateMoreUrl = getRulesUrl({ qprofile: profile.key, activation: 'false' }); const { actions = {} } = profile; - const { data: allRules, isLoading: isAllRulesLoading } = useSearchRulesQuery({ - ps: 1, - languages: profile.language, - facets: isLegacy - ? `${RulesFacetName.Types}` - : `${RulesFacetName.CleanCodeAttributeCategories},${RulesFacetName.ImpactSoftwareQualities}`, - }); + const { data: allRules, isLoading: isAllRulesLoading } = useSearchRulesQuery( + { + ps: 1, + languages: profile.language, + facets: isStandardMode + ? `${RulesFacetName.Types}` + : `${RulesFacetName.CleanCodeAttributeCategories},${RulesFacetName.ImpactSoftwareQualities}`, + }, + { staleTime: StaleTime.LIVE }, + ); const { data: activatedRules, isLoading: isActivatedRulesLoading } = useSearchRulesQuery( { ps: 1, activation: 'true', - facets: isLegacy + facets: isStandardMode ? `${RulesFacetName.Types}` : `${RulesFacetName.CleanCodeAttributeCategories},${RulesFacetName.ImpactSoftwareQualities}`, qprofile: profile.key, }, - { enabled: !!allRules }, + { enabled: !!allRules, staleTime: StaleTime.LIVE }, ); const { data: sonarWayDiff, isLoading: isShowProfileLoading } = useGetQualityProfile( @@ -123,7 +127,7 @@ export default function ProfileRules({ profile }: Readonly<Props>) { {translate('quality_profile.rules.breakdown')} </Heading> - {isLegacy && ( + {isStandardMode && ( <Table columnCount={3} columnWidths={['50%', '25%', '25%']} @@ -153,7 +157,7 @@ export default function ProfileRules({ profile }: Readonly<Props>) { </Table> )} - {!isLegacy && ( + {!isStandardMode && ( <> <Table className="sw-mb-4" diff --git a/server/sonar-web/src/main/js/apps/settings/components/authentication/GitHubAuthenticationTab.tsx b/server/sonar-web/src/main/js/apps/settings/components/authentication/GitHubAuthenticationTab.tsx index 057bebd138b..456d1c3f7e6 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/authentication/GitHubAuthenticationTab.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/authentication/GitHubAuthenticationTab.tsx @@ -372,7 +372,7 @@ export default function GitHubAuthenticationTab() { {isFormOpen && ( <GitHubConfigurationForm gitHubConfiguration={gitHubConfiguration} - isLegacyConfiguration={hasLegacyConfiguration} + isStandardModeConfiguration={hasLegacyConfiguration} onClose={() => { setIsFormOpen(false); }} diff --git a/server/sonar-web/src/main/js/apps/settings/components/authentication/GitHubConfigurationForm.tsx b/server/sonar-web/src/main/js/apps/settings/components/authentication/GitHubConfigurationForm.tsx index 693953ba25f..e4b71b2ea81 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/authentication/GitHubConfigurationForm.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/authentication/GitHubConfigurationForm.tsx @@ -48,7 +48,7 @@ import { interface Props { gitHubConfiguration?: GitHubConfigurationResponse; - isLegacyConfiguration: boolean; + isStandardModeConfiguration: boolean; onClose: () => void; } @@ -64,7 +64,7 @@ interface FormData { } export default function GitHubConfigurationForm(props: Readonly<Props>) { - const { gitHubConfiguration, isLegacyConfiguration, onClose } = props; + const { gitHubConfiguration, isStandardModeConfiguration, onClose } = props; const isCreate = gitHubConfiguration === undefined; const [errors, setErrors] = useState<Partial<Record<GitHubAuthFormFields, ErrorValue>>>({}); @@ -158,13 +158,13 @@ export default function GitHubConfigurationForm(props: Readonly<Props>) { } }; - const helpMessage = isLegacyConfiguration ? `legacy_help.${AlmKeys.GitHub}` : 'help'; + const helpMessage = isStandardModeConfiguration ? `legacy_help.${AlmKeys.GitHub}` : 'help'; const formBody = ( <form id={FORM_ID} onSubmit={handleSubmit}> <FlagMessage className="sw-w-full sw-mb-8" - variant={isLegacyConfiguration ? 'warning' : 'info'} + variant={isStandardModeConfiguration ? 'warning' : 'info'} > <span> <FormattedMessage @@ -192,7 +192,7 @@ export default function GitHubConfigurationForm(props: Readonly<Props>) { onFieldChange={(_, value) => { setFormData((prev) => ({ ...prev, [key]: { ...prev[key], value } })); }} - isNotSet={isCreate || isLegacyConfiguration} + isNotSet={isCreate || isStandardModeConfiguration} error={errors[key]?.message} /> </div> |