boomworks/payload-plugin-author-fields

When createdBy and updatedBy are undefined, it shows as the logged in user

Opened this issue · 4 comments

cerize commented

Thanks so much for this plugin, it is so helpful!

One thing I would like to mention is that for my documents created before I added the plugin (so createdBy and updatedBy are undefined) it shows these fields in the UI as the logged in user, instead of showing no value.

Probably this happen because those fields have a default value, so the component DisplayOnlyField is returned the default values when it calls 'useField()'?

Hi @cerize
Thanks for pointing that out - I can see how that could cause problems.

The best option I can think of would be to add a new configuration option to control that behaviour for existing documents - something along the lines of:

existingDocumentDefault: 'current-user' | 'undefined' | 'choose'

I should have some time this weekend to get it working.

cerize commented

Thanks a lot @lindsayevans !!!

cerize commented

I was thinking about this and hope it is ok to chime in! I think it's great to have a choice of leaving the field 'undefined' or 'choose a default user', but could not think of a use case to show the current-user, since it will be showing a different user for different people, and none will be saved in the db. For audit trail that could be confusing?

@cerize no problem :)

current-user would be more about keeping the existing behaviour in the (unlikely) event that somebody relies on it