-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ [#4606] Refactor ZGW options components structure
Refactored the components and hooks so we can lift up the retrieval of available catalogues in a ZGW API group. The parent component is now responsible for fetching the available catalogues and relays the loading/error state from useAsync. It also encapsulated the derived catalogueUrl when a valid value is available and selected, which other components need to look up related objects (like case types, document types, products and the future role types). I've opted to pass down the error into a component that just throws for the existing error boundary behaviour and location, as it's important that you can still change the API group to trigger a new attempt and we want to keep the code nicely organised. Finally, some more fieldsets were abstracted into their own components for readability reasons.
- Loading branch information
1 parent
f0aa235
commit 1540ab4
Showing
15 changed files
with
358 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/openforms/js/components/admin/form_design/registrations/zgw/LegacyOptionsFieldset.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import {FormattedMessage} from 'react-intl'; | ||
|
||
import Fieldset from 'components/admin/forms/Fieldset'; | ||
|
||
import {LegacyCaseType, LegacyDocumentType} from './fields'; | ||
|
||
/** | ||
* @deprecated | ||
*/ | ||
const LegacyOptionsFieldset = () => ( | ||
<Fieldset | ||
title={ | ||
<FormattedMessage | ||
description="ZGw APIs registration: legacy configuration options fieldset title" | ||
defaultMessage="Legacy configuration" | ||
/> | ||
} | ||
fieldNames={['zaaktype', 'informatieobjecttype']} | ||
collapsible | ||
> | ||
<div className="description"> | ||
<FormattedMessage | ||
description="ZGW APIs legacy config options informative message" | ||
defaultMessage={`The configuration options here are legacy options. They | ||
will continue working, but you should upgrade to the new configuration | ||
options above. If a new configuration option is specified, the matching | ||
legacy option will be ignored.`} | ||
/> | ||
</div> | ||
<LegacyCaseType /> | ||
<LegacyDocumentType /> | ||
</Fieldset> | ||
); | ||
|
||
export default LegacyOptionsFieldset; |
62 changes: 62 additions & 0 deletions
62
src/openforms/js/components/admin/form_design/registrations/zgw/ObjectsAPIOptionsFieldset.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import {useFormikContext} from 'formik'; | ||
import PropTypes from 'prop-types'; | ||
import {FormattedMessage} from 'react-intl'; | ||
|
||
import {ContentJSON} from 'components/admin/form_design/registrations/objectsapi/LegacyConfigFields'; | ||
import Fieldset from 'components/admin/forms/Fieldset'; | ||
import {ObjectsAPIGroup} from 'components/admin/forms/objects_api'; | ||
|
||
import {ObjectType, ObjectTypeVersion} from './fields'; | ||
|
||
/** | ||
* Callback to invoke when the API group changes - used to reset the dependent fields. | ||
*/ | ||
const onApiGroupChange = prevValues => ({ | ||
...prevValues, | ||
objecttype: '', | ||
objecttypeVersion: undefined, | ||
}); | ||
|
||
/** | ||
* Configuration fields related to the Objects API (template based) integration. | ||
*/ | ||
const ObjectsAPIOptionsFieldset = ({objectsApiGroupChoices}) => { | ||
const { | ||
values: {objecttype = ''}, | ||
} = useFormikContext(); | ||
return ( | ||
<Fieldset | ||
title={ | ||
<FormattedMessage | ||
description="ZGW APIs registration: Objects API fieldset title" | ||
defaultMessage="Objects API integration" | ||
/> | ||
} | ||
collapsible | ||
fieldNames={['objecttype', 'objecttypeVersion', 'contentJson']} | ||
> | ||
<ObjectsAPIGroup | ||
apiGroupChoices={objectsApiGroupChoices} | ||
onApiGroupChange={onApiGroupChange} | ||
required={!!objecttype} | ||
isClearable | ||
/> | ||
<ObjectType /> | ||
<ObjectTypeVersion /> | ||
<ContentJSON /> | ||
</Fieldset> | ||
); | ||
}; | ||
|
||
ObjectsAPIOptionsFieldset.propTypes = { | ||
objectsApiGroupChoices: PropTypes.arrayOf( | ||
PropTypes.arrayOf( | ||
PropTypes.oneOfType([ | ||
PropTypes.number, // value | ||
PropTypes.string, // label | ||
]) | ||
) | ||
), | ||
}; | ||
|
||
export default ObjectsAPIOptionsFieldset; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.