-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Admin UI: add adminIsReadOnly property to enable fields to appear read-only #2841
Conversation
🦋 Changeset is good to goLatest commit: 5581936 We got this. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This is already pending for long |
@gautamsi Thanks for the heads-up, you're right. Basically the same change. |
I guess it is not aligned with current roadmap that is why |
This has come up enough times that I think we should enable people do it. I like the idea of using the cell view over passing this prop around every field. This idea is good but we need a way of separating AdminUI configuration from the other field configurations. This is really why discussion on this has stalled in the past. A few of us feel that the best API for this is actually not config on the field itself but the right APIs to customise fields in general. I want it to be easier to simply override the rendering of this field. i.e. replace the field or the cell or any view. At the moment this is not too hard, create a custom field that extends the existing one and replace the field view. Perhaps we could add a read only example to the demos here: https://github.com/keystonejs/keystone/tree/master/demo-projects/custom-fields/ In the long run perhaps a better option might be to allow customisation from the field config like this: keystone.createList('Example', {
fields: {
example: {
type: Text,
views: {
Field: require.resolve('./path-to/read-only/component')
},
},
},
}); Other options available under I'd much rather figure out this API and provide examples of how to create read-only and other types of adminUI customisations such as #2646. The right API here will meet all the different requirements for field customisation without adding more AdminUI concerns to the field properties. Thoughts? |
I thought about using
|
A lot of the blockers for this is that our current mechanism for passing configuration from the list/field definitions into the admin UI client code is somewhat opaque. This makes it hard for us to evaluate the impact of API changes like this. I'm making a bunch of changes that you can probably see going through at the moment which are intended to shed light on the way we pass through this config, which will in turn allow us to better assess these changes. As Mike said, these are really useful features if we can get the APIs right, so hopefully we will be able to get some movement on these PRs soon 👍 |
This can be closed once #2258 goes through (In final review now). |
#2258 is now in 👍 |
Adds a property
adminIsReadOnly
to fields config, which enables the user to make certain fields appear read-only (although they remain changeable through GraphQL) inside the admin UI.This leverages the same view as the cells in list tables.
Especially useful for data fields, which are only to be changed by the underlying system, and not by actual users of the Admin UI thus diminishing the chance of accidental corruption of data in those fields.