react-jsonschema-form icon indicating copy to clipboard operation
react-jsonschema-form copied to clipboard

Refactored the ArrayFieldTemplate into 4 templates

Open heath-freenome opened this issue 3 years ago • 0 comments
trafficstars

Reasons for making this change

  • Updated the types in @rjsf/utils to make ArrayFieldTemplate required as well as adding the following 3 new templates:
    • ArrayFieldDescriptionTemplate, ArrayFieldItemTemplate and ArrayFieldTitleTemplate
    • Also added to new types ArrayFieldDescriptionProps and ArrayFieldTitleProps
  • Updated the core theme to support the updated ArrayFeildTemplates as follows:
    • Refactored the ArrayFieldDescription and ArrayFieldTitle from ArrayField.js as ArrayFieldDescriptionTemplate and ArrayFieldTitleTemplate
      • These new Typescript classes were added into the Templates directory
      • These two new templates were essentially the same across all themes, but made a template just in case and so they can be used in all themes
    • Refactored the DefaultArrayItem component from ArrayField.js as ArrayFieldItemTemplate as a new Typescript file in the Templates directory
    • Refactored the DefaultNormalArrayFieldTemplate from ArrayField.js as ArrayFieldTemplate as a new Typescript file in the Templates directory
      • Turns out the DefaultFixedArrayFieldTemplate was essentially the same as the other template (and was never customized in any of the themes)
      • As a result, this template was deemed unnecessary
  • Updated the antd theme to support the updated ArrayFieldTemplates as follows:
    • Renamed the ArrayFieldTemplateItem component as ArrayFieldItemTemplate in its own directory
    • Renamed the NormalArrayFieldTemplate as ArrayFieldTemplate (ignore git)
      • Switched to using the ArrayFieldDescriptionTemplate, ArrayFieldItemTemplate and ArrayFieldTitleTemplate from the templates directory
    • Deleted the main ArrayFieldTemplate/index.js and FixedArrayFieldTemplate.js files from the directory
    • Updated the Templates.tsx file to add the ArrayFieldItemTemplate into the templates object
  • Updated the bootstrap-4 theme to support the updated ArrayFieldTemplatess as follows:
    • Refactored the DefaultArrayItem component from ArrayFieldTemplate as ArrayFieldItemTemplate in its own directory
    • Updated ArrayFieldTemplate by deleting all the unnecessary code, turning the DefaultNormalArrayFieldTemplate into the ArrayFieldTemplate
      • Used the ArrayFieldDescriptionTemplate, ArrayFieldItemTemplate and ArrayFieldTitleTemplate from registry.templates
    • Updated the Templates.tsx file to add the ArrayFieldItemTemplate into the templates object
    • Deleted the test and snapshot for ArrayFieldTemplates since it was already covered elsewhere
    • Updated the registry mock to pull templates from the getDefaultRegistry(), overriding with the theme Templates
  • Updated the chakra-ui theme to support the updated ArrayFieldTemplatess as follows:
    • Refactored the DefaultArrayItem component from ArrayFieldTemplate as ArrayFieldItemTemplate in its own directory
    • Updated ArrayFieldTemplate by deleting all the unnecessary code, turning the DefaultNormalArrayFieldTemplate into the ArrayFieldTemplate
      • Used the ArrayFieldDescriptionTemplate, ArrayFieldItemTemplate and ArrayFieldTitleTemplate from registry.templates
    • Updated the Templates.tsx file to add the ArrayFieldItemTemplate into the templates object
  • Updated the chakra-ui theme to support the updated ArrayFieldTemplatess as follows:
    • Refactored the DefaultArrayItem component from ArrayFieldTemplate as ArrayFieldItemTemplate in its own directory
    • Updated ArrayFieldTemplate by deleting all the unnecessary code, turning the DefaultNormalArrayFieldTemplate into the ArrayFieldTemplate
      • Used the ArrayFieldDescriptionTemplate, ArrayFieldItemTemplate and ArrayFieldTitleTemplate from registry.templates
    • Updated the Templates.tsx file to add the ArrayFieldItemTemplate into the templates object
    • Updated the snapshot for the array templates to pick up the little changes from the refactor
  • Updated the material-ui and mui themes to support the updated ArrayFieldTemplatess as follows:
    • Refactored the DefaultArrayItem component from ArrayFieldTemplate as ArrayFieldItemTemplate in its own directory
    • Updated ArrayFieldTemplate by deleting all the unnecessary code, turning the DefaultNormalArrayFieldTemplate into the ArrayFieldTemplate
      • Used the ArrayFieldDescriptionTemplate, ArrayFieldItemTemplate and ArrayFieldTitleTemplate from registry.templates
    • Updated the Templates.tsx file to add the ArrayFieldItemTemplate into the templates object
    • Deleted the UpDownWidget tests and snapshots because they are duplicated in the Form tests
  • Updated the semantic-ui theme to support the updated ArrayFieldTemplatess as follows:
    • Refactored the DefaultArrayItem component from ArrayFieldTemplate as ArrayFieldItemTemplate in its own directory
    • Updated ArrayFieldTemplate by deleting all the unnecessary code, turning the DefaultNormalArrayFieldTemplate into the ArrayFieldTemplate
      • Used the ArrayFieldDescriptionTemplate, ArrayFieldItemTemplate and ArrayFieldTitleTemplate from registry.templates
    • Updated the Templates.tsx file to add the ArrayFieldItemTemplate into the templates object

Checklist

  • [ ] I'm updating documentation
  • [x] I'm adding or updating code
    • [x] I've added and/or updated tests. I've run npm run test:update to update snapshots, if needed.
    • [ ] I've updated docs if needed
    • [ ] I've updated the changelog with a description of the PR
  • [ ] I'm adding a new feature
    • [ ] I've updated the playground with an example use of the feature

heath-freenome avatar Aug 07 '22 07:08 heath-freenome