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 | |
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')
45 files changed, 255 insertions, 232 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 deb82e402fe..e8b3fc1340f 100644 --- a/server/sonar-web/src/main/js/app/components/ChangeInCalculationPill.tsx +++ b/server/sonar-web/src/main/js/app/components/ChangeInCalculationPill.tsx @@ -23,7 +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 { useStandardExperienceMode } from '../../queries/settings'; import { ComponentQualifier } from '../../sonar-aligned/types/component'; interface Props { @@ -32,9 +32,9 @@ interface Props { export default function ChangeInCalculation({ qualifier }: Readonly<Props>) { const [isPopoverOpen, setIsPopoverOpen] = React.useState(false); - const { data: isLegacy, isLoading } = useIsLegacyCCTMode(); + const { data: isStandardMode, isLoading } = useStandardExperienceMode(); - if (isLegacy || isLoading) { + if (isStandardMode || isLoading) { return null; } diff --git a/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx b/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx index 5df87de7d47..af79c64c70b 100644 --- a/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx +++ b/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx @@ -34,7 +34,7 @@ import { translateWithParameters } from '../../helpers/l10n'; import { HttpStatus } from '../../helpers/request'; import { getPortfolioUrl, getProjectUrl, getPullRequestUrl } from '../../helpers/urls'; import { useCurrentBranchQuery } from '../../queries/branch'; -import { useIsLegacyCCTMode } from '../../queries/settings'; +import { useStandardExperienceMode } from '../../queries/settings'; import { ProjectAlmBindingConfigurationErrors } from '../../types/alm-settings'; import { Branch } from '../../types/branch-like'; import { isFile } from '../../types/component'; @@ -73,8 +73,8 @@ function ComponentContainer({ hasFeature }: Readonly<WithAvailableFeaturesProps> fixedInPullRequest ? component : undefined, ); - //prefetch isLegacyCCTMode - useIsLegacyCCTMode(); + //prefetch isStandardExperienceMode + useStandardExperienceMode(); const isInTutorials = pathname.includes('tutorials'); diff --git a/server/sonar-web/src/main/js/app/components/__tests__/CalculationChangeMessage-test.tsx b/server/sonar-web/src/main/js/app/components/__tests__/CalculationChangeMessage-test.tsx index 737f980634a..fa213e0394c 100644 --- a/server/sonar-web/src/main/js/app/components/__tests__/CalculationChangeMessage-test.tsx +++ b/server/sonar-web/src/main/js/app/components/__tests__/CalculationChangeMessage-test.tsx @@ -53,7 +53,7 @@ it.each([ it.each([ ['Project', '/projects', ComponentQualifier.Project], ['Portfolios', '/portfolios', ComponentQualifier.Portfolio], -])('should not render on %s page if isLegacy', (_, path, qualifier) => { +])('should not render on %s page if isStandardMode', (_, path, qualifier) => { settingsHandler.set(SettingsKey.MQRMode, 'false'); render(path); expect(ui.alert.get()).toBeInTheDocument(); 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 10b7e06c5e8..5facef0fe93 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 @@ -52,7 +52,7 @@ jest.mock('../../../api/components', () => ({ })); jest.mock('../../../queries/settings', () => ({ - useIsLegacyCCTMode: jest.fn(), + useStandardExperienceMode: jest.fn(), })); jest.mock('../../../api/navigation', () => ({ diff --git a/server/sonar-web/src/main/js/app/components/calculation-notification/CalculationChangeMessage.tsx b/server/sonar-web/src/main/js/app/components/calculation-notification/CalculationChangeMessage.tsx index 34e97a11306..14b082b1235 100644 --- a/server/sonar-web/src/main/js/app/components/calculation-notification/CalculationChangeMessage.tsx +++ b/server/sonar-web/src/main/js/app/components/calculation-notification/CalculationChangeMessage.tsx @@ -25,7 +25,7 @@ import DocumentationLink from '../../../components/common/DocumentationLink'; import DismissableAlert from '../../../components/ui/DismissableAlert'; import { DocLink } from '../../../helpers/doc-links'; import { translate } from '../../../helpers/l10n'; -import { useIsLegacyCCTMode } from '../../../queries/settings'; +import { useStandardExperienceMode } from '../../../queries/settings'; import { Dict } from '../../../types/types'; const SHOW_MESSAGE_PATHS: Dict<ComponentQualifier> = { @@ -37,9 +37,9 @@ const ALERT_KEY = 'sonarqube.dismissed_calculation_change_alert'; export default function CalculationChangeMessage() { const location = useLocation(); - const { data: isLegacy } = useIsLegacyCCTMode(); + const { data: isStandardMode } = useStandardExperienceMode(); - if (isLegacy || !Object.keys(SHOW_MESSAGE_PATHS).includes(location.pathname)) { + if (isStandardMode || !Object.keys(SHOW_MESSAGE_PATHS).includes(location.pathname)) { return null; } diff --git a/server/sonar-web/src/main/js/app/components/metrics/RatingComponent.tsx b/server/sonar-web/src/main/js/app/components/metrics/RatingComponent.tsx index f63301ef1f3..50714c4d1a1 100644 --- a/server/sonar-web/src/main/js/app/components/metrics/RatingComponent.tsx +++ b/server/sonar-web/src/main/js/app/components/metrics/RatingComponent.tsx @@ -27,7 +27,7 @@ import { getLeakValue } from '../../../components/measure/utils'; import { SOFTWARE_QUALITY_RATING_METRICS_MAP } from '../../../helpers/constants'; import { isDiffMetric } from '../../../helpers/measures'; import { useMeasureQuery } from '../../../queries/measures'; -import { useIsLegacyCCTMode } from '../../../queries/settings'; +import { useStandardExperienceMode } from '../../../queries/settings'; import { BranchLike } from '../../../types/branch-like'; type SizeType = 'xs' | 'sm' | 'md' | 'lg' | 'xl'; @@ -59,7 +59,7 @@ function isNewRatingMetric(metricKey: MetricKey) { } const useGetMetricKeyForRating = (ratingMetric: RatingMetricKeys): MetricKey | null => { - const { data: isLegacy, isLoading } = useIsLegacyCCTMode(); + const { data: isStandardMode, isLoading } = useStandardExperienceMode(); const hasSoftwareQualityRating = !!SOFTWARE_QUALITY_RATING_METRICS_MAP[ratingMetric]; @@ -70,7 +70,7 @@ const useGetMetricKeyForRating = (ratingMetric: RatingMetricKeys): MetricKey | n if (isLoading) { return null; } - return isLegacy || !hasSoftwareQualityRating + return isStandardMode || !hasSoftwareQualityRating ? ratingMetric : SOFTWARE_QUALITY_RATING_METRICS_MAP[ratingMetric]; }; @@ -88,7 +88,7 @@ export default function RatingComponent(props: Readonly<Props>) { } = props; const metricKey = useGetMetricKeyForRating(ratingMetric as RatingMetricKeys); - const { data: isLegacy } = useIsLegacyCCTMode(); + const { data: isStandardMode } = useStandardExperienceMode(); const { data: targetMeasure, isLoading: isLoadingTargetMeasure } = useMeasureQuery( { componentKey, metricKey: metricKey ?? '', branchLike }, { enabled: !forceMetric && !!metricKey }, @@ -98,7 +98,8 @@ export default function RatingComponent(props: Readonly<Props>) { { componentKey, metricKey: ratingMetric, branchLike }, { enabled: - forceMetric || (!isLegacy && !isNewRatingMetric(ratingMetric) && targetMeasure === null), + forceMetric || + (!isStandardMode && !isNewRatingMetric(ratingMetric) && targetMeasure === null), }, ); 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> diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx index 2915ce50b29..ac85d31cb62 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx @@ -58,7 +58,7 @@ import { omitNil } from '../../helpers/request'; import { getBaseUrl } from '../../helpers/system'; import { isDefined } from '../../helpers/types'; import { getBranchLikeUrl, getCodeUrl } from '../../helpers/urls'; -import { useIsLegacyCCTMode } from '../../queries/settings'; +import { useStandardExperienceMode } from '../../queries/settings'; import type { BranchLike } from '../../types/branch-like'; import { IssueType } from '../../types/issues'; import type { Measure, SourceViewerFile } from '../../types/types'; @@ -76,7 +76,7 @@ interface Props { export default function SourceViewerHeader(props: Readonly<Props>) { const intl = useIntl(); - const { data: isLegacy = false } = useIsLegacyCCTMode(); + const { data: isStandardMode = false } = useStandardExperienceMode(); const { showMeasures, branchLike, hidePinOption, openComponent, componentMeasures } = props; const { key, measures, path, project, projectName, q } = props.sourceViewerFile; @@ -87,7 +87,7 @@ export default function SourceViewerHeader(props: Readonly<Props>) { const rawSourcesLink = `${getBaseUrl()}/api/sources/raw?${query}`; const renderIssueMeasures = () => { - const areCCTMeasuresComputed = !isLegacy && areCCTMeasuresComputedFn(componentMeasures); + const areCCTMeasuresComputed = !isStandardMode && areCCTMeasuresComputedFn(componentMeasures); return ( componentMeasures && @@ -115,7 +115,7 @@ export default function SourceViewerHeader(props: Readonly<Props>) { }); const qualityTitle = intl.formatMessage({ - id: `metric.${isLegacy ? deprecatedMetric : metric}.short_name`, + id: `metric.${isStandardMode ? deprecatedMetric : metric}.short_name`, }); return ( diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesIndicator.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesIndicator.tsx index a7d77852d73..17561817e60 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesIndicator.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineIssuesIndicator.tsx @@ -22,7 +22,7 @@ import { uniq } from 'lodash'; import * as React from 'react'; import { useIntl } from 'react-intl'; import Tooltip from '../../../components/controls/Tooltip'; -import { useIsLegacyCCTMode } from '../../../queries/settings'; +import { useStandardExperienceMode } from '../../../queries/settings'; import { Issue, SourceLine } from '../../../types/types'; const MOUSE_LEAVE_DELAY = 0.25; @@ -39,7 +39,7 @@ export function LineIssuesIndicator(props: LineIssuesIndicatorProps) { const { issues, issuesOpen, line, as = 'td' } = props; const hasIssues = issues.length > 0; const intl = useIntl(); - const { data: isLegacy } = useIsLegacyCCTMode(); + const { data: isStandardMode } = useStandardExperienceMode(); if (!hasIssues) { return <LineMeta />; @@ -49,7 +49,7 @@ export function LineIssuesIndicator(props: LineIssuesIndicatorProps) { const issueTypes = uniq(issues.map((issue) => issue.type)); let tooltipContent; - if (isLegacy ? issueTypes.length > 1 : issueAttributeCategories.length > 1) { + if (isStandardMode ? issueTypes.length > 1 : issueAttributeCategories.length > 1) { tooltipContent = intl.formatMessage( { id: 'source_viewer.issues_on_line.multiple_issues' }, { show: !issuesOpen }, @@ -57,7 +57,7 @@ export function LineIssuesIndicator(props: LineIssuesIndicatorProps) { } else { tooltipContent = intl.formatMessage( { - id: `source_viewer.issues_on_line.multiple_issues_same_category${isLegacy ? '.legacy' : ''}`, + id: `source_viewer.issues_on_line.multiple_issues_same_category${isStandardMode ? '.legacy' : ''}`, }, { show: !issuesOpen, diff --git a/server/sonar-web/src/main/js/components/activity-graph/utils.ts b/server/sonar-web/src/main/js/components/activity-graph/utils.ts index b1768446382..ebcc1aa3550 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/utils.ts +++ b/server/sonar-web/src/main/js/components/activity-graph/utils.ts @@ -91,20 +91,24 @@ export function getSeriesMetricType(series: Serie[]) { export function getDisplayedHistoryMetrics( graph: GraphType, customMetrics: string[], - isLegacy = false, + isStandardMode = false, ) { if (isCustomGraph(graph)) { return customMetrics; } - return isLegacy ? LEGACY_GRAPHS_METRICS_DISPLAYED[graph] : GRAPHS_METRICS_DISPLAYED[graph]; + return isStandardMode ? LEGACY_GRAPHS_METRICS_DISPLAYED[graph] : GRAPHS_METRICS_DISPLAYED[graph]; } -export function getHistoryMetrics(graph: GraphType, customMetrics: string[], isLegacy = false) { +export function getHistoryMetrics( + graph: GraphType, + customMetrics: string[], + isStandardMode = false, +) { if (isCustomGraph(graph)) { return customMetrics; } - return isLegacy ? LEGACY_GRAPHS_METRICS[graph] : GRAPHS_METRICS[graph]; + return isStandardMode ? LEGACY_GRAPHS_METRICS[graph] : GRAPHS_METRICS[graph]; } export function hasHistoryDataValue(series: Serie[]) { diff --git a/server/sonar-web/src/main/js/components/icon-mappers/SoftwareImpactSeverityIcon.tsx b/server/sonar-web/src/main/js/components/icon-mappers/SoftwareImpactSeverityIcon.tsx index 0d42c729b26..9f3ce0ca77b 100644 --- a/server/sonar-web/src/main/js/components/icon-mappers/SoftwareImpactSeverityIcon.tsx +++ b/server/sonar-web/src/main/js/components/icon-mappers/SoftwareImpactSeverityIcon.tsx @@ -27,7 +27,7 @@ import { } from 'design-system'; import * as React from 'react'; import { translate } from '../../helpers/l10n'; -import { useIsLegacyCCTMode } from '../../queries/settings'; +import { useStandardExperienceMode } from '../../queries/settings'; import { SoftwareImpactSeverity } from '../../types/clean-code-taxonomy'; import { IssueSeverity } from '../../types/issues'; import { Dict } from '../../types/types'; @@ -51,7 +51,7 @@ const severityIcons: Dict<(props: IconProps) => React.ReactElement> = { }; export default function SoftwareImpactSeverityIcon({ severity, ...iconProps }: Readonly<Props>) { - const { data: isLegacy } = useIsLegacyCCTMode(); + const { data: isStandardMode } = useStandardExperienceMode(); if (typeof severity !== 'string' || !severityIcons[severity]) { return null; } @@ -62,7 +62,7 @@ export default function SoftwareImpactSeverityIcon({ severity, ...iconProps }: R {...iconProps} width={iconProps?.width ?? defaultIconSize} height={iconProps?.height ?? defaultIconSize} - aria-label={translate(isLegacy ? 'severity' : 'severity_impact', severity)} + aria-label={translate(isStandardMode ? 'severity' : 'severity_impact', severity)} /> ); } diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.tsx b/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.tsx index 73f51cee95e..46215799b4e 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.tsx +++ b/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.tsx @@ -19,7 +19,7 @@ */ import * as React from 'react'; -import { useIsLegacyCCTMode } from '../../../queries/settings'; +import { useStandardExperienceMode } from '../../../queries/settings'; import { BranchLike } from '../../../types/branch-like'; import { Issue } from '../../../types/types'; import { CleanCodeAttributePill } from '../../shared/CleanCodeAttributePill'; @@ -33,7 +33,7 @@ export interface IssueTitleBarProps { export default function IssueTitleBar(props: Readonly<IssueTitleBarProps>) { const { issue, displayWhyIsThisAnIssue, branchLike } = props; - const { data: isLegacy } = useIsLegacyCCTMode(); + const { data: isStandardMode } = useStandardExperienceMode(); return ( <div className="sw-mt-1 sw-flex sw-items-start sw-justify-between sw-gap-8"> @@ -45,7 +45,7 @@ export default function IssueTitleBar(props: Readonly<IssueTitleBarProps>) { /> </div> - {!isLegacy && ( + {!isStandardMode && ( <CleanCodeAttributePill cleanCodeAttributeCategory={issue.cleanCodeAttributeCategory} /> )} </div> 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 b0bb17d6cbf..c9dd40bf03a 100644 --- a/server/sonar-web/src/main/js/components/shared/AnalysisMissingInfoMessage.tsx +++ b/server/sonar-web/src/main/js/components/shared/AnalysisMissingInfoMessage.tsx @@ -22,7 +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 { useStandardExperienceMode } from '../../queries/settings'; import DocumentationLink from '../common/DocumentationLink'; interface AnalysisMissingInfoMessageProps { @@ -36,10 +36,10 @@ export default function AnalysisMissingInfoMessage({ qualifier, className, }: Readonly<AnalysisMissingInfoMessageProps>) { - const { data: isLegacy, isLoading } = useIsLegacyCCTMode(); + const { data: isStandardMode, isLoading } = useStandardExperienceMode(); const intl = useIntl(); - if (hide || isLoading || isLegacy) { + if (hide || isLoading || isStandardMode) { return null; } diff --git a/server/sonar-web/src/main/js/components/shared/SoftwareImpactPillList.tsx b/server/sonar-web/src/main/js/components/shared/SoftwareImpactPillList.tsx index 5fb953f5a66..0275abea56c 100644 --- a/server/sonar-web/src/main/js/components/shared/SoftwareImpactPillList.tsx +++ b/server/sonar-web/src/main/js/components/shared/SoftwareImpactPillList.tsx @@ -20,7 +20,7 @@ import classNames from 'classnames'; import React from 'react'; import { translate } from '../../helpers/l10n'; -import { useIsLegacyCCTMode } from '../../queries/settings'; +import { useStandardExperienceMode } from '../../queries/settings'; import { SoftwareImpact, SoftwareImpactSeverity, @@ -54,7 +54,7 @@ export default function SoftwareImpactPillList({ className, ...props }: Readonly<SoftwareImpactPillListProps>) { - const { data: isLegacy } = useIsLegacyCCTMode(); + const { data: isStandardMode } = useStandardExperienceMode(); const getQualityLabel = (quality: SoftwareQuality) => translate('software_quality', quality); const sortingFn = (a: SoftwareImpact, b: SoftwareImpact) => { if (a.severity !== b.severity) { @@ -65,7 +65,7 @@ export default function SoftwareImpactPillList({ return ( <ul className={classNames('sw-flex sw-gap-2', className)} {...props}> - {!isLegacy && + {!isStandardMode && softwareImpacts .slice() .sort(sortingFn) @@ -78,10 +78,10 @@ export default function SoftwareImpactPillList({ /> </li> ))} - {!isLegacy && softwareImpacts.length === 0 && issueType === 'SECURITY_HOTSPOT' && ( + {!isStandardMode && softwareImpacts.length === 0 && issueType === 'SECURITY_HOTSPOT' && ( <IssueTypePill severity={issueSeverity ?? IssueSeverity.Info} issueType={issueType} /> )} - {isLegacy && issueType && issueSeverity && ( + {isStandardMode && issueType && issueSeverity && ( <IssueTypePill severity={issueSeverity} issueType={issueType} /> )} </ul> diff --git a/server/sonar-web/src/main/js/helpers/activity-graph.ts b/server/sonar-web/src/main/js/helpers/activity-graph.ts index 62c3e9d46c4..d2273460103 100644 --- a/server/sonar-web/src/main/js/helpers/activity-graph.ts +++ b/server/sonar-web/src/main/js/helpers/activity-graph.ts @@ -25,14 +25,14 @@ import { SOFTWARE_QUALITY_RATING_METRICS_MAP } from './constants'; export const mergeRatingMeasureHistory = ( historyData: TimeMachineResponse | undefined, parseDateFn: (date: string) => Date, - isLegacy = false, + isStandardMode = false, ) => { const softwareQualityMeasures = Object.values(SOFTWARE_QUALITY_RATING_METRICS_MAP); const softwareQualityMeasuresMap = new Map< string, { history: { date: string; value?: string }[]; index: number; splitDate?: Date } >(); - if (isLegacy) { + if (isStandardMode) { return ( historyData?.measures ?.filter((m) => !softwareQualityMeasures.includes(m.metric)) diff --git a/server/sonar-web/src/main/js/queries/rules.ts b/server/sonar-web/src/main/js/queries/rules.ts index 07f83be487e..2525d85133a 100644 --- a/server/sonar-web/src/main/js/queries/rules.ts +++ b/server/sonar-web/src/main/js/queries/rules.ts @@ -17,11 +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 { - queryOptions, - useMutation, - useQueryClient, -} from '@tanstack/react-query'; +import { queryOptions, useMutation, useQueryClient } from '@tanstack/react-query'; import { createRule, deleteRule, getRuleDetails, searchRules, updateRule } from '../api/rules'; import { mapRestRuleToRule } from '../apps/coding-rules/utils'; import { SearchRulesResponse } from '../types/coding-rules'; diff --git a/server/sonar-web/src/main/js/queries/settings.ts b/server/sonar-web/src/main/js/queries/settings.ts index 83d02cbaf81..e9fb110dd44 100644 --- a/server/sonar-web/src/main/js/queries/settings.ts +++ b/server/sonar-web/src/main/js/queries/settings.ts @@ -57,7 +57,7 @@ export const useGetValueQuery = createQueryHook( }, ); -export const useIsLegacyCCTMode = () => { +export const useStandardExperienceMode = () => { return useGetValueQuery( { key: SettingsKey.MQRMode }, { staleTime: Infinity, select: (data) => data?.value === 'false' }, |