-
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.
♻️ [#4859] Display copy toggle only if there are relevant backends
The toggle is not displayed if there are no backends to copy from, so the UI can be de-cluttered. Additionally, the mechanism/slot for the extra controls has been refactored to be more generic - anything can now be rendered there that may be relevant, and the state is specific to the UI being rendered so that has been removed from the generic parent component. We use the formik status to track form-specific state, through a small hook that normalizes the shape of the status (since it can be anything).
- Loading branch information
1 parent
7d48879
commit 7291cfa
Showing
6 changed files
with
69 additions
and
41 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
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
22 changes: 22 additions & 0 deletions
22
src/openforms/js/components/admin/form_design/variables/prefill/objects_api/useStatus.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,22 @@ | ||
import {useFormikContext} from 'formik'; | ||
|
||
/** | ||
* Convenience hook that wraps around Formik's status. | ||
* | ||
* This centralizes the shape of the status tracked in the Formik state. We use status | ||
* to track some configuration/state that affects the configuration modal without it | ||
* directly being a form field or requiring to be managed at a higher level. | ||
*/ | ||
const useStatus = () => { | ||
const {status = {}, setStatus} = useFormikContext(); | ||
const {showCopyButton = false} = status; | ||
const toggleShowCopyButton = () => { | ||
setStatus({...status, showCopyButton: !showCopyButton}); | ||
}; | ||
return { | ||
showCopyButton, | ||
toggleShowCopyButton, | ||
}; | ||
}; | ||
|
||
export default useStatus; |