Browse Source

SONAR-21798 Remove link from deprecated tooltip badge in activity

tags/10.5.0.89998
stanislavh 1 month ago
parent
commit
6f4f195adb

+ 6
- 22
server/sonar-web/src/main/js/components/activity-graph/AddGraphMetricPopup.tsx View File

@@ -23,7 +23,7 @@ import { FormattedMessage, useIntl } from 'react-intl';
import { DEPRECATED_ACTIVITY_METRICS } from '../../helpers/constants';
import { getLocalizedMetricName, translate, translateWithParameters } from '../../helpers/l10n';
import { MetricKey } from '../../types/metrics';
import DocumentationLink from '../common/DocumentationLink';
import { getDeprecatedTranslationKeyForTooltip } from './utils';

export interface AddGraphMetricPopupProps {
elements: string[];
@@ -64,9 +64,9 @@ export default function AddGraphMetricPopup({
);
}

const renderLabel = (key: string) => {
const renderLabel = (key: MetricKey) => {
const metricName = getLocalizedMetricName({ key });
const isDeprecated = DEPRECATED_ACTIVITY_METRICS.includes(key as MetricKey);
const isDeprecated = DEPRECATED_ACTIVITY_METRICS.includes(key);

return (
<>
@@ -78,26 +78,10 @@ export default function AddGraphMetricPopup({
);
};

const renderTooltip = (key: string) => {
const isDeprecated = DEPRECATED_ACTIVITY_METRICS.includes(key as MetricKey);

const renderTooltip = (key: MetricKey) => {
const isDeprecated = DEPRECATED_ACTIVITY_METRICS.includes(key);
if (isDeprecated) {
return (
<FormattedMessage
id="project_activity.custom_metric.deprecated"
tagName="div"
values={{
learn_more: (
<DocumentationLink
className="sw-ml-2 sw-whitespace-nowrap"
to="/user-guide/clean-code/code-analysis/"
>
{intl.formatMessage({ id: 'learn_more' })}
</DocumentationLink>
),
}}
/>
);
return <FormattedMessage id={getDeprecatedTranslationKeyForTooltip(key)} tagName="div" />;
}

return null;

+ 3
- 12
server/sonar-web/src/main/js/components/activity-graph/GraphsLegendItem.tsx View File

@@ -34,9 +34,9 @@ import { FormattedMessage, useIntl } from 'react-intl';
import { DEPRECATED_ACTIVITY_METRICS } from '../../helpers/constants';
import { translateWithParameters } from '../../helpers/l10n';
import { MetricKey } from '../../types/metrics';
import DocumentationLink from '../common/DocumentationLink';
import Tooltip from '../controls/Tooltip';
import { ChartLegend } from './ChartLegend';
import { getDeprecatedTranslationKeyForTooltip } from './utils';

interface Props {
className?: string;
@@ -78,17 +78,8 @@ export function GraphsLegendItem({
<Tooltip
overlay={
<FormattedMessage
id="project_activity.custom_metric.deprecated"
values={{
learn_more: (
<DocumentationLink
className="sw-ml-2 sw-whitespace-nowrap"
to="/user-guide/clean-code/code-analysis/"
>
{intl.formatMessage({ id: 'learn_more' })}
</DocumentationLink>
),
}}
id={getDeprecatedTranslationKeyForTooltip(metric as MetricKey)}
tagName="div"
/>
}
>

+ 17
- 1
server/sonar-web/src/main/js/components/activity-graph/utils.ts View File

@@ -18,7 +18,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { chunk, flatMap, groupBy, sortBy } from 'lodash';
import { CCT_SOFTWARE_QUALITY_METRICS } from '../../helpers/constants';
import {
CCT_SOFTWARE_QUALITY_METRICS,
OLD_TO_NEW_TAXONOMY_METRICS_MAP,
} from '../../helpers/constants';
import { getLocalizedMetricName, translate } from '../../helpers/l10n';
import { localizeMetric } from '../../helpers/measures';
import { get, save } from '../../helpers/storage';
@@ -192,6 +195,19 @@ export function getAnalysisEventsForDate(analyses: ParsedAnalysis[], date?: Date
return [];
}

export function getDeprecatedTranslationKeyForTooltip(metric: MetricKey) {
const quality = OLD_TO_NEW_TAXONOMY_METRICS_MAP[metric];

let deprecatedKey = 'severity';
if (quality) {
deprecatedKey = 'quality';
} else if (metric === MetricKey.confirmed_issues) {
deprecatedKey = 'confirmed';
}

return `project_activity.custom_metric.deprecated.${deprecatedKey}`;
}

function findMetric(key: string, metrics: Metric[]) {
return metrics.find((metric) => metric.key === key);
}

+ 4
- 1
sonar-core/src/main/resources/org/sonar/l10n/core.properties View File

@@ -1952,7 +1952,10 @@ project_activity.graphs.data_table.no_data_warning_check_dates_y=There is no dat
project_activity.graphs.data_table.no_data_warning_check_dates_x_y=There is no data for the selected date range ({start} to {end}). Try modifying the date filters on the main page.

project_activity.custom_metric.covered_lines=Covered Lines
project_activity.custom_metric.deprecated=We are deprecating those filters to align the Activity page with our definition of Clean Code. They will be removed in a future release. {learn_more}

project_activity.custom_metric.deprecated.severity=Old severities and the corresponding filters are deprecated.
project_activity.custom_metric.deprecated.quality=Issue types and the corresponding filters are deprecated. You can use filters by Software Quality.
project_activity.custom_metric.deprecated.confirmed=Confirmed issues and the corresponding filter is deprecated.

#------------------------------------------------------------------------------
#

Loading…
Cancel
Save