Skip to content
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

Field Visibility #2205

Closed
cansoysal opened this issue Jan 9, 2020 · 11 comments
Closed

Field Visibility #2205

cansoysal opened this issue Jan 9, 2020 · 11 comments

Comments

@cansoysal
Copy link

Hi,
I'm trying to change field visibility depending user's access-role. In Keystone Classic(v4) there are "hidden" and "noedit" properties. Seems like they are missing in V5.

@gautamsi
Copy link
Member

gautamsi commented Jan 9, 2020

you can use access control, if user read access is denied, they can not see this in admin-ui

@cansoysal
Copy link
Author

Ok, If I set field's access: false, it doesn't show up. But if a set it as below, It show up in entry list as 'error'. Create button is present too btw.

product.js

...
store: {
      access: {
        read: access.userIsAdmin,
        update: access.userIsAdmin,
        create: access.userIsAdmin,
        delete: access.userIsAdmin,
        // auth: true,
      },
      type: Relationship,
      ref: 'Store',
    },

store.js

const Store = {
  access: {
    read: access.userIsAdmin,
    update: access.userIsAdmin,
    create: access.userIsAdmin,
    delete: access.userIsAdmin,
  },

access.js

const userIsAdmin = ({ authentication: { item: user } }) => Boolean(user && user.isAdmin);

Screen Shot 2020-01-09 at 15 56 49

@justintemps
Copy link
Contributor

@cansoysal did you ever get any clarity on this?

@gautamsi
Copy link
Member

I have a PR which shows read only fields in the UI as disabled fields. #2258

this is only in the admin-ui, the graphql endpoint has to be protected with access control.

if you use a function in access control then this is going to be treated as "maybe true" in admin-ui and let access control protect you

@justintemps
Copy link
Contributor

justintemps commented Mar 31, 2020

But then if it's false, I can't access it from graphql either, can I?

@gautamsi
Copy link
Member

gautamsi commented Apr 7, 2020

if it is false you can not use it in GraphQL. maybe true means it does !!function(){} which is true so you see them in admin-ui.

I believe you still see them in GraphQL which evaluates in the backend and eventually deny based on access control.

@Sylchi
Copy link

Sylchi commented Apr 15, 2020

I need to hide some fields and even lists from admin ui, but still would like to use them in graphql. Example -> virtual fields that compute values from user input.

@gautamsi
Copy link
Member

I dont think that is possible. it is not hard to implement but have not seen this (or similar requests) on priority list for this repo.

you might want to fork admin ui to do the same. another caveat for that is you will need to form more packages to pass down configurable info.

if #2314 makes it way in, then it is only forking the admin-ui. I even have plan to publish my fork of admin ui with more customisability.

@Fabyao
Copy link
Contributor

Fabyao commented Apr 23, 2020

@gautamsi Thanks for the clarifications. I am also in the same situation as @Sylchi where I need to hide certain fields and lists from the Admin UI. This is to limit the amount of information the user administering the CMS sees.

@Sylchi
Copy link

Sylchi commented Apr 23, 2020

As far as I know this function has been available in the keystonejs in the earlier versions and has been omitted in the version 5. I guess this has just not been implemented. To me it seems like a core functionality that should be in the main repo.

Use case is where the fields are necessary to be accessable from the api, but are cluttering the admin UI.

@MadeByMike
Copy link
Contributor

We've now added readOnly fields: #2258

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants