-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(object): variable types #7031
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for decap-www ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@mmkal this looks great. @demshy could you look into this and answer the questions? To me, the Joining widget packages: we agree with this! But it would be a big effort for little effect (user-wise), so it wasn't very close on our radar. We would have to choose which to do first: remove immutable.js or join packages. We can't do both at the same time. |
Good to hear - if you're open to joining packages, maybe it could start with just the list and object widgets moving to decap-cms-core for now. IMO it'd make sense to do that before moving off immutablejs - it's easier to do and centralizing generally would probably make a big dependency change lower lift. |
@mmkal I merged
I never found anything pointing to this data being generated, so I suggest that we add it manually in those index files. To keep this moving I would address repackaging in a different PR. |
I'll try to take a look in the next week. I am a bit fuzzy on the details now! |
Summary
Allow for objects to use variable types - effectively enabling "dependent fields" for objects. Also, improve support for objects with
required: false
- use list widget for those too, so that you can add remove the whole object from the CMS, depending on whether the content author wants it to be defined or not.Implementation: use the
list
widget control forobjects
when eithertypes
is defined, or whenrequired=false
.Replaces #3891
Goes some of the way to addressing #565 (there's a limitation - dependent fields must be nested under an
object
orlist
).Test plan
Added the
typed_object
field to the "kitchen sink" collection and tried it out.Here's how it renders:
Screen.Recording.2024-01-12.at.11.19.25.AM.mov
Help needed
Code organisation: I don't like that the
object
widget is now actually defined in thedecap-cms-widget-list
package. Thedecap-cms-widget-object
package is now reduced to a dependency of thelist
widget. To be honest I don't really see the value in splitting the widgets out into separate packages anyway, but that's another story. It was a minimal way of getting the change in. Maybe a refactor to merge thedecap-cms-widget-list
anddecap-cms-widget-object
packages could be a follow-up.Naming: similarly, the helper which creates the widget is called
DecapCmsWidgetList.ObjectWidget()
but that's kind of confusing. It's the object widget. So maybe the following refactor would make sense:decap-cms-widget-object
package todecap-cms-widget-struct
- it's just a general purpose control component for rendering the fields for an dictionary-like field (either object or list). It doesn't correspond to an actual widget anymoredecap-cms-widget-object-and-list
which depends on bothdecap-cms-widget-list
anddecap-cms-widget-struct
. This new package is just a thin wrapper which decides whether to use the list control or the struct control.Testing: I tested it manually, but noticed there's are HTML files
dev-test/index.html
anddev-test/backends/test/index.html
which contain JSON-serialized values of kitchen sink collection sample files. Am I supposed to add to those by hand?@martinjagodic do you know who can help me answer some of these questions?
Next steps
Stuff I don't really want to do as part of this PR
decap-cms-widget-*
packages and just puts them in a subfolder insidedecap-cms-core
. I can't really see the downside of that as an end goal, but obviously it'd be a fair amount of work to actually do that, and a fair amount of work to get buy in from the maintenance team...Checklist