diff --git a/ui/src/app/dashboard/view/SourcesTab.js b/ui/src/app/dashboard/view/SourcesTab.js index 40ff4dd4f..b0d1352d3 100644 --- a/ui/src/app/dashboard/view/SourcesTab.js +++ b/ui/src/app/dashboard/view/SourcesTab.js @@ -37,7 +37,7 @@ export function SourcesTab () { React.useEffect(() => { loadSources() }, []); async function changeSourceGroup(source, group) { - await updater.put(`/${source.id}`, { + await updater.put(`/${source.id}/changeGroup/${group}`, { ...source, idOfOwner: group }); diff --git a/ui/src/app/metadata/copy/CopySource.js b/ui/src/app/metadata/copy/CopySource.js index f3ae6b142..d7d0be54a 100644 --- a/ui/src/app/metadata/copy/CopySource.js +++ b/ui/src/app/metadata/copy/CopySource.js @@ -34,7 +34,7 @@ export function CopySource({ copy, onNext }) { setSelected([]); }; - const { register, handleSubmit, control, formState, setValue, getValues } = useForm({ + const { register, handleSubmit, control, formState, setValue, getValues, watch } = useForm({ mode: 'onChange', reValidateMode: 'onBlur', defaultValues: { @@ -47,6 +47,8 @@ export function CopySource({ copy, onNext }) { shouldUnregister: false, }); + const target = watch('target'); + const { errors, isValid } = formState; React.useEffect(() => { @@ -92,25 +94,28 @@ export function CopySource({ copy, onNext }) {
- - - Select the Entity ID to copy - - - + + + + Select the Entity ID to copy + + + Entity ID to copy is Required - + + Metadata Source Name (Dashboard Display Only) - + + + aria-describedby="serviceProviderName-help" disabled={!target} /> Service Resolver Name is required @@ -118,12 +123,15 @@ export function CopySource({ copy, onNext }) { + New Entity ID - + + !(sourceIds.indexOf(v) > -1) diff --git a/ui/src/app/metadata/copy/EntityTypeahead.js b/ui/src/app/metadata/copy/EntityTypeahead.js index ed8b9a14e..716089039 100644 --- a/ui/src/app/metadata/copy/EntityTypeahead.js +++ b/ui/src/app/metadata/copy/EntityTypeahead.js @@ -1,10 +1,16 @@ +import { faSpinner } from '@fortawesome/free-solid-svg-icons'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import React from 'react'; import { Typeahead } from 'react-bootstrap-typeahead'; import { useController } from 'react-hook-form'; -import { useMetadataSources } from '../hooks/api'; +import { useMetadataEntity, useMetadataSources } from '../hooks/api'; +import Form from 'react-bootstrap/Form'; -export function EntityTypeahead ({id, control, name}) { +export function EntityTypeahead ({id, control, name, children}) { const { data = [] } = useMetadataSources({}, []); + + const { get, response, loading } = useMetadataEntity(); + const entities = React.useMemo(() => data.map(d => d.entityId), [data]); const { @@ -18,14 +24,30 @@ export function EntityTypeahead ({id, control, name}) { defaultValue: "", }); + const loadSelected = async (selected) => { + const toCopy = data.find(e => e.entityId === selected); + + const source = await get(`/${toCopy.id}`); + if (response.ok) { + onChange(source); + } + // + } + return ( - onChange(selected ? data.find(e => e.entityId === selected[0]) : '')} - defaultInputValue={value ? value.entityId : ''} - options={entities} - required={true} - id={id} - /> + + + {children} + {loading && } + + selected && selected.length > 0 ? loadSelected(selected[0]) : null} + defaultInputValue={value ? value.entityId : ''} + options={entities} + required={true} + id={id} + /> + ) } \ No newline at end of file