mirror of
https://github.com/logto-io/logto.git
synced 2025-04-07 23:01:25 -05:00
fix(console): change recaptcha form fields label (#7243)
This commit is contained in:
parent
b127e3d915
commit
8d7a910e1f
4 changed files with 42 additions and 9 deletions
|
@ -13,23 +13,27 @@ type Props = {
|
|||
};
|
||||
|
||||
function CaptchaFormFields({ metadata, errors, register }: Props) {
|
||||
const siteKeyField = metadata.requiredFields.find((field) => field.field === 'siteKey');
|
||||
const secretKeyField = metadata.requiredFields.find((field) => field.field === 'secretKey');
|
||||
const projectIdField = metadata.requiredFields.find((field) => field.field === 'projectId');
|
||||
|
||||
return (
|
||||
<>
|
||||
{metadata.requiredFields.includes('siteKey') && (
|
||||
<FormField title="security.captcha_details.site_key">
|
||||
{siteKeyField && (
|
||||
<FormField title={siteKeyField.label}>
|
||||
<TextInput error={Boolean(errors.siteKey)} {...register('siteKey', { required: true })} />
|
||||
</FormField>
|
||||
)}
|
||||
{metadata.requiredFields.includes('secretKey') && (
|
||||
<FormField title="security.captcha_details.secret_key">
|
||||
{secretKeyField && (
|
||||
<FormField title={secretKeyField.label}>
|
||||
<TextInput
|
||||
error={Boolean(errors.secretKey)}
|
||||
{...register('secretKey', { required: true })}
|
||||
/>
|
||||
</FormField>
|
||||
)}
|
||||
{metadata.requiredFields.includes('projectId') && (
|
||||
<FormField title="security.captcha_details.project_id">
|
||||
{projectIdField && (
|
||||
<FormField title={projectIdField.label}>
|
||||
<TextInput
|
||||
error={Boolean(errors.projectId)}
|
||||
{...register('projectId', { required: true })}
|
||||
|
|
|
@ -13,7 +13,20 @@ export const captchaProviders: CaptchaProviderMetadata[] = [
|
|||
logoDark: recaptchaEnterprise,
|
||||
description: 'security.captcha_providers.recaptcha_enterprise.description',
|
||||
readme: 'readme',
|
||||
requiredFields: ['siteKey', 'secretKey', 'projectId'],
|
||||
requiredFields: [
|
||||
{
|
||||
field: 'siteKey',
|
||||
label: 'security.captcha_details.recaptcha_key_id',
|
||||
},
|
||||
{
|
||||
field: 'secretKey',
|
||||
label: 'security.captcha_details.recaptcha_api_key',
|
||||
},
|
||||
{
|
||||
field: 'projectId',
|
||||
label: 'security.captcha_details.project_id',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'security.captcha_providers.turnstile.name',
|
||||
|
@ -22,6 +35,15 @@ export const captchaProviders: CaptchaProviderMetadata[] = [
|
|||
logoDark: turnstile,
|
||||
description: 'security.captcha_providers.turnstile.description',
|
||||
readme: 'readme',
|
||||
requiredFields: ['siteKey', 'secretKey'],
|
||||
requiredFields: [
|
||||
{
|
||||
field: 'siteKey',
|
||||
label: 'security.captcha_details.site_key',
|
||||
},
|
||||
{
|
||||
field: 'secretKey',
|
||||
label: 'security.captcha_details.secret_key',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import { type AdminConsoleKey } from '@logto/phrases';
|
||||
import { type CaptchaType } from '@logto/schemas';
|
||||
|
||||
type FormField = 'siteKey' | 'secretKey' | 'projectId';
|
||||
|
||||
export type CaptchaProviderMetadata = {
|
||||
name: AdminConsoleKey;
|
||||
type: CaptchaType;
|
||||
|
@ -8,5 +10,8 @@ export type CaptchaProviderMetadata = {
|
|||
logoDark: SvgComponent;
|
||||
description: AdminConsoleKey;
|
||||
readme: string;
|
||||
requiredFields: Array<'siteKey' | 'secretKey' | 'projectId'>;
|
||||
requiredFields: Array<{
|
||||
field: FormField;
|
||||
label: AdminConsoleKey;
|
||||
}>;
|
||||
};
|
||||
|
|
|
@ -41,6 +41,8 @@ const security = {
|
|||
site_key: 'Site key',
|
||||
secret_key: 'Secret key',
|
||||
project_id: 'Project ID',
|
||||
recaptcha_key_id: 'reCAPTCHA key ID',
|
||||
recaptcha_api_key: 'API key of the project',
|
||||
deletion_description: 'Are you sure you want to delete this CAPTCHA provider?',
|
||||
captcha_deleted: 'CAPTCHA provider deleted successfully',
|
||||
setup_captcha: 'Setup CAPTCHA',
|
||||
|
|
Loading…
Add table
Reference in a new issue