Singleton list types (single item list) #100
Replies: 12 comments 4 replies
-
I would prefer not to add to the keystone API for this unless we determine that it's not possible to do using pure config and the existing API. From the POV of setting up the list with graphQL, I think everything described here can be achieved with hooks and access control. The admin UI stuff might require some additional config, but we should probably build out the graphQL side of things first and make sure we understand the use case before building in highly specific UI. |
Beta Was this translation helpful? Give feedback.
-
I get there is not much difference between options and lists in the back-end, however there are big differences between how they are represented in the AdminUI and the required At the end of the day there are 2 goals for me here:
Even after our discussion I still feel |
Beta Was this translation helpful? Give feedback.
-
I would not want to create a single item list where there are 100s of settings items (look at vscode settings page, it has so many items). I would definitely be interested in Options/Settings page though. for this I would propose this:
|
Beta Was this translation helpful? Give feedback.
-
@gautamsi Could all the features you mention be served by the existing field types? I'd much rather leverage the fields so that an options page IS just like a list under the hood. This means we get a lot of the work done for free. |
Beta Was this translation helpful? Give feedback.
-
"dynamic type" field is not yet now. if that comes, all of this becomes reality. |
Beta Was this translation helpful? Give feedback.
-
@MadeByMike A couple things worth noting in your original proposal:
These two might want to still exist; they're what generates the special
This is correct, however an |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
We need to be able to create options on a list as well. It seems very likely that there will be per list options in many application. One example that surfaced this was my attempt to create role based access control via the new list plugin feature: This works for individual items and maybe it still should but it also make sense to apply these settings to a list. Perhaps the API should be consistent:
My demo: https://github.com/MadeByMike/keystone-access-control-demo |
Beta Was this translation helpful? Give feedback.
-
Options page would be awesome! |
Beta Was this translation helpful? Give feedback.
-
I know this is specifically for a use-case displaying an options panel in the CMS, but I would also find this useful for content entry for individual pages. I can achieve this by making the fields no create/delete when after they are first created, but the user interface is still awkward for clients (there are extra clicks to go into the list view, etc). There is the adminOptions object that is passed in at list creation, this handles some aspects of what data is brought into the listing view in the admin interface. For me, it would be good enough to add a singleton configuration there:
This could be handled in a few ways. Perhaps the simplest (but janky) is that, |
Beta Was this translation helpful? Give feedback.
-
would it be interesting to have a controlling list for item limiter per user or per list? Singleton ListI am going to create a PR for a
some other solution comes to my mind when considering singleton list. Limiting number of items in list by dev time numberslist plugin only solution which will enforce max items in a list and also optionally min items (it will not let you delete the item which will make overall item count to less than min allowed)? Limiting list items based on a ref listThis came to my mind while thinking about above that a max item plugin can also be used with combination of a admin managed list (all access to admin/su only) where the information for list items are stored. for example:
the hook is then applied to kind of a solution to manage these limitation without redeploying the solution. This may also be useful in adding a dynamic setting value which are usually set at build/deploy time like max item returned in a graphql query. |
Beta Was this translation helpful? Give feedback.
-
If we talking about singletons, they are always must have only one item, and must be accessed directly by singleton id, instead of something like For Singleton items I think will be much better to use some separate key-value storage, instead of separate tables (or mongo collections) for store only one item. So create some system list "Singletones" with only two fields:
This will dramatically speed-up loading and saving items and decrease complexity of database, because for singletones we don't need field indexing, filtering, ordering and all other features, only direct load-save the whole block of data. And reuse only this one table to store all singletones, defined in Keystone, with future ability to use redis or other more robust key-value storage as backend, instead of full-featured database. |
Beta Was this translation helpful? Give feedback.
-
A number of people in the community have expressed a desire to be able to configure a global 'options' page. This would work like a Keystone list however there is only a single item.
Currently settings like this are achieved with custom pages. What is wanted is the ability to use the fields API to generate these pages, along with access control and GraphQL endpoints.
I'm suggesting the following API that closely matches the
createList
API:All of the above would work the same as for lists.
The following list config would not be required on options pages:
labelField, labelResolver, listQueryName, singular, plural
I thought potentially you might want a different itemQueryName than what appears on the settings page? However since you would not be required to change the value of a setttings page name due to an ambiguous plural, I don't think we need a 'singular` option? If we do it should just be label?
I only see the need for one query which would match the
itemQueryName
. i.e:For mutations we should only need update. No
id
should be required. e.g:We keep the
data
key for consistency.Beta Was this translation helpful? Give feedback.
All reactions