mirror of
https://github.com/kremalicious/umami.git
synced 2025-01-12 05:55:51 +01:00
Fix display of encoded characters. Closes #1171.
This commit is contained in:
parent
11ae382209
commit
1bfb26ab44
@ -2,6 +2,7 @@ import React from 'react';
|
|||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import usePageQuery from 'hooks/usePageQuery';
|
import usePageQuery from 'hooks/usePageQuery';
|
||||||
|
import { safeDecodeURI } from 'lib/url';
|
||||||
import Icon from './Icon';
|
import Icon from './Icon';
|
||||||
import External from 'assets/arrow-up-right-from-square.svg';
|
import External from 'assets/arrow-up-right-from-square.svg';
|
||||||
import styles from './FilterLink.module.css';
|
import styles from './FilterLink.module.css';
|
||||||
@ -20,7 +21,7 @@ export default function FilterLink({ id, value, label, externalUrl }) {
|
|||||||
[styles.active]: active && selected,
|
[styles.active]: active && selected,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{label || value}
|
{safeDecodeURI(label || value)}
|
||||||
</a>
|
</a>
|
||||||
</Link>
|
</Link>
|
||||||
{externalUrl && (
|
{externalUrl && (
|
||||||
|
@ -1,14 +1,21 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import MetricsTable from './MetricsTable';
|
import MetricsTable from './MetricsTable';
|
||||||
import { percentFilter } from 'lib/filters';
|
import { percentFilter } from 'lib/filters';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { useIntl, defineMessages } from 'react-intl';
|
||||||
import FilterLink from 'components/common/FilterLink';
|
import FilterLink from 'components/common/FilterLink';
|
||||||
import useCountryNames from 'hooks/useCountryNames';
|
import useCountryNames from 'hooks/useCountryNames';
|
||||||
import useLocale from 'hooks/useLocale';
|
import useLocale from 'hooks/useLocale';
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
unknown: { id: 'label.unknown', defaultMessage: 'Unknown' },
|
||||||
|
countries: { id: 'label.countries', defaultMessage: 'Countries' },
|
||||||
|
visitors: { id: 'label.visitors', defaultMessage: 'Visitors' },
|
||||||
|
});
|
||||||
|
|
||||||
export default function CountriesTable({ websiteId, onDataLoad, ...props }) {
|
export default function CountriesTable({ websiteId, onDataLoad, ...props }) {
|
||||||
const { locale } = useLocale();
|
const { locale } = useLocale();
|
||||||
const countryNames = useCountryNames(locale);
|
const countryNames = useCountryNames(locale);
|
||||||
|
const { formatMessage } = useIntl();
|
||||||
|
|
||||||
function renderLink({ x: code }) {
|
function renderLink({ x: code }) {
|
||||||
return (
|
return (
|
||||||
@ -16,9 +23,7 @@ export default function CountriesTable({ websiteId, onDataLoad, ...props }) {
|
|||||||
<FilterLink
|
<FilterLink
|
||||||
id="country"
|
id="country"
|
||||||
value={code}
|
value={code}
|
||||||
label={
|
label={countryNames[code] ?? formatMessage(messages.unknown)}
|
||||||
countryNames[code] ?? <FormattedMessage id="label.unknown" defaultMessage="Unknown" />
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -27,9 +32,9 @@ export default function CountriesTable({ websiteId, onDataLoad, ...props }) {
|
|||||||
return (
|
return (
|
||||||
<MetricsTable
|
<MetricsTable
|
||||||
{...props}
|
{...props}
|
||||||
title={<FormattedMessage id="metrics.countries" defaultMessage="Countries" />}
|
title={formatMessage(messages.countries)}
|
||||||
type="country"
|
type="country"
|
||||||
metric={<FormattedMessage id="metrics.visitors" defaultMessage="Visitors" />}
|
metric={formatMessage(messages.visitors)}
|
||||||
websiteId={websiteId}
|
websiteId={websiteId}
|
||||||
onDataLoad={data => onDataLoad?.(percentFilter(data))}
|
onDataLoad={data => onDataLoad?.(percentFilter(data))}
|
||||||
renderLabel={renderLink}
|
renderLabel={renderLink}
|
||||||
|
Loading…
Reference in New Issue
Block a user