Skip to content

Commit

Permalink
Fixed issues
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Jun 2, 2021
1 parent cda97bb commit 64a81fb
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ export const BaseProviderDefinition = {
},
parser: (changes, base) => {

const baseFilters = base ? base.metadataFilters.filter(f => MetadataFilterTypes.indexOf(f['@type']) > -1) : []

const parsed = (changes.metadataFilters ? ({
...changes,
metadataFilters: [
...changes.metadataFilters.filter((filter, filterName) => (
Object.keys(filter).filter(k => k !== '@type').length > 0
)),
...base.metadataFilters.filter(f => MetadataFilterTypes.indexOf(f['@type']) > -1)
...baseFilters
]
}) : changes);

Expand Down
20 changes: 10 additions & 10 deletions ui/src/app/metadata/hoc/MetadataFormContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,22 @@ function reducer(state, action) {
/*eslint-disable react-hooks/exhaustive-deps*/
function MetadataForm({ children, initial = {} }) {

const [state, dispatch] = React.useReducer(
reducer,
initialState
);
const metadata = {
...useFormattedMetadata(initial)
};

const base = useFormattedMetadata(initial);
const [state, dispatch] = React.useReducer(reducer, {
...initialState,
metadata
});

React.useEffect(() => {
dispatch(setFormDataAction(base))
dispatch(setFormErrorAction(initialState.errors))
}, [initial])

const contextValue = React.useMemo(() => ({ state, dispatch }), [state, dispatch]);

return (
<Provider value={contextValue}>{children}</Provider>
<React.Fragment>
<Provider value={contextValue}>{children}</Provider>
</React.Fragment>
);
}

Expand Down
5 changes: 4 additions & 1 deletion ui/src/app/metadata/hoc/MetadataSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ export function MetadataSchema({ type, children, wizard = false }) {
}

/*eslint-disable react-hooks/exhaustive-deps*/
React.useEffect(() => { loadSchema(definition) }, [definition]);
React.useEffect(() => {
setSchema(null);
loadSchema(definition);
}, [definition]);

return (
<MetadataDefinitionContext.Provider value={definition}>
Expand Down
3 changes: 2 additions & 1 deletion ui/src/app/metadata/hooks/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export function useUiSchema(definition, schema, current, locked = true) {
const step = React.useMemo(() => definition ? definition.steps.find(step => step.id === current) : {fields: []}, [definition, current]);

const filled = React.useMemo(() => fillInRootProperties(schemaKeys, ui), [schemaKeys, ui]);

const mapped = React.useMemo(() => {
return Object.keys(filled).reduce((sch, key) => {
const obj = { ...filled[key] };
Expand All @@ -35,6 +34,8 @@ export function useUiSchema(definition, schema, current, locked = true) {
};
}, [mapped, step.locked, locked])

console.log(isLocked);

return {uiSchema: isLocked, step};
}

Expand Down
1 change: 0 additions & 1 deletion ui/src/app/metadata/view/MetadataWizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { MetadataProviderWizard } from '../wizard/MetadataProviderWizard';
import { Wizard } from '../wizard/Wizard';

export function MetadataWizard ({type, data, onCallback}) {

return (
<MetadataForm initial={data}>
<Wizard>
Expand Down

0 comments on commit 64a81fb

Please sign in to comment.