From 1dc1b7a899206e8cd5abb8e547b81bec9975fe80 Mon Sep 17 00:00:00 2001 From: Ryan Mathis Date: Thu, 25 Aug 2022 14:00:12 -0700 Subject: [PATCH 1/2] Fixed issue with changing filter type Former-commit-id: 3939df3761d61522aff021e35f278af2848b2c03 --- ui/src/app/metadata/Filter.js | 2 -- ui/src/app/metadata/editor/MetadataFilterEditor.js | 8 ++++++++ ui/src/app/metadata/hooks/schema.js | 6 +++++- ui/src/app/metadata/wizard/MetadataFilterTypeSelector.js | 4 ++-- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ui/src/app/metadata/Filter.js b/ui/src/app/metadata/Filter.js index 58b867040..4c1bc707c 100644 --- a/ui/src/app/metadata/Filter.js +++ b/ui/src/app/metadata/Filter.js @@ -11,8 +11,6 @@ export function Filter() { const { path, url } = useRouteMatch(); - console.log(path, url) - return ( diff --git a/ui/src/app/metadata/editor/MetadataFilterEditor.js b/ui/src/app/metadata/editor/MetadataFilterEditor.js index 538c85d0e..972905e0a 100644 --- a/ui/src/app/metadata/editor/MetadataFilterEditor.js +++ b/ui/src/app/metadata/editor/MetadataFilterEditor.js @@ -25,6 +25,13 @@ export function MetadataFilterEditor({children, onNavigate, block}) { const schema = React.useContext(MetadataSchemaContext); const current = React.useContext(MetadataFilterContext); + React.useEffect(() => { + const step = definition.steps.find(step => step.id === section); + if (!step) { + onNavigate(definition.steps[0].id); + } + }, [section, current, onNavigate, definition]); + const { state, dispatch } = React.useContext(MetadataFormContext); const { metadata, errors } = state; @@ -38,6 +45,7 @@ export function MetadataFilterEditor({children, onNavigate, block}) { const warnings = definition.warnings && definition.warnings(metadata); + return (
diff --git a/ui/src/app/metadata/hooks/schema.js b/ui/src/app/metadata/hooks/schema.js index 5083559b1..b8bfcf7ca 100644 --- a/ui/src/app/metadata/hooks/schema.js +++ b/ui/src/app/metadata/hooks/schema.js @@ -11,7 +11,11 @@ export function useUiSchema(definition, schema, current, locked = true) { const ui = React.useMemo(() => definition ? { ...definition.uiSchema } : {}, [definition]); const schemaKeys = React.useMemo(() => schema ? Object.keys(schema.properties) : [], [schema]); - const step = React.useMemo(() => definition ? definition.steps.find(step => step.id === current) : {fields: []}, [definition, current]); + let step = React.useMemo(() => definition ? definition.steps.find(step => step.id === current) : {fields: []}, [definition, current]); + + if (!step) { + step = definition.steps[0]; + } const filled = React.useMemo(() => fillInRootProperties(schemaKeys, ui), [schemaKeys, ui]); const mapped = React.useMemo(() => Object.keys(filled).reduce((sch, key) => { diff --git a/ui/src/app/metadata/wizard/MetadataFilterTypeSelector.js b/ui/src/app/metadata/wizard/MetadataFilterTypeSelector.js index ff16b61a4..d46e79999 100644 --- a/ui/src/app/metadata/wizard/MetadataFilterTypeSelector.js +++ b/ui/src/app/metadata/wizard/MetadataFilterTypeSelector.js @@ -5,7 +5,7 @@ import Translate from '../../i18n/components/translate'; import { InfoIcon } from '../../form/component/InfoIcon'; import { useTranslator } from '../../i18n/hooks'; -export function MetadataFilterTypeSelector({ types = [], children, actions}) { +export function MetadataFilterTypeSelector({ types = [], children}) { const translator = useTranslator(); @@ -29,7 +29,7 @@ export function MetadataFilterTypeSelector({ types = [], children, actions}) { React.useEffect(() => { setBase({ '@type': type - }) + }); }, [type]) return ( From fbca08abb1caf11964fd1f36bfb1e88ff6c6041d Mon Sep 17 00:00:00 2001 From: Ryan Mathis Date: Thu, 25 Aug 2022 14:03:02 -0700 Subject: [PATCH 2/2] Fixed message Former-commit-id: dc238e818afa99c340c591484c913d3b28cd1616 --- backend/src/main/resources/i18n/messages.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main/resources/i18n/messages.properties b/backend/src/main/resources/i18n/messages.properties index 92f1edb6f..29aaf5de9 100644 --- a/backend/src/main/resources/i18n/messages.properties +++ b/backend/src/main/resources/i18n/messages.properties @@ -534,7 +534,7 @@ label.role=Role message.delete-role-title=Delete Role? message.delete-role-body=You are requesting to delete a role. If you complete this process the role will be removed. This cannot be undone. Do you wish to continue? -message.duration=Requires a valid ISO 8601 duration (ex. PT2D) +message.duration=Requires a valid ISO 8601 duration (ex. PT4H) message.delete-user-title=Delete User? message.delete-user-body=You are requesting to delete a user. If you complete this process the user will be removed. This cannot be undone. Do you wish to continue?