Fix react-intl in table head

Signed-off-by: soupette <cyril@strapi.io>
This commit is contained in:
soupette 2021-09-15 14:32:50 +02:00
parent 2496f2559b
commit 566de24d88
3 changed files with 6 additions and 3 deletions

View File

@ -54,7 +54,10 @@ const FieldPicker = ({ layout }) => {
{allAllowedHeaders.map(header => { {allAllowedHeaders.map(header => {
return ( return (
<Option key={header.name} value={header.name}> <Option key={header.name} value={header.name}>
{formatMessage(header.intlLabel)} {formatMessage({
id: header.intlLabel.id || header.name,
defaultMessage: header.intlLabel.defaultMessage || header.name,
})}
</Option> </Option>
); );
})} })}

View File

@ -52,7 +52,7 @@ const TableHead = ({
{ id: 'components.TableHeader.sort', defaultMessage: 'Sort on {label}' }, { id: 'components.TableHeader.sort', defaultMessage: 'Sort on {label}' },
{ label } { label }
); );
const intlLabel = formatMessage({ id: label, defaultMessage: label }); const intlLabel = formatMessage({ id: label || name, defaultMessage: label || name });
const handleClickSort = (shouldAllowClick = true) => { const handleClickSort = (shouldAllowClick = true) => {
if (isSortable && shouldAllowClick) { if (isSortable && shouldAllowClick) {

View File

@ -45,7 +45,7 @@ const AttributeTag = ({ attribute, filter, onClick, operator, value }) => {
return ( return (
<Box padding={1} onClick={handleClick}> <Box padding={1} onClick={handleClick}>
<Tag icon={<Close />}> <Tag icon={<Close />}>
{attribute.metadatas.label}&nbsp; {attribute.metadatas.label || attribute.name}&nbsp;
{formatMessage({ {formatMessage({
id: `components.FilterOptions.FILTER_TYPES.${operator}`, id: `components.FilterOptions.FILTER_TYPES.${operator}`,
defaultMessage: operator, defaultMessage: operator,