0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-06 20:40:08 -05:00

fix(console): add url check for logo (#2771)

This commit is contained in:
wangsijie 2022-12-30 15:24:55 +08:00 committed by GitHub
parent ce48251920
commit 28f8e8a9a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,6 +12,7 @@ import FormField from '@/components/FormField';
import Select from '@/components/Select'; import Select from '@/components/Select';
import TextInput from '@/components/TextInput'; import TextInput from '@/components/TextInput';
import TextLink from '@/components/TextLink'; import TextLink from '@/components/TextLink';
import { uriValidator } from '@/utilities/validator';
import type { ConnectorFormType } from '../../types'; import type { ConnectorFormType } from '../../types';
import { SyncProfileMode } from '../../types'; import { SyncProfileMode } from '../../types';
@ -60,14 +61,27 @@ const ConnectorForm = ({ connector, isAllowEditTarget }: Props) => {
<div className={styles.tip}>{t('connectors.guide.name_tip')}</div> <div className={styles.tip}>{t('connectors.guide.name_tip')}</div>
</FormField> </FormField>
<FormField title="connectors.guide.logo"> <FormField title="connectors.guide.logo">
<TextInput placeholder={t('connectors.guide.logo_placeholder')} {...register('logo')} /> <TextInput
placeholder={t('connectors.guide.logo_placeholder')}
hasError={Boolean(errors.logo)}
errorMessage={errors.logo?.message}
{...register('logo', {
validate: (value) =>
!value || uriValidator(value) || t('errors.invalid_uri_format'),
})}
/>
<div className={styles.tip}>{t('connectors.guide.logo_tip')}</div> <div className={styles.tip}>{t('connectors.guide.logo_tip')}</div>
</FormField> </FormField>
{darkVisible && ( {darkVisible && (
<FormField title="connectors.guide.logo_dark"> <FormField title="connectors.guide.logo_dark">
<TextInput <TextInput
placeholder={t('connectors.guide.logo_dark_placeholder')} placeholder={t('connectors.guide.logo_dark_placeholder')}
{...register('logoDark')} hasError={Boolean(errors.logoDark)}
errorMessage={errors.logoDark?.message}
{...register('logoDark', {
validate: (value) =>
!value || uriValidator(value) || t('errors.invalid_uri_format'),
})}
/> />
<div className={styles.tip}>{t('connectors.guide.logo_dark_tip')}</div> <div className={styles.tip}>{t('connectors.guide.logo_dark_tip')}</div>
</FormField> </FormField>