kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
little oopsie with the intl stuff
rodzic
53c6da35ff
commit
0679b44652
|
@ -1,6 +1,6 @@
|
||||||
import CloseIcon from '@tabler/icons/outline/x.svg';
|
import CloseIcon from '@tabler/icons/outline/x.svg';
|
||||||
import { FC } from 'react';
|
import { FC } from 'react';
|
||||||
import { useIntl } from 'react-intl';
|
import { defineMessages, useIntl } from 'react-intl';
|
||||||
|
|
||||||
import { Card, CardHeader, CardBody } from 'soapbox/components/ui/card.tsx';
|
import { Card, CardHeader, CardBody } from 'soapbox/components/ui/card.tsx';
|
||||||
import Icon from 'soapbox/components/ui/icon.tsx';
|
import Icon from 'soapbox/components/ui/icon.tsx';
|
||||||
|
@ -8,6 +8,10 @@ import { PolicySpecItem, PolicyItem, PolicyState, PolicyAction } from 'soapbox/u
|
||||||
|
|
||||||
import { PolicyFields } from './PolicyFields.tsx';
|
import { PolicyFields } from './PolicyFields.tsx';
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
removePolicy: { id: 'admin.policies.remove_policy', defaultMessage: 'Remove policy' },
|
||||||
|
});
|
||||||
|
|
||||||
export const Policy: FC<{
|
export const Policy: FC<{
|
||||||
policy: PolicySpecItem;
|
policy: PolicySpecItem;
|
||||||
registry: PolicyItem[];
|
registry: PolicyItem[];
|
||||||
|
@ -30,6 +34,7 @@ export const Policy: FC<{
|
||||||
<button
|
<button
|
||||||
onClick={handleRemovePolicy}
|
onClick={handleRemovePolicy}
|
||||||
className='ml-2 text-gray-500 hover:text-gray-100'
|
className='ml-2 text-gray-500 hover:text-gray-100'
|
||||||
|
aria-label={intl.formatMessage(messages.removePolicy)}
|
||||||
>
|
>
|
||||||
<Icon src={CloseIcon} className='size-4' />
|
<Icon src={CloseIcon} className='size-4' />
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -16,11 +16,12 @@ const messages = defineMessages({
|
||||||
const MultiValueBadge: FC<{
|
const MultiValueBadge: FC<{
|
||||||
value: string | number;
|
value: string | number;
|
||||||
onRemove: () => void;
|
onRemove: () => void;
|
||||||
}> = ({ value, onRemove }) => {
|
intl: ReturnType<typeof useIntl>;
|
||||||
|
}> = ({ value, onRemove, intl }) => {
|
||||||
return (
|
return (
|
||||||
<div className='mb-2 mr-2 inline-flex items-center rounded-full bg-gray-200 px-2 py-1 text-gray-800'>
|
<div className='mb-2 mr-2 inline-flex items-center rounded-full bg-gray-200 px-2 py-1 text-gray-800'>
|
||||||
<span className='mr-1 max-w-28 overflow-hidden text-ellipsis' title={String(value)}>{value}</span>
|
<span className='mr-1 max-w-28 overflow-hidden text-ellipsis' title={String(value)}>{value}</span>
|
||||||
<button onClick={onRemove} className='text-gray-600 hover:text-gray-800' aria-label={messages.removeValue.defaultMessage}>
|
<button onClick={onRemove} className='text-gray-600 hover:text-gray-800' aria-label={intl.formatMessage(messages.removeValue)}>
|
||||||
<Icon src={CloseIcon} className='size-4' />
|
<Icon src={CloseIcon} className='size-4' />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -115,6 +116,7 @@ export const PolicyFields: FC<{
|
||||||
{((value || []) as (string | number)[]).map((v) => (
|
{((value || []) as (string | number)[]).map((v) => (
|
||||||
<MultiValueBadge
|
<MultiValueBadge
|
||||||
key={v}
|
key={v}
|
||||||
|
intl={intl}
|
||||||
value={v}
|
value={v}
|
||||||
onRemove={() => handleRemoveMultiValue(v)}
|
onRemove={() => handleRemoveMultiValue(v)}
|
||||||
/>
|
/>
|
||||||
|
|
Ładowanie…
Reference in New Issue