pixiebrix-extension icon indicating copy to clipboard operation
pixiebrix-extension copied to clipboard

Refactor Database storage field

Open BALEHOK opened this issue 3 years ago • 0 comments

Storage selection for Custom Form involves several actions and events that must go in a strict order and are not transparent for developers. The Database storage option is the most complex case. When Database is selected:

  1. The selection event updates the value of the field
  2. On the next render AppServiceField gets the updated Formik state add a field with a service reference

When another option is selected (database is removed):

  1. The selection event updates the value of the field
  2. On the next render an effect checks for unused service references and cleans up the root services field.

Need to refactor:

  1. AppServiceField. It can be included in the DatabaseField as a hook.
  2. usePruneUnusedServiceDependencies hook. It should be possible to work with the updated Formik state (an arbitrary object), so that updating the state and clearing the service references happen in the same render cycle.

Source code: FormRendererOptions

Related discussion: link

BALEHOK avatar Jun 27 '22 05:06 BALEHOK