-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
'@keystonejs/app-admin-ui': minor | ||
'@keystonejs/list-plugins': major | ||
--- | ||
|
||
* Added `singleton` list plugin which prevents creating more items for a list or delete the only item in the list. | ||
|
||
* Updated `admin-ui` to | ||
- Redirect to the only item if there is an item in singleton list | ||
- Hide `Search` field, `Back` and `AddNew` buttons on item details page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!--[meta] | ||
section: list-plugins | ||
title: singletoon | ||
[meta]--> | ||
|
||
# singleton Plugin | ||
|
||
This plugin makes a list singleton by allowing only one item in the list. Useful for list which must contain only one items. | ||
|
||
## Usage | ||
|
||
```js | ||
const { singleton } = require('@keystonejs/list-plugins'); | ||
|
||
keystone.createList('ListWithPlugin', { | ||
fields: {...}, | ||
plugins: [ | ||
singleton({...}), | ||
], | ||
}); | ||
``` | ||
|
||
## Config | ||
|
||
| Option | Type | Default | Description | | ||
| --------------- | --------- | ------- | ------------------------------------------------- | | ||
| `preventDelete` | `Boolean` | `true` | Prevents deletion of the (only) item in the list. | | ||
|
||
### `preventDelete` | ||
|
||
By default the plugin will prevent deletion of the only item in the list by setting `delete` access to false. If you want to control the access yourself, set this value to false. | ||
|
||
```javascript allowCopy=false showLanguage=false | ||
keystone.createList('ListWithPlugin', { | ||
fields: {...}, | ||
plugins: [ | ||
singleton({ preventDelete: false }), | ||
], | ||
}); | ||
``` |