jekyll / jekyll-admin

A Jekyll plugin that provides users with a traditional CMS-style graphical interface to author content and administer Jekyll sites.
https://jekyll.github.io/jekyll-admin/
MIT License
2.82k stars 357 forks source link

Allow default metadata fields to be overridden and edited in place #597

Closed i-a-n closed 4 years ago

i-a-n commented 4 years ago

Resolves #596

override-revert

First PR, happy to receive any additional pushes, and sorry for any inconsistencies.

This allows a user to see the default fields for a new or existing document, choose to "override" the defaults, and revert back to the default at any time. The way I accomplished this in general was by removing the StaticMetaFields component, and instead allowing MetaFields to display both default and additional fields. By checking the redux store (specifically the metadata: { metadata:{} } object), the MetaFields component will render each field as either a Static or regular MetaField, and by passing in props, each subcomponent is able to tell whether it is a default field, and whether it is currently in "default mode".

Choosing to "override" a default simply adds that key/value to the metadata redux object, allowing it to be rendered as a regular MetaField. "Reverting" it simply removes it, and it goes back to being rendered as a StaticMetaField.

Note: I updated snapshot testing and added action/reducer tests, but added no unit tests. I'd appreciate any help or direction on that, if you feel we need them. Thanks again.

ashmaroli commented 4 years ago

Good job, @i-a-n! The code looks good to me on first glance..

mertkahyaoglu commented 4 years ago

@i-a-n We can merge this after tests are passing.

ashmaroli commented 4 years ago

Thank you @i-a-n