font-weight: 600;
color: ${themeColor('linkNaked')};
- &:hover,
- &:focus,
- &:active {
- color: ${themeColor('linkActive')};
- }
+ ${({ disabled, theme }) =>
+ disabled
+ ? tw`sw-cursor-default`
+ : `&:hover,
+ &:focus,
+ &:active {
+ color: ${themeColor('linkActive')({ theme })};
+ }`};
`;
export const DrilldownLink = styled(StyledBaseLink)`
background-color: none;
display: block;
}
+
+ ${({ disabled }) => (disabled ? tw`sw-cursor-default` : '')};
`;
LinkBox.displayName = 'DiscreetLinkBox';
import { Component, MeasureEnhanced } from '../../../types/types';
import MeasuresCard from '../components/MeasuresCard';
import MeasuresCardNumber from '../components/MeasuresCardNumber';
+import { OverviewDisabledLinkTooltip } from '../components/OverviewDisabledLinkTooltip';
import { MeasuresTabs } from '../utils';
import MeasuresPanelPercentCards from './MeasuresPanelPercentCards';
import SoftwareImpactMeasureCard from './SoftwareImpactMeasureCard';
color={acceptedIssues === '0' ? 'overviewCardDefaultIcon' : 'overviewCardWarningIcon'}
/>
}
+ disabled={component.needIssueSync}
+ tooltip={component.needIssueSync ? <OverviewDisabledLinkTooltip /> : null}
>
<TextSubdued className="sw-body-xs sw-mt-3">
{intl.formatMessage({
}),
},
)}
+ disabled={component.needIssueSync}
to={url}
>
<span>{formatMeasure(value, MetricType.ShortInteger)}</span>
} from 'design-system';
import * as React from 'react';
import { useIntl } from 'react-intl';
+import Tooltip from '../../../components/controls/Tooltip';
import { DEFAULT_ISSUES_QUERY } from '../../../components/shared/utils';
import { formatMeasure } from '../../../helpers/measures';
import { getComponentIssuesUrl } from '../../../helpers/urls';
} from '../../../types/clean-code-taxonomy';
import { MetricKey, MetricType } from '../../../types/metrics';
import { Component, MeasureEnhanced } from '../../../types/types';
+import { OverviewDisabledLinkTooltip } from '../components/OverviewDisabledLinkTooltip';
import { softwareQualityToMeasure } from '../utils';
import SoftwareImpactMeasureBreakdownCard from './SoftwareImpactMeasureBreakdownCard';
import SoftwareImpactMeasureRating from './SoftwareImpactMeasureRating';
const measureRaw = measures.find((m) => m.metric.key === metricKey);
const measure = JSON.parse(measureRaw?.value ?? 'null') as SoftwareImpactMeasureData;
+ const renderDisabled = !measure || component.needIssueSync;
+
// Find rating measure
const ratingMeasure = measures.find((m) => m.metric.key === ratingMetricKey);
<div className="sw-flex sw-flex-col sw-gap-3">
<div
className={classNames('sw-flex sw-gap-1 sw-items-end', {
- 'sw-opacity-60': !measure,
+ 'sw-opacity-60': renderDisabled,
})}
>
{measure ? (
- <NakedLink
- data-testid={`overview__software-impact-${softwareQuality}`}
- aria-label={intl.formatMessage(
- {
- id: `overview.measures.software_impact.see_list_of_x_open_issues`,
- },
- {
- count: measure.total,
- softwareQuality: intl.formatMessage({
- id: `software_quality.${softwareQuality}`,
- }),
- },
- )}
- className="sw-text-xl"
- to={totalLinkHref}
- >
- {formatMeasure(measure.total, MetricType.ShortInteger)}
- </NakedLink>
+ <Tooltip overlay={component.needIssueSync ? <OverviewDisabledLinkTooltip /> : null}>
+ <NakedLink
+ data-testid={`overview__software-impact-${softwareQuality}`}
+ aria-label={intl.formatMessage(
+ {
+ id: `overview.measures.software_impact.see_list_of_x_open_issues`,
+ },
+ {
+ count: measure.total,
+ softwareQuality: intl.formatMessage({
+ id: `software_quality.${softwareQuality}`,
+ }),
+ },
+ )}
+ className="sw-text-xl"
+ to={totalLinkHref}
+ disabled={component.needIssueSync}
+ >
+ {formatMeasure(measure.total, MetricType.ShortInteger)}
+ </NakedLink>
+ </Tooltip>
) : (
<StyledDash className="sw-self-center sw-font-bold" name="-" />
)}
false,
]);
});
+
+ it('should disable software impact measure card links during reindexing', async () => {
+ const { user, ui } = getPageObjects();
+ renderBranchOverview({
+ component: mockComponent({
+ breadcrumbs: [mockComponent({ key: 'foo' })],
+ key: 'foo',
+ needIssueSync: true,
+ }),
+ });
+
+ await user.click(await ui.overallCodeButton.find());
+
+ expect(await ui.softwareImpactMeasureCard(SoftwareQuality.Security).find()).toBeInTheDocument();
+
+ ui.expectSoftwareImpactMeasureCard(
+ SoftwareQuality.Security,
+ 'B',
+ {
+ total: 1,
+ [SoftwareImpactSeverity.High]: 0,
+ [SoftwareImpactSeverity.Medium]: 1,
+ [SoftwareImpactSeverity.Low]: 0,
+ },
+ [false, true, false],
+ );
+
+ await expect(
+ byRole('link', {
+ name: `overview.measures.software_impact.see_list_of_x_open_issues.${1}.software_quality.${
+ SoftwareQuality.Security
+ }`,
+ }).get(),
+ ).toHaveATooltipWithContent('indexation.in_progress');
+ });
});
describe('application overview', () => {
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import styled from '@emotion/styled';
-import { Badge, Card, ContentLink, themeBorder, themeColor } from 'design-system';
+import { Badge, Card, ContentLink, Tooltip, themeBorder, themeColor } from 'design-system';
import * as React from 'react';
import { To } from 'react-router-dom';
import { translate, translateWithParameters } from '../../../helpers/l10n';
label: string;
failed?: boolean;
icon?: React.ReactElement;
+ disabled?: boolean;
+ tooltip?: React.ReactNode | null;
}
export default function MeasuresCard(
props: React.PropsWithChildren<MeasuresCardProps & React.HTMLAttributes<HTMLDivElement>>,
) {
- const { failed, children, metric, icon, value, url, label, ...rest } = props;
+ const { failed, children, metric, icon, value, url, label, disabled, tooltip, ...rest } = props;
return (
<StyledCard className="sw-h-fit sw-p-6 sw-rounded-2 sw-text-base" {...rest}>
)}
<div className="sw-flex sw-items-center sw-mt-1 sw-justify-between sw-font-semibold">
{value ? (
- <ContentLink
- aria-label={translateWithParameters(
- 'overview.see_more_details_on_x_of_y',
- value,
- localizeMetric(metric),
- )}
- className="it__overview-measures-value sw-text-lg"
- to={url}
- >
- {value}
- </ContentLink>
+ <Tooltip overlay={tooltip}>
+ <ContentLink
+ aria-label={translateWithParameters(
+ 'overview.see_more_details_on_x_of_y',
+ value,
+ localizeMetric(metric),
+ )}
+ className="it__overview-measures-value sw-text-lg"
+ to={url}
+ disabled={disabled}
+ >
+ {value}
+ </ContentLink>
+ </Tooltip>
) : (
<ColorBold> — </ColorBold>
)}