From 97cc723c298fa1802d74a40b7ba512205825bc4c Mon Sep 17 00:00:00 2001 From: Ryan Mathis Date: Mon, 17 Oct 2022 15:19:09 -0700 Subject: [PATCH 1/2] Updated id attribute --- ui/src/app/metadata/domain/source/component/SourceList.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/app/metadata/domain/source/component/SourceList.js b/ui/src/app/metadata/domain/source/component/SourceList.js index 671c08a0b..923f41273 100644 --- a/ui/src/app/metadata/domain/source/component/SourceList.js +++ b/ui/src/app/metadata/domain/source/component/SourceList.js @@ -68,7 +68,7 @@ export default function SourceList({ entities, onDelete, onEnable, onChangeGroup {onEnable && canEnable ? onEnable(source, checked)} From fb8a2f976bf4655cc282acbae48c0ad9f3f7e969 Mon Sep 17 00:00:00 2001 From: Ryan Mathis Date: Tue, 18 Oct 2022 07:43:58 -0700 Subject: [PATCH 2/2] Fixed validation regex for sources --- .../wizard/MetadataSourceProtocolSelector.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ui/src/app/metadata/wizard/MetadataSourceProtocolSelector.js b/ui/src/app/metadata/wizard/MetadataSourceProtocolSelector.js index a9f99dab1..9256a698d 100644 --- a/ui/src/app/metadata/wizard/MetadataSourceProtocolSelector.js +++ b/ui/src/app/metadata/wizard/MetadataSourceProtocolSelector.js @@ -8,6 +8,7 @@ import Translate from '../../i18n/components/translate'; import { InfoIcon } from '../../form/component/InfoIcon'; import { useTranslator } from '../../i18n/hooks'; import { useMetadataSources } from '../hooks/api'; +import { useUserGroup } from '../../core/user/UserContext'; import Button from 'react-bootstrap/Button'; export function MetadataSourceProtocolSelector({ types = [], loading, children}) { @@ -51,7 +52,7 @@ export function MetadataSourceProtocolSelector({ types = [], loading, children}) setSourceIds(data.map(s => s.entityId)); }, [data]); - React.useState(() => console.log(sourceNames), [sourceNames]); + const group = useUserGroup(); return ( <>{showSelector ? @@ -135,12 +136,17 @@ export function MetadataSourceProtocolSelector({ types = [], loading, children}) !(sourceIds.indexOf(v) > -1) - }})} /> + type="text" {...register('entityId', { + required: true, + validate: { + unique: v => !(sourceIds.indexOf(v) > -1) + }, + pattern: new RegExp(group?.validationRegex) + })} /> {errors?.entityId?.type === 'unique' && } {errors?.entityId?.type === 'required' && } + {errors?.entityId?.type === 'pattern' && }