Skip to content

Commit 78c0793

Browse files
liufuyangmartinjagodicyanthomasdev
authored
feat: add uuid widget (#6675)
* feat: add uuid widget Add a uuid widget which supports options: * read_only (bool) * prefix (string) * use_b32_encoding (bool) close: #1975 * fix(widget-uuid): align Base32 config and i18n generation --------- Co-authored-by: Martin Jagodic <jagodicmartin1@gmail.com> Co-authored-by: Yan <61414485+yanthomasdev@users.noreply.github.com>
1 parent 128207a commit 78c0793

15 files changed

Lines changed: 292 additions & 2 deletions

File tree

dev-test/backends/test/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ collections: # A list of collections the CMS should be able to edit
117117
search_fields: ['title', 'body']
118118
value_field: 'title'
119119
- { label: 'Title', name: 'title', widget: 'string' }
120+
- { label: 'ID', name: 'uuid', widget: 'uuid', read_only: true, prefix: '', use_b32_encoding: false }
120121
- { label: 'Boolean', name: 'boolean', widget: 'boolean', default: true }
121122
- { label: 'Map', name: 'map', widget: 'map' }
122123
- { label: 'Text', name: 'text', widget: 'text', hint: 'Plain text, not markdown' }

dev-test/backends/test/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dev-test/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ collections: # A list of collections the CMS should be able to edit
150150
search_fields: ['title', 'body']
151151
value_field: 'title'
152152
- { label: 'Title', name: 'title', widget: 'string' }
153+
- { label: 'ID', name: 'uuid', widget: 'uuid', read_only: true, prefix: '', use_b32_encoding: false }
153154
- { label: 'Boolean', name: 'boolean', widget: 'boolean', default: true }
154155
- { label: 'Map', name: 'map', widget: 'map' }
155156
- { label: 'Text', name: 'text', widget: 'text', hint: 'Plain text, not markdown' }

dev-test/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

package-lock.json

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/decap-cms-app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"decap-cms-widget-select": "^3.3.0",
6464
"decap-cms-widget-string": "^3.2.0",
6565
"decap-cms-widget-text": "^3.2.0",
66+
"decap-cms-widget-uuid": "^3.0.0",
6667
"immutable": "^3.7.6",
6768
"lodash": "^4.17.11",
6869
"prop-types": "^15.7.2",

packages/decap-cms-app/src/extensions.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import DecapCmsWidgetMap from 'decap-cms-widget-map';
2727
import DecapCmsWidgetDatetime from 'decap-cms-widget-datetime';
2828
import DecapCmsWidgetCode from 'decap-cms-widget-code';
2929
import DecapCmsWidgetColorString from 'decap-cms-widget-colorstring';
30+
import DecapCmsWidgetUuid from 'decap-cms-widget-uuid';
3031
// Editor Components
3132
import image from 'decap-cms-editor-component-image';
3233
// Locales
@@ -59,6 +60,7 @@ CMS.registerWidget([
5960
DecapCmsWidgetDatetime.Widget(),
6061
DecapCmsWidgetCode.Widget(),
6162
DecapCmsWidgetColorString.Widget(),
63+
DecapCmsWidgetUuid.Widget(),
6264
]);
6365
CMS.registerEditorComponent(image);
6466
CMS.registerEditorComponent({
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Change Log
2+
3+
All notable changes to this project will be documented in this file.
4+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5+
6+
7+
**Note:** Version bump only for package decap-cms-widget-uuid
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# decap-cms-widget-uuid
2+
3+
UUID widget for Decap CMS.
4+
5+
## Options
6+
7+
- `read_only`: Prevent editing the generated UUID. Defaults to `true`.
8+
- `prefix`: String prepended to the generated UUID. Defaults to an empty string.
9+
- `use_b32_encoding`: Encode the UUID using unpadded, lowercase RFC 4648 Base32. Defaults to `false`.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "decap-cms-widget-uuid",
3+
"description": "Widget for UUID values in Decap CMS.",
4+
"version": "3.0.0",
5+
"homepage": "https://www.decapcms.org/docs/widgets/#uuid",
6+
"repository": "https://github.com/decaporg/decap-cms/tree/main/packages/decap-cms-widget-uuid",
7+
"bugs": "https://github.com/decaporg/decap-cms/issues",
8+
"module": "dist/esm/index.js",
9+
"main": "dist/decap-cms-widget-uuid.js",
10+
"license": "MIT",
11+
"keywords": [
12+
"decap-cms",
13+
"widget",
14+
"uuid"
15+
],
16+
"sideEffects": false,
17+
"scripts": {
18+
"develop": "npm run build:esm -- --watch",
19+
"build": "cross-env NODE_ENV=production webpack",
20+
"build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore \"**/__tests__\" --root-mode upward"
21+
},
22+
"dependencies": {
23+
"base32-encode": "^2.0.0",
24+
"hex-to-array-buffer": "^2.0.0"
25+
},
26+
"peerDependencies": {
27+
"decap-cms-ui-default": "^3.0.0",
28+
"prop-types": "^15.7.2",
29+
"react": "^19.1.0"
30+
}
31+
}

0 commit comments

Comments
 (0)