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 {
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;
}
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';
fixedInPullRequest ? component : undefined,
);
- //prefetch isLegacyCCTMode
- useIsLegacyCCTMode();
+ //prefetch isStandardExperienceMode
+ useStandardExperienceMode();
const isInTutorials = pathname.includes('tutorials');
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();
}));
jest.mock('../../../queries/settings', () => ({
- useIsLegacyCCTMode: jest.fn(),
+ useStandardExperienceMode: jest.fn(),
}));
jest.mock('../../../api/navigation', () => ({
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> = {
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;
}
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';
}
const useGetMetricKeyForRating = (ratingMetric: RatingMetricKeys): MetricKey | null => {
- const { data: isLegacy, isLoading } = useIsLegacyCCTMode();
+ const { data: isStandardMode, isLoading } = useStandardExperienceMode();
const hasSoftwareQualityRating = !!SOFTWARE_QUALITY_RATING_METRICS_MAP[ratingMetric];
if (isLoading) {
return null;
}
- return isLegacy || !hasSoftwareQualityRating
+ return isStandardMode || !hasSoftwareQualityRating
? ratingMetric
: SOFTWARE_QUALITY_RATING_METRICS_MAP[ratingMetric];
};
} = 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 },
{ componentKey, metricKey: ratingMetric, branchLike },
{
enabled:
- forceMetric || (!isLegacy && !isNewRatingMetric(ratingMetric) && targetMeasure === null),
+ forceMetric ||
+ (!isStandardMode && !isNewRatingMetric(ratingMetric) && targetMeasure === null),
},
);
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';
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 }),
);
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]);
</FlagMessage>
)}
- <Spinner isLoading={loading || isLoadingLegacy}>
+ <Spinner isLoading={loading || isLoadingStandardMode}>
{!allComponentsHaveSoftwareQualityMeasures && (
<AnalysisMissingInfoMessage
qualifier={component.qualifier}
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';
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;
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 {
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;
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',
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';
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 =
disabledHelper={translate('coding_rules.filters.language.inactive')}
/>
- {isLegacy && (
+ {isStandardMode && (
<>
<BasicSeparator className="sw-my-4" />
</>
)}
- {!isLegacy && (
+ {!isStandardMode && (
<>
<BasicSeparator className="sw-my-4" />
</>
)}
- {!isLegacy && (
+ {!isStandardMode && (
<>
<BasicSeparator className="sw-my-4" />
</>
)}
- {!isLegacy && (
+ {!isStandardMode && (
<>
<BasicSeparator className="sw-my-4" />
</>
)}
- {isLegacy && (
+ {isStandardMode && (
<>
<BasicSeparator className="sw-my-4" />
</>
)}
- {!isLegacy && (
+ {!isStandardMode && (
<>
<BasicSeparator className="sw-my-4" />
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';
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;
<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"
</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>
);
}
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';
const { mutate: deactivateRule } = useDeactivateRuleMutation((data) =>
onDeactivate(data.key, data.rule),
);
- const { data: isLegacy } = useIsLegacyCCTMode();
+ const { data: isStandardMode } = useStandardExperienceMode();
const activation =
data && ruleIsChanged
</div>
<div>
- {rule.cleanCodeAttributeCategory !== undefined && !isLegacy && (
+ {rule.cleanCodeAttributeCategory !== undefined && !isStandardMode && (
<CleanCodeAttributePill
cleanCodeAttributeCategory={rule.cleanCodeAttributeCategory}
type="rule"
*/
import { areCCTMeasuresComputed, areSoftwareQualityRatingsComputed } from '../../helpers/measures';
-import { useIsLegacyCCTMode } from '../../queries/settings';
+import { useStandardExperienceMode } from '../../queries/settings';
import { MeasureEnhanced } from '../../types/types';
import {
legacyBubbles,
} 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;
}
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 {
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);
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}
/>
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';
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) => {
];
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) => {
};
});
- if (!isLegacy && areLeakCCTMeasuresComputed(measures)) {
+ if (!isStandardMode && areLeakCCTMeasuresComputed(measures)) {
populatedMeasures = populatedMeasures.filter(
(measure) => !LEAK_OLD_TAXONOMY_METRICS.includes(measure.metric.key as MetricKey),
);
}
// 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) &&
);
}
- if (!isLegacy && areCCTMeasuresComputed(measures)) {
+ if (!isStandardMode && areCCTMeasuresComputed(measures)) {
populatedMeasures = populatedMeasures.filter(
(measure) => !OLD_TAXONOMY_METRICS.includes(measure.metric.key as MetricKey),
);
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');
}
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';
}
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"
/>
</IssueHeaderInfo>
- {!isLegacy && (
+ {!isStandardMode && (
<IssueHeaderInfo title={translate('issue.cct_attribute.label')}>
<CleanCodeAttributePill
cleanCodeAttributeCategory={issue.cleanCodeAttributeCategory}
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';
} = props;
const { settings } = useAppState();
const { hasFeature } = useAvailableFeatures();
- const { data: isLegacy } = useIsLegacyCCTMode();
+ const { data: isStandardMode } = useStandardExperienceMode();
const renderComponentFacets = () => {
const hasFileOrDirectory =
<PeriodFilter onChange={props.onFilterChange} newCodeSelected={query.inNewCodePeriod} />
)}
- {!isLegacy && !needIssueSync && (
+ {!isStandardMode && !needIssueSync && (
<>
<SoftwareQualityFacet
fetching={props.loadingFacets.impactSoftwareQualities === true}
</>
)}
- {isLegacy && (
+ {isStandardMode && (
<>
<TypeFacet
fetching={props.loadingFacets.types === true}
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,
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;
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';
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,
};
const loadHistoryMeasures = React.useCallback(() => {
- const graphMetrics = getHistoryMetrics(graph, [], isLegacy);
+ const graphMetrics = getHistoryMetrics(graph, [], isStandardMode);
const metrics = uniq([...HISTORY_METRICS_LIST, ...graphMetrics]);
return getAllTimeMachineData({
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';
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(
>
<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">
<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(
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';
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();
return null;
}
- if (isLegacy && value !== undefined) {
+ if (isStandardMode && value !== undefined) {
return <RatingTooltipContent metricKey={ratingMetricKey} value={value} />;
}
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';
);
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(
{
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(() => {
return (
component && (
- <Spinner isLoading={isLoadingLegacy}>
+ <Spinner isLoading={isLoadingStandardMode}>
<ProjectActivityAppRenderer
analyses={analyses}
- isLegacy={
- isLegacy ||
+ isStandardMode={
+ isStandardMode ||
!firstSoftwareQualityRatingMetric ||
firstSoftwareQualityRatingMetric.history.every((h) => h.value === undefined)
}
analysesLoading: boolean;
graphLoading: boolean;
initializing: boolean;
- isLegacy?: boolean;
+ isStandardMode?: boolean;
leakPeriodDate?: Date;
measuresHistory: MeasureHistory[];
metrics: Metric[];
graphLoading,
metrics,
project,
- isLegacy,
+ isStandardMode,
} = props;
const { configuration, qualifier } = props.project;
const canAdmin =
analyses={analyses}
leakPeriodDate={leakPeriodDate}
loading={graphLoading}
- isLegacy={isLegacy}
+ isStandardMode={isStandardMode}
measuresHistory={measuresHistory}
metrics={metrics}
project={project.key}
interface Props {
analyses: ParsedAnalysis[];
- isLegacy?: boolean;
+ isStandardMode?: boolean;
leakPeriodDate?: Date;
loading: boolean;
measuresHistory: MeasureHistory[];
};
renderQualitiesMetricInfoMessage = () => {
- const { measuresHistory, isLegacy } = this.props;
+ const { measuresHistory, isStandardMode } = this.props;
const qualityMeasuresHistory = measuresHistory.find((history) =>
CCT_SOFTWARE_QUALITY_METRICS.includes(history.metric),
if (
this.hasGaps(qualityMeasuresHistory) ||
- (!isLegacy && this.hasGaps(ratingQualityMeasuresHistory))
+ (!isStandardMode && this.hasGaps(ratingQualityMeasuresHistory))
) {
return (
<FlagMessage variant="info">
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',
incorrect_property: 'should not appear in post data',
search: 'foo',
},
- isLegacy: true,
+ isStandardMode: true,
});
expect(searchProjects).toHaveBeenCalledWith({
});
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',
incorrect_property: 'should not appear in post data',
search: 'foo',
},
- isLegacy: false,
+ isStandardMode: false,
});
expect(searchProjects).toHaveBeenCalledWith({
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 },
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';
appState: AppState;
currentUser: CurrentUser;
isFavorite: boolean;
- isLegacy: boolean;
+ isStandardMode: boolean;
location: Location;
router: Router;
}
}
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,
+ );
}
};
};
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) {
};
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,
});
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(
() => {
return (
<Spinner isLoading={isLoading}>
- <AllProjects {...props} isLegacy={isLegacy ?? false} />
+ <AllProjects {...props} isStandardMode={isStandardMode ?? false} />
</Spinner>
);
}
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';
);
}
-function renderRatings(props: ProjectCardMeasuresProps, isLegacy: boolean) {
+function renderRatings(props: ProjectCardMeasuresProps, isStandardMode: boolean) {
const { isNewCode, measures, componentKey } = props;
const measuresByCodeLeak = isNewCode
: [
{
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,
},
{
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,
},
{
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,
export default function ProjectCardMeasures(props: ProjectCardMeasuresProps) {
const { isNewCode, measures, componentQualifier } = props;
- const { data: isLegacy } = useIsLegacyCCTMode();
+ const { data: isStandardMode } = useStandardExperienceMode();
const { ncloc } = measures;
const measureList = [
renderNewIssues(props),
- ...renderRatings(props, !!isLegacy),
+ ...renderRatings(props, !!isStandardMode),
renderCoverage(props),
renderDuplication(props),
].filter(isDefined);
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';
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) => {
facet={facet}
header={translate('metric_domain', name)}
description={
- hasDescription(property, isLegacy)
+ hasDescription(property, isStandardMode)
? translate(`projects.facets.${property.replace('new_', '')}.description`)
: undefined
}
);
}
-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);
};
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);
/>
<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>
* 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';
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']),
};
}
-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) {
}
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),
);
[
'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 ');
}
}
-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(
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]));
}
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',
});
.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,
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;
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;
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;
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';
}
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 &&
<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>
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';
}
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(
{translate('quality_profile.rules.breakdown')}
</Heading>
- {isLegacy && (
+ {isStandardMode && (
<Table
columnCount={3}
columnWidths={['50%', '25%', '25%']}
</Table>
)}
- {!isLegacy && (
+ {!isStandardMode && (
<>
<Table
className="sw-mb-4"
{isFormOpen && (
<GitHubConfigurationForm
gitHubConfiguration={gitHubConfiguration}
- isLegacyConfiguration={hasLegacyConfiguration}
+ isStandardModeConfiguration={hasLegacyConfiguration}
onClose={() => {
setIsFormOpen(false);
}}
interface Props {
gitHubConfiguration?: GitHubConfigurationResponse;
- isLegacyConfiguration: boolean;
+ isStandardModeConfiguration: boolean;
onClose: () => void;
}
}
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>>>({});
}
};
- 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
onFieldChange={(_, value) => {
setFormData((prev) => ({ ...prev, [key]: { ...prev[key], value } }));
}}
- isNotSet={isCreate || isLegacyConfiguration}
+ isNotSet={isCreate || isStandardModeConfiguration}
error={errors[key]?.message}
/>
</div>
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';
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;
const rawSourcesLink = `${getBaseUrl()}/api/sources/raw?${query}`;
const renderIssueMeasures = () => {
- const areCCTMeasuresComputed = !isLegacy && areCCTMeasuresComputedFn(componentMeasures);
+ const areCCTMeasuresComputed = !isStandardMode && areCCTMeasuresComputedFn(componentMeasures);
return (
componentMeasures &&
});
const qualityTitle = intl.formatMessage({
- id: `metric.${isLegacy ? deprecatedMetric : metric}.short_name`,
+ id: `metric.${isStandardMode ? deprecatedMetric : metric}.short_name`,
});
return (
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;
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 />;
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 },
} 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,
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[]) {
} 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';
};
export default function SoftwareImpactSeverityIcon({ severity, ...iconProps }: Readonly<Props>) {
- const { data: isLegacy } = useIsLegacyCCTMode();
+ const { data: isStandardMode } = useStandardExperienceMode();
if (typeof severity !== 'string' || !severityIcons[severity]) {
return null;
}
{...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)}
/>
);
}
*/
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';
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">
/>
</div>
- {!isLegacy && (
+ {!isStandardMode && (
<CleanCodeAttributePill cleanCodeAttributeCategory={issue.cleanCodeAttributeCategory} />
)}
</div>
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 {
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;
}
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,
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) {
return (
<ul className={classNames('sw-flex sw-gap-2', className)} {...props}>
- {!isLegacy &&
+ {!isStandardMode &&
softwareImpacts
.slice()
.sort(sortingFn)
/>
</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>
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))
* 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';
},
);
-export const useIsLegacyCCTMode = () => {
+export const useStandardExperienceMode = () => {
return useGetValueQuery(
{ key: SettingsKey.MQRMode },
{ staleTime: Infinity, select: (data) => data?.value === 'false' },