fix: missing translation richText link modal (#1573)

This commit is contained in:
Dan Ribbens
2022-12-03 12:29:33 -05:00
committed by GitHub
parent ca59efe396
commit 2dcada199c
4 changed files with 72 additions and 12 deletions

View File

@@ -1,36 +1,48 @@
import { Config } from '../../../../../../../../config/types';
import { Field } from '../../../../../../../../fields/config/types';
import { extractTranslations } from '../../../../../../../../translations/extractTranslations';
const translations = extractTranslations([
'fields:textToDisplay',
'fields:linkType',
'fields:chooseBetweenCustomTextOrDocument',
'fields:customURL',
'fields:internalLink',
'fields:enterURL',
'fields:chooseDocumentToLink',
'fields:openInNewTab',
]);
export const getBaseFields = (config: Config): Field[] => [
{
name: 'text',
label: 'Text to display',
label: translations['fields:textToDisplay'],
type: 'text',
required: true,
},
{
name: 'linkType',
label: 'Link Type',
label: translations['fields:linkType'],
type: 'radio',
required: true,
admin: {
description: 'Choose between entering a custom text URL or linking to another document.',
description: translations['fields:chooseBetweenCustomTextOrDocument'],
},
defaultValue: 'custom',
options: [
{
label: 'Custom URL',
label: translations['fields:customURL'],
value: 'custom',
},
{
label: 'Internal Link',
label: translations['fields:internalLink'],
value: 'internal',
},
],
},
{
name: 'url',
label: 'Enter a URL',
label: translations['fields:enterURL'],
type: 'text',
required: true,
admin: {
@@ -41,7 +53,7 @@ export const getBaseFields = (config: Config): Field[] => [
},
{
name: 'doc',
label: 'Choose a document to link to',
label: translations['fields:chooseDocumentToLink'],
type: 'relationship',
required: true,
relationTo: config.collections.map(({ slug }) => slug),
@@ -53,7 +65,7 @@ export const getBaseFields = (config: Config): Field[] => [
},
{
name: 'newTab',
label: 'Open in new tab',
label: translations['fields:openInNewTab'],
type: 'checkbox',
},
];

View File

@@ -1,5 +1,6 @@
import { Modal } from '@faceless-ui/modal';
import React from 'react';
import { useTranslation } from 'react-i18next';
import { MinimalTemplate } from '../../../../../..';
import Button from '../../../../../../elements/Button';
import X from '../../../../../../icons/X';
@@ -20,6 +21,8 @@ export const EditModal: React.FC<Props> = ({
fieldSchema,
modalSlug,
}) => {
const { t } = useTranslation('fields');
return (
<Modal
slug={modalSlug}
@@ -27,7 +30,7 @@ export const EditModal: React.FC<Props> = ({
>
<MinimalTemplate className={`${baseClass}__template`}>
<header className={`${baseClass}__header`}>
<h3>Edit Link</h3>
<h3>{t('editLink')}</h3>
<Button
buttonStyle="none"
onClick={close}
@@ -46,7 +49,7 @@ export const EditModal: React.FC<Props> = ({
forceRender
/>
<FormSubmit>
Confirm
{t('general:submit')}
</FormSubmit>
</Form>
</MinimalTemplate>