import * as React from 'react';
import { getLeakValue } from '../../../components/measure/utils';
import DrilldownLink from '../../../components/shared/DrilldownLink';
-import { getLocalizedMetricName, translate } from '../../../helpers/l10n';
+import { getLocalizedMetricName, translate, translateWithParameters } from '../../../helpers/l10n';
import { findMeasure, formatMeasure, localizeMetric } from '../../../helpers/measures';
import { BranchLike } from '../../../types/branch-like';
import { MetricKey } from '../../../types/metrics';
export function DebtValue(props: DebtValueProps) {
const { branchLike, component, measures, useDiffMetric = false } = props;
- const metric = useDiffMetric ? MetricKey.new_technical_debt : MetricKey.sqale_index;
- const measure = findMeasure(measures, metric);
+ const metricKey = useDiffMetric ? MetricKey.new_technical_debt : MetricKey.sqale_index;
+ const measure = findMeasure(measures, metricKey);
let value;
+ let metricName;
if (measure) {
value = useDiffMetric ? getLeakValue(measure) : measure.value;
+ metricName = getLocalizedMetricName(measure.metric, true);
+ } else {
+ metricName = localizeMetric(metricKey);
}
+ const formattedValue = formatMeasure(value, 'WORK_DUR');
return (
<>
<span aria-label={translate('no_data')} className="overview-measures-empty-value" />
) : (
<DrilldownLink
+ ariaLabel={translateWithParameters(
+ 'overview.see_more_details_on_x_of_y',
+ formattedValue,
+ metricName
+ )}
branchLike={branchLike}
className="overview-measures-value text-light"
component={component.key}
- metric={metric}>
- {formatMeasure(value, 'WORK_DUR')}
+ metric={metricKey}>
+ {formattedValue}
</DrilldownLink>
)}
- <span className="big-spacer-left">
- {measure ? getLocalizedMetricName(measure.metric, true) : localizeMetric(metric)}
- </span>
+ <span className="big-spacer-left">{metricName}</span>
</>
);
}
*/
import * as React from 'react';
import DrilldownLink from '../../../components/shared/DrilldownLink';
-import { getLocalizedMetricName } from '../../../helpers/l10n';
-import { findMeasure, formatMeasure } from '../../../helpers/measures';
+import { getLocalizedMetricName, translateWithParameters } from '../../../helpers/l10n';
+import { findMeasure, formatMeasure, localizeMetric } from '../../../helpers/measures';
import { BranchLike } from '../../../types/branch-like';
import { MetricKey } from '../../../types/metrics';
import { Component, MeasureEnhanced } from '../../../types/types';
const measure = findMeasure(measures, metric);
let content;
- if (!measure) {
+ if (!measure || measure.value === undefined) {
content = <span className="overview-measures-value text-light">-</span>;
} else {
content = (
<span>
<DrilldownLink
+ ariaLabel={translateWithParameters(
+ 'overview.see_more_details_on_x_y',
+ measure.value,
+ localizeMetric(metric)
+ )}
branchLike={branchLike}
className="overview-measures-value text-light"
component={component.key}
exports[`should render correctly 1`] = `
<Fragment>
<DrilldownLink
+ ariaLabel="overview.see_more_details_on_x_of_y.work_duration.x_minutes.1.Sqale_index"
branchLike={
Object {
"analysisDate": "2018-01-01",
exports[`should render correctly 2`] = `
<Fragment>
<DrilldownLink
+ ariaLabel="overview.see_more_details_on_x_of_y.work_duration.x_minutes.1.New_technical_debt"
branchLike={
Object {
"analysisDate": "2018-01-01",
>
<span>
<DrilldownLink
+ ariaLabel="overview.see_more_details_on_x_y.1.0.metric.tests.name"
branchLike={
Object {
"analysisDate": "2018-01-01",
import HelpTooltip from '../../../components/controls/HelpTooltip';
import { getLeakValue } from '../../../components/measure/utils';
import { getBranchLikeQuery } from '../../../helpers/branch-like';
-import { translate } from '../../../helpers/l10n';
+import { translate, translateWithParameters } from '../../../helpers/l10n';
import { findMeasure, formatMeasure, localizeMetric } from '../../../helpers/measures';
import { getComponentIssuesUrl, getComponentSecurityHotspotsUrl } from '../../../helpers/urls';
import { BranchLike } from '../../../types/branch-like';
export function IssueLabel(props: IssueLabelProps) {
const { branchLike, component, helpTooltip, measures, type, useDiffMetric = false } = props;
- const metric = getIssueMetricKey(type, useDiffMetric);
- const measure = findMeasure(measures, metric);
+ const metricKey = getIssueMetricKey(type, useDiffMetric);
+ const measure = findMeasure(measures, metricKey);
const iconClass = getIssueIconClass(type);
let value;
inNewCodePeriod: useDiffMetric ? 'true' : 'false'
};
+ const url =
+ type === IssueType.SecurityHotspot
+ ? getComponentSecurityHotspotsUrl(component.key, params)
+ : getComponentIssuesUrl(component.key, params);
+
return (
<>
{value === undefined ? (
<span aria-label={translate('no_data')} className="overview-measures-empty-value" />
) : (
<Link
+ aria-label={translateWithParameters(
+ 'overview.see_list_of_x_y_issues',
+ value,
+ localizeMetric(metricKey)
+ )}
className="overview-measures-value text-light"
- to={
- type === IssueType.SecurityHotspot
- ? getComponentSecurityHotspotsUrl(component.key, params)
- : getComponentIssuesUrl(component.key, params)
- }>
+ to={url}>
{formatMeasure(value, 'SHORT_INT')}
</Link>
)}
{React.createElement(iconClass, { className: 'big-spacer-left little-spacer-right' })}
- {localizeMetric(metric)}
+ {localizeMetric(metricKey)}
{helpTooltip && <HelpTooltip className="little-spacer-left" overlay={helpTooltip} />}
</>
);
import { FormattedMessage } from 'react-intl';
import { getLeakValue } from '../../../components/measure/utils';
import DrilldownLink from '../../../components/shared/DrilldownLink';
-import { translate } from '../../../helpers/l10n';
-import { findMeasure, formatMeasure } from '../../../helpers/measures';
+import { translate, translateWithParameters } from '../../../helpers/l10n';
+import { findMeasure, formatMeasure, localizeMetric } from '../../../helpers/measures';
import { BranchLike } from '../../../types/branch-like';
import { Component, MeasureEnhanced } from '../../../types/types';
import {
if (!measure) {
return translate(labelKey);
- } else {
- const value = useDiffMetric ? getLeakValue(measure) : measure.value;
-
- return (
- <FormattedMessage
- defaultMessage={translate(expandedLabelKey)}
- id={expandedLabelKey}
- values={{
- count: (
- <DrilldownLink
- branchLike={branchLike}
- className="big"
- component={component.key}
- metric={linesMetric}>
- {formatMeasure(value, 'SHORT_INT')}
- </DrilldownLink>
- )
- }}
- />
- );
}
+
+ const value = useDiffMetric ? getLeakValue(measure) : measure.value;
+
+ return (
+ <FormattedMessage
+ defaultMessage={translate(expandedLabelKey)}
+ id={expandedLabelKey}
+ values={{
+ count: (
+ <DrilldownLink
+ branchLike={branchLike}
+ className="big"
+ component={component.key}
+ metric={linesMetric}>
+ {formatMeasure(value, 'SHORT_INT')}
+ </DrilldownLink>
+ )
+ }}
+ />
+ );
};
render() {
const { branchLike, centered, component, measures, type, useDiffMetric = false } = this.props;
const iconClass = getMeasurementIconClass(type);
- const metric = getMeasurementMetricKey(type, useDiffMetric);
- const measure = findMeasure(measures, metric);
+ const metricKey = getMeasurementMetricKey(type, useDiffMetric);
+ const measure = findMeasure(measures, metricKey);
let value;
if (measure) {
}
const icon = React.createElement(iconClass, { size: 'big', value: Number(value) });
+ const formattedValue = formatMeasure(value, 'PERCENT', {
+ decimals: 2,
+ omitExtraDecimalZeros: true
+ });
const link = (
<DrilldownLink
+ ariaLabel={translateWithParameters(
+ 'overview.see_more_details_on_x_of_y',
+ formattedValue,
+ localizeMetric(metricKey)
+ )}
branchLike={branchLike}
className="overview-measures-value text-light"
component={component.key}
- metric={metric}>
- {formatMeasure(value, 'PERCENT', { decimals: 2, omitExtraDecimalZeros: true })}
+ metric={metricKey}>
+ {formattedValue}
</DrilldownLink>
);
const label = this.getLabelText();
exports[`should render correctly for bugs 1`] = `
<Fragment>
<Link
+ aria-label="overview.see_list_of_x_y_issues.1.0.metric.bugs.name"
className="overview-measures-value text-light"
to={
Object {
exports[`should render correctly for bugs 2`] = `
<Fragment>
<Link
+ aria-label="overview.see_list_of_x_y_issues.1.0.metric.new_bugs.name"
className="overview-measures-value text-light"
to={
Object {
exports[`should render correctly for code smells 1`] = `
<Fragment>
<Link
+ aria-label="overview.see_list_of_x_y_issues.1.0.metric.code_smells.name"
className="overview-measures-value text-light"
to={
Object {
exports[`should render correctly for code smells 2`] = `
<Fragment>
<Link
+ aria-label="overview.see_list_of_x_y_issues.1.0.metric.new_code_smells.name"
className="overview-measures-value text-light"
to={
Object {
exports[`should render correctly for hotspots 1`] = `
<Fragment>
<Link
+ aria-label="overview.see_list_of_x_y_issues.1.0.metric.security_hotspots.name"
className="overview-measures-value text-light"
to={
Object {
exports[`should render correctly for hotspots 2`] = `
<Fragment>
<Link
+ aria-label="overview.see_list_of_x_y_issues.1.0.metric.new_security_hotspots.name"
className="overview-measures-value text-light"
to={
Object {
exports[`should render correctly for vulnerabilities 1`] = `
<Fragment>
<Link
+ aria-label="overview.see_list_of_x_y_issues.1.0.metric.vulnerabilities.name"
className="overview-measures-value text-light"
to={
Object {
exports[`should render correctly for vulnerabilities 2`] = `
<Fragment>
<Link
+ aria-label="overview.see_list_of_x_y_issues.1.0.metric.new_vulnerabilities.name"
className="overview-measures-value text-light"
to={
Object {
>
<span>
<DrilldownLink
+ ariaLabel="overview.see_more_details_on_x_of_y.1.0%.metric.coverage.name"
branchLike={
Object {
"analysisDate": "2018-01-01",
>
<span>
<DrilldownLink
+ ariaLabel="overview.see_more_details_on_x_of_y.1.0%.metric.coverage.name"
branchLike={
Object {
"analysisDate": "2018-01-01",
>
<span>
<DrilldownLink
+ ariaLabel="overview.see_more_details_on_x_of_y.1.0%.metric.new_coverage.name"
branchLike={
Object {
"analysisDate": "2018-01-01",
>
<span>
<DrilldownLink
+ ariaLabel="overview.see_more_details_on_x_of_y.1.0%.metric.duplicated_lines_density.name"
branchLike={
Object {
"analysisDate": "2018-01-01",
>
<span>
<DrilldownLink
+ ariaLabel="overview.see_more_details_on_x_of_y.1.0%.metric.duplicated_lines_density.name"
branchLike={
Object {
"analysisDate": "2018-01-01",
>
<span>
<DrilldownLink
+ ariaLabel="overview.see_more_details_on_x_of_y.1.0%.metric.new_duplicated_lines_density.name"
branchLike={
Object {
"analysisDate": "2018-01-01",
/>
</span>
<DrilldownLink
+ ariaLabel="overview.see_more_details_on_x_of_y.1.0%.metric.coverage.name"
branchLike={
Object {
"analysisDate": "2018-01-01",
import { getBranchLikeQuery } from '../../helpers/branch-like';
import { getComponentDrilldownUrl, getComponentIssuesUrl } from '../../helpers/urls';
import { BranchLike } from '../../types/branch-like';
+import { MetricKey } from '../../types/metrics';
import { Dict } from '../../types/types';
const ISSUE_MEASURES = [
- 'violations',
- 'new_violations',
- 'blocker_violations',
- 'critical_violations',
- 'major_violations',
- 'minor_violations',
- 'info_violations',
- 'new_blocker_violations',
- 'new_critical_violations',
- 'new_major_violations',
- 'new_minor_violations',
- 'new_info_violations',
- 'open_issues',
- 'reopened_issues',
- 'confirmed_issues',
- 'false_positive_issues',
- 'code_smells',
- 'new_code_smells',
- 'bugs',
- 'new_bugs',
- 'vulnerabilities',
- 'new_vulnerabilities'
+ MetricKey.violations,
+ MetricKey.new_violations,
+ MetricKey.blocker_violations,
+ MetricKey.critical_violations,
+ MetricKey.major_violations,
+ MetricKey.minor_violations,
+ MetricKey.info_violations,
+ MetricKey.new_blocker_violations,
+ MetricKey.new_critical_violations,
+ MetricKey.new_major_violations,
+ MetricKey.new_minor_violations,
+ MetricKey.new_info_violations,
+ MetricKey.open_issues,
+ MetricKey.reopened_issues,
+ MetricKey.confirmed_issues,
+ MetricKey.false_positive_issues,
+ MetricKey.code_smells,
+ MetricKey.new_code_smells,
+ MetricKey.bugs,
+ MetricKey.new_bugs,
+ MetricKey.vulnerabilities,
+ MetricKey.new_vulnerabilities
];
const issueParamsPerMetric: Dict<Dict<string>> = {
- blocker_violations: { resolved: 'false', severities: 'BLOCKER' },
- new_blocker_violations: { resolved: 'false', severities: 'BLOCKER' },
- critical_violations: { resolved: 'false', severities: 'CRITICAL' },
- new_critical_violations: { resolved: 'false', severities: 'CRITICAL' },
- major_violations: { resolved: 'false', severities: 'MAJOR' },
- new_major_violations: { resolved: 'false', severities: 'MAJOR' },
- minor_violations: { resolved: 'false', severities: 'MINOR' },
- new_minor_violations: { resolved: 'false', severities: 'MINOR' },
- info_violations: { resolved: 'false', severities: 'INFO' },
- new_info_violations: { resolved: 'false', severities: 'INFO' },
- open_issues: { resolved: 'false', statuses: 'OPEN' },
- reopened_issues: { resolved: 'false', statuses: 'REOPENED' },
- confirmed_issues: { resolved: 'false', statuses: 'CONFIRMED' },
- false_positive_issues: { resolutions: 'FALSE-POSITIVE' },
- code_smells: { resolved: 'false', types: 'CODE_SMELL' },
- new_code_smells: { resolved: 'false', types: 'CODE_SMELL' },
- bugs: { resolved: 'false', types: 'BUG' },
- new_bugs: { resolved: 'false', types: 'BUG' },
- vulnerabilities: { resolved: 'false', types: 'VULNERABILITY' },
- new_vulnerabilities: { resolved: 'false', types: 'VULNERABILITY' }
+ [MetricKey.blocker_violations]: { resolved: 'false', severities: 'BLOCKER' },
+ [MetricKey.new_blocker_violations]: { resolved: 'false', severities: 'BLOCKER' },
+ [MetricKey.critical_violations]: { resolved: 'false', severities: 'CRITICAL' },
+ [MetricKey.new_critical_violations]: { resolved: 'false', severities: 'CRITICAL' },
+ [MetricKey.major_violations]: { resolved: 'false', severities: 'MAJOR' },
+ [MetricKey.new_major_violations]: { resolved: 'false', severities: 'MAJOR' },
+ [MetricKey.minor_violations]: { resolved: 'false', severities: 'MINOR' },
+ [MetricKey.new_minor_violations]: { resolved: 'false', severities: 'MINOR' },
+ [MetricKey.info_violations]: { resolved: 'false', severities: 'INFO' },
+ [MetricKey.new_info_violations]: { resolved: 'false', severities: 'INFO' },
+ [MetricKey.open_issues]: { resolved: 'false', statuses: 'OPEN' },
+ [MetricKey.reopened_issues]: { resolved: 'false', statuses: 'REOPENED' },
+ [MetricKey.confirmed_issues]: { resolved: 'false', statuses: 'CONFIRMED' },
+ [MetricKey.false_positive_issues]: { resolutions: 'FALSE-POSITIVE' },
+ [MetricKey.code_smells]: { resolved: 'false', types: 'CODE_SMELL' },
+ [MetricKey.new_code_smells]: { resolved: 'false', types: 'CODE_SMELL' },
+ [MetricKey.bugs]: { resolved: 'false', types: 'BUG' },
+ [MetricKey.new_bugs]: { resolved: 'false', types: 'BUG' },
+ [MetricKey.vulnerabilities]: { resolved: 'false', types: 'VULNERABILITY' },
+ [MetricKey.new_vulnerabilities]: { resolved: 'false', types: 'VULNERABILITY' }
};
interface Props {
+ ariaLabel?: string;
branchLike?: BranchLike;
children?: React.ReactNode;
className?: string;
export default class DrilldownLink extends React.PureComponent<Props> {
isIssueMeasure = () => {
- return ISSUE_MEASURES.indexOf(this.props.metric) !== -1;
+ return ISSUE_MEASURES.indexOf(this.props.metric as MetricKey) !== -1;
};
propsToIssueParams = () => {
};
renderIssuesLink = () => {
- const url = getComponentIssuesUrl(this.props.component, {
+ const { ariaLabel, className, component, children, branchLike } = this.props;
+
+ const url = getComponentIssuesUrl(component, {
...this.propsToIssueParams(),
- ...getBranchLikeQuery(this.props.branchLike)
+ ...getBranchLikeQuery(branchLike)
});
return (
- <Link className={this.props.className} to={url}>
- {this.props.children}
+ <Link aria-label={ariaLabel} className={className} to={url}>
+ {children}
</Link>
);
};
if (this.isIssueMeasure()) {
return this.renderIssuesLink();
}
+ const { ariaLabel, className, metric, component, children, branchLike } = this.props;
const url = getComponentDrilldownUrl({
- componentKey: this.props.component,
- metric: this.props.metric,
- branchLike: this.props.branchLike,
+ componentKey: component,
+ metric,
+ branchLike,
listView: true
});
return (
- <Link className={this.props.className} to={url}>
- {this.props.children}
+ <Link aria-label={ariaLabel} className={className} to={url}>
+ {children}
</Link>
);
}
overview.previous_analysis_on_x=Previous analysis on {0}
overview.on_new_code=On New Code
overview.on_new_code_long=Conditions on New Code
+overview.see_list_of_x_y_issues=See the list of {0} {1}
+overview.see_more_details_on_x_of_y=See more details on {0} of {1}
+overview.see_more_details_on_x_y=See more details on {0} {1}
overview.about_this_portfolio=About This Portfolio
overview.about_this_project.APP=About This Application
overview.about_this_project.TRK=About This Project