Compare commits

...

682 Commits

Author SHA1 Message Date
Elliot DeNolf
33c1f287f3 chore(release): v1.1.17 2022-10-25 11:09:30 -04:00
Elliot DeNolf
cd4861afda chore: move release-it back to dev deps 2022-10-25 11:03:13 -04:00
James
9f56ac182f Merge branch 'master' of github.com:payloadcms/payload 2022-10-25 11:00:48 -04:00
James
3301f59822 fix: enforces depth: 0 in graphql resolvers 2022-10-25 11:00:38 -04:00
James
f9ca3a9f96 chore: fixes bad field name 2022-10-25 11:00:22 -04:00
Elliot DeNolf
3ba7594a65 chore: update release-it plugin 2022-10-25 10:31:37 -04:00
TomDo1234
6a1b25ab30 feat: adds default max length for text-based fields
* feat: Added to types.ts the default Max Field Length

* feat: Added the defaultMaxFieldLength to the schema.ts

* feat: applying defaultMaxFieldLength to 3 validators

* feat: renamed defaultMaxFieldLength to defaultMaxTextLength , adding defaultMax and min nums

* feat: validating numbers with new defaultminnum and defaultmaxnum

* feat: FIXED BUG, do not return an error message on the defaultmaxnum and minnum override checks

* Added test fields

* Eslint compliance

* feat : eslint compliacnce

* Added tests, though a reasonable payload config needs to be imported to them

* Removed my failed jest tests, relying on the yarn dev test instead

* Increased default num max and min range to JS safe integer

* Jmi suggestions

* feat: removing the superfluous number max and min default

* Added test for max text field

Co-authored-by: Tom Do <tom@iifuture.com>
Co-authored-by: TomDoFuture <108644869+TomDoFuture@users.noreply.github.com>
2022-10-24 18:57:45 -04:00
James
17dbbc7775 fix: group + group styles within collapsible 2022-10-24 18:56:56 -04:00
James
7e25abf87a chore: type fixes 2022-10-24 12:26:25 -04:00
James
0591dfd05b chore: typo 2022-10-24 12:18:03 -04:00
Will Laeri
17610adf36 chore: upgrade vulnerable dependencies (#1228)
* upgrade vulnerable deps

* removed specified node/yarn versions
2022-10-24 12:14:48 -04:00
Will Laeri
91814777b0 feat: specify node 14+ and yarn classic LTS (#1240) 2022-10-24 12:14:22 -04:00
Daniel Söderling
09d793926d feat: added beforeLogin hook (#1289) 2022-10-24 12:05:12 -04:00
James
a9f2f0ec03 fix: #1290, renders more than one rich text leaf where applicable 2022-10-24 12:03:06 -04:00
James
66bf8c3cbd fix: #1286, uses defaultDepth in graphql rich text depth 2022-10-24 11:31:09 -04:00
James
3967c1233f fix: #1291, add inline relationship drafts 2022-10-24 11:23:01 -04:00
James
c929725dd5 fix: ensures field updates when disableFormData changes 2022-10-24 08:56:08 -04:00
James
9c6098b191 chore(release): v1.1.16 2022-10-21 15:48:40 -04:00
James
6daab398da Merge branch 'master' of github.com:payloadcms/payload 2022-10-21 15:39:36 -04:00
James
36ef3789fb fix: obscure bug where upload collection has upload field relating to itself 2022-10-21 15:39:29 -04:00
Hung Vu
14cbf2f079 docs: correction to demo code of radio field (#1266) 2022-10-18 14:10:27 -04:00
Dan Ribbens
87bbf4416b Merge pull request #1272 from payloadcms/fix/#1271-index-sortable-fields-regression 2022-10-18 14:05:36 -04:00
Dan Ribbens
785b992c3e fix: indexSortableFields not respected 2022-10-17 20:17:55 -04:00
James
b4695e10b6 chore(release): v1.1.15 2022-10-14 11:38:48 -04:00
James
0b0d971491 fix: ensures svg mime type is always image/svg+xml 2022-10-14 11:33:41 -04:00
James
02af6b90b2 chore(release): v1.1.14 2022-10-14 10:22:14 -04:00
James
2181bc84a1 1.1.13 2022-10-14 10:02:40 -04:00
James
036cd5f831 1.1.12 2022-10-14 10:02:33 -04:00
James
da9825cd99 chore: reverts hiding scrollbars in tabs 2022-10-14 09:53:43 -04:00
James
4a43f95952 fix: hides scrollbar in tabs with overflowing tabs, closes #1259 2022-10-14 09:51:44 -04:00
James
9af9b73132 fix: cleans up draft global action buttons 2022-10-14 09:37:27 -04:00
James
7f7d3dbeef Merge branch 'master' of github.com:payloadcms/payload 2022-10-13 08:28:37 -04:00
James
8ef9206001 chore: properly exports BeforeDuplicate type 2022-10-13 08:17:05 -04:00
James
21ba237135 fix: #1183 - better handling of mime types with svgs + similar files 2022-10-13 08:12:15 -04:00
James Mikrut
3bda163e7b Merge pull request #1241 from jacobsfletch/master
feat: bumps @faceless-ui/modal to v2.0.1
2022-10-12 12:00:22 -04:00
James
e4e4ad1b08 chore: ensures beforeDuplicate works on each locale 2022-10-12 11:59:56 -04:00
James
f7352a7d08 chore(release): v1.1.11 2022-10-12 11:52:48 -04:00
James
6f6f2f8e7b feat: builds beforeDuplicate admin hook, closes #1243 2022-10-12 11:44:41 -04:00
James
5ca5abab42 fix: ensures arrays and blocks mount as disableFormData: true, fixes #1242 2022-10-12 10:52:59 -04:00
Jacob Fletcher
9a7553099c feat: migrates @faceless-ui/modal to v2.0.1 2022-10-12 01:28:17 -04:00
James
55d0c917e6 chore(release): v1.1.10 2022-10-11 13:40:19 -04:00
James
f52daeccf0 docs: adds access control vid to docs 2022-10-11 13:34:35 -04:00
James
6c871c57fc chore(release): v1.1.9 2022-10-11 12:12:40 -04:00
James
5322ada9e6 feat: improves access control typing 2022-10-11 11:46:58 -04:00
James
ee83a50ea9 chore: improves read-only styling of all react-selects 2022-10-11 11:46:44 -04:00
James
f6b19e074c chore: more predictably exports Access type 2022-10-11 09:44:52 -04:00
James
6cc1d9e41b chore(release): v1.1.8 2022-10-11 09:24:07 -04:00
James
74863f9462 chore: workaround for faceless-ui modal types 2022-10-11 09:19:20 -04:00
James
fdcf029da2 chore: adjusts LeaveWithoutSaving z-index 2022-10-11 09:00:19 -04:00
James
3e3d151e4c docs: #1235, broken typescript link 2022-10-11 08:32:27 -04:00
James Mikrut
5da204b152 Merge pull request #1224 from payloadcms/feat/use-context-selector
Feat/use context selector
2022-10-10 18:38:36 -04:00
James
3d6c3f7339 chore: cleanup 2022-10-10 18:38:15 -04:00
James
8d49517004 chore: merge master 2022-10-10 15:12:38 -04:00
James Mikrut
d1c0f2b97b Merge pull request #1230 from payloadcms/feat/add-inline-relationship
feat: adds ability to create related docs while editing another
2022-10-10 15:07:41 -04:00
James
1bc42ae098 chore: tests 2022-10-10 14:56:10 -04:00
James
c6edb7f53a chore: improves design 2022-10-10 13:57:08 -04:00
James
1e048fe037 feat: adds ability to create related docs while editing another 2022-10-09 20:24:38 -04:00
James
8fabdce584 chore: restores old useWatchForm to avoid breaking change 2022-10-07 17:54:35 -04:00
James
5c1a3fabee feat: implements use-context-selector for form field access 2022-10-07 17:41:41 -04:00
James
fe6d30210b Merge branch 'master' of github.com:payloadcms/payload into feat/use-context-selector 2022-10-07 10:09:20 -04:00
James
93f71e621c chore(release): v1.1.7 2022-10-06 18:14:37 -04:00
James Mikrut
39d1a09d5a Merge pull request #1215 from damtzi/chore/credentials-include
chore: Add 'credentials: include' to all fetch calls
2022-10-06 17:55:55 -04:00
Damian Tziamtzis
74ae6fd1d5 chore: Add 'credentials: include' to all fetch calls 2022-10-06 23:14:55 +02:00
James
bbbcf8c869 chore(release): v1.1.6 2022-10-06 17:10:10 -04:00
James
b379666dec chore: improves upload field button aesthetics a bit 2022-10-06 17:04:29 -04:00
James Mikrut
6f40b5c9ab Merge pull request #1175 from bigmistqke/fix/responsive-fileupload-width
Fix: responsive fileupload width
2022-10-06 16:42:25 -04:00
James Mikrut
b329be7dc1 Merge pull request #1214 from payloadcms/fix/#1184
fix: #1184
2022-10-06 16:12:05 -04:00
James
c2ec54a7cb fix: #1184 2022-10-06 16:11:24 -04:00
James
3641dfd38a fix: #1189 2022-10-06 15:42:20 -04:00
James
5bf1354741 chore: fixes tests 2022-10-06 15:23:49 -04:00
James Mikrut
b894b809bf Merge pull request #1212 from payloadcms/fix/#940
Fix/#940
2022-10-06 14:24:51 -04:00
James
a4504ca15b Merge branch 'master' of github.com:payloadcms/payload into fix/#940 2022-10-06 14:23:37 -04:00
James
7926083732 fix: #940 2022-10-06 14:23:08 -04:00
James Mikrut
534cd5ae53 Merge pull request #1211 from jacobsfletch/master
feat: async admin access control
2022-10-06 13:31:01 -04:00
James Mikrut
fb329a99ba Merge pull request #1210 from payloadcms/fix/#1204
fix: #1204
2022-10-06 13:24:42 -04:00
James Mikrut
9e726d9b90 Merge pull request #1174 from payloadcms/fix/#1156-file-uploads-changing-extensions
fix: upload xls renaming ext
2022-10-06 13:23:23 -04:00
James Mikrut
8d065d619d Merge pull request #1124 from payloadcms/feat/sortable-by-default
feat: sort select and relationship fields by default
2022-10-06 13:20:32 -04:00
James Mikrut
cbff1776e7 Merge pull request #1168 from payloadcms/fix/read-only
Fix: read only field styles
2022-10-06 13:20:16 -04:00
nwhitmont
e517695000 docs: +note that collection slug must be in kebab-case, refactor example routes to match (#1176)
Co-authored-by: Nils Whitmont <nwhitmont@genvidtech.com>
2022-10-06 13:18:44 -04:00
James Mikrut
4370cfca0c Merge pull request #1195 from bigmistqke/fix/textarea-resize-vertical
fix: resize textarea only vertically
2022-10-06 13:17:51 -04:00
James Mikrut
4135b618ef Merge pull request #1198 from dsod/fix/resize-images-naming-and-mimetype
use the converted image mimeType for filename and admin interface
2022-10-06 13:17:22 -04:00
Jacob Fletcher
1cfce87549 feat: async admin access control 2022-10-06 13:16:15 -04:00
James Mikrut
c48283ac1d Merge pull request #1201 from christian-reichart/fix/sibling-data-in-after-read
fix: sibling data in after read hook
2022-10-06 13:15:52 -04:00
James Mikrut
328be3e4bc Merge pull request #1206 from payloadcms/style/color-scheme
fix: system dark scrollbars
2022-10-06 13:14:54 -04:00
James
b4becd1493 fix: #1204 2022-10-06 13:11:25 -04:00
James
95fac0bd62 chore: wip 2022-10-05 15:51:22 -04:00
Jarrod Flesch
a30d9dc1d7 fix(style): system dark scrollbars 2022-10-05 15:33:41 -04:00
Christian Reichart
7bfcefbfea fix sibling data in after read hook 2022-10-04 14:39:09 +02:00
dsod
131b2796e7 now uses the converted image mimeType for file extension and in the admin interface 2022-10-03 19:24:14 +02:00
Elliot DeNolf
debcb003bb docs: clarify api key auth usage 2022-10-03 08:41:23 -04:00
bigmistqke
6e1dfff1b8 fix: resize textarea only vertically 2022-10-02 17:37:27 +02:00
Jarrod Flesch
a9ebb71a09 Merge branch 'master' into fix/read-only 2022-09-30 10:47:34 -04:00
James
3e34e5216f chore(release): v1.1.5 2022-09-29 17:56:44 -04:00
James
2400c58219 chore: addresses more flaky tests 2022-09-29 17:52:51 -04:00
James
90d504526c chore: adds more delay to flaky test 2022-09-29 17:17:14 -04:00
Jarrod Flesch
c97d4f9545 Merge branch 'master' into fix/read-only 2022-09-29 12:54:02 -04:00
Jarrod Flesch
09a8144f3c fix: richText e2e test, specific selectors 2022-09-29 12:53:16 -04:00
Jarrod Flesch
00ef1700ae fix: ajusts how disabled states are being set on anchors and buttons 2022-09-29 11:49:25 -04:00
James
3e03b2b5df Merge branch 'master' of github.com:payloadcms/payload 2022-09-29 11:11:14 -04:00
James
974f79e57e chore: sends 204 on GraphQL OPTIONS requests 2022-09-29 11:11:02 -04:00
James
34f42083b5 chore: rolls back changes to useThrottledEffect 2022-09-29 10:26:06 -04:00
Elliot DeNolf
c0cae1e834 chore: reorder bug report template 2022-09-29 09:27:33 -04:00
James
3ce8ee4661 fix: bug in useThrottledEffect 2022-09-28 17:40:31 -04:00
bigmistqke
f9feff58d6 add flex-wrap: wrap to upload__wrap 2022-09-26 21:03:28 +02:00
bigmistqke
73848b6037 fix: remove min-width from fileupload 2022-09-26 20:51:45 +02:00
Dan Ribbens
7fd8124df6 fix: upload xls renaming ext 2022-09-26 08:19:58 -04:00
James Mikrut
1c77455403 Merge pull request #1169 from payloadcms/docs/test-cache
Improves contributing doc
2022-09-24 12:06:42 -07:00
James
051a0fad84 chore(release): v1.1.4 2022-09-23 20:15:52 -07:00
Jarrod Flesch
8e53ef47a0 chore: adds note about clearing the node module cache when switching test directories 2022-09-23 15:23:28 -04:00
Jarrod Flesch
918130486e fix: styles readOnly RichTextEditor, removes interactivity within when readOnly 2022-09-23 14:34:02 -04:00
Jarrod Flesch
b454811698 fix: threads readOnly to ReactSelect 2022-09-23 13:17:11 -04:00
James Mikrut
f87c68f310 Merge pull request #1147 from abaco/fix/refine-relationship-typegen
fix: refine type generation for relationships
2022-09-23 09:51:36 -07:00
James
25006d44e8 Merge branch 'master' of github.com:payloadcms/payload 2022-09-23 09:49:06 -07:00
James Mikrut
d8e51dd200 Merge pull request #1157 from payloadcms/docs/cell-component-props
docs: cell component props and example
2022-09-23 09:46:49 -07:00
James Mikrut
f54210a528 Merge pull request #1161 from jacobsfletch/master
feat: supports root endpoints
2022-09-23 09:46:30 -07:00
James Mikrut
96dab15cd1 Merge pull request #1163 from payloadcms/fix/nested-fields-permissions
fix: field level access for nested fields
2022-09-23 09:44:02 -07:00
James Mikrut
4126843619 Merge pull request #1165 from jacobsfletch/docs/webpack-cache
docs: adds tip for clearing webpack cache when aliasing server modules
2022-09-23 09:42:35 -07:00
James
e0238ad393 chore: updates sass 2022-09-23 09:42:10 -07:00
Jacob Fletcher
aa0302c05e docs: adds tip for clearing webpack cache when aliasing server modules 2022-09-23 12:24:51 -04:00
Jacob Fletcher
1040ad2cfe Merge branch 'payloadcms:master' into master 2022-09-23 12:23:57 -04:00
Dan Ribbens
c64f15d4d9 test: field level access for nested fields 2022-09-23 03:26:26 -04:00
Dan Ribbens
22ea98ca33 fix: field level access for nested fields 2022-09-22 21:37:02 -04:00
Jacob Fletcher
75bab716d1 chore: adds root endpoint test 2022-09-22 13:23:42 -04:00
Dan Ribbens
52a8e9624c docs: plugins typo 2022-09-22 12:19:18 -04:00
Jacob Fletcher
52cd3b4a7e feat: supports root endpoints 2022-09-22 10:49:49 -04:00
addison-codes
cc63167307 docs: fix highlighting 2022-09-22 00:51:25 -04:00
Dan Ribbens
314671b3b7 docs: cell component props and example 2022-09-21 14:20:01 -04:00
Dario Aprea
ef83bdb709 fix: refine type generation for relationships 2022-09-20 16:27:09 +02:00
Dan Ribbens
686085496a chore(release): v1.1.3 2022-09-16 17:05:57 -04:00
Dan Ribbens
76ae20aa16 fix: disable-local-strategy-and-graphql 2022-09-16 16:56:29 -04:00
Dan Ribbens
a1a55386f0 fix: duplicate with relationships 2022-09-16 14:57:29 -04:00
Elliot DeNolf
b3bb421c6c fix: adjust prevPage and nextPage graphql typing (#1140) 2022-09-16 09:40:21 -07:00
Dan Ribbens
eabb981243 fix: duplicate with relationships 2022-09-16 12:26:18 -04:00
Dan Ribbens
4be14a12d0 chore(release): v1.1.2 2022-09-14 15:42:13 -04:00
Dan Ribbens
ce174878f3 fix: disableLocalStorage with image resizing 2022-09-14 15:34:59 -04:00
Dan Ribbens
14966796ae fix: resize images without local storage 2022-09-14 13:07:18 -04:00
Dan Ribbens
7b756f3421 fix: resize images without local storage 2022-09-14 11:34:40 -04:00
Marco Sangalli
9fea2b4e08 chore: fixing uploadFile when using s3 bucket 2022-09-14 14:43:47 +02:00
James
f9b1b1fe7f docs: adds Link example in rich text 2022-09-13 21:25:08 -07:00
Elliot DeNolf
205404a88a chore: remove unused cypress package 2022-09-13 20:09:24 -07:00
Elliot DeNolf
813c46c86d feat: sort select and relationship fields by default 2022-09-13 20:06:12 -07:00
Luciano Greiner
8bfe253157 Avoid adding password and email to schemas when disableLocalStrategy is on 2022-09-13 17:55:22 -03:00
Dan Ribbens
ed8e581629 chore: changelog update 2022-09-13 13:44:22 -04:00
Dan Ribbens
7cf66b081a chore(release): v1.1.1 2022-09-13 13:20:24 -04:00
Dan Ribbens
64503f8267 fix: conditions on collapsible fields 2022-09-13 13:16:52 -04:00
Dan Ribbens
d82c12eab6 Merge pull request #1120 from payloadcms/fix/#1117 2022-09-13 11:58:28 -04:00
Dan Ribbens
9c4f2b68b0 fix: conditions on conditionals 2022-09-13 11:53:52 -04:00
James
bcfda707ff Merge branch 'master' of github.com:payloadcms/payload 2022-09-13 07:40:57 -07:00
James
66b77f7dca chore: re-adds key to tabs RenderFields 2022-09-13 07:40:48 -07:00
Dan Ribbens
dcc8dad53b fix: dashboard links to globals 2022-09-13 09:47:28 -04:00
Elliot DeNolf
bb1477e08b chore(release): v1.1.0 2022-09-12 20:54:50 -07:00
James
4e165cf52e chore: ensures new listSearchableFields works with complex queries 2022-09-12 19:40:01 -07:00
James Mikrut
a1083727ef feat: #1001 - builds a way to allow list view to search multiple fields
* make textfields searchable

* shorten namings in placeholder function

* chore: finishes listSearchableFields

Co-authored-by: Christian Reichart <christian.reichart@camperboys.com>
2022-09-12 16:38:02 -07:00
Elliot DeNolf
d5ccd45b53 Ability to get the "previous" state in the AfterChange Hook (#1115)
Co-authored-by: Alessio Gravili <alessio@bonfireleads.com>
Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
2022-09-12 15:48:50 -07:00
Dan Ribbens
94d355ba5e Merge pull request #1102 from payloadcms/feat/group-collections 2022-09-12 16:52:24 -04:00
Dan Ribbens
892a774998 Merge branch 'master' into feat/group-collections 2022-09-12 16:39:07 -04:00
James
78f39af5cf chore: finishes collapsible nav groups 2022-09-12 12:45:06 -07:00
James
813fa1571c Merge branch 'feat/group-collections' of github.com:payloadcms/payload into feat/group-collections 2022-09-12 10:55:15 -07:00
Dan Ribbens
c40e232ac6 feat: hide nav labels with no un-grouped collections 2022-09-12 13:51:24 -04:00
Dan Ribbens
834f4ebd38 feat/add support for setting collapsable fields (array, block, collapsable… (#1057)
Co-authored-by: liorix <liorix@gmail.com>
Co-authored-by: Elliot DeNolf <denolfe@gmail.com>
2022-09-12 10:39:49 -07:00
Elliot DeNolf
ca434b8a92 feat: implement gravatar (#1107) 2022-09-12 10:29:22 -07:00
Dan Ribbens
7acf944a28 Feat/expose sharp options (#1029)
Co-authored-by: khakimvinh <kha.kim.vinh@gmail.com>
Co-authored-by: Elliot DeNolf <denolfe@gmail.com>
2022-09-12 10:29:07 -07:00
Elliot DeNolf
391c9d8682 fix: word boundaries, no regex lookbehind support for Safari (#1114) 2022-09-12 10:28:29 -07:00
James Mikrut
8e47961da1 Merge pull request #814 from slavanossar/feat/optional-tab-namespacing
feat: optional tab namespacing
2022-09-11 21:42:54 -07:00
James
016f3e47ab chore: ensures generate types works with named tabs 2022-09-11 21:19:20 -07:00
James
21eb19edd1 chore: further refinements 2022-09-11 20:57:30 -07:00
James
ad4f7a5fff chore: fixes and cleanup 2022-09-11 20:07:02 -07:00
James
cd209379b2 chore: merge master 2022-09-11 18:07:05 -07:00
Elliot DeNolf
14a16dc05f chore: remove unneeded package (#1110) 2022-09-11 16:39:16 -07:00
James
9a461b8536 fix: #1106 2022-09-10 17:58:39 -07:00
Dan Ribbens
59af8725b4 feat: globals groups 2022-09-10 19:59:11 -04:00
Dan Ribbens
dffeaf6a69 feat: collection groups 2022-09-10 19:59:11 -04:00
James
c7851f8189 chore(release): v1.0.36 2022-09-10 13:55:23 -07:00
James
ada1871993 fix: bug with account view 2022-09-10 13:50:34 -07:00
James
78ccd2ad9b chore: cleanup exports 2022-09-10 13:33:14 -07:00
James
4cb69039ed chore(release): v1.0.35 2022-09-09 20:12:41 -07:00
James
c8b37f40cb fix: incorrect auth strategy type 2022-09-09 20:03:49 -07:00
Elliot DeNolf
4963f10a18 Merge pull request #1083 from payloadcms/feat/improve-rich-text-link
Co-authored-by: Elliot DeNolf <denolfe@gmail.com>
Co-authored-by: Jacob Fletcher <jacobsfletch@gmail.com>
2022-09-09 15:34:17 -07:00
Elliot DeNolf
6f77fe7c27 Merge branch 'master' into feat/improve-rich-text-link 2022-09-09 15:23:46 -07:00
Elliot DeNolf
c584c2ed47 test: rich text link e2e 2022-09-09 15:18:02 -07:00
Elliot DeNolf
5a19f6915a fix: rich text link with no selection 2022-09-09 15:17:51 -07:00
Jacob Fletcher
48f0c06edc chore: bumps @faceless-ui/modal to v2.0.0-alpha.4 2022-09-09 00:13:27 -04:00
Jacob Fletcher
50cc3c5a21 chore: bumps @faceless-ui/modal to v2.0.0-alpha.3 2022-09-08 23:08:54 -04:00
James
6674a0df6b Merge branch 'feat/improve-rich-text-link' of github.com:payloadcms/payload into feat/improve-rich-text-link 2022-09-08 18:05:39 -07:00
James
cbbace21ca chore: updates faceless modal 2022-09-08 18:05:21 -07:00
Elliot DeNolf
87346a97ab test: rich text internal link 2022-09-08 15:40:49 -07:00
Elliot DeNolf
4357c5491d docs: add rich text link fields 2022-09-08 15:40:49 -07:00
Elliot DeNolf
03847703b0 chore: update rich text data seeding 2022-09-08 15:40:49 -07:00
James
3c46851426 chore: migrates to new faceless modal version 2022-09-08 15:22:09 -07:00
James Mikrut
8115855e5a Merge pull request #1089 from payloadcms/fix/height-width-by-default
fix: add height/width if imageSizes not specified
2022-09-07 20:03:39 -07:00
James Mikrut
ddb2a0a4f5 Merge pull request #1095 from jacobsfletch/master
chore: bumps @faceless-ui/modal to v1.3.2 #1070
2022-09-07 20:03:27 -07:00
James
a45577f182 chore: misc ux improvements to rich text link 2022-09-07 17:25:15 -07:00
James
eb963066f7 chore: fixes bug with links always populating 2022-09-07 16:52:32 -07:00
James
a99d9c98c3 feat: allows rich text links to link to other docs 2022-09-07 16:42:43 -07:00
James
cdfc0dec70 chore: ensures logic is accurate while updating links 2022-09-07 13:48:36 -07:00
Elliot DeNolf
eb1ff7efce chore: update label for bug reports 2022-09-07 12:40:00 -07:00
Jacob Fletcher
55843f6c55 chore: bumps @faceless-ui/modal to v1.3.2 #1070 2022-09-07 15:23:47 -04:00
James
7856f66b31 merge master 2022-09-07 11:53:02 -07:00
James Mikrut
47ac86b4b7 Merge pull request #1094 from payloadcms/fix/#1059
fix: #1059
2022-09-07 11:51:42 -07:00
James
13dc39dc6d fix: #1059 2022-09-07 11:50:55 -07:00
James
65653bd1d3 chore(release): v1.0.34 2022-09-07 09:39:24 -07:00
James
299ee82ccf chore: pins faceless ui 2022-09-07 09:35:24 -07:00
James
b38b6427b8 fix: pins faceless ui modal 2022-09-07 09:29:04 -07:00
James
784696f9a6 chore: comments todos 2022-09-07 09:27:39 -07:00
Elliot DeNolf
8bd2a0e6c9 fix: add height/width if imageSizes not specified 2022-09-07 08:58:02 -07:00
Dan Ribbens
0f671b1b35 chore(release): v1.0.33 2022-09-07 10:57:08 -04:00
Dan Ribbens
d56882cc20 fix: require min 1 option in field schema validation (#1082) 2022-09-07 10:53:21 -04:00
James
6d13ae6846 chore: removes old comment 2022-09-06 22:58:14 -07:00
James
91000d7fda feat: improves rich text link ux 2022-09-06 22:53:27 -07:00
Elliot DeNolf
888734dcdf fix: accented label char sanitization for GraphQL (#1080) 2022-09-06 16:03:43 -07:00
James Mikrut
e81da57f61 Merge pull request #1079 from payloadcms/fix/#1062
fix: #1062
2022-09-06 13:58:20 -07:00
James
05d1b141b2 fix: #1062 2022-09-06 13:56:53 -07:00
Elliot DeNolf
b7e5828adc feat: cyrillic like query support (#1078) 2022-09-06 16:47:57 -04:00
Dan Ribbens
2ee4c7ad72 fix: update removing an upload with null (#1076) 2022-09-06 16:19:59 -04:00
max frühschütz
77ab11bce8 docs: move description prop doc to right place (#1077) 2022-09-06 16:19:47 -04:00
Arick
cd8edbaa1f fix: reorder plugin wrapping (#1051) 2022-09-06 16:19:21 -04:00
Matt Arnold
5e21048457 docs: update custom endpoints link (#1075) 2022-09-06 15:41:27 -04:00
pixelistik
c0c093d16c docs: Fix missing word (#1063) 2022-09-05 21:03:48 -04:00
James
117153fad7 chore: bump version 2022-09-02 14:56:09 -07:00
James
5ae666b0e0 fix: ensures adding new media to upload works when existing doc does not exist 2022-09-02 14:39:41 -07:00
Dustin Miller
afa03789b8 docs: Correct “autheticate” misspelling in docs (#1048) 2022-09-02 15:27:06 -04:00
Dan Ribbens
44b0073834 fix: update removing a relationship with null (#1056) 2022-09-02 15:21:09 -04:00
Dan Ribbens
254636167d test: custom css (#1053) 2022-09-02 14:03:49 -04:00
Dan Ribbens
29e82ec845 fix: children of conditional fields required in graphql schema (#1055) 2022-09-02 14:02:58 -04:00
Wesley
c3a0bd8625 fix: implement the same word boundary search as the like query (#1038)
Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
2022-09-01 13:03:21 -04:00
Ikko Ashimine
32a4e8e9b9 docs: update overview.mdx (#1046) 2022-09-01 12:58:09 -04:00
Elliot DeNolf
482cbe71c7 feat: update operator type with contains (#1045) 2022-09-01 12:17:53 -04:00
Elliot DeNolf
7dbcd9ca89 docs: fix relationship where query 2022-09-01 12:14:07 -04:00
Dan Ribbens
a1f2dcab8f docs: fix defaultValue example (#1044) 2022-09-01 10:26:41 -04:00
James
21417c6598 chore: better logic for changing password in ui 2022-08-30 17:58:17 -07:00
James
f1a272f407 1.0.31 2022-08-30 15:21:59 -07:00
James Mikrut
064f797023 Merge pull request #1033 from Elliot67/patch-1
docs: fix graphql `disable` property explanation
2022-08-30 15:21:10 -07:00
James Mikrut
26c2020b12 Merge pull request #1034 from payloadcms/feat/duplicate-all-locales
Feat/duplicate all locales
2022-08-30 15:13:07 -07:00
James
af1a483e64 chore: ensures new Edit view is mounted when going directly between one id and another 2022-08-30 15:12:23 -07:00
James
f517cb5e93 chore: cleanup 2022-08-30 15:07:38 -07:00
James
c8a8914ea7 Merge branch 'feat/duplicate-all-locales' of github.com:payloadcms/payload into feat/duplicate-all-locales 2022-08-30 14:52:51 -07:00
James Mikrut
4f834c6bf8 Merge pull request #1035 from payloadcms/fix/#981
fix: #981
2022-08-30 14:44:40 -07:00
James
d588843121 fix: #981 2022-08-30 14:43:44 -07:00
Dan Ribbens
51c7770b10 feat: duplicate copies all locales 2022-08-30 17:23:30 -04:00
Elliot Lintz
18ff5d29b0 docs: fix graphql disable property explanation 2022-08-30 22:41:00 +02:00
Dan Ribbens
e31098eaa5 test: duplicate copies all locales 2022-08-30 16:25:26 -04:00
James Mikrut
0873050b32 Merge pull request #1032 from payloadcms/fix/#948
fix: #948
2022-08-30 11:55:39 -07:00
James
8df9ee7b2d fix: #948 2022-08-30 11:54:41 -07:00
Dan Ribbens
a9ef557ca4 chore(release): v1.0.30 2022-08-29 22:55:12 -04:00
Dan Ribbens
689fa008fb fix: upload field validation not required (#1025) 2022-08-29 22:49:08 -04:00
James
1a4ce65e6c chore(release): v1.0.29 2022-08-29 15:58:30 -07:00
James Mikrut
f6dff04cfe Merge pull request #1022 from payloadcms/fix/#953
fix: #953
2022-08-29 15:42:44 -07:00
James
a73c391c2c fix: #953 2022-08-29 15:41:59 -07:00
James
e88c7ca4b2 chore: revises the logic while clearing wherebuilder queries 2022-08-29 15:13:14 -07:00
Dan Ribbens
0cd8446735 chore(release): v1.0.28 2022-08-29 17:08:17 -04:00
Dan Ribbens
6a3cfced9a fix: relationship cell loading (#1021)
* fix: relationship cell lazy loading items in viewport

* fix: collection list page param changing
2022-08-29 17:03:45 -04:00
Hung Vu
0586d7aa7d fix: unpublish item will not crash the UI anymore (#1016) 2022-08-29 15:39:46 -04:00
Dan Ribbens
3736755a12 feat: types custom components to allow any props (#1013) 2022-08-29 14:57:30 -04:00
Dan Ribbens
d727fc8e24 feat: validate relationship and upload ids (#1004)
* feat: validate relationship and upload ids

* chore: update fields-relationship test data

* fix: skip FE relationship and upload id validation
2022-08-29 14:57:06 -04:00
Dan Ribbens
50b0303ab3 fix: incorrect field paths when nesting unnamed fields (#1011)
* chore: reproduce issue #976

* fix: incorrect field paths when nesting non-named fields
2022-08-29 14:52:17 -04:00
Dan Ribbens
6bc6e7bb61 fix: require properties in blocks and arrays fields (#1020)
* fix: make blocks required in block fields

* fix: make fields required in array fields
2022-08-29 14:51:12 -04:00
Dan Ribbens
cf2eb3e482 chore: fix dev hooks (#1006) 2022-08-26 11:11:21 -04:00
James Mikrut
4aa5500593 Merge pull request #965 from payloadcms/test/code-field
test: add code fields to test config
2022-08-24 08:26:08 -07:00
James Mikrut
c7432fb6e6 Merge pull request #986 from charkour/patch-1
docs: fix typo about collections
2022-08-24 08:25:46 -07:00
James Mikrut
f895443e33 Merge pull request #990 from payloadcms/docs/examples-with-ts-types
docs: update examples with ts types
2022-08-24 08:25:33 -07:00
James Mikrut
32cebb56ff Merge pull request #999 from jacobsfletch/master
chore: exports PayloadHandler interface
2022-08-24 08:24:14 -07:00
James Mikrut
4a6b01d094 Merge pull request #996 from payloadcms/fix/#948-tab-nav-scroll
fix: remove lazy load of array and blocks components
2022-08-24 08:23:46 -07:00
James Mikrut
f8295f7577 Merge pull request #1000 from payloadcms/ci/actions-on-pr
ci: run actions on PRs
2022-08-24 08:20:33 -07:00
Elliot DeNolf
a2fa99d06f ci: run actions on PRs 2022-08-24 09:00:52 -04:00
Jacob Fletcher
c508ac6dee chore: exports PayloadHandler interface 2022-08-24 07:54:09 -04:00
Dan Ribbens
4900fa799f fix: remove lazy loading of array and blocks 2022-08-23 15:42:33 -04:00
James Mikrut
135b1bcdd7 Merge pull request #975 from dsod/fix/node15-keep-request-properties
Keep original request and add properties to it, instead of copy
2022-08-23 11:19:01 -07:00
Elliot DeNolf
25f5d68b74 feat: export more fields config types and validation type (#989) 2022-08-23 13:26:00 -04:00
Elliot DeNolf
1ed867ce0c docs: update examples with ts types 2022-08-23 11:43:24 -04:00
Charles Kornoelje
5ef5f09a5c fix typo about collections
Really interesting product. Reading through the docs now. Loving it so far. 

Thanks
2022-08-22 16:23:59 -04:00
dsod
bc97d3d6f2 Keep original request and add properties to it, instead of copy 2022-08-20 01:33:29 +02:00
Dan Ribbens
b21a56fdf7 chore(release): v1.0.27 2022-08-18 17:45:16 -04:00
Dan Ribbens
97f2a9b484 test: fix e2e relationship 2022-08-18 17:43:06 -04:00
James
4ef6801230 fix: react-sortable-hoc dependency instead of dev dependency 2022-08-18 14:37:45 -07:00
Dan Ribbens
8e21a91b2c chore(release): v1.0.26 2022-08-18 17:03:45 -04:00
Afzaal Ahmad
38a1a38c0c feat: enable reordering of hasMany relationship and select fields (#952)
* feature: enable reordering of hasMany relationship and select fields using config

* update: correct docs for select, and relationship field for sortable config

* update: move sortable to admin config, and rename it to isSortable, apply grab, and grabbing classes while drag, and drop
2022-08-18 16:59:33 -04:00
Dan Ribbens
2b7785d101 chore: update endpoint type (#966) 2022-08-18 16:22:35 -04:00
Dan Ribbens
2cf9d35fed chore: run ci tests on pull request (#955)
* chore: run ci tests on pull request
2022-08-18 15:17:02 -04:00
Elliot DeNolf
4e1f9c7280 test: add code fields to test config 2022-08-18 14:44:10 -04:00
Will Viles
f45d5a0421 feat: adds more prismjs syntax highlighting options for code blocks (#961) 2022-08-18 13:17:05 -04:00
Dan Ribbens
39586d3cdb fix: missing fields in rows on custom id collections (#954) 2022-08-18 12:26:05 -04:00
James
5e66e3ee78 chore(release): v1.0.25 2022-08-17 15:36:28 -07:00
James Mikrut
a284f6c066 Merge pull request #950 from payloadcms/feat/top-level-endpoints
Feat/top level endpoints
2022-08-17 15:32:35 -07:00
James Mikrut
fdc0ad8a3c Merge pull request #947 from rustyy/chore/code-improvements
Chore/code improvements
2022-08-17 15:32:09 -07:00
James
fa01b353ef chore: removes unused code 2022-08-17 15:31:39 -07:00
Dan Ribbens
dac3308441 docs: custom api endpoints 2022-08-17 14:08:01 -04:00
Dan Ribbens
11d8fc71e8 feat: custom api endpoints 2022-08-17 13:28:50 -04:00
Dan Ribbens
771bbaedbc chore: validation reuses endpoints schema 2022-08-17 13:06:58 -04:00
Dan Ribbens
040833ead8 test: move endpoints tests to new suite 2022-08-17 12:57:07 -04:00
Felix Hofmann
7c2acb4324 chore: use type-var instead of 'as'-keyword for jwtDecode 2022-08-16 23:22:00 +02:00
Felix Hofmann
88fe797007 chore: remove unreachable return statement 2022-08-16 23:21:38 +02:00
Elliot DeNolf
5825d7e64f test: skip flaky sorting test for now (#945) 2022-08-16 12:04:25 -04:00
James Mikrut
97ff49f2bf Merge pull request #926 from rustyy/feat/datepicker-month-only
feat: add new pickerAppearance option 'monthOnly'
2022-08-15 19:21:50 -07:00
James
ccada2e8c9 chore: migrates to PATCH for collection updates 2022-08-15 19:19:44 -07:00
James
1d8bcd6e16 Merge commit 'refs/pull/863/head' of github.com:payloadcms/payload 2022-08-15 18:55:07 -07:00
James
1b58094e6f Merge branch 'master' of github.com:payloadcms/payload 2022-08-15 18:54:43 -07:00
James
1437bfe0c9 merge: #799 2022-08-15 18:54:34 -07:00
James Mikrut
171da32b00 Merge pull request #944 from payloadcms/fix/#568
fix: #568
2022-08-15 18:42:15 -07:00
James
a3edbf4fef fix: #568 2022-08-15 18:41:34 -07:00
James Mikrut
8ab4ec8d54 Update CHANGELOG.md 2022-08-15 18:04:32 -07:00
James
f8365abf1b chore(release): v1.0.24 2022-08-15 18:03:57 -07:00
James
078e8dcc51 feat: ensures you can query on blocks via specifying locale or not specifying locale 2022-08-15 17:59:08 -07:00
James
b1a1575122 fix: #939 2022-08-15 17:58:59 -07:00
James
201a8e1053 Merge branch 'master' of github.com:payloadcms/payload 2022-08-15 17:58:53 -07:00
Dan Ribbens
ff4c1a1c01 chore: simplifies indexing
* fix: create indexes in nested fields

* chore: remove unused devDependency mongodb

* fix: point index

* fix: nested schema indexes

* chore: begins to simplify index creation

* chore: simplifies index creation

Co-authored-by: James <james@trbl.design>
2022-08-15 17:56:39 -07:00
James
7c449e0d30 Merge branch 'chore/simplify-indexes' of github.com:payloadcms/payload 2022-08-15 13:58:10 -07:00
Dan Ribbens
2ca526bd22 chore: simplifies index creation 2022-08-15 16:54:23 -04:00
James
48f929f3ab chore: begins to simplify index creation 2022-08-15 13:03:13 -07:00
James
f2bec90663 Merge branch 'fix/#922-nested-index-creation' of github.com:payloadcms/payload into fix/#922-nested-index-creation 2022-08-15 12:37:10 -07:00
Dan Ribbens
1c7445dc7f fix: format graphql localization input type (#932)
* fix: format locales for graphql

* fix: locale missing from graphql mutation args
2022-08-15 11:42:29 -04:00
James
78630cafa2 chore(release): v1.0.23 2022-08-14 18:54:13 -07:00
James Mikrut
0a40dd43cb test: adds dataloader test (#936)
* chore: adds dataloader test config

* test: passing dataloader test
2022-08-14 11:04:05 -07:00
James Mikrut
32fb72a5bb Merge pull request #935 from payloadcms/fix/#930
fix: #930
2022-08-14 10:42:10 -07:00
James
cbb1c84be7 fix: #930 2022-08-14 10:40:52 -07:00
Dan Ribbens
145e1db05d fix: dev:generate-types on all test configs (#919) 2022-08-13 13:04:24 -04:00
Elliot DeNolf
4115045c15 test: flaky admin test fix (#929) 2022-08-13 08:08:40 -04:00
Dan Ribbens
d0744f3702 fix: nested schema indexes 2022-08-13 07:44:36 -04:00
James
e7caaf57a9 chore(release): v1.0.22 2022-08-12 16:25:55 -07:00
James
fba0847f0f fix: ensures you can query on mixed schema type within blocks 2022-08-12 16:08:36 -07:00
Felix Hofmann
566c6ba3a9 feat: add new pickerAppearance option 'monthOnly' 2022-08-12 23:11:33 +02:00
Dan Ribbens
b860959fea fix: point index 2022-08-12 16:35:08 -04:00
James
9e4e4b231c chore: adds commenting to obscure form function 2022-08-12 13:11:49 -07:00
James
b8421ddc0c fix: #905 2022-08-12 12:18:02 -07:00
Dan Ribbens
9165b25fd6 chore: remove unused devDependency mongodb 2022-08-12 12:01:34 -04:00
Dan Ribbens
f615abc9b1 fix: create indexes in nested fields 2022-08-12 11:59:51 -04:00
James
9237dd67da chore(release): v1.0.21 2022-08-11 15:06:20 -07:00
James
e1347d5a39 Merge branch 'master' of github.com:payloadcms/payload 2022-08-11 15:02:28 -07:00
James
ca852e8cb2 fix: ensures you can query on nested block fields 2022-08-11 15:02:17 -07:00
KGZM
d0da3d7962 fix: saving multiple versions (#918)
* test: saving multiple versions with unique fields

* fix: saving multiple versions with unique fields

Version schemas were getting produced with uniqueness constraints which
caused updates to likely fail because each successive version would
potentially reuse unchanged unique key-values (particularly ident keys
like slug) from previous versions.

This was due to `mongoose.buildSchema` not respecting buildSchemaOptions.disableUnique.

This regression was introduced with the fix at commit c175476e.

* test: eslint fix

Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
2022-08-11 15:53:51 -04:00
Dan Ribbens
2ae33b603a feat: WIP tab compatible with traverseFields 2022-08-11 12:05:35 -04:00
Dan Ribbens
6a6a69190f feat: tabs support localization at the tab level 2022-08-11 12:05:33 -04:00
Dan Ribbens
a7b882c03d chore: run ci test workflow on pull requests 2022-08-11 12:05:05 -04:00
Dan Ribbens
a83921a2fe feat: support localized tab fields 2022-08-11 12:05:02 -04:00
Slava Nossar
4b7b04d5fa return full Tab object for column display 2022-08-11 12:04:20 -04:00
Slava Nossar
b403f5228b update Tabs field docs 2022-08-11 12:04:20 -04:00
Slava Nossar
dd289ca24a update data and path when tab had name 2022-08-11 12:04:20 -04:00
Slava Nossar
daf5fc83d8 update test data 2022-08-11 12:04:20 -04:00
Slava Nossar
08271086c3 return tab.name for columns 2022-08-11 12:04:20 -04:00
Slava Nossar
30da37becd add namespaced field path 2022-08-11 12:04:20 -04:00
Slava Nossar
df1491de74 add extra test fields and data 2022-08-11 12:04:20 -04:00
Slava Nossar
420fd67905 update mongodb schema builder 2022-08-11 12:04:20 -04:00
Slava Nossar
17a55e4a3a add tab field with name and data to test suite 2022-08-11 12:04:20 -04:00
Slava Nossar
1b3a328388 update graphql schema builder 2022-08-11 12:04:20 -04:00
Slava Nossar
060ee40bab add name to schema and types 2022-08-11 12:04:20 -04:00
Dan Ribbens
103966d36e chore(release): v1.0.20 2022-08-11 11:55:09 -04:00
Dan Ribbens
1ce2dc8e6d chore: update dependencies (#917)
* chore: update dependencies

* chore: mongoose version update

* chore: yarn lock

Co-authored-by: Elliot DeNolf <denolfe@gmail.com>
2022-08-11 11:51:30 -04:00
Tim Hallyburton
2f4f075441 feat: field name validation (#903)
* feat: add simple validation for field names

* test: add invalid field name coverage
2022-08-11 08:02:55 -04:00
Arick
50972b98a1 fix: E11000 duplicate key error has no keyValue (#916) 2022-08-11 07:49:59 -04:00
Dan Ribbens
874c001d3b fix: number validation works with 0 min and max (#906) 2022-08-10 08:18:39 -04:00
Petre Tudor
63519a8f54 docs: missing word (#909)
add `wait` in `...the second hook will wait for the first to complete before it starts.`
2022-08-10 07:59:52 -04:00
finnelliott
63a0336e98 docs: add missing comma to radio example (#901)
Missing comma in example, leading to syntax error when copied by user.
2022-08-08 20:56:55 -04:00
Yves Léon Jansen
ae51836187 docs: tabs example typo (#904) 2022-08-08 20:55:51 -04:00
James
888e756c6e chore(release): v1.0.19 2022-08-07 19:04:22 -04:00
James
a8d2e09952 feat: exposes static upload handlers 2022-08-07 19:00:26 -04:00
James
23d2ef5027 chore(release): v1.0.18 2022-08-06 15:44:34 -04:00
James
3735a28b0c chore: allows url to be used as thumbnail when no adminThumbnail property present 2022-08-06 15:35:54 -04:00
James
112defe846 chore(release): v1.0.17 2022-08-06 13:27:38 -04:00
James
804f3ced95 chore: simplifies base field merging 2022-08-06 13:12:47 -04:00
James
209b02b069 fix: #898 2022-08-06 13:12:25 -04:00
James
a5918059a8 chore(release): v1.0.16 2022-08-05 11:29:08 -04:00
James
c32dfea356 fix: #896 2022-08-05 11:22:26 -04:00
James
3b2061e54a chore(release): v1.0.15 2022-08-04 16:42:09 -04:00
James
61673907ca chore: threads through forceNullable in buildObjectType 2022-08-04 16:37:04 -04:00
James
1e72301cdf chore(release): v1.0.14 2022-08-04 16:14:30 -04:00
James Mikrut
055d1b9ea1 Merge pull request #892 from payloadcms/fix/allow-incomplete-drafts-graphql
fix: allows querying incomplete drafts in graphql
2022-08-04 15:47:41 -04:00
James
8d968b7690 fix: allows querying incomplete drafts in graphql 2022-08-04 15:45:33 -04:00
James Mikrut
2989ec5100 Merge pull request #887 from shumakmanohar/patch-1
Update overview.mdx
2022-08-04 14:05:00 -04:00
James Mikrut
c4d7df8bba Merge pull request #888 from payloadcms/feat/allow-rich-text-querying
feat: allows querying on rich text content
2022-08-04 14:04:40 -04:00
James Mikrut
d6cd5b1f0d Merge pull request #889 from payloadcms/fix/#884
Fix/#884
2022-08-04 14:04:28 -04:00
James
e9b3f3f060 fix: #884 2022-08-04 14:03:23 -04:00
James
ed80c30c74 chore: adds tests to reproduce #884 2022-08-04 11:39:15 -04:00
James
3343adb952 feat: allows querying on rich text content 2022-08-04 10:59:56 -04:00
Shumak Manohar
a8aaa6deea Update overview.mdx 2022-08-04 18:41:09 +05:30
Dan Ribbens
3c8fa72dc8 chore(release): v1.0.13 2022-08-03 15:33:52 -04:00
James
91c4f4f980 chore: remove duplicative video in docs 2022-08-03 15:28:29 -04:00
James
b2406b3696 docs: adds intro video to docs 2022-08-03 15:27:27 -04:00
James
b8504ffb25 fix: #878 2022-08-03 15:21:44 -04:00
James
0294c02aed feat: improves adjacent group styling 2022-08-03 15:21:32 -04:00
James Mikrut
31680dcdea Merge pull request #882 from payloadcms/fix/#880
fix: #880
2022-08-03 13:50:01 -04:00
James
d91b69c465 test: improves nested block test coverage 2022-08-03 13:49:49 -04:00
James
9c0c606b20 fix: #880 2022-08-03 13:39:22 -04:00
Dan Ribbens
6791352ce8 docs: payload plugins and getting started video (#876)
* docs: add link to payload-plugins github topic

* docs: add getting started developer intro video link
2022-08-02 17:08:02 -04:00
Dan Ribbens
d17d227fad chore(release): v1.0.12 2022-08-02 12:01:52 -04:00
Dan Ribbens
c175476e74 fix: unique index creation (#867)
* fix: unique indexes created for mongo 5 and later

* test: add index test coverage for unique, nested and localized fields
2022-08-02 11:56:18 -04:00
Falko Woudstra
f0ff1c7c99 Update documentation for PATCH instead of PUT in Rest API 2022-08-02 00:02:50 +02:00
Falko Woudstra
d0d498e9c7 Add warning PATCH update route and add deprecation warning on PUT 2022-08-01 23:59:26 +02:00
Dan Ribbens
da2a262208 test: e2e windows compatibility (#861)
* test: e2e compatible with windows
* chore: mongoose type fix
2022-08-01 15:21:25 -04:00
James
2f86a39e38 test: adds more tabs tests 2022-08-01 13:11:08 -04:00
James
408b66590a fix/#853 2022-08-01 12:23:53 -04:00
James
663cae4788 fix: ensures tabs can overflow on mobile when there are many 2022-08-01 08:54:23 -04:00
James
3a66860ab2 Merge branch 'master' of github.com:payloadcms/payload 2022-08-01 08:40:54 -04:00
James
9abb74abf7 fix/#854 2022-08-01 08:40:48 -04:00
Elliot DeNolf
bf47f69258 chore(release): v1.0.11 2022-07-28 14:09:41 -04:00
Elliot DeNolf
0b57e45ee4 test: consolidate e2e npm script 2022-07-28 13:51:34 -04:00
Elliot DeNolf
bf942bf015 ci: run all e2e tests (#847) 2022-07-28 13:33:06 -04:00
Elliot DeNolf
b2ae5da62a test: fix fields-relationship e2e (#846) 2022-07-28 11:50:23 -04:00
James
858b1afa54 fix: ensures when initial values changes, field value is updated 2022-07-28 11:46:52 -04:00
lordie
bc83153b60 assert every list element non null 2022-07-27 18:46:39 -03:00
Elliot DeNolf
1997153549 test: implement script to execute all e2e tests (#840) 2022-07-27 17:22:49 -04:00
Elliot DeNolf
b479013f00 test: fix admin e2e config (#839) 2022-07-27 17:10:51 -04:00
Dan Ribbens
211b960440 chore(release): v1.0.10 2022-07-27 15:53:41 -04:00
James
7157f70790 Merge branch 'master' of github.com:payloadcms/payload 2022-07-27 15:43:11 -04:00
James
84611aff2c fix: #836 2022-07-27 15:43:02 -04:00
James Mikrut
bd4dd45f8e Merge pull request #819 from payloadcms/feat/dataloader
feat: greatly enhances performance by using dataloader pattern to batch populations
2022-07-27 11:36:28 -04:00
James Mikrut
f190ad3576 Merge pull request #834 from payloadcms/fix/gql-refresh-resolver
fix: accesses payload config correctly in gql refresh resolver
2022-07-27 11:36:16 -04:00
Dan Ribbens
9813216ea9 test: add circular relationship to tests (#835) 2022-07-27 11:16:05 -04:00
Jarrod Flesch
d5e88cc1a9 fix: accesses payload config correctly in gql refresh resolver 2022-07-27 09:17:07 -04:00
James
5dc7caf356 fix: id now properly required in graphql findByID operation 2022-07-26 16:59:29 -04:00
James
a8a21e119b chore: better naming conventions within local api 2022-07-26 12:58:02 -04:00
Elliot DeNolf
2c9d45c59c chore: remove unused files 2022-07-26 11:02:53 -04:00
Elliot DeNolf
d176633804 test: increase custom id randomization window (#829) 2022-07-26 10:35:46 -04:00
wristshot9987
f65594be43 doc: Adding a contributing section to README.md (#804) 2022-07-26 09:58:11 -04:00
Elliot DeNolf
f0466f885f chore: update contributing guide (#825) 2022-07-25 21:07:28 -04:00
James Mikrut
309a8cde95 Merge pull request #823 from payloadcms/fix/#809
fix: ensures collapsible preferences are retained through doc save
2022-07-25 15:03:41 -07:00
James
61f0e8ea9f fix: ensures collapsible preferences are retained through doc save 2022-07-25 18:02:48 -04:00
James Mikrut
af00eb9cc4 Merge pull request #820 from payloadcms/fix/#801
fix: email not always loading while viewing auth collections
2022-07-25 14:07:50 -07:00
James Mikrut
61e8a4d6ee Merge pull request #821 from payloadcms/fix/#806
fix: #806, allow partial word matches using 'like' operator
2022-07-25 14:07:39 -07:00
James Mikrut
55a273d982 Merge pull request #811 from vincentvandijck/fix/set-overflow-modal-to-auto
fix: set overflow payload modal container to auto
2022-07-25 14:03:32 -07:00
James Mikrut
0993223e5c Merge pull request #810 from vincentvandijck/fix/trim-login-email
Fix/trim login email
2022-07-25 14:02:23 -07:00
James
08a38b03b9 chore: applies fix to other edit views 2022-07-25 16:58:47 -04:00
James
b79ae00603 test: adds like query partial word match test 2022-07-25 16:56:45 -04:00
James
c96985be0c fix: #806, allow partial word matches using 'like' operator 2022-07-25 16:48:45 -04:00
James
36e9acc637 fix: email not always loading while viewing auth collections 2022-07-25 16:29:20 -04:00
James
e541713282 chore: linting 2022-07-25 16:03:50 -04:00
James
5d57bfa438 feat: significantly improves complex GraphQL query performance 2022-07-25 15:54:52 -04:00
James
c5bcd1e341 feat: greatly enhances performance by using dataloader pattern to batch populations 2022-07-25 15:12:28 -04:00
Vincent Van Dijck
cfb5540e64 fix: set overflow payload modal container to auto 2022-07-25 03:14:19 +02:00
Vincent Van Dijck
38d1794ee2 Merge branch 'fix/trim-login-email' of https://github.com/vincentvandijck/payload into fix/trim-login-email 2022-07-24 23:12:09 +02:00
Vincent Van Dijck
8feed39fb9 fix: trim trailing whitespaces of email in login 2022-07-24 23:08:35 +02:00
Vincent Van Dijck
3140f9c3b8 trim trailing whitespaces of email in login 2022-07-24 23:05:50 +02:00
lordie
e13c6fa955 graphql schema: check blockfield 'required' property for null-ability 2022-07-22 18:05:43 -03:00
James Mikrut
b201168bd0 Merge pull request #796 from wenqingl/master
doc: Update README.md
2022-07-21 16:48:56 -07:00
James Mikrut
e5e675c14a Update CHANGELOG.md 2022-07-21 16:48:20 -07:00
James
9589f0798f chore(release): v1.0.9 2022-07-21 16:47:15 -07:00
James
e1c35b5220 chore: further documents strategies 2022-07-21 16:42:40 -07:00
Dan Ribbens
f22f56e73c feat: use provided auth strategy name or strategy.name (#797)
* feat: use provided auth strategy name or strategy.name

* fix: require strategy name when providing custom auth
2022-07-21 19:36:31 -04:00
wenqingl
61280e36c4 Update README.md 2022-07-21 16:17:10 -07:00
Luciano Greiner
3b4d5afd41 fix: avoid assuming Email will be present on JWT token. Using ID instead as email might not be in if using disableLocalStrategy (#789) 2022-07-21 15:20:23 -07:00
Luciano Greiner
3a3026cd63 feat: pass payload and names to custom auth strategies (#781) 2022-07-21 18:18:26 -04:00
Marco Sangalli
2a1f387bcc fix: enable index creation from schema (#791) 2022-07-21 18:16:28 -04:00
Jarrod Flesch
6f8b8d0fb8 fix(doc): corrects doc to match underlying Access type (#792) 2022-07-21 18:00:17 -04:00
Elliot DeNolf
8a81d0b274 fix: graphql gen logging output (#795) 2022-07-21 13:48:54 -07:00
Jarrod Flesch
e2c366f536 fix: sharpens radio input edges by replacing box-shadow trick with border property (#768) 2022-07-21 09:55:37 -07:00
Elliot DeNolf
4415f9db48 chore: add error message if test config doesn't exist 2022-07-21 08:17:54 -07:00
Elliot DeNolf
f6ff308dc4 chore(release): v1.0.8 2022-07-20 16:52:27 -07:00
Elliot DeNolf
546011d8a9 chore: add MIT license badge 2022-07-20 15:05:47 -07:00
Elliot DeNolf
60c0f0fb08 chore: organize relationship custom id tests 2022-07-20 15:04:57 -07:00
James Mikrut
4b6f451022 Merge pull request #785 from payloadcms/fix/#756
Fix/#756
2022-07-20 14:51:31 -07:00
Elliot DeNolf
3fb2bcfac7 feat: export PayloadRequest 2022-07-20 12:43:03 -07:00
Elliot DeNolf
66c820c863 feat: export PayloadRequest 2022-07-20 12:37:19 -07:00
Dan Ribbens
09f57e9a4c test: group relationships
* test: relationship fields inside groups and subgroup

* test: group nested relationships and arrays

* test: improves coverage for hooks

Co-authored-by: James <james@trbl.design>
2022-07-20 11:52:21 -07:00
James Mikrut
6f748f1adb feat: improves generated types by removing unnecessary optional properties (#784) 2022-07-20 11:51:19 -07:00
Dan Ribbens
893772ebd8 fix: await field hooks recursively 2022-07-19 19:57:47 -04:00
James
b987cb8dc4 fix: potential solution for #756 2022-07-19 15:52:05 -07:00
Dan Ribbens
aa322b2cf2 chore(release): v1.0.7 2022-07-19 14:45:11 -04:00
Dan Ribbens
4c68f64829 docs: update demo links and add examples to test dir (#773) 2022-07-19 14:42:14 -04:00
Elliot DeNolf
cc360191b5 docs: remove references to demo config 2022-07-19 11:09:13 -07:00
Elliot DeNolf
1d06117619 chore: adjust banner color 2022-07-19 07:20:59 -07:00
James
446a4e1d8a chore(release): v1.0.6 2022-07-19 01:46:02 -07:00
James
428edb05c4 feat: improves initAsync pattern 2022-07-19 01:42:56 -07:00
James
21708bcc1c chore(release): v1.0.5 2022-07-19 01:34:03 -07:00
James
23d605c5aa Merge branch 'master' of github.com:payloadcms/payload 2022-07-19 01:32:36 -07:00
James
b4ffa22885 feat: adds initAsync 2022-07-19 01:32:25 -07:00
Elliot DeNolf
d2bc4b72a0 chore: update onInit type 2022-07-19 01:05:49 -07:00
Elliot DeNolf
27c352c2ff chore: update changelog 2022-07-19 00:07:13 -07:00
James
19a354863f chore(release): v1.0.4 2022-07-18 23:54:41 -07:00
James
33f4a1322d chore: 1.0.3 2022-07-18 23:53:22 -07:00
Elliot DeNolf
563f98e2fb feat: merge 1.0 #762 2022-07-18 23:22:02 -07:00
Dan Ribbens
1e4b94c508 Merge branch 'feat/1.0' of github.com:payloadcms/payload into feat/1.0 2022-07-19 02:03:24 -04:00
Dan Ribbens
cd8d1c7ace docs: dark mode 2022-07-19 02:02:30 -04:00
Dan Ribbens
2ea545f0cf test: list cell data 2022-07-19 02:02:06 -04:00
Elliot DeNolf
e8a1cdafba test: misc e2e fixes 2022-07-18 22:59:48 -07:00
Elliot DeNolf
1f8b5d8e1a test: make auth e2e a todo 2022-07-18 22:53:30 -07:00
Dan Ribbens
793dfe96b9 test: promise hooks 2022-07-19 01:32:31 -04:00
Elliot DeNolf
6533af9c0e chore: add scss breaking change to changelog 2022-07-18 22:23:26 -07:00
Dan Ribbens
87ead2f89b Merge branch 'feat/1.0' of github.com:payloadcms/payload into feat/1.0 2022-07-18 23:50:57 -04:00
Dan Ribbens
28e3928094 test: array fields 2022-07-18 23:50:28 -04:00
Elliot DeNolf
dc41372acb test: test sibling data in access control 2022-07-18 20:33:36 -07:00
Elliot DeNolf
6a9ea638d5 test: add access-control int tests 2022-07-18 18:50:41 -07:00
Elliot DeNolf
2a7651eb9c test: fix odd behavior 2022-07-18 15:27:20 -07:00
James
9021d5352d Merge branch 'feat/1.0' of github.com:payloadcms/payload into feat/1.0 2022-07-18 13:07:25 -07:00
James
dc5c9ee3a0 chore: better fix to rich text upload 2022-07-18 13:07:20 -07:00
James
079623f40a fix: responsive improvements to rich text upload 2022-07-18 12:50:20 -07:00
Dan Ribbens
b59ba230de Merge branch 'feat/1.0' of github.com:payloadcms/payload into feat/1.0 2022-07-18 14:26:09 -04:00
Dan Ribbens
6826e44072 test: field default values 2022-07-18 14:25:18 -04:00
Elliot DeNolf
878fd4ab92 test: custom id crud 2022-07-18 10:29:33 -07:00
Elliot DeNolf
abfb1868ab test: custom id number relation test 2022-07-18 10:08:01 -07:00
Elliot DeNolf
7319a8e90d test: rest client update now can return errors 2022-07-18 10:07:25 -07:00
Elliot DeNolf
d2be893a5a test: port relationships spec 2022-07-18 09:55:59 -07:00
Dan Ribbens
cc8b636248 test: relationship populates with locale 2022-07-18 12:19:35 -04:00
Elliot DeNolf
a103665bd9 chore: typo 2022-07-17 16:38:24 -07:00
Elliot DeNolf
0d1603b467 test: fix more stuff 2022-07-17 16:22:20 -07:00
Elliot DeNolf
d6a7b8c319 test: remove demo and rework node scripts 2022-07-17 16:18:48 -07:00
Elliot DeNolf
f5ad7a163a test: remove all old tests 2022-07-17 16:08:07 -07:00
James
d433351dbd chore: typo in changelog 2022-07-17 15:12:55 -07:00
James
3601ef90bc Merge branch 'feat/1.0' of github.com:payloadcms/payload into feat/1.0 2022-07-17 15:12:36 -07:00
James
76b6c736e1 fix: success banner color rendering incorrectly 2022-07-17 15:12:27 -07:00
Dan Ribbens
a194a64845 Merge branch 'feat/1.0' of github.com:payloadcms/payload into feat/1.0 2022-07-17 18:02:49 -04:00
Dan Ribbens
b00d8584f3 feat: test admin globals 2022-07-17 18:02:41 -04:00
James
39d075b999 fix: ensures passing partial data to update works when fields are localized 2022-07-17 15:00:38 -07:00
James
e57a5741e5 chore: reduces lorem ipsum amount in rich text 2022-07-17 13:34:06 -07:00
James
a6a9ab15b7 feat: merges select isClearable 2022-07-17 13:29:18 -07:00
James
4280a59c77 Merge branch 'master' of github.com:payloadcms/payload into feat/1.0 2022-07-17 13:23:04 -07:00
James
3259e34e27 chore: merges master 2022-07-17 13:23:00 -07:00
Arick
3132d35e27 feat: allow clear select value (#735) 2022-07-17 13:22:49 -07:00
James
7376246592 fix: ensures success pills are properly colored 2022-07-17 13:22:01 -07:00
James
69ce6d78da Merge branch 'feat/1.0' of github.com:payloadcms/payload into feat/1.0 2022-07-17 13:11:47 -07:00
James
b43e8c5db0 tests: ports versions tests to new infra 2022-07-17 13:11:38 -07:00
Dan Ribbens
e348bdcc21 Merge branch 'feat/1.0' of github.com:payloadcms/payload into feat/1.0 2022-07-17 15:58:47 -04:00
Dan Ribbens
039c3ec110 test: int test globals and endpoints 2022-07-17 15:58:32 -04:00
Elliot DeNolf
f98ef62ad3 test: port auth tests to int 2022-07-17 10:46:07 -07:00
Elliot DeNolf
17ebcc6925 chore: remove .prettierignore, unused 2022-07-17 10:45:46 -07:00
James
6347a2febf fix: ensures column selector renders active columns properly 2022-07-17 10:06:58 -07:00
James
2ef8a1e35a fix: ensures point field doesn't interrupt version creation 2022-07-17 10:03:22 -07:00
James
df11478905 Merge branch 'feat/1.0' of github.com:payloadcms/payload into feat/1.0 2022-07-17 09:51:55 -07:00
James
e7d2bdb45a fix: styles empty version diff row for dark mode 2022-07-17 09:51:42 -07:00
Dan Ribbens
1564fcaeb3 fix test collections rest endpoints 2022-07-17 12:44:39 -04:00
Dan Ribbens
cf38e8d520 feat: test collections rest endpoints 2022-07-17 12:41:47 -04:00
Dan Ribbens
bb9f28fb08 feat: remove files test helper 2022-07-17 12:39:45 -04:00
James
d8a28acfa8 feat: expands rich text field config for better coverage 2022-07-17 09:26:43 -07:00
Elliot DeNolf
b0eccdd12e chore: revert prettier
This reverts commit bc9de859c4.
2022-07-17 09:06:37 -07:00
James
1427fb4078 Merge branch 'feat/1.0' of github.com:payloadcms/payload into feat/1.0 2022-07-17 08:32:23 -07:00
James
1812be2e16 feat: adds uploads collection for testing to /fields tests 2022-07-17 08:32:15 -07:00
Elliot DeNolf
db87179576 chore: fix .prettierignore 2022-07-17 08:32:06 -07:00
Elliot DeNolf
0d8d41ce7e chore: format demo dir 2022-07-17 08:29:53 -07:00
Elliot DeNolf
a2f95f6cea test: add .gitkeep to uploads/media 2022-07-17 08:23:26 -07:00
Elliot DeNolf
fa9bd6191c chore: run prettier on entire test dir 2022-07-17 08:20:01 -07:00
Elliot DeNolf
bc9de859c4 chore: add prettier config, test dir only 2022-07-17 08:19:07 -07:00
James
73d04262ad chore: version bump 2022-07-16 18:12:18 -07:00
James
6e7d547da5 Merge branch 'feat/1.0' of github.com:payloadcms/payload into feat/1.0 2022-07-16 18:08:46 -07:00
James
6060e4cb27 fix: bug with version diff screen when arrays have no labels 2022-07-16 18:08:37 -07:00
Elliot DeNolf
b5ce54c7ae test: localization relationship tests 2022-07-16 18:01:13 -07:00
Dan Ribbens
492a1308cc Merge branch 'feat/1.0' of github.com:payloadcms/payload into feat/1.0 2022-07-16 21:00:35 -04:00
Dan Ribbens
147a4f8624 hooks tests 2022-07-16 21:00:18 -04:00
James
eac982398e feat: avoids forcing fonts to be inline within webpack builds 2022-07-16 17:59:24 -07:00
Dan Ribbens
9afd51b7dd Merge branch 'feat/1.0' into feat/test-hooks 2022-07-16 20:42:13 -04:00
Dan Ribbens
dd810a3593 fix: tabs top margin 2022-07-16 19:09:36 -04:00
James
75a4c52071 chore: reduces padding in eyebrow on mobile 2022-07-16 16:03:22 -07:00
James
2707af1d45 fix: ensures blocks can be nested within tabs / rows / collapsibles 2022-07-16 15:51:05 -07:00
James
b7d49db536 Merge branch 'feat/1.0' of github.com:payloadcms/payload into feat/1.0 2022-07-16 15:45:20 -07:00
James
3a98c6ad53 feat: ensures groups within blocks render properly 2022-07-16 15:45:15 -07:00
Elliot DeNolf
79f3de8042 test: add localization int tests 2022-07-16 15:01:31 -07:00
Elliot DeNolf
81024e4753 test: extra desc block 2022-07-16 15:00:44 -07:00
James
e2c333ac02 Merge branch 'feat/1.0' of github.com:payloadcms/payload into feat/1.0 2022-07-16 13:57:44 -07:00
James
1bdacb9bda chore: removes unused file 2022-07-16 13:57:32 -07:00
James
2fa680cdf8 feat: refactors z index methodology 2022-07-16 13:56:49 -07:00
James
3a17a8a001 feat: styles nested groups and adds gutter back to richText 2022-07-16 12:45:15 -07:00
Dan Ribbens
afbb014cbd Merge branch 'feat/1.0' of github.com:payloadcms/payload into feat/1.0 2022-07-16 14:40:46 -04:00
Dan Ribbens
c75c67ec86 feat: point field int test 2022-07-16 14:40:02 -04:00
James
e8b72f186f chore: restores deprecated features for ease of uploading 2022-07-16 11:27:28 -07:00
James
a777032894 chore: only imports get-port if dev 2022-07-16 11:11:14 -07:00
James
624e25c077 chore: adds pretest 2022-07-16 11:06:06 -07:00
James
34d0b89376 chore: increases jest timeout 2022-07-16 11:01:09 -07:00
James
fcd3b0d2cb chore: updates version 2022-07-16 10:59:25 -07:00
James
5512022a10 chore(release): v0.20.1 2022-07-16 10:58:46 -07:00
James
28e31fee72 chore: patch 0.20.0 2022-07-16 10:56:53 -07:00
James
779a60a42c chore: removes unused dependencies 2022-07-16 10:41:54 -07:00
Dan Ribbens
ba29898d97 Merge branch 'feat/1.0' of github.com:payloadcms/payload into feat/1.0 2022-07-16 13:40:12 -04:00
Dan Ribbens
a636c65e34 chore: do not track images in media 2022-07-16 13:38:33 -04:00
Dan Ribbens
ff3e137c78 chore: media test dir 2022-07-16 13:37:56 -04:00
James
8c4e0fa7b2 feat: updates styling of group field 2022-07-15 22:24:52 -07:00
James
3ae1c26a07 fix: ensures duplicated rows have properly created ids 2022-07-15 22:04:31 -07:00
James
7a6f2392fa feat: restores built-in fields into table column builder 2022-07-15 21:08:49 -07:00
James
07949525ef Merge branch 'feat/1.0' of github.com:payloadcms/payload into feat/1.0 2022-07-15 21:06:22 -07:00
James
3b9fdf3ffd feat: ensures nested fields not affecting data can be traversed properly 2022-07-15 21:06:12 -07:00
Dan Ribbens
2694c0d5bd * feat: point field e2e test (#760) 2022-07-15 23:36:07 -04:00
Elliot DeNolf
4f8b5b9f85 test(int): collections-graphl 2022-07-15 20:32:40 -07:00
Dan Ribbens
e75cca4512 feat: upload integration tests (#759) 2022-07-15 22:48:39 -04:00
James
68e7c41fdc feat: finishes tabs field 2022-07-15 18:40:31 -07:00
James
735e385537 feat: only renders arrays and blocks once they are initialized 2022-07-15 17:26:05 -07:00
James
c995f797fe feat: initializes useField internalValue with incoming field value 2022-07-15 17:20:32 -07:00
James
54162b52cc feat: ensures tabs and collapsibles render in version diff 2022-07-15 17:18:33 -07:00
James
66fc06895a Merge branch 'feat/1.0' of github.com:payloadcms/payload into feat/tabs 2022-07-15 16:24:59 -07:00
James
85b7a490eb feat: scaffolds tabs field 2022-07-15 16:24:54 -07:00
Elliot DeNolf
4b0a257246 test: fix all test scripts 2022-07-15 14:36:09 -07:00
Elliot DeNolf
29f1af7eb4 chore: remove console logs 2022-07-15 12:53:07 -07:00
Elliot DeNolf
ba79b4446c test: refactor all test directories into one 2022-07-15 12:51:43 -07:00
Dan Ribbens
40b6afff2d feat: remove duplication of config in tests 2022-07-15 14:11:16 -04:00
Dan Ribbens
a664b627f6 fix: upload e2e file path 2022-07-15 13:39:12 -04:00
Elliot DeNolf
3a4657e368 test: fix bad file ref and update locators 2022-07-15 10:02:09 -07:00
James
4cb565f1cc Merge branch 'feat/1.0' of github.com:payloadcms/payload into feat/1.0 2022-07-14 16:35:58 -07:00
James
31ca363982 feat: revises e2e field testing 2022-07-14 16:35:35 -07:00
Elliot DeNolf
4a3588e965 test: collections and new test ids and classes 2022-07-14 16:16:16 -07:00
Dan Ribbens
11600930b7 feat: e2e test upload (#755) 2022-07-14 18:43:19 -04:00
James
4bb0d3994f fix: bug with base colors 2022-07-14 15:27:17 -07:00
James
5fc4f3adad feat: more maintainable colors 2022-07-14 15:20:34 -07:00
James
41a0ba5780 feat: finishes block field 2022-07-14 14:46:42 -07:00
Elliot DeNolf
f7a81d70ac test(access-control): restricted and read-only (#754) 2022-07-14 14:33:54 -07:00
Elliot DeNolf
baf4664073 feat: add card ids 2022-07-14 14:09:59 -07:00
Dan Ribbens
48700a93e3 * fix: css selectors 2022-07-14 17:00:34 -04:00
James
49d09a349f feat: updates block field to use new collapsible 2022-07-14 14:00:14 -07:00
Dan Ribbens
31bc4c6532 * feat: optimize collection list relationship queries (#749)
* feat: optimize collection list relationship queries
2022-07-14 16:51:41 -04:00
James
aa89251a3b feat: retrofits array to new collapsible component 2022-07-13 20:09:50 -07:00
Elliot DeNolf
057846e250 test: collections-rest and dev type generation (#750) 2022-07-13 17:46:59 -07:00
Dan Ribbens
5a5e3b589c chore: set playwright timeout to 10m 2022-07-13 20:20:25 -04:00
James
270dd22f08 docs: updates fields overview to include collapsible 2022-07-13 15:41:41 -07:00
James
beec04a1bc docs: collapsible 2022-07-13 15:40:59 -07:00
James
60bfb1c3b8 feat: finishes collapsible field 2022-07-13 15:29:49 -07:00
James
98676bea69 feat: adds collapsible field type 2022-07-13 14:45:10 -07:00
James
8589fdefda feat: reorganizes mongo connection 2022-07-13 13:17:00 -07:00
James
8ba25e8602 chore: renames admin url util conventions 2022-07-13 12:47:53 -07:00
James
de43e21ebc chore: stubs out fields e2e 2022-07-13 12:40:29 -07:00
Elliot DeNolf
90ba15f9bd feat: testing refactor (e2e/int) (#748)
Co-authored-by: James <james@trbl.design>
Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
2022-07-13 11:00:10 -07:00
James Mikrut
b9f9f15d77 feat/adds dark mode and evolves admin ui
* feat: builds color palette for light and dark mode, removes all conflicting rgba sass

* chore: replaces colors with css vars

* chore: adapts blur-bg to be more performant and stable

* chore: getting ready for dark mode

* chore: removes unused file

* chore: reverts input bg

* chore: reverses selection in dark mode

* feat: builds theme toggler

* feat: adds auto mode for theme

* feat: establishes light / dark css pattern, updates account and list

* chore: migrates more views to gutter component

* chore: adapts global, adjusts popups

* chore: finishes retrofitting views

* feat: moves to medium instead of semi-bold for headlines

* feat: introduces new font for rte

* feat: updates rich text styles

* feat: styles react select in dark mode

* chore: styles datepicker, misc refinements

* chore: updates style of UploadCard

* chore: fixes code styles

* chore: styles PerPage

* chore: improves styling of column / where selector

* feat: improves field errors in dark mode

* chore: styles built-in rich text elements

* chore: improves styling of rte elements

* chore: tweaks
2022-07-13 10:36:25 -07:00
James
cac5266c79 chore: changelog 2022-07-11 11:53:12 -07:00
James
420afc6838 chore(release): v0.19.2 2022-07-11 11:50:25 -07:00
James
4e3c4e9c0c Merge branch 'master' of github.com:payloadcms/payload into feat/extensible-auth-strategies 2022-07-11 11:45:48 -07:00
James
2c27812ba1 chore: removes cookie-parser 2022-07-11 11:45:44 -07:00
James Mikrut
2f57a983cd Merge pull request #739 from payloadcms/feat/extensible-auth-strategies
Feat/extensible auth strategies
2022-07-11 11:44:32 -07:00
James
91c4ef226b fix: ensures router switch only contains top-level route components 2022-07-11 08:31:43 -07:00
James
38b52bf67b feat: better types useAuth and custom provider components 2022-07-09 22:23:37 -07:00
James
281985970d Merge branch 'feat/extensible-auth-strategies' of github.com:payloadcms/payload into feat/extensible-auth-strategies 2022-07-09 17:39:19 -07:00
James
03f28a4804 feat: ensures auth component doesn't render if disabled 2022-07-09 17:16:19 -07:00
Dan Ribbens
c0acba94c6 Merge branch 'feat/extensible-auth-strategies' of github.com:payloadcms/payload into feat/extensible-auth-strategies 2022-07-09 19:58:19 -04:00
Dan Ribbens
8d550d411e docs: update collection hooks 2022-07-09 19:57:58 -04:00
Elliot DeNolf
e8064371b0 feat: add preMiddleware and postMiddleware, deprecate middleware 2022-07-09 16:47:23 -07:00
Dan Ribbens
166bd31506 feat: add res to token hooks 2022-07-09 19:38:24 -04:00
Dan Ribbens
4055908bc8 feat: add afterMe afterLogout and afterRefresh 2022-07-09 19:29:00 -04:00
James
d68bb8c292 fix: removes reliance on auth email 2022-07-09 14:40:31 -07:00
James
c8be171f24 chore: further disabling of local auth strategy 2022-07-09 12:04:21 -07:00
Dan Ribbens
43eafd4b9f chore(release): v0.19.1 2022-07-09 12:04:17 -04:00
Dan Ribbens
ce1c99b01c fix: ensures duplicative relationship options are not present (#732)
Co-authored-by: James <james@trbl.design>
2022-07-09 11:58:03 -04:00
James
4b2bc36f89 chore: reduces unnecessary strategy complexity 2022-07-09 08:40:13 -07:00
James
58587525e5 feat: adds cookie-parser 2022-07-08 18:36:12 -07:00
James
df76f60e7f fix: ensures anonymous passport strategy is loaded last 2022-07-08 17:56:39 -07:00
James
2c66ad8689 feat: ensures only plain objects are merged within incoming configs 2022-07-08 17:37:43 -07:00
James
6016e2346c feat: extends strategies with more properties 2022-07-08 15:16:30 -07:00
James
56cdd943fd feat: only adds email if local strategy enabled 2022-07-08 14:50:04 -07:00
James
6d02f7d3ac feat: begins extensible auth strategies 2022-07-08 13:46:12 -07:00
Dan Ribbens
18f8790062 chore: breaking changes 0.19.0 2022-07-08 14:08:04 -04:00
Dan Ribbens
854b63ec34 chore(release): v0.19.0 2022-07-08 14:07:28 -04:00
Dan Ribbens
beccbbd3e8 chore: package script quotes windows compatibility 2022-07-08 14:00:23 -04:00
Dan Ribbens
91d0d84c65 docs: update graphql schema 2022-07-08 13:53:40 -04:00
chris-schra
7dd67a8d39 chore: ignore Yarn Berry files in .gitignore (#713) 2022-07-08 13:51:42 -04:00
Dan Ribbens
ad43cbc808 feat: graphql schema output (#730)
* chore: refactor graphql initialization

* feat: generate graphql schema script

* feat: script commands are case insenstive
2022-07-08 13:50:46 -04:00
James Mikrut
2b2a562d83 Merge pull request #731 from payloadcms/fix/auth-me-gql-relationships
Fix/auth me gql relationships
2022-07-08 10:48:09 -07:00
James
d9e7696384 chore: strips trailing slashes from jwt strategy 2022-07-08 10:41:10 -07:00
James
01bc1fef1e fix: ensures auth/me relations in gql can be queried 2022-07-08 10:25:00 -07:00
Dan Ribbens
567d8c19bf fix: allow passing of autoIndex mongoose connectionOptions (#722) 2022-07-06 15:57:02 -04:00
James Mikrut
b722bed24f Merge pull request #720 from payloadcms/fix/#692
fix: ensures old data from arrays is not persisted
2022-07-06 14:36:00 -04:00
James
0af66d68a7 chore: tests array functionality 2022-07-06 11:34:22 -07:00
Henri Tuan
f3b7dcff57 feat: File argument in create/update operation (#708)
Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
2022-07-06 11:26:04 -07:00
chris-schra
67331eb975 fix: copyfiles cross platform (#712) 2022-07-06 13:57:18 -04:00
James
d9ef803d20 fix: ensures old data from arrays is not persisted 2022-07-06 10:52:52 -07:00
Andrzej Kłapeć
9fd171b26d feat: allow clearing DatePicker value (#641)
Co-authored-by: Elliot DeNolf <denolfe@gmail.com>
2022-07-06 09:38:45 -07:00
Dan Ribbens
91e33d1c1c fix: relationship field disabled from access control in related collections (#644)
* fix: disabled relationship field from access control in related collections

* fix: ids can be read from relationships regardless of access of related document
2022-07-03 07:01:45 -04:00
Akansh Sirohi
601e69ab0d Fixes payloadcms/payload#650 (#706)
* fix: min/max number validation of decimal values
2022-07-03 06:25:03 -04:00
Andres Kalle
81aa74bbbe docs: fixed example URL (#705) 2022-07-02 07:42:12 -04:00
Dan Ribbens
e84b7a9c58 chore(release): v0.18.5 2022-06-29 14:14:47 -04:00
Dan Ribbens
b6b0ffb674 fix: empty cell data renders in list (#699) 2022-06-29 14:07:21 -04:00
Dan Ribbens
62bd2db5f9 chore: update json-schema-to-typescript to v11 (#700) 2022-06-29 14:03:30 -04:00
Steven Roh
74342a4dea Avoid app crashing when code (data) is undefined (#681)
* fix: code field ui errors when data is undefined
2022-06-29 12:12:33 -04:00
Min Somai
c78d77446a fix: icon appears above select field's option list (#685)
* fix: icon of the date field appears above the option list
2022-06-29 12:09:53 -04:00
Dan Ribbens
6eb4fc04b1 Fix/validate imagesizes with mimetypes (#688)
* fix: mimetype validation with image sizes

* fix: unique filename error on image sizes
2022-06-29 12:05:57 -04:00
Dan Ribbens
f1b00e85fc docs: update links 2022-06-29 11:19:34 -04:00
gonza moiguer
7c73f2c1d9 Corrected Radio field doc, 'option' for 'label' (#690) 2022-06-27 13:03:41 -04:00
James
704e543c7e chore(release): v0.18.4 2022-06-24 17:53:35 -04:00
Lachlan Heywood
fcaa1454dc Update load.ts (#679) 2022-06-24 17:52:06 -04:00
James
9d388f7a89 chore(release): v0.18.3 2022-06-24 17:51:01 -04:00
James
918062de2f fix: #670, max tokenExpiration 2022-06-24 17:49:36 -04:00
James
375738d99c chore(release): v0.18.2 2022-06-24 17:34:07 -04:00
Dan Ribbens
1c37ec3902 feat: telemetry
* feat: add telemetry to payload config

wip: more telemetry

* feat: send telemetry events

* chore: update node ci versions

* chore: cleanup console log

* chore: updates ts due to dependency update

* chore: remove unused deps

* chore: fix origin and casing

* docs: telemetry

* feat: uses oneWayHash within telemetry

* chore: sends hashed domain in telemetry

* feat: improves reliability of telemetry projectID

* chore: revises telemetry docs

Co-authored-by: Elliot DeNolf <denolfe@gmail.com>
Co-authored-by: James <james@trbl.design>
2022-06-24 17:32:09 -04:00
Kent Warren
7eb804daf9 docs: typo (#683)
Changes "you" to "your"
2022-06-24 16:52:57 -04:00
James
d99a67ca95 chore(release): v0.18.1 2022-06-21 15:45:20 -04:00
James
3d5ed93fce fix: #671, password reset broken 2022-06-21 15:43:12 -04:00
Ahmet Kilinc
b80006be45 Change "ist" to "it" (#668)
docs: Small typo on middleware page
2022-06-20 10:45:34 -04:00
Dan Ribbens
70edb0ba38 chore(release): v0.18.0 2022-06-14 08:53:17 -04:00
Dan Ribbens
a1fe17d05d fix: me auth route breaks with query params (#648) 2022-06-13 11:49:04 -04:00
James Mikrut
7083225abd Feat/remove this bindings (#629)
* feat: removes this bindings for cleaner, more maintainable code

Co-authored-by: Elliot DeNolf <denolfe@users.noreply.github.com>
Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
2022-06-08 14:44:34 -04:00
Jarrod Flesch
af6479bf34 feat: adds timestamps to generated collection types if enabled (#604)
* feat: adds timestamps to generated collection types if enabled
2022-06-08 11:41:09 -04:00
Dan Ribbens
44c12325b4 feat: enable webpack filesystem cache in dev (#621) 2022-06-08 11:38:07 -04:00
Dan Ribbens
f2bf2399fa fix: custom fields values resetting in ui (#626) 2022-06-08 11:37:31 -04:00
Dan Ribbens
7fe2fece6c chore: remove node-sass (#605) 2022-06-08 11:36:33 -04:00
James
bf0fe090ab chore(release): v0.17.3 2022-06-08 10:33:12 -04:00
Dan Ribbens
397dba4a30 Fix/delete document workflow (#622)
* fix: admin ui display server errors when deleting documents

* fix: admin ui display delete document state gets stuck after 403
2022-06-08 10:24:34 -04:00
Dan Ribbens
593d6a596a docs: remove withCondition for custom component fields (#588) 2022-06-08 10:24:21 -04:00
Dan Ribbens
82a6db8b4f docs: add examples to collection hooks (#620) 2022-06-08 10:23:55 -04:00
Dan Ribbens
28aa3dd17b chore: update license in package.json (#631) 2022-06-08 10:23:15 -04:00
James Mikrut
3d4d807370 Fix/propagate locale relationship (#637)
* fix: propagate locale through relationship

* fix: ensures locales are populated properly through local operations

* chore: adds test for locale propagation

Co-authored-by: Elliot DeNolf <denolfe@gmail.com>
2022-06-08 10:23:01 -04:00
James
c18cc23c71 fix: ensures unflattening locales only happens if config specifies locales 2022-06-08 10:07:17 -04:00
GeorgeyB
7ee374ea1a Custom collection/global endpoints (#607)
* feat: add custom endpoints for collections and globals REST APIs

Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
2022-05-30 12:43:18 -04:00
Dan Ribbens
20bbda95c6 fix: duplicate objects in array fields in validate data and siblingData (#599) 2022-05-25 13:44:28 -04:00
864 changed files with 31444 additions and 21378 deletions

View File

@@ -21,6 +21,28 @@ module.exports = {
},
},
overrides: [
{
files: ['test/**/int.spec.ts'],
rules: {
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/consistent-type-imports': 'warn',
'jest/prefer-strict-equal': 'off',
}
},
{
files: ['test/**/e2e.spec.ts'],
extends: [
'plugin:playwright/playwright-test'
],
rules: {
'jest/consistent-test-it': 'off',
'jest/require-top-level-describe': 'off',
'jest/no-test-callback': 'off',
'jest/prefer-strict-equal': 'off',
'jest/expect-expect': 'off',
'jest-dom/prefer-to-have-attribute': 'off',
}
},
{
files: ['*.ts', '*.tsx'],
parser: '@typescript-eslint/parser',
@@ -66,7 +88,7 @@ module.exports = {
'no-underscore-dangle': 'off',
'no-use-before-define': 'off',
'arrow-body-style': 0,
'@typescript-eslint/no-use-before-define': ['error'],
'@typescript-eslint/no-use-before-define': 'off',
'import/extensions': [
'error',
'ignorePackages',

View File

@@ -1,27 +1,28 @@
---
name: Bug Report
about: Create a bug report for Payload
labels: 'bug'
labels: 'possible-bug'
---
# Bug Report
<!--- Provide a general summary of the issue in the Title above -->
## Expected Behavior
<!--- Tell us what should happen -->
## Current Behavior
<!--- Tell us what happens instead of the expected behavior -->
## Expected Behavior
<!--- Tell us what you expected happen -->
## Possible Solution
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
<!--- Optional. If familiar with the codebase, suggest a fix/reason for the bug. -->
## Steps to Reproduce
<!--- Steps to reproduce this bug. Include any code, if relevant -->
1.
2.
3.

View File

@@ -1,13 +1,17 @@
name: build
on: [push]
on:
pull_request:
types: [opened, reopened, edited, synchronize]
push:
branches: ['master']
jobs:
build_yarn:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
node-version: [14.x, 16.x, 18.x]
steps:
- uses: actions/checkout@v2
@@ -31,11 +35,26 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: yarn build
- run: yarn test:client
- run: yarn test:int # In-memory db + api tests
- run: yarn demo:generate:types
env:
CI: true
- name: Component Tests
run: yarn test:components
- name: Integration Tests
run: yarn test:int
- name: Generate Payload Types
run: yarn dev:generate-types fields
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: E2E Tests
run: yarn test:e2e --bail
# - uses: actions/upload-artifact@v2
# if: always()
# with:
# name: playwright-report
# path: playwright-report/
# retention-days: 30
install_npm:
runs-on: ubuntu-latest
strategy:

12
.gitignore vendored
View File

@@ -2,8 +2,6 @@ coverage
package-lock.json
dist
.idea
cypress/videos
cypress/screenshots
# Created by https://www.gitignore.io/api/node,macos,windows,webstorm,sublimetext,visualstudiocode
@@ -88,6 +86,15 @@ typings/
# Yarn Integrity file
.yarn-integrity
# Yarn Berry
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
.pnp.*
# dotenv environment variables file
.env
@@ -233,3 +240,4 @@ components/styles.css
# Ignore generated
demo/generated-types.ts
demo/generated-schema.graphql

1
.node-version Normal file
View File

@@ -0,0 +1 @@
v16.14.2

44
.vscode/launch.json vendored
View File

@@ -29,55 +29,17 @@
"request": "launch",
"name": "Launch Program",
"env": {
"PAYLOAD_CONFIG_PATH": "demo/payload.config.ts",
"BABEL_ENV": "development"
},
"program": "${workspaceFolder}/demo/index.js",
"program": "${workspaceFolder}/test/dev.js",
"skipFiles": [
"<node_internals>/**"
],
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/babel-node",
"runtimeArgs": [
"--nolazy"
],
},
{
"type": "node",
"request": "launch",
"name": "Launch Program - Production",
"env": {
"PAYLOAD_CONFIG_PATH": "demo/payload.config.ts",
"NODE_ENV": "production",
"BABEL_ENV": "development"
},
"program": "${workspaceFolder}/demo/index.js",
"skipFiles": [
"<node_internals>/**"
],
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/babel-node",
"outputCapture": "std",
"runtimeArgs": [
"--nolazy"
],
},
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against Localhost",
"url": "http://localhost:3000/admin",
"webRoot": "${workspaceFolder}"
},
{
"type": "node",
"request": "launch",
"name": "Debug Payload Generate Types",
"program": "${workspaceFolder}/src/bin/generateTypes.ts",
"env": {
"PAYLOAD_CONFIG_PATH": "demo/payload.config.ts",
},
"outFiles": [
"${workspaceFolder}/dist/**/*.js",
"!**/node_modules/**"
"args": [
"fields"
]
},
]

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,9 @@
<h1 align="center">Payload</h1>
<p align="center">A free and open-source TypeScript headless CMS & application framework built with Express, MongoDB and React.</p>
<p align="center">
<a href="https://opensource.org/licenses/MIT">
<img src="https://img.shields.io/badge/License-MIT-blue.svg" />
</a>
<a href="https://github.com/payloadcms/payload/actions">
<img src="https://github.com/payloadcms/payload/workflows/build/badge.svg" />
</a>
@@ -45,10 +48,10 @@
Payload is a CMS that has been designed for developers from the ground up to deliver them what they need to build great digital products. If you know JavaScript, you know Payload. It's a _code-first_ CMS, which allows us to do a lot of things right:
- Payload gives you everything you need, but then steps back and lets you build what you want in JavaScript or TypeScript - with no unnecessary complexity brought by GUIs. You'll understand how your CMS works, because you will have written it exactly how you want it.
- Payload gives you everything you need, but then steps back and lets you build what you want in JavaScript or TypeScript - with no unnecessary complexity brought by GUIs. You'll understand how your CMS works because you will have written it exactly how you want it.
- Bring your own Express server and do whatever you need on top of Payload. Payload doesn't impose anything on you or your app.
- Completely control the Admin panel by using your own React components. Swap out fields or even entire views with ease.
- Use your data however and wherever you need thanks to auto-generated, yet fully extensible REST, GraphQL and Local Node APIs.
- Use your data however and wherever you need thanks to auto-generated, yet fully extensible REST, GraphQL, and Local Node APIs.
### Quick Start
@@ -65,6 +68,9 @@ Alternatively, it only takes about five minutes to [create an app from scratch](
### Documentation
Check out the [Payload website](https://payloadcms.com/docs/getting-started/what-is-payload) to find in-depth documentation for everything that Payload offers.
### Contributing
If you want to add contributions to this repository, please follow the instructions in [contributing.md](./contributing.md).
### Other Resources

View File

@@ -2,3 +2,4 @@ export { default as Button } from '../dist/admin/components/elements/Button';
export { default as Card } from '../dist/admin/components/elements/Card';
export { default as Eyebrow } from '../dist/admin/components/elements/Eyebrow';
export { default as Nav } from '../dist/admin/components/elements/Nav';
export { Gutter } from '../dist/admin/components/elements/Gutter';

View File

@@ -1,12 +1,21 @@
export {
useForm,
/**
* @deprecated useWatchForm is no longer preferred. If you need all form fields, prefer `useAllFormFields`.
*/
useWatchForm,
useFormFields,
useAllFormFields,
useFormSubmitted,
useFormProcessing,
useFormModified,
} from '../dist/admin/components/forms/Form/context';
export { default as useField } from '../dist/admin/components/forms/useField';
/**
* @deprecated This method is now called useField. The useFieldType alias will be removed in an upcoming version.
*/
export { default as useFieldType } from '../dist/admin/components/forms/useField';
export { default as Form } from '../dist/admin/components/forms/Form';
@@ -24,5 +33,6 @@ export { default as Submit } from '../dist/admin/components/forms/Submit';
export { default as Label } from '../dist/admin/components/forms/Label';
export { default as reduceFieldsToValues } from '../dist/admin/components/forms/Form/reduceFieldsToValues';
export { default as getSiblingData } from '../dist/admin/components/forms/Form/getSiblingData';
export { default as withCondition } from '../dist/admin/components/forms/withCondition';

View File

@@ -20,9 +20,39 @@ Payload documentation can be found directly within its codebase and you can feel
If you're an incredibly awesome person and want to help us make Payload even better through new features or additions, we would be thrilled to work with you.
To help us work on new features, you can reach out to our Development team at [`dev@payloadcms.com`](mailto:dev@payloadcms.com). Be as complete and descriptive as possible regarding your vision and we'll go from there!
### Before Starting
To help us work on new features, you can create a new feature request post in [GitHub Discussion](https://github.com/payloadcms/payload/discussions) or discuss it in our [Discord](https://discord.com/invite/r6sCXqVk3v). New functionality often has large implications across the entire Payload repo, so it is best to discuss the architecture and approach before starting work on a pull request.
### Code
Most new functionality should keep testing in mind. With 1.0, testability of new features has been vastly improved. All top-level directories within the `test/` directory are for testing a specific category: `fields`, `collections`, etc.
If it makes sense to add your feature to an existing test directory, please do so.
A typical directory with `test/` will be structured like this:
```text
.
├── config.ts
├── int.spec.ts
├── e2e.spec.ts
└── payload-types.ts
```
- `config.ts` - This is the _granular_ Payload config for testing. It should be as lightweight as possible. Reference existing configs for an example
- `int.spec.ts` - This is the test file run by jest. Any test file must have a `*int.spec.ts` suffix.
- `e2e.spec.ts` - This is the end-to-end test file that will load up the admin UI using the above config and run Playwright tests. These tests are typically only needed if a large change is being made to the Admin UI.
- `payload-types.ts` - Generated types from `config.ts`. Generate this file by running `yarn dev:generate-types my-test-dir`.
The directory split up in this way specifically to reduce friction when creating tests and to add the ability to boot up Payload with that specific config.
The following command will start Payload with your config: `yarn dev my-test-dir`. This command will start up Payload using your config and refresh a test database on every restart.
When switching between test directories, you will want to remove your `node_modules/.cache ` manually or by running `yarn clean:cache`.
NOTE: It is recommended to add the test credentials (located in `test/credentials.ts`) to your autofill for `localhost:3000/admin` as this will be required on every nodemon restart.
## Pull Requests
For all Pull Requests, you should be extremely descriptive about both your problem and proposed solution. If there are any affected open or closed issues, please leave the issue number in your PR message.

View File

@@ -1,8 +0,0 @@
{
"$schema": "https://on.cypress.io/cypress.schema.json",
"testFiles": "**/*e2e.ts",
"ignoreTestFiles": "**/examples/*spec.js",
"viewportWidth": 1440,
"viewportHeight": 900,
"baseUrl": "http://localhost:3000"
}

16
cypress/cypress.d.ts vendored
View File

@@ -1,16 +0,0 @@
export { };
declare global {
namespace Cypress {
interface Chainable<Subject> {
visitAdmin(): Chainable<any>
/**
* Login
*
* Creates user if not exists
*/
login(): Chainable<any>
apiLogin(): Chainable<any>
}
}
}

View File

@@ -1,5 +0,0 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}

View File

@@ -1,43 +0,0 @@
import { adminURL } from './common/constants';
import { credentials } from './common/credentials';
describe('Collections', () => {
const collectionName = 'Admins';
before(() => {
cy.apiLogin();
});
beforeEach(() => {
cy.visitAdmin();
});
it('can view collection', () => {
cy.contains(collectionName).click();
cy.get('.collection-list__wrap')
.should('be.visible');
cy.get('.collection-list__header')
.contains(collectionName)
.should('be.visible');
cy.get('.table')
.contains(credentials.email)
.should('be.visible');
});
it('can create new', () => {
cy.contains(collectionName).click();
cy.contains('Create New').click();
cy.url().should('contain', `${adminURL}/collections/${collectionName.toLowerCase()}/create`);
});
it('can create new - plus button', () => {
cy.contains(collectionName)
.get('.card__actions')
.first()
.click();
cy.url().should('contain', `${adminURL}/collections/${collectionName.toLowerCase()}/create`);
});
});

View File

@@ -1 +0,0 @@
export const adminURL = 'http://localhost:3000/admin';

View File

@@ -1,5 +0,0 @@
export const credentials = {
email: 'test@test.com',
password: 'test123',
roles: ['admin'],
};

View File

@@ -1,76 +0,0 @@
describe('Fields', () => {
before(() => {
cy.apiLogin();
});
describe('Array', () => {
beforeEach(() => {
cy.visit('/admin/collections/all-fields/create');
});
it('can add and remove rows', () => {
cy.contains('Add Array').click();
cy.contains('Array Text 1')
.should('be.visible');
cy.get('.action-panel__add-row').first().click();
cy.get('.field-type.array')
.filter(':contains("Editable Array")')
.should('contain', '02');
cy.get('.action-panel__remove-row').first().click();
cy.get('.field-type.array')
.filter(':contains("Editable Array")')
.should('not.contain', '02')
.should('contain', '01');
});
it('can be readOnly', () => {
cy.get('.field-type.array')
.filter(':contains("readOnly Array")')
.should('not.contain', 'Add Row');
cy.get('.field-type.array')
.filter(':contains("readOnly Array")')
.children('.action-panel__add-row')
.should('not.exist');
cy.get('.field-type.array')
.filter(':contains("readOnly Array")')
.children('.position-panel__move-backward')
.should('not.exist');
cy.get('.field-type.array')
.filter(':contains("readOnly Array")')
.children('.position-panel__move-forward')
.should('not.exist');
});
});
describe('Admin', () => {
describe('Conditions', () => {
beforeEach(() => {
cy.visit('/admin/collections/conditions/create');
});
it('can see conditional fields', () => {
cy.get('#simpleCondition')
.should('not.exist');
cy.get('#customComponent')
.should('not.exist');
cy.contains('Enable Test').click();
cy.get('#simpleCondition')
.should('be.visible');
cy.get('#customComponent')
.should('be.visible');
});
});
});
});

View File

@@ -1,99 +0,0 @@
/* eslint-disable jest/expect-expect */
import { adminURL } from './common/constants';
import { credentials } from './common/credentials';
// running login more than one time is not working
const viewportSizes: Cypress.ViewportPreset[] = [
'macbook-15',
// 'iphone-x',
// 'ipad-2',
];
// intermittent failure
describe.skip('Payload Login', () => {
beforeEach(() => {
cy.clearCookies();
});
after(() => {
cy.apiLogin();
});
viewportSizes.forEach((viewportSize) => {
describe(`Login (${viewportSize})`, () => {
beforeEach(() => {
cy.visit(adminURL);
});
it('success', () => {
cy.viewport(viewportSize);
cy.url().should('include', '/admin/login');
cy.get('.field-type.email input').type(credentials.email);
cy.get('.field-type.password input').type(credentials.password);
cy.get('form')
.contains('form', 'Login')
.should('be.visible')
.submit();
cy.get('.template-default')
.find('h3.dashboard__label')
.should('have.length', 2); // TODO: Should assert label content
cy.url().should('eq', adminURL);
});
// skip due to issue with cookies not being reset between tests
it.skip('bad Password', () => {
cy.viewport(viewportSize);
cy.visit(adminURL);
cy.get('#email').type(credentials.email);
cy.get('#password').type('badpassword');
cy.get('form')
.contains('form', 'Login')
.should('be.visible')
.submit();
cy.get('.Toastify')
.contains('The email or password provided is incorrect.')
.should('be.visible');
});
// skip due to issue with cookies not being reset between tests
it.skip('bad Password - Retry Success', () => {
cy.viewport(viewportSize);
cy.visit(adminURL);
cy.get('#email').type(credentials.email);
cy.get('#password').type('badpassword');
cy.get('form')
.contains('form', 'Login')
.should('be.visible')
.submit();
cy.get('.Toastify')
.contains('The email or password provided is incorrect.')
.should('be.visible');
// Dismiss notification
cy.wait(500);
cy.get('.Toastify__toast-body').click();
cy.wait(200);
cy.get('.Toastify__toast-body').should('not.be.visible');
cy.url().should('eq', `${adminURL}/login`);
cy.get('#password').clear().type(credentials.password);
cy.get('form')
.contains('form', 'Login')
.should('be.visible')
.submit();
cy.get('.template-default')
.find('h3.dashboard__label')
.should('have.length', 2); // TODO: Should assert label content
cy.url().should('eq', adminURL);
});
});
});
});

View File

@@ -1,17 +0,0 @@
require('isomorphic-fetch');
const { credentials } = require('../integration/common/credentials');
/**
* @type {Cypress.PluginConfig}
*/
module.exports = (on) => {
on('before:run', () => {
return fetch('http://localhost:3000/api/admins/first-register', {
body: JSON.stringify(credentials),
headers: {
'Content-Type': 'application/json',
},
method: 'post',
});
});
};

View File

@@ -1,54 +0,0 @@
import { adminURL } from '../integration/common/constants';
import { credentials } from '../integration/common/credentials';
Cypress.Commands.add('visitAdmin', () => {
cy.visit(adminURL);
});
Cypress.Commands.add('login', () => {
cy.clearCookies();
cy.visit(adminURL);
cy.get('#email').type(credentials.email);
cy.get('#password').type(credentials.password);
cy.get('body')
.then((body) => {
if (body.find('.dashboard__card-list').length) {
cy.get('.dashboard__card-list')
.should('be.visible');
}
if (body.find('#confirm-password').length) {
cy.get('#confirm-password').type(credentials.password);
cy.get('.rs__indicators').first()
.click();
cy.get('.rs__menu').first().contains('admin')
.click();
cy.get('form')
.contains('form', 'Create')
.should('be.visible')
.submit();
}
if (body.find('form').length) {
cy.get('form')
.contains('form', 'Login')
.should('be.visible')
.submit();
}
cy.get('.dashboard__card-list')
.should('be.visible');
});
});
Cypress.Commands.add('apiLogin', () => {
cy.api({
url: '/api/admins/login',
method: 'POST',
body: credentials,
failOnStatusCode: true,
}).should(({ status }) => {
cy.wrap(status).should('equal', 200);
});
});

View File

@@ -1,25 +0,0 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
import '@bahmutov/cy-api';
// Import commands.js using ES2015 syntax:
import './commands';
// Alternatively you can use CommonJS syntax:
// require('./commands')
Cypress.Cookies.defaults({
preserve: 'payload-token',
});

View File

@@ -1,15 +0,0 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"es5",
"dom"
],
"types": [
"cypress"
]
},
"include": [
"**/*.ts"
]
}

View File

@@ -1,17 +0,0 @@
/**
* authorize a request by comparing the current user with one or more roles
* @param allRoles
* @param user
* @returns {Function}
*/
const checkRole = (allRoles, user) => {
if (user) {
if (allRoles.some((role) => user.roles && user.roles.some((individualRole) => individualRole === role))) {
return true;
}
}
return false;
};
export default checkRole;

View File

@@ -1,7 +0,0 @@
export default [
'admin',
'editor',
'moderator',
'user',
'viewer',
];

View File

@@ -1,26 +0,0 @@
import { Block } from '../../src/fields/config/types';
const CTA: Block = {
slug: 'cta',
labels: {
singular: 'Call to Action',
plural: 'Calls to Action',
},
fields: [
{
name: 'label',
label: 'Label',
type: 'text',
maxLength: 100,
required: true,
},
{
name: 'url',
label: 'URL',
type: 'text',
required: true,
},
],
};
export default CTA;

View File

@@ -1,19 +0,0 @@
import { Block } from '../../src/fields/config/types';
const Email: Block = {
slug: 'email',
labels: {
singular: 'Email',
plural: 'Emails',
},
fields: [
{
name: 'testEmail',
label: 'Test Email Field',
type: 'email',
required: true,
},
],
};
export default Email;

View File

@@ -1,20 +0,0 @@
import { Block } from '../../src/fields/config/types';
const NumberBlock: Block = {
slug: 'number',
labels: {
singular: 'Number',
plural: 'Numbers',
},
fields: [
{
name: 'testNumber',
label: 'Test Number Field',
type: 'number',
max: 100,
required: true,
},
],
};
export default NumberBlock;

View File

@@ -1,27 +0,0 @@
import { Block } from '../../src/fields/config/types';
const Quote: Block = {
imageURL: '/static/assets/images/generic-block-image.svg',
slug: 'quote',
labels: {
singular: 'Quote',
plural: 'Quotes',
},
fields: [
{
name: 'quote',
label: 'Quote',
type: 'textarea',
required: true,
},
{
name: 'color',
label: 'Color',
type: 'text',
maxLength: 7,
required: true,
},
],
};
export default Quote;

View File

@@ -1,16 +0,0 @@
// As this is the demo folder, we import Payload SCSS functions relatively.
@import '../../../../scss';
// In your own projects, you'd import as follows:
// @import '~payload/scss';
.after-dashboard {
margin-top: base(2);
&__cards {
list-style: none;
margin: 0;
padding: 0;
}
}

View File

@@ -1,41 +0,0 @@
import React from 'react';
import { useHistory } from 'react-router-dom';
import { useConfig } from '../../../../src/admin/components/utilities/Config';
// As this is the demo project, we import our dependencies from the `src` directory.
import Card from '../../../../src/admin/components/elements/Card';
// In your projects, you can import as follows:
// import { Card } from 'payload/components/elements';
import './index.scss';
const baseClass = 'after-dashboard';
const AfterDashboard: React.FC = () => {
const history = useHistory();
const { routes: { admin: adminRoute } } = useConfig();
return (
<div className={baseClass}>
<h3>Custom Routes &amp; Dashboard Components</h3>
<p>This is a custom component that is rendered within the built-in dashboard component after its contents are rendered. Below, there are two cards that link to custom routes.</p>
<ul className="dashboard__card-list">
<li>
<Card
title="Default Template"
onClick={() => history.push(`${adminRoute}/custom-default-route`)}
/>
</li>
<li>
<Card
title="Minimal Template"
onClick={() => history.push(`${adminRoute}/custom-minimal-route`)}
/>
</li>
</ul>
</div>
);
};
export default AfterDashboard;

View File

@@ -1,14 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<div id="app"></div>
<div id="portal"></div>
</body>
</html>

View File

@@ -1,9 +0,0 @@
<svg width="82" height="53" viewBox="0 0 82 53" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<rect x="0.713013" width="80.574" height="52.7791" fill="url(#pattern0)"/>
<defs>
<pattern id="pattern0" patternContentUnits="objectBoundingBox" width="1" height="1">
<use xlink:href="#image0" transform="scale(0.00387597 0.00591716)"/>
</pattern>
<image id="image0" width="258" height="169" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQIAAACpCAYAAADA4zPJAAALpklEQVR4Ae2dSY/UOhSF+///DCSGHQuEgAVI7BBITAI2zCCGZuhmpqEBP53W8yOvK1UdO3Zyr/NFilJdXalyTo4/X984zlZgQQEUWLwCW4tXAAFQAAUCIMAEKIACgAAPoAAKBECACVAABQABHkABFAiAABOgAAoAAjyAAiggBbhqgA9QAAUAAR5AARQgIsADKIACdA3wAAqggBQgR4APUAAFAAEeQAEUICLAAyiAAnQN8AAKoIAUIEeAD1AABQABHkABFCAiwAMogAJ0DfAACqCAFCBHgA9QAAUAAR5AARQgIsADKIACdA3wAAqggBQgR4APUAAFAAEeQAEUICLAAyiAAnQN8AAKoIAUIEeAD1AABQABHkABFCAiwAMogAJ0DfAACqCAFCBHgA9QAAUAAR5AARQgIsADKIACdA3wAAqggBQgR4APUAAFAAEeQAEUICLAAyiAAnQN8AAKoIAUIEeAD1AABQABHkABFCAiwAMLVmB/fz98+/YtfPr0KXz48CHs7u6GnZ2dg+3Hjx/D169fw48fP8KfP3+aV4muQfOnmAPsKqDKr4r/9u3bsL29PXgVKPb29pqFAiDouoTXzSrw8+fPg5Y+pfL3ffbdu3fh+/fvzekECJo7pRxQVwGF9YoA+ir1mPfUhVB00coCCFo5kxzHigKqqGrBx1T4Tfu+efOmmegAEKzYhzdaUEBdAVXUTRW51P+UVPS+AALvZ5DyryigSGAqCESYeIcBIFixEW94VuDXr1/JVwRiZR671VUFrwsg8HrmKPeKAkoMKok3tkLn7q8oRCDyuAACj2eNMvcqoMFBuZW41H4alORxAQQezxplXlHg9+/fk+cF1sHDYxcBEKxYijc8KvDly5fZo4EIhvfv37uTEBC4O2UU+LACyg2kDhmOlbbWVpcvPS2AwNPZoqy9CigUr1Whc79Xoxk9LYDA09mirL0K1BhCnAuAuJ8iFE8LIPB0tihrrwI1hxHHip2z9XQpERD0Wos3vSig/EBOJZ1iH09XDwCBF8dTzl4FNJx4ikqd8xu6kuFlAQRezhTl7FVAMwjlVNIp9vn8+XNvmS2+aR4E6md56mtZPMktl8niFYMIGU9XDkyDQCdZ47e1eupvtVzxrB0bEUGZM2ISBEoAafLISNa4FWH1PxYUiApo4E70h7UtOYJ4ljK2OrGbLgfpfy1NEZUhEbt0FNA9BtYAEMvjaW5DMxGBWnpN7hBFPGrrfSKIjpd5OVIBa8OLo3c9DTM2AQJRXbdvRgGHbrWP9mVZtgKaanyoZ6b6nPJanrqxs4MgJgRzTxCJxGVDQEevEDzXP7X2E5w8LbOBQLQsOUZ8TCLx9evX4fHjx+HRo0esTjW4efNmKL3eu3cvyBs5sPB2lWsWENSaZlr3gacmEi9fvhyOHTvGiga9Hjh79mwyDJSz8NQtUOQyOQhSEoI5JNY+mrJqyPLy5cvekw8YAGPXA7du3UqKCob6b4hHp/rMZCDITQjmwmBIIvH+/fuAgEjgSA9cuXJlMAh0edtbNCDYTAICjf6a4xKPflO/vW4BBLT83ZZ/3esUEHi6ZNitF1VBIDLqxovcVr3UfipDH6UBASBYV/m77w8FgaeRhF0I6HU1EChpp+Rdqco89nv6EomAABB0K/y610NAoCHxfY3N4Qpn9e8qILAwv3wfODTmoJvIef78+ZH9w3Xm4P3lQOTGjRsbGzSNGfAMgeIRgRKCFkd5HYaCyqiyaj1//jwwIGG41gOnT58Ourp02EPx7zHjVyxFB8UigrkSgvGEpG5jIlEw0ECiO3fusDaowe3bt8PVq1eDwvvU9fr162sh0NqI1tEgsJIQTAVB/Py6RKIlWlOWcQrIo+oSlrpypShADUhLyygQaOYgSwnBWLlTtzoGZkFqydb9xxKBkONZQUSNRqs+yQaBbvRQeJRa6ax+Xsfi6f7xfqvz7lAFVKEVJSjbLzCookc/a6uBQcol6ZKgxgZ4TwYepUsyCBQSeUgI5gJHxmgt7DvKBPwfBZJAIDKW6mflVtQp9tMxeh0hhqVRIEeBQSBQWKQQaYpKaOk3dMyth4Q5pmGf9hQ4EgTqS+3s7CwOAhFIOvZWE0Tt2ZkjylVgIwhaSwjGyp26JZGYay/286JALwiULOubTjy1ArX2ee/jyb2YknJOr8AKCJQk06WT1ipxqeORNiQSpzcqv1hXgf9AsNSEYC4gSCTWNSbfPq0CByBYekIwFwYkEqc1K79WT4GtsdOJ51aiVvZTItHbjLX17MQ3e1Vgq5UKOfdxtHI7ajSy7iYlFxLVaH8LCLa3iyVGlUhMnU7dmsWUK+pOL6dZpxlUZe0slS8PICgIghiV6F4M3ct+6dIlV+vFixcPJmo5d+5c6K4XLlwI+p/l47l27RpdtBF8AAQVQHDmzJm1M94wxVm9Kc6kOzeM5dEAEBQGgR6dRmWvV9mP0lbdM5Z0BQBBYRA8ePAAEMw4B6KeVciSrgAgAARNgQsQpENAewACQAAI8upOU3sBgsIgePjwYVMV66g+ubX/ExHk8QkQFAaB5sA/ceIEMJghT3D8+HHmnczjAF2DeO2/5Pbu3bvh1KlTwGBCGJw8eTI8efIksxqwGxFB4YggAuXVq1fh2bNn4enTp0euL168OJj/QaP4Sq26O1JzLw75/Rqf0czApY5lyPcwfmAczABBJRBEIAzd6ual7nMZx5xWK3eTxkfLjTkW9p1GAUBgBAQRGGMrj7W7SRWV6AYmFtsKAAJjIBAQciqPbgyyPL0cj5YDBMXu7out5lK2QyuPl+nleLScXRgQERiMCLqg2zQLkqIAJdK6n7f+mhmhbcIAEBgHgSp2X+VRlnx3d9cVBLqQGpsLsVmd/JYKEDgAQaxA8bmM1hKCsXypWx4tZwccgMARCFTRFB2kVjjrn2dG6PmBAAicgcB6pc4t36ZcyPzVpP0SAAJAYCbC6MuFtF8FbRwhIAAEZkAQowkeLTc9HAABIDAHAgGBR8tNCwNAAAhMgiBGByQSpwECIAAEpkEgIJBIrA8DQAAIzINAMFAikUfL1QMCIAAELkAQuwqtPVquXtVO+2ZAAAhcgUBAaOHRcmnVtP6nAQEgcAeCGB3ohiuWMgoAAkDgFgQCgm68Ypqy8TAABIDANQgEAxKJgMC9iWOYy3b84+lJJOYDgYiAiKApmGoWpP39/fwasdA9AQEgaAoEMbIqNSP0UrgACABBkyAQEEgkDscYIAAEzYJAMMiZEXp49Wnnk4AAEDQNgthVGDojdDtVO+1IAAEgWAQIBAQSievhAAgAwWJAIBhozAGJxFUgAAJAsCgQxK4C06n/HwaAABAsEgQCAonEvzAABIBgsSCI0QGJxBAAASBYPAgEhKU/lxEQAAJA8K8HljydOiAABIDgkAfio+X+9qDbfwUIDpkg9hvZjr8b0LOGS3suIyAABEQEGzywlOnUAcEGE3hu0Sh7uYhmCdOpAwJAQEQwwAOtJxIBwQAT0LqWa129a9nqcxkBASAgIkj0QIvPZQQEiSbw3qJR/nLRTUuJREAACIgIRniglUQiIBhhAlrXcq2rZy1bmE4dEAACIoJCHvA8nTogKGQCzy0aZS8X2Xh9LiMgAAREBBU84O25jICgggloYcu1sJ619DSdOiAABEQEFT3gJZEICCqawHNrRtnLRjXWE4mAABAQEUzkAcvTqQOCiUxAC1u2hfWsp8Xp1AEBICAimMED1hKJgGAGE3huzSh7ucjG0nTqgAAQEBHM7AEL06kDgplNQAtbroX1rOXciURAAAiICIx4QGMO5kokAgIjJvDcmlH2slHNHM9lBASAgIjAoAemTiQCAoMmoIUt28J61nOqRCIgAAREBMY9MMUsSIDAuAk8t2aUvVxkU3s6dUAACIgIHHmg1nMZAYEjE9DClmthPWtZYzp1QAAIiAiceqDkdOqAwKkJPLdolL1cZFMqkbilkUysaIAH/Hpgb28vjF3+AbSb48mcXO9tAAAAAElFTkSuQmCC"/>
</defs>
</svg>

Before

Width:  |  Height:  |  Size: 4.4 KiB

View File

@@ -1,67 +0,0 @@
import { CollectionConfig } from '../../src/collections/config/types';
import roles from '../access/roles';
import checkRole from '../access/checkRole';
const access = ({ req: { user } }) => {
const result = checkRole(['admin'], user);
return result;
};
const Admin: CollectionConfig = {
slug: 'admins',
labels: {
singular: 'Admin',
plural: 'Admins',
},
access: {
create: access,
read: access,
update: access,
delete: access,
admin: () => true,
},
auth: {
tokenExpiration: 7200, // 2 hours
verify: false,
maxLoginAttempts: 5,
lockTime: 600 * 1000, // lock time in ms
useAPIKey: true,
depth: 0,
cookies: {
secure: false,
sameSite: 'lax',
domain: undefined,
},
},
fields: [
{
name: 'roles',
label: 'Role',
type: 'select',
options: roles,
defaultValue: 'user',
required: true,
saveToJWT: true,
hasMany: true,
},
{
name: 'publicUser',
type: 'relationship',
hasMany: true,
relationTo: 'public-users',
},
{
name: 'apiKey',
type: 'text',
access: {
read: ({ req: { user } }) => checkRole(['admin'], user),
},
},
],
timestamps: true,
admin: {
useAsTitle: 'email',
},
};
export default Admin;

View File

@@ -1,363 +0,0 @@
import { CollectionConfig } from '../../src/collections/config/types';
import checkRole from '../access/checkRole';
import Email from '../blocks/Email';
import Quote from '../blocks/Quote';
import NumberBlock from '../blocks/Number';
import CallToAction from '../blocks/CallToAction';
import CollectionDescription from '../customComponents/CollectionDescription';
import DemoUIField from '../client/components/DemoUIField/Field';
import DemoUIFieldCell from '../client/components/DemoUIField/Cell';
const AllFields: CollectionConfig = {
slug: 'all-fields',
labels: {
singular: 'All Fields',
plural: 'All Fields',
},
admin: {
defaultColumns: ['text', 'demo', 'createdAt'],
useAsTitle: 'text',
preview: (doc, { token }) => {
const { text } = doc;
if (doc && text) {
return `http://localhost:3000/previewable-posts/${text}?preview=true&token=${token}`;
}
return null;
},
description: CollectionDescription,
},
versions: {
maxPerDoc: 20,
retainDeleted: true,
drafts: false,
},
access: {
read: () => true,
},
fields: [
{
name: 'text',
type: 'text',
label: 'Text',
required: true,
defaultValue: 'Default Value',
unique: true,
access: {
create: ({ req: { user } }) => checkRole(['admin'], user),
update: ({ req: { user } }) => checkRole(['admin'], user),
read: ({ req: { user } }) => Boolean(user),
},
},
{
name: 'descriptionText',
type: 'text',
label: 'Text with text description',
defaultValue: 'Default Value',
admin: {
description: 'This text describes the field',
},
},
{
name: 'descriptionFunction',
type: 'text',
label: 'Text with function description',
defaultValue: 'Default Value',
maxLength: 20,
admin: {
description: ({ value }) => (typeof value === 'string' ? `${20 - value.length} characters left` : ''),
},
},
{
name: 'image',
type: 'upload',
label: 'Image',
relationTo: 'media',
admin: {
description: 'No selfies',
},
},
{
name: 'select',
label: 'Select',
type: 'select',
options: [{
value: 'option-1',
label: 'Option 1 Label',
}, {
value: 'option-2',
label: 'Option 2 Label',
}, {
value: 'option-3',
label: 'Option 3 Label',
}, {
value: 'option-4',
label: 'Option 4 Label',
}],
defaultValue: 'option-1',
required: true,
},
{
name: 'selectMany',
label: 'Select w/ hasMany',
type: 'select',
options: [{
value: 'option-1',
label: 'Option 1 Label',
}, {
value: 'option-2',
label: 'Option 2 Label',
}, {
value: 'option-3',
label: 'Option 3 Label',
}, {
value: 'option-4',
label: 'Option 4 Label',
}],
defaultValue: 'option-1',
required: true,
hasMany: true,
},
{
name: 'dayOnlyDateFieldExample',
label: 'Day Only',
type: 'date',
required: true,
admin: {
date: {
pickerAppearance: 'dayOnly',
monthsToShow: 2,
},
},
},
{
name: 'timeOnlyDateFieldExample',
label: 'Time Only',
type: 'date',
admin: {
date: {
pickerAppearance: 'timeOnly',
},
},
},
{
name: 'point',
label: 'Point Field (GeoJSON)',
type: 'point',
},
{
name: 'radioGroupExample',
label: 'Radio Group Example',
type: 'radio',
options: [{
value: 'option-1',
label: 'Options 1 Label',
}, {
value: 'option-2',
label: 'Option 2 Label',
}, {
value: 'option-3',
label: 'Option 3 Label',
}],
defaultValue: 'option-2',
required: true,
admin: {
readOnly: true,
},
},
{
type: 'row',
fields: [
{
name: 'email',
label: 'Email',
type: 'email',
}, {
name: 'number',
label: 'Number',
type: 'number',
},
],
},
{
type: 'group',
label: 'Group',
name: 'group',
fields: [
{
type: 'row',
fields: [
{
name: 'nestedText1',
label: 'Nested Text 1',
type: 'text',
}, {
name: 'nestedText2',
label: 'Nested Text 2',
type: 'text',
},
],
},
],
},
{
type: 'array',
label: 'Editable Array',
name: 'array',
minRows: 2,
maxRows: 4,
fields: [
{
type: 'row',
fields: [
{
name: 'arrayText1',
label: 'Array Text 1',
type: 'text',
required: true,
admin: {
width: '50%',
},
},
{
name: 'arrayText2',
label: 'Array Text 2',
type: 'text',
required: true,
admin: {
width: '50%',
},
access: {
read: ({ req: { user } }) => Boolean(user),
update: ({ req: { user } }) => checkRole(['admin'], user),
},
},
],
},
{
type: 'text',
name: 'arrayText3',
label: 'Array Text 3',
admin: {
readOnly: true,
},
},
{
name: 'checkbox',
label: 'Checkbox',
type: 'checkbox',
},
],
},
{
type: 'array',
name: 'readOnlyArray',
label: 'readOnly Array',
admin: {
readOnly: true,
},
defaultValue: [{
text: 'text in readOnly array one',
},
{
text: 'text in readOnly array two',
}],
fields: [
{
type: 'text',
name: 'text',
},
],
},
{
type: 'blocks',
label: 'Blocks Content',
name: 'blocks',
minRows: 2,
blocks: [Email, NumberBlock, Quote, CallToAction],
localized: true,
required: true,
},
{
type: 'relationship',
label: 'Relationship to One Collection',
name: 'relationship',
relationTo: 'conditions',
admin: {
description: 'Relates to description',
},
},
{
type: 'relationship',
label: 'Relationship hasMany',
name: 'relationshipHasMany',
relationTo: 'localized-posts',
hasMany: true,
},
{
type: 'relationship',
label: 'Relationship to Multiple Collections',
name: 'relationshipMultipleCollections',
relationTo: ['localized-posts', 'conditions'],
},
{
type: 'textarea',
label: 'Textarea',
name: 'textarea',
admin: {
description: 'Hello textarea description',
},
},
{
name: 'richText',
type: 'richText',
label: 'Rich Text',
required: true,
},
{
type: 'ui',
name: 'demo',
admin: {
position: 'sidebar',
components: {
Field: DemoUIField,
Cell: DemoUIFieldCell,
},
},
},
{
name: 'slug',
type: 'text',
label: 'Slug',
admin: {
position: 'sidebar',
},
localized: true,
unique: true,
required: true,
},
{
name: 'checkbox',
type: 'checkbox',
label: 'Checkbox',
admin: {
position: 'sidebar',
},
},
{
name: 'dateFieldExample',
label: 'Day and Time',
type: 'date',
admin: {
position: 'sidebar',
date: {
timeIntervals: 30,
},
},
},
],
timestamps: true,
};
export default AllFields;

View File

@@ -1,102 +0,0 @@
import { CollectionConfig } from '../../src/collections/config/types';
const AutoLabel: CollectionConfig = {
slug: 'auto-label',
admin: {
useAsTitle: 'autoLabelField',
enableRichTextRelationship: true,
},
fields: [
{
name: 'autoLabelField',
type: 'text',
},
{
name: 'noLabel',
type: 'text',
label: false,
},
{
name: 'labelOverride',
type: 'text',
label: 'Custom Label',
},
{
name: 'testRelationship',
type: 'relationship',
relationTo: 'all-fields',
},
{
name: 'specialBlock',
type: 'blocks',
minRows: 1,
maxRows: 20,
// Will auto-label
// labels: {
// singular: 'Special Block',
// plural: 'Special Blocks',
// },
blocks: [
{
slug: 'number',
// Will auto-label
// labels: {
// singular: 'Number',
// plural: 'Numbers',
// },
fields: [
{
name: 'testNumber',
type: 'number',
},
],
},
],
},
{
name: 'noLabelBlock',
type: 'blocks',
label: false,
minRows: 1,
maxRows: 20,
blocks: [
{
slug: 'number',
// labels: {
// singular: 'Number',
// plural: 'Numbers',
// },
fields: [
{
name: 'testNumber',
type: 'number',
},
],
},
],
},
{
name: 'items',
type: 'array',
fields: [
{
name: 'itemName',
type: 'text',
},
],
},
{
name: 'noLabelArray',
type: 'array',
label: false,
fields: [
{
type: 'text',
name: 'textField',
},
],
},
],
};
export default AutoLabel;

View File

@@ -1,46 +0,0 @@
import { CollectionConfig } from '../../src/collections/config/types';
import Email from '../blocks/Email';
import Quote from '../blocks/Quote';
import NumberBlock from '../blocks/Number';
import CallToAction from '../blocks/CallToAction';
const Blocks: CollectionConfig = {
slug: 'blocks',
labels: {
singular: 'Blocks',
plural: 'Blocks',
},
access: {
read: () => true,
},
versions: {
drafts: true,
},
fields: [
{
name: 'layout',
label: 'Layout Blocks',
labels: {
singular: 'Block',
plural: 'Blocks',
},
type: 'blocks',
blocks: [Email, NumberBlock, Quote, CallToAction],
localized: true,
required: true,
},
{
name: 'nonLocalizedLayout',
label: 'Non Localized Layout',
labels: {
singular: 'Layout',
plural: 'Layouts',
},
type: 'blocks',
blocks: [Email, NumberBlock, Quote, CallToAction],
required: true,
},
],
};
export default Blocks;

View File

@@ -1,23 +0,0 @@
import { CollectionConfig } from '../../src/collections/config/types';
const Code: CollectionConfig = {
slug: 'code',
labels: {
singular: 'Code',
plural: 'Codes',
},
fields: [
{
name: 'code',
type: 'code',
label: 'Code',
required: true,
admin: {
language: 'js',
description: 'javascript example',
},
},
],
};
export default Code;

View File

@@ -1,86 +0,0 @@
import { CollectionConfig } from '../../src/collections/config/types';
import Email from '../blocks/Email';
import Quote from '../blocks/Quote';
import NumberBlock from '../blocks/Number';
import CallToAction from '../blocks/CallToAction';
import Text from './CustomComponents/components/fields/Text/Field';
const Conditions: CollectionConfig = {
slug: 'conditions',
labels: {
singular: 'Conditions',
plural: 'Conditions',
},
fields: [
{
name: 'title',
type: 'text',
label: 'Title',
required: true,
},
{
name: 'enableTest',
type: 'checkbox',
label: 'Enable Test',
},
{
name: 'number',
type: 'number',
label: 'Number Field',
},
{
name: 'simpleCondition',
type: 'text',
label: 'Enable Test is checked',
required: true,
admin: {
condition: (_, siblings) => siblings.enableTest === true,
},
},
{
name: 'orCondition',
type: 'text',
label: 'Number is greater than 20 OR enableTest is checked',
required: true,
admin: {
condition: (_, siblings) => siblings.number > 20 || siblings.enableTest === true,
},
},
{
name: 'nestedConditions',
type: 'text',
label: 'Number is either greater than 20 AND enableTest is checked, OR number is less than 20 and enableTest is NOT checked',
admin: {
condition: (_, siblings) => (siblings.number > 20 && siblings.enableTest === true) || (siblings.number < 20 && siblings.enableTest === false),
},
},
{
name: 'blocks',
label: 'Blocks',
labels: {
singular: 'Block',
plural: 'Blocks',
},
type: 'blocks',
blocks: [Email, NumberBlock, Quote, CallToAction],
required: true,
admin: {
condition: (_, siblings) => siblings?.enableTest === true,
},
},
{
name: 'customComponent',
type: 'text',
label: 'Custom Component with Enable Test is checked',
required: true,
admin: {
condition: (_, siblings) => siblings?.enableTest === true,
components: {
Field: Text,
},
},
},
],
};
export default Conditions;

View File

@@ -1,5 +0,0 @@
import React from 'react';
const Cell: React.FC = () => <div className="description">fake description cell</div>;
export default Cell;

View File

@@ -1,5 +0,0 @@
import React from 'react';
const Description: React.FC = () => <div className="description">fake description field</div>;
export default Description;

View File

@@ -1,3 +0,0 @@
.custom-description-filter {
background: lightgray;
}

View File

@@ -1,15 +0,0 @@
import React from 'react';
import { Props } from './types';
import './index.scss';
const Filter: React.FC<Props> = ({ onChange, value }) => (
<input
className="custom-description-filter"
type="text"
onChange={(e) => onChange(e.target.value)}
value={value}
/>
);
export default Filter;

View File

@@ -1,4 +0,0 @@
export type Props = {
value?: string
onChange?: (value: string) => void
}

View File

@@ -1,19 +0,0 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Group } from '../../../../../../../components/forms';
const CustomGroup: React.FC = (props) => (
<div className="custom-group">
<Group {...props} />
</div>
);
CustomGroup.defaultProps = {
value: '',
};
CustomGroup.propTypes = {
value: PropTypes.string,
};
export default CustomGroup;

View File

@@ -1,5 +0,0 @@
import React from 'react';
const NestedArrayCustomField = () => <div className="nested-array-custom-field">Nested array custom field</div>;
export default NestedArrayCustomField;

View File

@@ -1,5 +0,0 @@
import React from 'react';
const NestedGroupCustomField = () => <div className="nested-group-custom-field">Nested group custom field</div>;
export default NestedGroupCustomField;

View File

@@ -1,5 +0,0 @@
import React from 'react';
const NestedText1 = () => <div className="nested-text-1">Nested Text 1</div>;
export default NestedText1;

View File

@@ -1,61 +0,0 @@
import React, { useCallback } from 'react';
import SelectInput from '../../../../../../../src/admin/components/forms/field-types/Select/Input';
import { Props as SelectFieldType } from '../../../../../../../src/admin/components/forms/field-types/Select/types';
import useField from '../../../../../../../src/admin/components/forms/useField';
const Select: React.FC<SelectFieldType> = (props) => {
const {
path,
name,
label,
options,
} = props;
const {
showError,
value,
setValue,
} = useField({
path,
});
const onChange = useCallback((incomingOption) => {
const { value: incomingValue } = incomingOption;
const sendToCRM = async () => {
try {
const req = await fetch('https://fake-crm.com', {
method: 'post',
body: JSON.stringify({
someKey: incomingValue,
}),
});
const res = await req.json();
if (res.ok) {
console.log('Successfully synced to CRM.'); // eslint-disable-line no-console
}
} catch (e) {
console.error(e);
}
};
sendToCRM();
setValue(incomingValue);
}, [
setValue,
]);
return (
<SelectInput
name={name}
label={label}
options={options}
value={value as string}
onChange={onChange}
showError={showError}
/>
);
};
export default Select;

View File

@@ -1,44 +0,0 @@
import React, { useCallback } from 'react';
import TextInput from '../../../../../../../src/admin/components/forms/field-types/Text/Input';
import { Props as TextFieldType } from '../../../../../../../src/admin/components/forms/field-types/Text/types';
import useField from '../../../../../../../src/admin/components/forms/useField';
const Text: React.FC<TextFieldType> = (props) => {
const {
path,
name,
label,
} = props;
const field = useField({
path,
enableDebouncedValue: true,
});
const {
showError,
value,
setValue,
} = field;
const onChange = useCallback((e) => {
const { value: incomingValue } = e.target;
const valueWithoutSpaces = incomingValue.replace(/\s/g, '');
setValue(valueWithoutSpaces);
}, [
setValue,
]);
return (
<TextInput
path={path}
name={name}
value={value as string || ''}
label={label}
onChange={onChange}
showError={showError}
/>
);
};
export default Text;

View File

@@ -1,41 +0,0 @@
import React, { useCallback } from 'react';
import TextAreaInput from '../../../../../../../src/admin/components/forms/field-types/Textarea/Input';
import { Props as TextFieldType } from '../../../../../../../src/admin/components/forms/field-types/Text/types';
import useField from '../../../../../../../src/admin/components/forms/useField';
const TextArea: React.FC<TextFieldType> = (props) => {
const {
path,
name,
label,
} = props;
const field = useField({
path,
});
const {
showError,
value,
setValue,
} = field;
const onChange = useCallback((e) => {
const { value: incomingValue } = e.target;
setValue(incomingValue);
}, [
setValue,
]);
return (
<TextAreaInput
name={name}
value={value as string || ''}
label={label}
onChange={onChange}
showError={showError}
/>
);
};
export default TextArea;

View File

@@ -1,50 +0,0 @@
import React, { useCallback } from 'react';
import TextInput from '../../../../../../../src/admin/components/forms/field-types/Text';
import { UIField as UIFieldType } from '../../../../../../../src/fields/config/types';
import SelectInput from '../../../../../../../src/admin/components/forms/field-types/Select';
const UIField: React.FC<UIFieldType> = () => {
const [textValue, setTextValue] = React.useState('');
const [selectValue, setSelectValue] = React.useState('');
const onTextChange = useCallback((incomingValue) => {
setTextValue(incomingValue);
}, [])
const onSelectChange = useCallback((incomingValue) => {
setSelectValue(incomingValue);
}, [])
return (
<div>
<TextInput
name="ui-text"
label="Presentation-only text field (does not submit)"
value={textValue as string}
onChange={onTextChange}
/>
<SelectInput
name="ui-select"
label="Presentation-only select field (does not submit)"
options={[
{
label: 'Option 1',
value: 'option-1'
},
{
label: 'Option 2',
value: 'option-2'
},
{
label: 'Option 3',
value: 'option-4'
}
]}
value={selectValue as string}
onChange={onSelectChange}
/>
</div>
)
};
export default UIField;

View File

@@ -1,57 +0,0 @@
import React, { useCallback } from 'react';
import UploadInput from '../../../../../../../src/admin/components/forms/field-types/Upload/Input';
import { Props as UploadFieldType } from '../../../../../../../src/admin/components/forms/field-types/Upload/types';
import useField from '../../../../../../../src/admin/components/forms/useField';
import { SanitizedCollectionConfig } from '../../../../../../../src/collections/config/types';
import { useConfig } from '../../../../../../../src/admin/components/utilities/Config';
const Text: React.FC<UploadFieldType> = (props) => {
const {
path,
name,
label,
relationTo,
fieldTypes,
} = props;
const {
value,
setValue,
showError,
} = useField({
path,
});
const onChange = useCallback((incomingValue) => {
const incomingID = incomingValue?.id || incomingValue;
setValue(incomingID);
}, [setValue]);
const {
collections,
serverURL,
routes: {
api,
},
} = useConfig();
const collection = collections.find((coll) => coll.slug === relationTo) || undefined;
return (
<UploadInput
path={path}
relationTo={relationTo}
fieldTypes={fieldTypes}
name={name}
label={label}
value={value as string}
onChange={onChange}
showError={showError}
collection={collection as SanitizedCollectionConfig}
serverURL={serverURL}
api={api}
/>
);
};
export default Text;

View File

@@ -1,5 +0,0 @@
$color: purple;
.custom-list {
color: $color;
}

View File

@@ -1,14 +0,0 @@
import React from 'react';
import DefaultList from '../../../../../../src/admin/components/views/collections/List/Default';
import './index.scss';
const CustomListView: React.FC = (props) => (
<div className="custom-list">
<p>This is a custom Pages list view</p>
<p>Sup</p>
<DefaultList {...props} />
</div>
);
export default CustomListView;

View File

@@ -1,224 +0,0 @@
import { CollectionConfig } from '../../../src/collections/config/types';
import DescriptionField from './components/fields/Description/Field';
import TextField from './components/fields/Text/Field';
import SelectField from './components/fields/Select/Field';
import TextAreaField from './components/fields/TextArea/Field';
import UploadField from './components/fields/Upload/Field';
import DescriptionCell from './components/fields/Description/Cell';
import DescriptionFilter from './components/fields/Description/Filter';
import NestedArrayField from './components/fields/NestedArrayCustomField/Field';
import GroupField from './components/fields/Group/Field';
import NestedGroupField from './components/fields/NestedGroupCustomField/Field';
import NestedText1Field from './components/fields/NestedText1/Field';
import UIField from './components/fields/UI/Field';
import ListView from './components/views/List';
import CustomDescriptionComponent from '../../customComponents/Description';
const CustomComponents: CollectionConfig = {
slug: 'custom-components',
labels: {
singular: 'Custom Component',
plural: 'Custom Components',
},
fields: [
{
name: 'title',
label: 'Title',
type: 'text',
maxLength: 100,
required: true,
unique: true,
},
{
name: 'normalText',
label: 'Normal text field',
type: 'text',
// required: true,
},
{
name: 'customText',
label: 'Custom text field (removes whitespace)',
type: 'text',
// required: true,
admin: {
components: {
Field: TextField,
},
},
},
{
name: 'normalSelect',
label: 'Normal select field',
type: 'select',
options: [
{
label: 'Option 1',
value: '1',
},
{
label: 'Option 2',
value: '2',
},
{
label: 'Option 3',
value: '3',
},
],
},
{
name: 'customSelect',
label: 'Custom select field (syncs value with crm)',
type: 'select',
options: [
{
label: 'Option 1',
value: '1',
},
{
label: 'Option 2',
value: '2',
},
{
label: 'Option 3',
value: '3',
},
],
admin: {
components: {
Field: SelectField,
},
},
},
{
name: 'normalTextarea',
label: 'Normal textarea field',
type: 'textarea',
},
{
name: 'customTextarea',
label: 'Custom textarea field',
type: 'textarea',
admin: {
components: {
Field: TextAreaField,
},
},
},
{
name: 'ui',
label: 'UI',
type: 'ui',
admin: {
components: {
Field: UIField,
},
},
},
{
name: 'normalUpload',
label: 'Normal upload field',
type: 'upload',
relationTo: 'media',
},
{
name: 'customUpload',
label: 'Custom upload field',
type: 'upload',
relationTo: 'media',
admin: {
components: {
Field: UploadField,
},
},
},
{
name: 'description',
label: 'Description',
type: 'textarea',
admin: {
components: {
Field: DescriptionField,
Cell: DescriptionCell,
Filter: DescriptionFilter,
},
},
},
{
name: 'componentDescription',
label: 'Component ViewDescription',
type: 'text',
admin: {
description: CustomDescriptionComponent,
},
},
{
name: 'array',
label: 'Array',
type: 'array',
fields: [
{
type: 'text',
name: 'nestedArrayCustomField',
label: 'Nested Array Custom Field',
admin: {
components: {
Field: NestedArrayField,
},
},
},
],
},
{
name: 'group',
label: 'Group',
type: 'group',
admin: {
components: {
Field: GroupField,
},
},
fields: [
{
type: 'text',
name: 'nestedGroupCustomField',
label: 'Nested Group Custom Field',
admin: {
components: {
Field: NestedGroupField,
},
},
},
],
},
{
type: 'row',
fields: [
{
name: 'nestedText1',
label: 'Nested Text 1',
type: 'text',
admin: {
components: {
Field: NestedText1Field,
},
},
}, {
name: 'nestedText2',
label: 'Nested Text 2',
type: 'text',
},
],
},
],
timestamps: true,
admin: {
useAsTitle: 'title',
components: {
views: {
List: ListView,
},
},
},
};
export default CustomComponents;

View File

@@ -1,22 +0,0 @@
import { CollectionConfig } from '../../src/collections/config/types';
const CustomID: CollectionConfig = {
slug: 'custom-id',
labels: {
singular: 'CustomID',
plural: 'CustomIDs',
},
fields: [
{
name: 'id',
type: 'number',
},
{
name: 'name',
type: 'text',
required: true,
},
],
};
export default CustomID;

View File

@@ -1,329 +0,0 @@
import { CollectionConfig } from '../../src/collections/config/types';
import checkRole from '../access/checkRole';
import Email from '../blocks/Email';
import Quote from '../blocks/Quote';
import NumberBlock from '../blocks/Number';
import CallToAction from '../blocks/CallToAction';
const DefaultValues: CollectionConfig = {
slug: 'default-values',
labels: {
singular: 'Default Value Test',
plural: 'Default Value Tests',
},
admin: {
useAsTitle: 'text',
},
access: {
read: () => true,
},
fields: [
{
name: 'text',
type: 'text',
label: 'Text',
defaultValue: 'Default Value',
unique: true,
access: {
create: ({ req: { user } }) => checkRole(['admin'], user),
update: ({ req: { user } }) => checkRole(['admin'], user),
read: ({ req: { user } }) => Boolean(user),
},
},
{
name: 'image',
type: 'upload',
label: 'Image',
relationTo: 'media',
},
{
name: 'select',
label: 'Select',
type: 'select',
options: [{
value: 'option-1',
label: 'Option 1 Label',
}, {
value: 'option-2',
label: 'Option 2 Label',
}, {
value: 'option-3',
label: 'Option 3 Label',
}, {
value: 'option-4',
label: 'Option 4 Label',
}],
defaultValue: 'option-1',
},
{
name: 'selectMany',
label: 'Select w/ hasMany',
type: 'select',
options: [{
value: 'option-1',
label: 'Option 1 Label',
}, {
value: 'option-2',
label: 'Option 2 Label',
}, {
value: 'option-3',
label: 'Option 3 Label',
}, {
value: 'option-4',
label: 'Option 4 Label',
}],
defaultValue: ['option-1', 'option-4'],
hasMany: true,
},
{
name: 'radioGroupExample',
label: 'Radio Group Example',
type: 'radio',
options: [{
value: 'option-1',
label: 'Options 1 Label',
}, {
value: 'option-2',
label: 'Option 2 Label',
}, {
value: 'option-3',
label: 'Option 3 Label',
}],
defaultValue: 'option-2',
},
{
type: 'row',
fields: [
{
name: 'email',
label: 'Email',
type: 'email',
defaultValue: 'some@email.com',
}, {
name: 'number',
label: 'Number',
type: 'number',
defaultValue: 5,
},
],
},
{
type: 'group',
label: 'Group',
name: 'group',
defaultValue: {
nestedText2: 'nested default text 2',
nestedText3: 'neat',
},
fields: [
{
type: 'row',
fields: [
{
name: 'nestedText1',
label: 'Nested Text 1',
type: 'text',
defaultValue: 'this should take priority',
},
{
name: 'nestedText2',
label: 'Nested Text 2',
type: 'text',
},
{
name: 'nestedText3',
type: 'text',
},
],
},
],
},
{
type: 'array',
label: 'Array',
name: 'array',
admin: {
readOnly: true,
},
defaultValue: [
{
arrayText1: 'Get out',
arrayText2: 'Get in',
},
],
fields: [
{
type: 'row',
fields: [
{
name: 'arrayText1',
label: 'Array Text 1',
type: 'text',
admin: {
width: '50%',
},
defaultValue: 'default array text',
},
{
name: 'arrayText2',
label: 'Array Text 2',
type: 'text',
admin: {
width: '50%',
},
access: {
read: ({ req: { user } }) => Boolean(user),
update: ({ req: { user } }) => checkRole(['admin'], user),
},
},
],
},
{
type: 'text',
name: 'arrayText3',
label: 'Array Text 3',
admin: {
readOnly: true,
},
},
{
name: 'checkbox',
label: 'Checkbox',
type: 'checkbox',
defaultValue: true,
},
],
},
{
type: 'blocks',
label: 'Blocks Content',
name: 'blocks',
labels: {
singular: 'Block',
plural: 'Blocks',
},
blocks: [Email, NumberBlock, Quote, CallToAction],
localized: true,
admin: {
readOnly: true,
},
defaultValue: [
{
blockType: 'email',
testEmail: 'dev@payloadcms.com',
},
],
},
{
type: 'relationship',
label: 'Relationship to One Collection',
name: 'relationship',
relationTo: 'conditions',
},
{
type: 'relationship',
label: 'Relationship hasMany',
name: 'relationshipHasMany',
relationTo: 'localized-posts',
hasMany: true,
},
{
type: 'relationship',
label: 'Relationship to Multiple Collections',
name: 'relationshipMultipleCollections',
relationTo: ['localized-posts', 'conditions'],
},
{
type: 'textarea',
label: 'Textarea',
name: 'textarea',
defaultValue: 'my textarea text',
},
{
name: 'slug',
type: 'text',
label: 'Slug',
admin: {
position: 'sidebar',
},
localized: true,
unique: true,
defaultValue: 'my-slug',
},
{
name: 'checkbox',
type: 'checkbox',
label: 'Checkbox',
admin: {
position: 'sidebar',
},
defaultValue: true,
},
{
name: 'richText',
type: 'richText',
label: 'Rich Text',
admin: {
elements: [
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'blockquote',
'ul',
'ol',
'link',
],
leaves: [
'bold',
'italic',
'underline',
'strikethrough',
],
},
defaultValue: [{
children: [{ text: 'Cookin now' }],
}],
},
{
type: 'array',
name: 'asyncArray',
defaultValue: () => {
return [{ child: 'ok' }];
},
fields: [
{
name: 'child',
type: 'text',
defaultValue: () => {
return 'async child';
},
},
],
},
{
name: 'asyncText',
type: 'text',
defaultValue: async (): Promise<string> => {
return new Promise((resolve) => setTimeout(() => {
resolve('asyncFunction');
}, 50));
},
},
{
name: 'function',
type: 'text',
defaultValue: (args): string => {
const { locale } = args;
if (locale === 'en') {
return 'function';
}
return '';
},
},
],
timestamps: true,
};
export default DefaultValues;

View File

@@ -1,70 +0,0 @@
import { CollectionConfig } from '../../src/collections/config/types';
import checkRole from '../access/checkRole';
const access = ({ req: { user } }) => {
const isAdmin = checkRole(['admin'], user);
if (isAdmin) {
return true;
}
if (user) {
return {
owner: {
equals: user.id,
},
};
}
return false;
};
const Files: CollectionConfig = {
slug: 'files',
labels: {
singular: 'File',
plural: 'Files',
},
upload: {
staticURL: '/files',
staticDir: './files',
},
access: {
create: () => true,
read: access,
update: access,
delete: access,
},
fields: [
{
name: 'type',
label: 'Type',
type: 'select',
options: [{
value: 'Type 1',
label: 'Type 1 Label',
}, {
value: 'Type 2',
label: 'Type 2 Label',
}, {
value: 'Type 3',
label: 'Type 3 Label',
}],
defaultValue: 'Type 1',
required: true,
},
{
name: 'owner',
label: 'Owner',
type: 'relationship',
relationTo: 'admins',
required: true,
},
],
timestamps: true,
admin: {
useAsTitle: 'filename',
},
};
export default Files;

View File

@@ -1,43 +0,0 @@
import { CollectionConfig } from '../../src/collections/config/types';
const HiddenFields: CollectionConfig = {
slug: 'hidden-fields',
labels: {
singular: 'Hidden Fields',
plural: 'Hidden Fields',
},
fields: [
{
name: 'title',
type: 'text',
label: 'Title - Not Hidden',
required: true,
},
{
name: 'hiddenAdmin',
type: 'text',
label: 'Hidden on Admin',
admin: {
hidden: true,
},
required: true,
defaultValue: 'should be hidden from admin, visible in API',
},
{
name: 'hiddenAPI',
type: 'text',
label: 'Hidden on API',
hidden: true,
required: true,
hooks: {
beforeValidate: [
({ value }) => {
return value || 'should be hidden from API';
},
],
},
},
],
};
export default HiddenFields;

View File

@@ -1,98 +0,0 @@
/* eslint-disable no-param-reassign, no-console */
// If importing outside of demo project, should import CollectionAfterReadHook, CollectionBeforeChangeHook, etc
import { AfterChangeHook, AfterDeleteHook, AfterReadHook, BeforeChangeHook, BeforeDeleteHook, BeforeReadHook, CollectionConfig } from '../../src/collections/config/types';
import { FieldHook } from '../../src/fields/config/types';
import { Hook } from '../payload-types';
const Hooks: CollectionConfig = {
slug: 'hooks',
labels: {
singular: 'Hook',
plural: 'Hooks',
},
admin: {
useAsTitle: 'title',
},
access: {
create: () => true,
read: () => true,
update: () => true,
delete: () => true,
},
hooks: {
beforeRead: [
((operation) => {
if (operation.req.headers.hook === 'beforeRead') {
console.log('before reading Hooks document');
}
}) as BeforeReadHook<Hook>,
],
beforeChange: [
((operation) => {
if (operation.req.headers.hook === 'beforeChange') {
operation.data.description += '-beforeChangeSuffix';
}
return operation.data;
}) as BeforeChangeHook<Hook>,
],
beforeDelete: [
((operation) => {
if (operation.req.headers.hook === 'beforeDelete') {
// TODO: Find a better hook operation to assert against in tests
operation.req.headers.hook = 'afterDelete';
}
}) as BeforeDeleteHook,
],
afterRead: [
((operation) => {
const { doc, findMany } = operation;
doc.afterReadHook = true;
doc.findMany = findMany;
return doc;
}) as AfterReadHook<Hook & { afterReadHook: boolean, findMany: boolean }>,
],
afterChange: [
((operation) => {
if (operation.req.headers.hook === 'afterChange') {
operation.doc.afterChangeHook = true;
}
return operation.doc;
}) as AfterChangeHook<Hook & { afterChangeHook: boolean }>,
],
afterDelete: [
((operation) => {
if (operation.req.headers.hook === 'afterDelete') {
operation.doc.afterDeleteHook = true;
}
return operation.doc;
}) as AfterDeleteHook,
],
},
fields: [
{
name: 'title',
label: 'Title',
type: 'text',
maxLength: 100,
required: true,
unique: true,
localized: true,
hooks: {
afterRead: [
({ value }) => (value ? value.toUpperCase() : null) as FieldHook<Hook, 'title'>,
],
},
},
{
name: 'description',
label: 'Description',
type: 'textarea',
required: true,
localized: true,
},
],
timestamps: true,
};
export default Hooks;

View File

@@ -1,22 +0,0 @@
import { CollectionConfig } from '../../src/collections/config/types';
const Images: CollectionConfig = {
slug: 'images',
admin: {
description: 'Used to test upload relationship queries',
},
labels: {
singular: 'Image',
plural: 'Images',
},
fields: [
{
name: 'upload',
type: 'upload',
relationTo: 'media',
},
],
timestamps: true,
};
export default Images;

View File

@@ -1,38 +0,0 @@
import { CollectionConfig } from '../../src/collections/config/types';
const LocalOperations: CollectionConfig = {
slug: 'local-operations',
labels: {
singular: 'Local Operation',
plural: 'Local Operations',
},
hooks: {
afterRead: [
async ({ req, doc }) => {
const formattedData = { ...doc };
const localizedPosts = await req.payload.find({
collection: 'localized-posts',
});
const blocksGlobal = await req.payload.findGlobal({
slug: 'blocks-global',
});
formattedData.localizedPosts = localizedPosts;
formattedData.blocksGlobal = blocksGlobal;
return formattedData;
},
],
},
fields: [
{
name: 'title',
type: 'text',
label: 'title',
required: true,
},
],
};
export default LocalOperations;

View File

@@ -1,146 +0,0 @@
import { CollectionConfig } from '../../src/collections/config/types';
import { PayloadRequest } from '../../src/express/types';
import { Block } from '../../src/fields/config/types';
const validateLocalizationTransform = (hook: string, value, req: PayloadRequest) => {
if (req.locale !== 'all' && value !== undefined && typeof value !== 'string' && value !== null) {
console.error(hook, value);
throw new Error('Locale transformation should happen before hook is called');
}
return value;
};
const RichTextBlock: Block = {
slug: 'richTextBlock',
labels: {
singular: 'Rich Text Block',
plural: 'Rich Text Blocks',
},
fields: [
{
name: 'content',
localized: true,
type: 'richText',
admin: {
hideGutter: true,
},
},
],
};
const LocalizedPosts: CollectionConfig = {
slug: 'localized-posts',
labels: {
singular: 'Localized Post',
plural: 'Localized Posts',
},
admin: {
useAsTitle: 'title',
defaultColumns: [
'title',
'priority',
'createdAt',
],
enableRichTextRelationship: true,
},
access: {
read: () => true,
},
fields: [
{
name: 'title',
label: 'Title',
type: 'text',
maxLength: 100,
required: true,
unique: true,
localized: true,
hooks: {
beforeValidate: [({ value, req }) => validateLocalizationTransform('beforeValidate', value, req)],
beforeChange: [({ value, req }) => validateLocalizationTransform('beforeChange', value, req)],
afterChange: [({ value, req }) => validateLocalizationTransform('afterChange', value, req)],
afterRead: [({ value, req }) => validateLocalizationTransform('afterRead', value, req)],
},
},
{
name: 'summary',
label: 'Summary',
type: 'text',
index: true,
},
{
name: 'description',
label: 'Description',
type: 'textarea',
required: true,
localized: true,
},
{
type: 'richText',
name: 'richText',
label: 'Rich Text',
},
{
name: 'priority',
label: 'Priority',
type: 'number',
localized: true,
},
{
name: 'localizedGroup',
label: 'Localized Group',
type: 'group',
localized: true,
fields: [
{
type: 'text',
name: 'text',
label: 'Text',
},
{
type: 'text',
name: 'demoHiddenField',
hidden: true,
},
],
},
{
name: 'nonLocalizedGroup',
label: 'Non-Localized Group',
type: 'group',
fields: [
{
type: 'text',
name: 'text',
label: 'Text',
localized: true,
},
],
},
{
type: 'array',
label: 'Non-Localized Array',
name: 'nonLocalizedArray',
maxRows: 3,
fields: [
{
type: 'text',
name: 'localizedEmbeddedText',
label: 'Localized Embedded Text',
localized: true,
},
],
},
{
label: 'Blocks',
name: 'richTextBlocks',
type: 'blocks',
blocks: [
RichTextBlock,
],
},
],
timestamps: true,
};
export default LocalizedPosts;

View File

@@ -1,79 +0,0 @@
import { CollectionConfig } from '../../src/collections/config/types';
import { FieldAccess } from '../../src/fields/config/types';
import checkRole from '../access/checkRole';
const PublicReadabilityAccess: FieldAccess = ({ req: { user }, siblingData }) => {
if (checkRole(['admin'], user)) {
return true;
}
if (siblingData?.allowPublicReadability) return true;
return false;
};
const LocalizedArrays: CollectionConfig = {
slug: 'localized-arrays',
labels: {
singular: 'Localized Array',
plural: 'Localized Arrays',
},
access: {
read: () => true,
},
fields: [
{
type: 'array',
label: false,
name: 'array',
localized: true,
required: true,
minRows: 2,
maxRows: 4,
fields: [
{
type: 'row',
fields: [
{
name: 'allowPublicReadability',
label: 'Allow Public Readability',
type: 'checkbox',
},
{
name: 'arrayText1',
label: 'Array Text 1',
type: 'text',
required: true,
admin: {
width: '50%',
},
access: {
read: PublicReadabilityAccess,
},
},
{
name: 'arrayText2',
label: 'Array Text 2',
type: 'text',
required: true,
admin: {
width: '50%',
},
},
],
},
{
type: 'text',
name: 'arrayText3',
label: 'Array Text 3',
admin: {
readOnly: true,
},
},
],
},
],
timestamps: true,
};
export default LocalizedArrays;

View File

@@ -1,81 +0,0 @@
import { CollectionConfig, BeforeChangeHook } from '../../src/collections/config/types';
const checkForUploadSizesHook: BeforeChangeHook = ({ req: { payloadUploadSizes }, data }) => {
if (typeof payloadUploadSizes === 'object') {
return {
...data,
foundUploadSizes: true,
};
}
return data;
};
const Media: CollectionConfig = {
slug: 'media',
labels: {
singular: 'Media',
plural: 'Media',
},
access: {
read: () => true,
},
admin: {
enableRichTextRelationship: true,
description: 'No selfies please',
},
hooks: {
beforeChange: [
checkForUploadSizesHook,
],
},
upload: {
staticURL: '/media',
staticDir: './media',
adminThumbnail: ({ doc }) => `/media/${doc.filename}`,
imageSizes: [
{
name: 'maintainedAspectRatio',
width: 1024,
height: null,
crop: 'center',
},
{
name: 'tablet',
width: 640,
height: 480,
crop: 'left top',
},
{
name: 'mobile',
width: 320,
height: 240,
crop: 'left top',
},
{
name: 'icon',
width: 16,
height: 16,
},
],
staticOptions: {
maxAge: 21600000, // 6 hours in milliseconds
},
},
fields: [
{
name: 'alt',
label: 'Alt Text',
type: 'text',
required: true,
localized: true,
},
{
name: 'foundUploadSizes',
type: 'checkbox',
},
],
timestamps: true,
};
export default Media;

View File

@@ -1,71 +0,0 @@
import { CollectionConfig } from '../../src/collections/config/types';
const NestedArray: CollectionConfig = {
slug: 'nested-arrays',
labels: {
singular: 'Nested Array',
plural: 'Nested Arrays',
},
access: {
read: () => true,
},
fields: [
{
type: 'array',
label: 'Array',
name: 'array',
labels: {
singular: 'Parent Row',
plural: 'Parent Rows',
},
required: true,
minRows: 2,
maxRows: 4,
fields: [
{
name: 'parentIdentifier',
label: 'Parent Identifier',
defaultValue: ' ',
type: 'text',
required: true,
},
{
type: 'array',
name: 'nestedArray',
labels: {
singular: 'Child Row',
plural: 'Child Rows',
},
required: true,
fields: [
{
name: 'childIdentifier',
label: 'Child Identifier',
type: 'text',
required: true,
},
{
type: 'array',
name: 'deeplyNestedArray',
labels: {
singular: 'Grandchild Row',
plural: 'Grandchild Rows',
},
required: true,
fields: [
{
name: 'grandchildIdentifier',
label: 'Grandchild Identifier',
type: 'text',
},
],
},
],
},
],
},
],
timestamps: true,
};
export default NestedArray;

View File

@@ -1,37 +0,0 @@
import { CollectionConfig } from '../../src/collections/config/types';
const Preview: CollectionConfig = {
slug: 'previewable-post',
labels: {
singular: 'Previewable Post',
plural: 'Previewable Posts',
},
admin: {
useAsTitle: 'title',
preview: async (doc, { token }) => {
const { title } = doc;
if (title) {
const mockAsyncReq = await fetch(`http://localhost:3000/api/previewable-post?depth=0`)
const mockJSON = await mockAsyncReq.json();
const mockParam = mockJSON?.docs?.[0]?.title || '';
return `http://localhost:3000/previewable-posts/${title}?preview=true&token=${token}&mockParam=${mockParam}`;
}
return null;
},
},
fields: [
{
name: 'title',
label: 'Title',
type: 'text',
maxLength: 100,
required: true,
unique: true,
localized: true,
},
],
timestamps: true,
};
export default Preview;

View File

@@ -1,61 +0,0 @@
import checkRole from '../access/checkRole';
import { CollectionConfig } from '../../src/collections/config/types';
const access = ({ req: { user } }) => checkRole(['admin'], user);
const PublicUsers: CollectionConfig = {
slug: 'public-users',
labels: {
singular: 'Public User',
plural: 'Public Users',
},
admin: {
useAsTitle: 'email',
},
access: {
admin: () => false,
create: () => true,
read: () => true,
update: ({ req: { user } }) => {
if (checkRole(['admin'], user)) {
return true;
}
if (user) {
return {
id: user.id,
};
}
return false;
},
delete: ({ req: { user } }) => checkRole(['admin'], user),
},
auth: {
tokenExpiration: 300,
verify: true,
maxLoginAttempts: 5,
lockTime: 600 * 1000, // lock time in ms
cookies: {
secure: process.env.NODE_ENV === 'production',
sameSite: 'lax',
domain: undefined,
},
},
fields: [
{
name: 'adminOnly',
label: 'This field should only be readable and editable by Admins with "admin" role',
type: 'text',
defaultValue: 'test',
access: {
create: access,
read: access,
update: access,
},
},
],
timestamps: true,
};
export default PublicUsers;

View File

@@ -1,86 +0,0 @@
import { CollectionConfig } from '../../src/collections/config/types';
const RelationshipA: CollectionConfig = {
slug: 'relationship-a',
access: {
read: () => true,
},
labels: {
singular: 'Relationship A',
plural: 'Relationship A',
},
fields: [
{
name: 'post',
label: 'Post',
type: 'relationship',
relationTo: 'relationship-b',
},
{
name: 'LocalizedPost',
label: 'Localized Post',
type: 'relationship',
relationTo: 'localized-posts',
hasMany: true,
localized: true,
},
{
name: 'postLocalizedMultiple',
label: 'Localized Post Multiple',
type: 'relationship',
relationTo: ['localized-posts', 'all-fields', 'custom-id'],
hasMany: true,
localized: true,
},
{
name: 'postManyRelationships',
label: 'Post Many Relationships',
type: 'relationship',
relationTo: ['relationship-b'],
localized: true,
hasMany: false,
},
{
name: 'postMaxDepth',
maxDepth: 0,
label: 'Post With MaxDepth',
type: 'relationship',
relationTo: 'relationship-b',
hasMany: false,
},
{
name: 'customID',
label: 'CustomID Relation',
type: 'relationship',
relationTo: 'custom-id',
hasMany: true,
localized: true,
},
{
name: 'filterRelationship',
type: 'relationship',
relationTo: 'relationship-b',
filterOptions: {
disableRelation: {
not_equals: true,
},
},
},
{
name: 'files',
type: 'upload',
relationTo: 'files',
filterOptions: {
type: { equals: 'Type 2' },
},
},
{
name: 'demoHiddenField',
type: 'text',
hidden: true,
},
],
timestamps: true,
};
export default RelationshipA;

View File

@@ -1,65 +0,0 @@
import { CollectionConfig } from '../../src/collections/config/types';
const RelationshipB: CollectionConfig = {
slug: 'relationship-b',
access: {
read: () => true,
},
admin: {
useAsTitle: 'title',
},
labels: {
singular: 'Relationship B',
plural: 'Relationship B',
},
fields: [
{
name: 'title',
type: 'text',
},
{
name: 'disableRelation', // used on RelationshipA.filterRelationship field
type: 'checkbox',
required: true,
admin: {
position: 'sidebar',
},
},
{
name: 'post',
label: 'Post',
type: 'relationship',
relationTo: 'relationship-a',
localized: false,
hasMany: true,
},
{
name: 'postManyRelationships',
label: 'Post Many Relationships',
type: 'relationship',
relationTo: ['relationship-a', 'media'],
localized: true,
hasMany: false,
},
{
name: 'localizedPosts',
label: 'Localized Posts',
type: 'relationship',
hasMany: true,
relationTo: ['localized-posts', 'previewable-post'],
},
{
name: 'nonLocalizedRelationToMany',
type: 'relationship',
relationTo: ['localized-posts', 'relationship-a'],
},
{
name: 'strictAccess',
type: 'relationship',
relationTo: 'strict-access',
},
],
timestamps: true,
};
export default RelationshipB;

View File

@@ -1,112 +0,0 @@
import Button from '../client/components/richText/elements/Button';
import PurpleBackground from '../client/components/richText/leaves/PurpleBackground';
import { CollectionConfig } from '../../src/collections/config/types';
const RichText: CollectionConfig = {
slug: 'rich-text',
labels: {
singular: 'Rich Text',
plural: 'Rich Texts',
},
access: {
read: ({ req }) => {
if (req.user) return true;
return {
_status: {
equals: 'published',
},
};
},
},
versions: {
drafts: {
autosave: false,
},
},
admin: {
preview: () => 'https://payloadcms.com',
useAsTitle: 'title',
},
fields: [
{
name: 'title',
type: 'text',
},
{
name: 'defaultRichText',
type: 'richText',
label: 'Default Rich Text',
required: true,
admin: {
upload: {
collections: {
media: {
fields: [
{
type: 'richText',
name: 'caption',
label: 'Caption',
},
{
type: 'row',
fields: [
{
type: 'relationship',
relationTo: 'admins',
name: 'linkToAdmin',
label: 'Link to Admin',
},
{
type: 'select',
name: 'imageAlignment',
label: 'Image Alignment',
options: [
{
label: 'Left',
value: 'left',
},
{
label: 'Center',
value: 'center',
},
{
label: 'Right',
value: 'right',
},
],
},
],
},
{
type: 'checkbox',
name: 'wrapText',
label: 'Wrap Text',
},
],
},
},
},
},
},
{
name: 'customRichText',
type: 'richText',
label: 'Customized Rich Text',
required: true,
admin: {
elements: [
'h2',
'h3',
Button,
],
leaves: [
'bold',
PurpleBackground,
],
},
},
],
};
export default RichText;

View File

@@ -1,99 +0,0 @@
import { CollectionConfig } from '../../src/collections/config/types';
const Select: CollectionConfig = {
slug: 'select',
labels: {
singular: 'Select',
plural: 'Selects',
},
fields: [
{
name: 'select',
type: 'select',
options: [{
value: 'one',
label: 'One',
}, {
value: 'two',
label: 'Two',
}, {
value: 'three',
label: 'Three',
}],
label: 'Select From',
required: true,
},
{
name: 'selectHasMany',
type: 'select',
options: [{
value: 'one',
label: 'One',
}, {
value: 'two',
label: 'Two',
}, {
value: 'three',
label: 'Three',
}],
label: 'Select HasMany',
required: true,
hasMany: true,
},
{
name: 'selectJustStrings',
type: 'select',
options: ['blue', 'green', 'yellow'],
label: 'Select Just Strings',
required: true,
hasMany: true,
},
{
name: 'selectWithEmptyString',
type: 'select',
defaultValue: '',
options: [{
value: '',
label: 'None',
}, {
value: 'option',
label: 'Option',
}],
required: true,
},
{
name: 'radio',
type: 'radio',
options: [{
value: 'one',
label: 'One',
}, {
value: 'two',
label: 'Two',
}, {
value: 'three',
label: 'Three',
}],
label: 'Choose From',
required: true,
},
{
name: 'radioWithEmptyString',
type: 'radio',
defaultValue: '',
options: [{
value: '',
label: 'None',
}, {
value: 'one',
label: 'One',
}, {
value: 'two',
label: 'Two',
}],
required: true,
},
],
};
export default Select;

View File

@@ -1,76 +0,0 @@
import { CollectionConfig } from '../../src/collections/config/types';
import checkRole from '../access/checkRole';
const StrictAccess: CollectionConfig = {
slug: 'strict-access',
labels: {
singular: 'Strict Access',
plural: 'Strict Access',
},
admin: {
useAsTitle: 'address',
},
access: {
create: () => true,
read: ({ req: { user } }) => {
if (checkRole(['admin'], user)) {
return true;
}
if (user) {
return {
owner: {
equals: user.id,
},
};
}
return false;
},
update: ({ req: { user } }) => {
if (checkRole(['admin'], user)) {
return true;
}
if (user) {
return {
owner: {
equals: user.id,
},
};
}
return false;
},
delete: ({ req: { user } }) => checkRole(['admin'], user),
},
fields: [
{
name: 'address',
type: 'text',
label: 'Address',
required: true,
},
{
name: 'city',
type: 'text',
label: 'City',
required: true,
},
{
name: 'state',
type: 'text',
label: 'State',
required: true,
},
{
name: 'zip',
type: 'number',
label: 'ZIP Code',
required: true,
},
],
timestamps: true,
};
export default StrictAccess;

View File

@@ -1,25 +0,0 @@
import { CollectionConfig } from '../../src/collections/config/types';
const Uniques: CollectionConfig = {
slug: 'uniques',
labels: {
singular: 'Unique',
plural: 'Uniques',
},
fields: [
{
name: 'title',
type: 'text',
label: 'Title',
required: true,
unique: true,
},
{
name: 'description',
type: 'textarea',
label: 'Description',
},
],
};
export default Uniques;

View File

@@ -1,35 +0,0 @@
import { CollectionConfig } from '../../src/collections/config/types';
const UnstoredMedia: CollectionConfig = {
slug: 'unstored-media',
labels: {
singular: 'Unstored Media',
plural: 'Unstored Media',
},
access: {
read: () => true,
},
upload: {
staticURL: '/unstored-media',
disableLocalStorage: true,
imageSizes: [
{
name: 'tablet',
width: 640,
height: 480,
crop: 'left top',
},
],
},
fields: [
{
name: 'alt',
label: 'Alt Text',
type: 'text',
required: true,
localized: true,
},
],
};
export default UnstoredMedia;

View File

@@ -1,141 +0,0 @@
import { CollectionConfig } from '../../src/collections/config/types';
const Validations: CollectionConfig = {
slug: 'validations',
labels: {
singular: 'Validation',
plural: 'Validations',
},
access: {
read: () => true,
},
fields: [
{
name: 'validationOptions',
type: 'text',
label: 'Text with siblingData Validation',
required: true,
validate: (value: string, { data, siblingData, id, operation, user }) => {
if (typeof value === 'undefined') {
return 'Validation is missing value';
}
if (data?.text !== 'test') {
return 'The next field should be test';
}
if (siblingData?.text !== 'test') {
return 'The next field should be test';
}
if (!user) {
return 'ValidationOptions is missing "user"';
}
if (typeof operation === 'undefined') {
return 'ValidationOptions is missing "operation"';
}
if (operation === 'update' && typeof id === 'undefined') {
return 'ValidationOptions is missing "id"';
}
return true;
},
},
{
name: 'text',
type: 'text',
label: 'Text',
required: true,
validate: (value) => {
const result = value === 'test';
if (!result) {
return 'The only accepted value of this field is "test".';
}
return true;
},
},
{
type: 'row',
fields: [
{
name: 'lessThan10',
label: 'Less than 10',
type: 'number',
required: true,
validate: (value) => {
const result = parseInt(value, 10) < 10;
if (!result) {
return 'The value of this field needs to be less than 10.';
}
return true;
},
}, {
name: 'greaterThan10LessThan50',
label: 'Greater than 10, Less than 50',
type: 'number',
required: true,
min: 10,
max: 50,
},
],
},
{
type: 'array',
label: 'Should have at least 3 rows',
name: 'atLeast3Rows',
required: true,
validate: (value) => {
const result = value >= 3;
if (!result) {
return 'This array needs to have at least 3 rows.';
}
return true;
},
fields: [
{
type: 'number',
name: 'greaterThan30',
label: 'Number should be greater than 30',
required: true,
validate: (value) => {
const result = value > 30;
if (!result) {
return 'This value of this field needs to be greater than 30.';
}
return true;
},
},
],
},
{
type: 'array',
label: 'Default array validation',
name: 'array',
required: true,
fields: [
{
type: 'number',
name: 'lessThan20',
label: 'Number should be less than 20',
required: true,
validate: (value) => {
const result = value < 20;
if (!result) {
return 'This value of this field needs to be less than 20.';
}
return true;
},
},
],
},
],
};
export default Validations;

View File

@@ -1,15 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="application-name" content="My Payload Application" />
</head>
<body>
<div id="app"></div>
<div id="portal"></div>
</body>
</html>

View File

@@ -1,9 +0,0 @@
import React from 'react';
const CollectionDescription: React.FC = () => (
<div>
Collection description
</div>
);
export default CollectionDescription;

View File

@@ -1,11 +0,0 @@
import React from 'react';
const CustomDescriptionComponent: React.FC = ({ value }) => (
<div>
Character count:
{' '}
{ value?.length || 0 }
</div>
);
export default CustomDescriptionComponent;

View File

@@ -1,5 +0,0 @@
import React from 'react';
const CustomAccountView: React.FC = () => <div>fake account view</div>;
export default CustomAccountView;

View File

@@ -1,5 +0,0 @@
import React from 'react';
const CustomDashboardView: React.FC = () => <div>fake dashboard view</div>;
export default CustomDashboardView;

View File

@@ -1,43 +0,0 @@
import checkRole from '../access/checkRole';
import Quote from '../blocks/Quote';
import CallToAction from '../blocks/CallToAction';
import { GlobalConfig } from '../../src/globals/config/types';
const BlocksGlobal: GlobalConfig = {
slug: 'blocks-global',
label: 'Blocks Global',
versions: {
max: 20,
drafts: {
autosave: true,
},
},
access: {
update: ({ req: { user } }) => checkRole(['admin'], user),
read: ({ draft, req: { user } }) => {
// To read a draft of this global, you need to be authenticated
if (draft) {
return Boolean(user);
}
return true;
},
},
fields: [
{
name: 'title',
type: 'text',
required: true,
localized: true,
},
{
name: 'blocks',
label: 'Blocks',
type: 'blocks',
blocks: [Quote, CallToAction],
localized: true,
},
],
};
export default BlocksGlobal;

View File

@@ -1,37 +0,0 @@
import { GlobalConfig } from '../../src/globals/config/types';
import checkRole from '../access/checkRole';
const GlobalWithAccess: GlobalConfig = {
slug: 'global-with-access',
label: 'Global with Strict Access',
access: {
update: ({ req: { user } }) => checkRole(['admin'], user),
read: ({ req: { user } }) => checkRole(['admin'], user),
},
fields: [
{
name: 'title',
label: 'Site Title',
type: 'text',
maxLength: 100,
required: true,
},
{
name: 'relationship',
label: 'Test Relationship',
type: 'relationship',
relationTo: 'localized-posts',
hasMany: true,
required: true,
},
{
name: 'singleRelationship',
label: 'Test Single Relationship',
type: 'relationship',
relationTo: 'localized-posts',
required: true,
},
],
};
export default GlobalWithAccess;

View File

@@ -1,32 +0,0 @@
import { GlobalConfig } from '../../src/globals/config/types';
import checkRole from '../access/checkRole';
const NavigationArray: GlobalConfig = {
slug: 'navigation-array',
access: {
update: ({ req: { user } }) => checkRole(['admin', 'user'], user),
read: () => true,
},
admin: {
description: 'A description for the editor',
},
fields: [
{
name: 'array',
label: 'Array',
type: 'array',
localized: true,
fields: [{
name: 'text',
label: 'Text',
type: 'text',
}, {
name: 'textarea',
label: 'Textarea',
type: 'textarea',
}],
},
],
};
export default NavigationArray;

View File

@@ -1,14 +0,0 @@
const babelConfig = require('../babel.config');
require('@babel/register')({
...babelConfig,
extensions: ['.ts', '.tsx', '.js', '.jsx'],
env: {
development: {
sourceMaps: 'inline',
retainLines: true,
},
},
});
require('./server.ts');

View File

@@ -1,747 +0,0 @@
/* tslint:disable */
/**
* This file was automatically generated by Payload CMS.
* DO NOT MODIFY IT BY HAND. Instead, modify your source Payload config,
* and re-run `payload generate:types` to regenerate this file.
*/
export interface Config {}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "blocks-global".
*/
export interface BlocksGlobal {
id: string;
_status?: 'draft' | 'published';
title: string;
blocks?: (
| {
quote: string;
color: string;
id?: string;
blockName?: string;
blockType: 'quote';
}
| {
label: string;
url: string;
id?: string;
blockName?: string;
blockType: 'cta';
}
)[];
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "navigation-array".
*/
export interface NavigationArray {
id: string;
array?: {
text?: string;
textarea?: string;
id?: string;
}[];
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "global-with-access".
*/
export interface GlobalWithStrictAccess {
id: string;
title: string;
relationship: (string | LocalizedPost)[];
singleRelationship: string | LocalizedPost;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "localized-posts".
*/
export interface LocalizedPost {
id: string;
title: string;
summary?: string;
description: string;
richText?: {
[k: string]: unknown;
}[];
priority?: number;
localizedGroup?: {
text?: string;
demoHiddenField?: string;
};
nonLocalizedGroup?: {
text?: string;
};
nonLocalizedArray?: {
localizedEmbeddedText?: string;
id?: string;
}[];
richTextBlocks?: {
content?: {
[k: string]: unknown;
}[];
id?: string;
blockName?: string;
blockType: 'richTextBlock';
}[];
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "admins".
*/
export interface Admin {
id: string;
email?: string;
resetPasswordToken?: string;
resetPasswordExpiration?: string;
enableAPIKey?: boolean;
apiKey?: string;
apiKeyIndex?: string;
loginAttempts?: number;
lockUntil?: string;
roles: ('admin' | 'editor' | 'moderator' | 'user' | 'viewer')[];
publicUser?: (string | PublicUser)[];
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "public-users".
*/
export interface PublicUser {
id: string;
email?: string;
resetPasswordToken?: string;
resetPasswordExpiration?: string;
_verified?: boolean;
_verificationToken?: string;
loginAttempts?: number;
lockUntil?: string;
adminOnly?: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "all-fields".
*/
export interface AllFields {
id: string;
text: string;
descriptionText?: string;
descriptionFunction?: string;
image?: string | Media;
select: 'option-1' | 'option-2' | 'option-3' | 'option-4';
selectMany: ('option-1' | 'option-2' | 'option-3' | 'option-4')[];
dayOnlyDateFieldExample: string;
timeOnlyDateFieldExample?: string;
point?: [number, number];
radioGroupExample: 'option-1' | 'option-2' | 'option-3';
email?: string;
number?: number;
group?: {
nestedText1?: string;
nestedText2?: string;
};
array?: {
arrayText1: string;
arrayText2: string;
arrayText3?: string;
checkbox?: boolean;
id?: string;
}[];
blocks: (
| {
testEmail: string;
id?: string;
blockName?: string;
blockType: 'email';
}
| {
testNumber: number;
id?: string;
blockName?: string;
blockType: 'number';
}
| {
quote: string;
color: string;
id?: string;
blockName?: string;
blockType: 'quote';
}
| {
label: string;
url: string;
id?: string;
blockName?: string;
blockType: 'cta';
}
)[];
relationship?: string | Conditions;
relationshipHasMany?: (string | LocalizedPost)[];
relationshipMultipleCollections?:
| {
value: string | LocalizedPost;
relationTo: 'localized-posts';
}
| {
value: string | Conditions;
relationTo: 'conditions';
};
textarea?: string;
richText: {
[k: string]: unknown;
}[];
slug: string;
checkbox?: boolean;
dateFieldExample?: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "media".
*/
export interface Media {
id: string;
url?: string;
filename?: string;
mimeType?: string;
filesize?: number;
width?: number;
height?: number;
sizes?: {
maintainedAspectRatio?: {
url?: string;
width?: number;
height?: number;
mimeType?: string;
filesize?: number;
filename?: string;
};
tablet?: {
url?: string;
width?: number;
height?: number;
mimeType?: string;
filesize?: number;
filename?: string;
};
mobile?: {
url?: string;
width?: number;
height?: number;
mimeType?: string;
filesize?: number;
filename?: string;
};
icon?: {
url?: string;
width?: number;
height?: number;
mimeType?: string;
filesize?: number;
filename?: string;
};
};
alt: string;
foundUploadSizes?: boolean;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "conditions".
*/
export interface Conditions {
id: string;
title: string;
enableTest?: boolean;
number?: number;
simpleCondition: string;
orCondition: string;
nestedConditions?: string;
blocks: (
| {
testEmail: string;
id?: string;
blockName?: string;
blockType: 'email';
}
| {
testNumber: number;
id?: string;
blockName?: string;
blockType: 'number';
}
| {
quote: string;
color: string;
id?: string;
blockName?: string;
blockType: 'quote';
}
| {
label: string;
url: string;
id?: string;
blockName?: string;
blockType: 'cta';
}
)[];
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "auto-label".
*/
export interface AutoLabel {
id: string;
autoLabelField?: string;
noLabel?: string;
labelOverride?: string;
testRelationship?: string | AllFields;
specialBlock?: {
testNumber?: number;
id?: string;
blockName?: string;
blockType: 'number';
}[];
noLabelBlock?: {
testNumber?: number;
id?: string;
blockName?: string;
blockType: 'number';
}[];
items?: {
itemName?: string;
id?: string;
}[];
noLabelArray?: {
textField?: string;
id?: string;
}[];
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "autosave-posts".
*/
export interface AutosavePost {
id: string;
_status?: 'draft' | 'published';
title: string;
description: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "blocks".
*/
export interface Blocks {
id: string;
_status?: 'draft' | 'published';
layout: (
| {
testEmail: string;
id?: string;
blockName?: string;
blockType: 'email';
}
| {
testNumber: number;
id?: string;
blockName?: string;
blockType: 'number';
}
| {
quote: string;
color: string;
id?: string;
blockName?: string;
blockType: 'quote';
}
| {
label: string;
url: string;
id?: string;
blockName?: string;
blockType: 'cta';
}
)[];
nonLocalizedLayout: (
| {
testEmail: string;
id?: string;
blockName?: string;
blockType: 'email';
}
| {
testNumber: number;
id?: string;
blockName?: string;
blockType: 'number';
}
| {
quote: string;
color: string;
id?: string;
blockName?: string;
blockType: 'quote';
}
| {
label: string;
url: string;
id?: string;
blockName?: string;
blockType: 'cta';
}
)[];
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "code".
*/
export interface Code {
id: string;
code: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "custom-id".
*/
export interface CustomID {
id: number;
name: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "default-values".
*/
export interface DefaultValueTest {
id: string;
text?: string;
image?: string | Media;
select?: 'option-1' | 'option-2' | 'option-3' | 'option-4';
selectMany?: ('option-1' | 'option-2' | 'option-3' | 'option-4')[];
radioGroupExample?: 'option-1' | 'option-2' | 'option-3';
email?: string;
number?: number;
group?: {
nestedText1?: string;
nestedText2?: string;
nestedText3?: string;
};
array?: {
arrayText1?: string;
arrayText2?: string;
arrayText3?: string;
checkbox?: boolean;
id?: string;
}[];
blocks?: (
| {
testEmail: string;
id?: string;
blockName?: string;
blockType: 'email';
}
| {
testNumber: number;
id?: string;
blockName?: string;
blockType: 'number';
}
| {
quote: string;
color: string;
id?: string;
blockName?: string;
blockType: 'quote';
}
| {
label: string;
url: string;
id?: string;
blockName?: string;
blockType: 'cta';
}
)[];
relationship?: string | Conditions;
relationshipHasMany?: (string | LocalizedPost)[];
relationshipMultipleCollections?:
| {
value: string | LocalizedPost;
relationTo: 'localized-posts';
}
| {
value: string | Conditions;
relationTo: 'conditions';
};
textarea?: string;
slug?: string;
checkbox?: boolean;
richText?: {
[k: string]: unknown;
}[];
asyncArray?: {
child?: string;
id?: string;
}[];
asyncText?: string;
function?: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "files".
*/
export interface File {
id: string;
url?: string;
filename?: string;
mimeType?: string;
filesize?: number;
type: 'Type 1' | 'Type 2' | 'Type 3';
owner: string | Admin;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "geolocation".
*/
export interface Geolocation {
id: string;
location?: [number, number];
localizedPoint?: [number, number];
group?: {
point?: [number, number];
};
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "hidden-fields".
*/
export interface HiddenFields {
id: string;
title: string;
hiddenAdmin: string;
hiddenAPI: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "hooks".
*/
export interface Hook {
id: string;
title: string;
description: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "localized-arrays".
*/
export interface LocalizedArray {
id: string;
array: {
allowPublicReadability?: boolean;
arrayText1: string;
arrayText2: string;
arrayText3?: string;
id?: string;
}[];
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "local-operations".
*/
export interface LocalOperation {
id: string;
title: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "images".
*/
export interface Image {
id: string;
upload?: string | Media;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "nested-arrays".
*/
export interface NestedArray {
id: string;
array: {
parentIdentifier: string;
nestedArray: {
childIdentifier: string;
deeplyNestedArray: {
grandchildIdentifier?: string;
id?: string;
}[];
id?: string;
}[];
id?: string;
}[];
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "previewable-post".
*/
export interface PreviewablePost {
id: string;
title: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "relationship-a".
*/
export interface RelationshipA {
id: string;
post?: string | RelationshipB;
LocalizedPost?: (string | LocalizedPost)[];
postLocalizedMultiple?: (
| {
value: string | LocalizedPost;
relationTo: 'localized-posts';
}
| {
value: string | AllFields;
relationTo: 'all-fields';
}
| {
value: number | CustomID;
relationTo: 'custom-id';
}
)[];
postManyRelationships?: {
value: string | RelationshipB;
relationTo: 'relationship-b';
};
postMaxDepth?: string | RelationshipB;
customID?: (number | CustomID)[];
filterRelationship?: string | RelationshipB;
files?: string | File;
demoHiddenField?: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "relationship-b".
*/
export interface RelationshipB {
id: string;
title?: string;
disableRelation: boolean;
post?: (string | RelationshipA)[];
postManyRelationships?:
| {
value: string | RelationshipA;
relationTo: 'relationship-a';
}
| {
value: string | Media;
relationTo: 'media';
};
localizedPosts?: (
| {
value: string | LocalizedPost;
relationTo: 'localized-posts';
}
| {
value: string | PreviewablePost;
relationTo: 'previewable-post';
}
)[];
nonLocalizedRelationToMany?:
| {
value: string | LocalizedPost;
relationTo: 'localized-posts';
}
| {
value: string | RelationshipA;
relationTo: 'relationship-a';
};
strictAccess?: string | StrictAccess;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "strict-access".
*/
export interface StrictAccess {
id: string;
address: string;
city: string;
state: string;
zip: number;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "rich-text".
*/
export interface RichText {
id: string;
_status?: 'draft' | 'published';
title?: string;
defaultRichText: {
[k: string]: unknown;
}[];
customRichText: {
[k: string]: unknown;
}[];
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "select".
*/
export interface Select {
id: string;
select: 'one' | 'two' | 'three';
selectHasMany: ('one' | 'two' | 'three')[];
selectJustStrings: ('blue' | 'green' | 'yellow')[];
selectWithEmptyString: '' | 'option';
radio: 'one' | 'two' | 'three';
radioWithEmptyString: '' | 'one' | 'two';
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "validations".
*/
export interface Validation {
id: string;
validationOptions: string;
text: string;
lessThan10: number;
greaterThan10LessThan50: number;
atLeast3Rows: {
greaterThan30: number;
id?: string;
}[];
array: {
lessThan20: number;
id?: string;
}[];
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "uniques".
*/
export interface Unique {
id: string;
title: string;
description?: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "unstored-media".
*/
export interface UnstoredMedia {
id: string;
url?: string;
filename?: string;
mimeType?: string;
filesize?: number;
width?: number;
height?: number;
sizes?: {
tablet?: {
url?: string;
width?: number;
height?: number;
mimeType?: string;
filesize?: number;
filename?: string;
};
};
alt: string;
}

View File

@@ -1,179 +0,0 @@
import path from 'path';
import { buildConfig } from '../src/config/build';
import Admin from './collections/Admin';
import AllFields from './collections/AllFields';
import AutoLabel from './collections/AutoLabel';
import Autosave from './collections/Autosave';
import Code from './collections/Code';
import Conditions from './collections/Conditions';
// import CustomComponents from './collections/CustomComponents';
import File from './collections/File';
import Blocks from './collections/Blocks';
import CustomID from './collections/CustomID';
import DefaultValues from './collections/DefaultValues';
import HiddenFields from './collections/HiddenFields';
import Hooks from './collections/Hooks';
import Localized from './collections/Localized';
import LocalizedArray from './collections/LocalizedArray';
import LocalOperations from './collections/LocalOperations';
import Media from './collections/Media';
import Images from './collections/Images';
import NestedArrays from './collections/NestedArrays';
import Preview from './collections/Preview';
import PublicUsers from './collections/PublicUsers';
import RelationshipA from './collections/RelationshipA';
import RelationshipB from './collections/RelationshipB';
import RichText from './collections/RichText';
import Select from './collections/Select';
import StrictAccess from './collections/StrictAccess';
import Validations from './collections/Validations';
import Uniques from './collections/Uniques';
import Geolocation from './collections/Geolocation';
import BlocksGlobal from './globals/BlocksGlobal';
import NavigationArray from './globals/NavigationArray';
import GlobalWithStrictAccess from './globals/GlobalWithStrictAccess';
import UnstoredMedia from './collections/UnstoredMedia';
import CustomRouteWithMinimalTemplate from './client/components/views/CustomMinimal';
import CustomRouteWithDefaultTemplate from './client/components/views/CustomDefault';
import AfterDashboard from './client/components/AfterDashboard';
import AfterNavLinks from './client/components/AfterNavLinks';
import BeforeLogin from './client/components/BeforeLogin';
// import CustomProvider from './client/components/CustomProvider';
export default buildConfig({
cookiePrefix: 'payload',
serverURL: 'http://localhost:3000',
typescript: {
outputFile: path.resolve(__dirname, './payload-types.ts'),
},
admin: {
user: 'admins',
indexHTML: path.resolve(__dirname, './client/index.html'),
// meta: {
// titleSuffix: '- Payload Demo',
// // ogImage: '/static/find-image-here.jpg',
// // favicon: '/img/whatever.png',
// },
// disable: true,
scss: path.resolve(__dirname, './client/scss/overrides.scss'),
components: {
// providers: [CustomProvider, CustomProvider],
routes: [
{
path: '/custom-minimal-route',
Component: CustomRouteWithMinimalTemplate,
},
{
path: '/custom-default-route',
Component: CustomRouteWithDefaultTemplate,
},
],
afterDashboard: [
AfterDashboard,
],
beforeLogin: [
BeforeLogin,
],
afterNavLinks: [
AfterNavLinks,
],
// Nav: () => (
// <div>Hello</div>
// ),
views: {
// Dashboard: CustomDashboardView,
// Account: CustomAccountView,
},
},
webpack: (config) => config,
},
collections: [
Admin,
AllFields,
AutoLabel,
Autosave,
Blocks,
Code,
Conditions,
// CustomComponents,
CustomID,
DefaultValues,
File,
Geolocation,
HiddenFields,
Hooks,
Localized,
LocalizedArray,
LocalOperations,
Media,
Images,
NestedArrays,
Preview,
PublicUsers,
RelationshipA,
RelationshipB,
RichText,
Select,
StrictAccess,
Validations,
Uniques,
UnstoredMedia,
],
globals: [
BlocksGlobal,
NavigationArray,
GlobalWithStrictAccess,
],
// cors: [
// 'http://localhost',
// 'http://localhost:3000',
// 'http://localhost:8080',
// 'http://localhost:8081',
// ],
// csrf: [
// 'http://localhost:3000',
// 'https://other-app-here.com',
// ],
routes: {
api: '/api',
admin: '/admin',
graphQL: '/graphql',
graphQLPlayground: '/graphql-playground',
},
defaultDepth: 2,
graphQL: {
maxComplexity: 1000,
disablePlaygroundInProduction: false,
disable: false,
},
// rateLimit: {
// window: 15 * 60 * 100,
// max: 100,
// trustProxy: true,
// skip: (req) => req.ip === '127.0.0.1',
// },
maxDepth: 10,
localization: {
locales: [
'en',
'es',
],
defaultLocale: 'en',
fallback: true,
},
// indexSortableFields: true,
hooks: {
afterError: (err) => {
if (process.env.DISABLE_LOGGING !== 'true') {
console.error('global error config handler', err);
}
},
},
upload: {
limits: {
fileSize: 10000000, // 10MB
},
},
});

View File

@@ -1,40 +0,0 @@
/* eslint-disable no-console */
import express from 'express';
import path from 'path';
import payload from '../src';
const expressApp = express();
expressApp.use('/static', express.static(path.resolve(__dirname, 'client/static')));
payload.init({
secret: 'SECRET_KEY',
mongoURL: process.env.MONGO_URL || 'mongodb://localhost/payload',
express: expressApp,
email: {
fromName: 'Payload',
fromAddress: 'hello@payloadcms.com',
},
onInit: (app) => {
app.logger.info('Payload Demo Initialized');
},
});
const externalRouter = express.Router();
externalRouter.use(payload.authenticate);
externalRouter.get('/', (req, res) => {
if (req.user) {
return res.send(`Authenticated successfully as ${req.user.email}.`);
}
return res.send('Not authenticated');
});
expressApp.use('/external-route', externalRouter);
expressApp.listen(3000, async () => {
payload.logger.info(`Admin URL on ${payload.getAdminURL()}`);
payload.logger.info(`API URL on ${payload.getAPIURL()}`);
});

View File

@@ -27,8 +27,10 @@ If a Collection supports [`Authentication`](/docs/authentication/overview), the
| **[`unlock`](#unlock)** | Used to restrict which users can access the `unlock` operation |
**Example Collection config:**
```js
export default {
```ts
import { CollectionConfig } from 'payload/types';
const Posts: CollectionConfig = {
slug: "posts",
// highlight-start
access: {
@@ -40,58 +42,135 @@ export default {
},
// highlight-end
};
export default Categories;
```
### Create
Returns a boolean which allows/denies access to the `create` request.
**Available argument properties :**
**Available argument properties:**
| Option | Description |
| ---------- | ----------- |
| **`req`** | The Express `request` object containing the currently authenticated `user` |
| **`data`** | The data passed to create the document with. |
**Example:**
```ts
const PublicUsers = {
slug: 'public-users',
access: {
// highlight-start
// allow guest users to self-registration
create: () => true,
// highlight-end
...
},
fields: [ ... ],
}
```
### Read
Read access functions can return a boolean result or optionally return a [query constraint](/docs/queries/overview) which limits the documents that are returned to only those that match the constraint you provide. This can be helpful to restrict users' access to only certain documents however you specify.
**Available argument properties :**
**Available argument properties:**
| Option | Description |
| --------- | ----------- |
| **`req`** | The Express `request` object containing the currently authenticated `user` |
| **`id`** | `id` of document requested, if within `findByID`. |
| **`id`** | `id` of document requested, if within `findByID` |
**Example:**
```ts
import { Access } from 'payload/config';
const canReadPage: Access = ({ req: { user } }) => {
// allow authenticated users
if (user) {
return true;
}
// using a query constraint, guest users can access when a field named 'isPublic' is set to true
return {
// assumes we have a checkbox field named 'isPublic'
isPublic: {
equals: true,
},
}
};
```
### Update
Update access functions can return a boolean result or optionally return a [query constraint](/docs/queries/overview) to limit the document(s) that can be updated by the currently authenticated user. For example, returning a `query` from the `update` Access Control is helpful in cases where you would like to restrict a user to only being able to update the documents containing a `createdBy` relationship field equal to the user's ID.
**Available argument properties :**
**Available argument properties:**
| Option | Description |
| ---------- | ----------- |
| **`req`** | The Express `request` object containing the currently authenticated `user` |
| **`id`** | `id` of document requested to update |
| **`data`** | The data passed to update the document with. |
| **`data`** | The data passed to update the document with |
**Example:**
```ts
import { Access } from 'payload/config';
const canUpdateUser: Access = ({ req: { user }, id }) => {
// allow users with a role of 'admin'
if (user.roles && user.roles.some(role => role === 'admin')) {
return true;
}
// allow any other users to update only oneself
return user.id === id;
};
```
### Delete
Similarly to the Update function, returns a boolean or a [query constraint](/docs/queries/overview) to limit which documents can be deleted by which users.
**Available argument properties :**
**Available argument properties:**
| Option | Description |
| --------- | ----------- |
| **`req`** | The Express `request` object with additional `user` property, which is the currently logged in user |
| **`id`** | `id` of document requested to delete |
**Example:**
```ts
import { Access } from 'payload/config'
const canDeleteCustomer: Access = async ({ req, id }) => {
if (!id) {
// allow the admin UI to show controls to delete since it is indeterminate without the id
return true;
}
// query another collection using the id
const result = await req.payload.find({
collection: 'contracts',
limit: 0,
depth: 0,
where: {
customer: { equals: id },
},
});
return result.totalDocs === 0;
};
```
### Admin
If the Collection is [used to access the Payload Admin panel](/docs/admin/overview#the-admin-user-collection), the `Admin` Access Control function determines whether or not the currently logged in user can access the admin UI.
**Available argument properties :**
**Available argument properties:**
| Option | Description |
| --------- | ----------- |
@@ -101,7 +180,7 @@ If the Collection is [used to access the Payload Admin panel](/docs/admin/overvi
Determines which users can [unlock](/docs/authentication/operations#unlock) other users who may be blocked from authenticating successfully due to [failing too many login attempts](/docs/authentication/config#options).
**Available argument properties :**
**Available argument properties:**
| Option | Description |
| --------- | ----------- |

View File

@@ -17,8 +17,10 @@ Field Access Control is specified with functions inside a field's config. All fi
| **[`update`](#update)** | Allows or denies the ability to update a field's value |
**Example Collection config:**
```js
export default {
```ts
import { CollectionConfig } from 'payload/types';
const Posts: CollectionConfig = {
slug: 'posts',
fields: [
{
@@ -33,7 +35,7 @@ export default {
// highlight-end
};
],
}
};
```
### Create

View File

@@ -18,16 +18,20 @@ You can define Global-level Access Control within each Global's `access` propert
| **[`update`](#update)** | Used in the `update` Global operation |
**Example Global config:**
```js
export default {
```ts
import { GlobalConfig } from 'payload/types';
const Header: GlobalConfig = {
slug: "header",
// highlight-start
access: {
read: ({ req: { user } }) => { ... },
update: ({ req: { user } }) => { ... },
read: ({ req: { user } }) => { /* */ },
update: ({ req: { user } }) => { /* */ },
},
// highlight-end
};
export default Header;
```
### Read

View File

@@ -8,6 +8,11 @@ keywords: overview, access control, permissions, documentation, Content Manageme
Access control within Payload is extremely powerful while remaining easy and intuitive to manage. Declaring who should have access to what documents is no more complex than writing a simple JavaScript function that either returns a `boolean` or a [`query`](/docs/queries/overview) constraint to restrict which documents users can interact with.
<YouTube
id="DoPLyXG26Dg"
title="Overview of Payload Access Control"
/>
**Example use cases:**
- Allowing anyone `read` access to all `Post`s
@@ -23,7 +28,7 @@ Access control within Payload is extremely powerful while remaining easy and int
**Default Access function:**
```js
```ts
const defaultPayloadAccess = ({ req: { user } }) => {
// Return `true` if a user is found
// and `false` if it is undefined or null
@@ -50,7 +55,7 @@ You can manage access within Payload on three different levels:
<Banner type="success">
<strong>Note:</strong><br/>
Access control functions are utilized in two places. It's important to understand how and when your access control is executed.
<Banner />
</Banner>
#### As you execute operations
@@ -67,6 +72,6 @@ To accomplish this, Payload ships with an `Access` operation, which is executed
<Banner type="warning">
<strong>Important:</strong><br/>
When your access control functions are executed via the <strong>access</strong> operation, the <strong>id</strong> and <strong>data</strong> arguments will be <strong>undefined</strong>, because Payload is executing your functions without referencing a specific document.
<Banner />
</Banner>
If you use `id` or `data` within your access control functions, make sure to check that they are defined first. If they are not, then you can assume that your access control is being executed via the `access` operation, to determine solely what the user can do within the Admin UI.

View File

@@ -22,8 +22,8 @@ You can override a set of admin panel-wide components by providing a component t
| Path | Description |
| --------------------- | -------------|
| **`Nav`** | Contains the sidebar and mobile Nav in its entirety. |
| **`BeforeDashboard`** | Array of components to inject into the built-in Dashboard, _before_ the default dashboard contents. [Demo](https://github.com/payloadcms/payload/tree/master/demo/client/components/AfterDashboard) |
| **`AfterDashboard`** | Array of components to inject into the built-in Dashboard, _after_ the default dashboard contents. |
| **`BeforeDashboard`** | Array of components to inject into the built-in Dashboard, _before_ the default dashboard contents. |
| **`AfterDashboard`** | Array of components to inject into the built-in Dashboard, _after_ the default dashboard contents. [Demo](https://github.com/payloadcms/payload/tree/master/test/admin/components/AfterDashboard/index.tsx)|
| **`BeforeLogin`** | Array of components to inject into the built-in Login, _before_ the default login form. |
| **`AfterLogin`** | Array of components to inject into the built-in Login, _after_ the default login form. |
| **`BeforeNavLinks`** | Array of components to inject into the built-in Nav, _before_ the links themselves. |
@@ -38,9 +38,16 @@ You can override a set of admin panel-wide components by providing a component t
#### Full example:
`payload.config.js`
```js
import { buildConfig } from 'payload/config';
import { MyCustomNav, MyCustomLogo, MyCustomIcon, MyCustomAccount, MyCustomDashboard, MyProvider } from './customComponents.js';
```ts
import { buildConfig } from 'payload/config'
import {
MyCustomNav,
MyCustomLogo,
MyCustomIcon,
MyCustomAccount,
MyCustomDashboard,
MyProvider,
} from './customComponents';
export default buildConfig({
admin: {
@@ -55,12 +62,12 @@ export default buildConfig({
Dashboard: MyCustomDashboard,
},
providers: [MyProvider],
}
}
})
},
},
});
```
*For more examples regarding how to customize components, look at the [demo app](https://github.com/payloadcms/payload/tree/master/demo).*
*For more examples regarding how to customize components, look at the following [examples](https://github.com/payloadcms/payload/tree/master/test/admin/components).*
### Collections
@@ -90,78 +97,73 @@ All Payload fields support the ability to swap in your own React components. So,
**Fields support the following custom components:**
| Component | Description |
| --------------- | -------------|
| **`Filter`** | Override the text input that is presented in the `List` view when a user is filtering documents by the customized field. |
| **`Cell`** | Used in the `List` view's table to represent a table-based preview of the data stored in the field. |
| **`Field`** | Swap out the field itself within all `Edit` views. |
| Component | Description |
| --------------- |------------------------------------------------------------------------------------------------------------------------------|
| **`Filter`** | Override the text input that is presented in the `List` view when a user is filtering documents by the customized field. |
| **`Cell`** | Used in the `List` view's table to represent a table-based preview of the data stored in the field. [More](#cell-component) |
| **`Field`** | Swap out the field itself within all `Edit` views. [More](#field-component) |
## Cell Component
These are the props that will be passed to your custom Cell to use in your own components.
| Property | Description |
|--------------|-------------------------------------------------------------------|
| **`field`** | An object that includes the field configuration. |
| **`colIndex`** | A unique number for the column in the list. |
| **`collection`** | An object with the config of the collection that the field is in. |
| **`cellData`** | The data for the field that the cell represents. |
| **`rowData`** | An object with all the field values for the row. |
#### Example
```tsx
import React from 'react';
import './index.scss';
const baseClass = 'custom-cell';
const CustomCell: React.FC<Props> = (props) => {
const {
field,
colIndex,
collection,
cellData,
rowData,
} = props;
return (
<span className={baseClass}>
{ cellData }
</span>
);
};
```
## Field Component
When writing your own custom components you can make use of a number of hooks to set data, get reactive changes to other fields, get the id of the document or interact with a context from a custom provider.
### Sending and receiving values from the form
When swapping out the `Field` component, you'll be responsible for sending and receiving the field's `value` from the form itself. To do so, import the `useField` hook as follows:
```js
import { useField } from 'payload/components/forms';
```tsx
import { useField } from 'payload/components/forms'
const CustomTextField = ({ path }) => {
type Props = { path: string }
const CustomTextField: React.FC<Props> = ({ path }) => {
// highlight-start
const { value, setValue } = useField({ path });
const { value, setValue } = useField<Props>({ path })
// highlight-end
return (
<input
onChange={(e) => setValue(e.target.value)}
value={value}
/>
)
return <input onChange={e => setValue(e.target.value)} value={value.path} />
}
```
### Getting other field values from the form
There are times when a custom field component needs to have access to data from other fields. This can be done using `getDataByPath` from `useWatchForm` as follows:
```js
import { useWatchForm } from 'payload/components/forms';
const DisplayFee = () => {
const { getDataByPath } = useWatchForm();
const amount = getDataByPath('amount');
const feePercentage = getDataByPath('feePercentage');
if (amount && feePercentage) {
return (
<span>The fee is ${ amount * feePercentage / 100 }</span>
);
}
};
```
### Getting the document ID
The document ID can be very useful for certain custom components. You can get the `id` from the `useDocumentInfo` hook. Here is an example of a `UI` field using `id` to link to related collections:
```js
import { useDocumentInfo } from 'payload/components/utilities';
const LinkFromCategoryToPosts = () => {
// highlight-start
const { id } = useDocumentInfo();
// highlight-end
// id will be undefined on the create form
if (!id) {
return null;
}
return (
<a href={`/admin/collections/posts?where[or][0][and][0][category][in][0]=[${id}]`} >
View posts
</a>
)
};
```
<Banner type="success">
For more information regarding the hooks that are available to you while you build custom components, including the <strong>useField</strong> hook, <a href="/docs/admin/hooks" style={{color: 'black'}}>click here</a>.
</Banner>
## Custom routes
@@ -195,12 +197,12 @@ Your custom route components will be given all the props that a React Router `<R
#### Example
You can find examples of custom route views in the [Payload source code `/demo/client/components/views` folder](https://github.com/payloadcms/payload/tree/master/demo/client/components/views). There, you'll find two custom routes:
You can find examples of custom route views in the [Payload source code `/test/admin/components/views` folder](https://github.com/payloadcms/payload/tree/master/test/admin/components/views). There, you'll find two custom routes:
1. A custom view that uses the `DefaultTemplate`, which is the built-in Payload template that displays the sidebar and "eyebrow nav"
1. A custom view that uses the `MinimalTemplate` - which is just a centered template used for things like logging in or out
To see how to pass in your custom views to create custom routes of your own, take a look at the `admin.components.routes` property of the [Payload demo config](https://github.com/payloadcms/payload/blob/master/demo/payload.config.ts).
To see how to pass in your custom views to create custom routes of your own, take a look at the `admin.components.routes` property of the [Payload test admin config](https://github.com/payloadcms/payload/blob/master/test/admin/config.ts).
## Custom providers
@@ -222,10 +224,10 @@ To make use of Payload SCSS variables / mixins to use directly in your own compo
In any custom component you can get the selected locale with the `useLocale` hook. Here is a simple example:
```js
```tsx
import { useLocale } from 'payload/components/utilities';
const Greeting = () => {
const Greeting: React.FC = () => {
// highlight-start
const locale = useLocale();
// highlight-end
@@ -237,6 +239,6 @@ const Greeting = () => {
return (
<span> { trans[locale] } </span>
)
}
);
};
```

View File

@@ -1,7 +1,7 @@
---
title: Customizing CSS & SCSS
label: Customizing CSS
order: 30
order: 40
desc: Customize your Payload admin panel further by adding your own CSS or SCSS style sheet to the configuration, powerful theme and design options are waiting for you.
keywords: admin, css, scss, documentation, Content Management System, cms, headless, javascript, node, react, express
---
@@ -13,7 +13,7 @@ You can add your own CSS by providing your base Payload config with a path to yo
To do so, provide your base Payload config with a path to your own stylesheet. It can be either a CSS or SCSS file.
**Example in payload.config.js:**
```js
```ts
import { buildConfig } from 'payload/config';
import path from 'path';
@@ -21,51 +21,29 @@ const config = buildConfig({
admin: {
css: path.resolve(__dirname, 'relative/path/to/stylesheet.scss'),
},
})
});
```
### Overriding SCSS variables
### Overriding built-in styles
You can specify your own SCSS variable stylesheet that will allow for the override of Payload's base theme. This unlocks a ton of powerful theming and design options such as:
To make it as easy as possible for you to override our styles, Payload uses [BEM naming conventions](http://getbem.com/) for all CSS within the Admin UI. If you provide your own CSS, you can override any built-in styles easily.
- Changing dashboard font families
- Modifying color palette
- Creating a dark theme
- Etc.
In addition to adding your own style definitions, you can also override Payload's built-in CSS variables. We use as much as possible behind the scenes, and you can override any of them that you'd like to.
To do so, provide your base Payload config with a path to your own SCSS variable sheet.
You can find the built-in Payload CSS variables within [`./src/admin/scss/app.scss`](https://github.com/payloadcms/payload/blob/master/src/admin/scss/app.scss) and [`./src/admin/scss/colors.scss`](https://github.com/payloadcms/payload/blob/master/src/admin/scss/colors.scss). The following variables are defined and can be overridden:
**NOTE: Before you start editing your SCSS file, make sure you install 'sass-loader' & 'node-sass' as dev dependencies.**
**Node**
```
npm install sass-loader node-sass --save-dev
```
**YARN**
```
yarn add sass-loader node-sass --save-dev
```
- Breakpoints
- Base color shades (white to black by default)
- Success / warning / error color shades
- Theme-specific colors (background, input background, text color, etc.)
- Elevation colors (used to determine how "bright" something should be when compared to the background)
- Fonts
- Horizontal gutter
**Example in payload.config.js:**
```js
import { buildConfig } from 'payload/config';
import path from 'path';
#### Dark mode
const config = buildConfig({
admin: {
scss: path.resolve(__dirname, 'relative/path/to/vars.scss'),
},
})
```
**Example stylesheet override:**
```scss
$font-body: 'Papyrus';
$style-radius-m: 10px;
```
To reference all Sass variables that you can override, look at the default [SCSS variable stylesheet](https://github.com/payloadcms/payload/blob/master/src/admin/scss/vars.scss) within the Payload source code.
<Banner type="error">
<strong>Warning:</strong><br />
Only SCSS variables, mixins, functions, and extends are allowed in <strong>your SCSS overrides</strong>. Do not attempt to add any CSS declarations to this file, as this variable stylesheet is imported by many components throughout the Payload Admin panel and will result in your CSS definition(s) being duplicated many times. If you need to add real CSS definitions, see "Adding your own CSS / SCSS" the top of this page.
<Banner type="warning">
If you're overriding colors or theme elevations, make sure to consider how your changes will affect dark mode.
</Banner>
By default, Payload automatically overrides all `--theme-elevation`s and inverts all success / warning / error shades to suit dark mode. We also update some base theme variables like `--theme-bg`, `--theme-text`, etc.

271
docs/admin/hooks.mdx Normal file
View File

@@ -0,0 +1,271 @@
---
title: React Hooks
label: React Hooks
order: 30
desc: Make use of all of the powerful React hooks that Payload provides.
keywords: admin, components, custom, documentation, Content Management System, cms, headless, javascript, node, react, express
---
Payload provides a variety of powerful hooks that can be used within your own React components. With them, you can interface with Payload itself and build just about any type of complex customization you can think of—directly in familiar React code.
### useField
The `useField` hook is used internally within every applicable Payload field component, and it manages sending and receiving a field's state from its parent form.
Outside of internal use, its most common use-case is in custom `Field` components. When you build a custom React `Field` component, you'll be responsible for sending and receiving the field's `value` from the form itself. To do so, import the `useField` hook as follows:
```tsx
import { useField } from 'payload/components/forms'
type Props = { path: string }
const CustomTextField: React.FC<Props> = ({ path }) => {
// highlight-start
const { value, setValue } = useField<string>({ path })
// highlight-end
return <input onChange={e => setValue(e.target.value)} value={value.path} />
}
```
The `useField` hook accepts an `args` object and sends back information and helpers for you to make use of:
```ts
const field = useField<string>({
path: 'fieldPathHere', // required
validate: myValidateFunc, // optional
disableFormData?: false, // if true, the field's data will be ignored
condition?: myConditionHere, // optional, used to skip validation if condition fails
})
// Here is what `useField` sends back
const {
showError, // whether or not the field should show as errored
errorMessage, // the error message to show, if showError
value, // the current value of the field from the form
formSubmitted, // if the form has been submitted
formProcessing, // if the form is currently processing
setValue, // method to set the field's value in form state
initialValue, // the initial value that the field mounted with
} = field;
// The rest of your component goes here
```
### useFormFields
There are times when a custom field component needs to have access to data from other fields, and you have a few options to do so. The `useFormFields` hook is a powerful and highly performant way to retrieve a form's field state, as well as to retrieve the `dispatchFields` method, which can be helpful for setting other fields' form states from anywhere within a form.
<Banner type="success">
<strong>This hook is great for retrieving only certain fields from form state</strong> because it ensures that it will only cause a rerender when the items that you ask for change.
</Banner>
Thanks to the awesome package [`use-context-selector`](https://github.com/dai-shi/use-context-selector), you can retrieve a specific field's state easily. This is ideal because you can ensure you have an up-to-date field state, and your component will only re-render when _that field's state_ changes.
You can pass a Redux-like selector into the hook, which will ensure that you retrieve only the field that you want. The selector takes an argument with type of `[fields: Fields, dispatch: React.Dispatch<Action>]]`.
```tsx
import { useFormFields } from 'payload/components/forms';
const MyComponent: React.FC = () => {
// Get only the `amount` field state, and only cause a rerender when that field changes
const amount = useFormFields(([fields, dispatch]) => fields.amount);
// Do the same thing as above, but to the `feePercentage` field
const feePercentage = useFormFields(([fields, dispatch]) => fields.feePercentage);
if (typeof amount?.value !== 'undefined' && typeof feePercentage?.value !== 'undefined') {
return (
<span>The fee is ${(amount.value * feePercentage.value) / 100}</span>
);
}
};
```
### useAllFormFields
**To retrieve more than one field**, you can use the `useAllFormFields` hook. Your component will re-render when _any_ field changes, so use this hook only if you absolutely need to. Unlike the `useFormFields` hook, this hook does not accept a "selector", and it always returns an array with type of `[fields: Fields, dispatch: React.Dispatch<Action>]]`.
You can do lots of powerful stuff by retrieving the full form state, like using built-in helper functions to reduce field state to values only, or to retrieve sibling data by path.
```tsx
import { useAllFormFields, reduceFieldsToValues, getSiblingData } from 'payload/components/forms';
const ExampleComponent: React.FC = () => {
// the `fields` const will be equal to all fields' state,
// and the `dispatchFields` method is usable to send field state up to the form
const [fields, dispatchFields] = useAllFormFields();
// Pass in fields, and indicate if you'd like to "unflatten" field data.
// The result below will reflect the data stored in the form at the given time
const formData = reduceFieldsToValues(fields, true);
// Pass in field state and a path,
// and you will be sent all sibling data of the path that you've specified
const siblingData = getSiblingData(fields, 'someFieldName');
return (
// return some JSX here if necessary
)
};
```
##### Updating other fields' values
If you are building a custom component, then you should use `setValue` which is returned from the `useField` hook to programmatically set your field's value. But if you're looking to update _another_ field's value, you can use `dispatchFields` returned from `useFormFields`.
You can send the following actions to the `dispatchFields` function.
| Action | Description |
|------------------------|----------------------------------------------------------------------------|
| **`ADD_ROW`** | Adds a row of data (useful in array / block field data) |
| **`DUPLICATE_ROW`** | Duplicates a row of data (useful in array / block field data) |
| **`MODIFY_CONDITION`** | Updates a field's conditional logic result (true / false) |
| **`MOVE_ROW`** | Moves a row of data (useful in array / block field data) |
| **`REMOVE`** | Removes a field from form state |
| **`REMOVE_ROW`** | Removes a row of data from form state (useful in array / block field data) |
| **`REPLACE_STATE`** | Completely replaces form state |
| **`UPDATE`** | Update any property of a specific field's state |
To see types for each action supported within the `dispatchFields` hook, check out the Form types [here](https://github.com/payloadcms/payload/blob/master/src/admin/components/forms/Form/types.ts).
### useForm
The `useForm` hook can be used to interact with the form itself, and sends back many methods that can be used to reactively fetch form state without causing rerenders within your components each time a field is changed. This is useful if you have action-based callbacks that your components fire, and need to interact with form state _based on a user action_.
<Banner type="warning">
<strong>Warning:</strong><br/>
This hook is optimized to avoid causing rerenders when fields change, and as such, its `fields` property will be out of date. You should only leverage this hook if you need to perform actions against the form in response to your users' actions. Do not rely on its returned "fields" as being up-to-date. They will be removed from this hook's response in an upcoming version.
</Banner>
The `useForm` hook returns an object with the following properties:
| Action | Description |
|----------------------|---------------------------------------------------------------------|
| **`fields`** | Deprecated. This property cannot be relied on as up-to-date. |
| **`submit`** | Method to trigger the form to submit |
| **`dispatchFields`** | Dispatch actions to the form field state |
| **`validateForm`** | Trigger a validation of the form state |
| **`createFormData`** | Create a `multipart/form-data` object from the current form's state |
| **`disabled`** | Boolean denoting whether or not the form is disabled |
| **`getFields`** | Gets all fields from state |
| **`getField`** | Gets a single field from state by path |
| **`getData`** | Returns the data stored in the form |
| **`getSiblingData`** | Returns form sibling data for the given field path |
| **`setModified`** | Set the form's `modified` state |
| **`setProcessing`** | Set the form's `processing` state |
| **`setSubmitted`** | Set the form's `submitted` state |
| **`formRef`** | The ref from the form HTML element |
| **`reset`** | Method to reset the form to its initial state |
### useDocumentInfo
The `useDocumentInfo` hook provides lots of information about the document currently being edited, including the following:
| Property | Description |
|---------------------------|------------------------------------------------------------------------------------|
| **`collection`** | If the doc is a collection, its collection config will be returned |
| **`global`** | If the doc is a global, its global config will be returned |
| **`type`** | The type of document being edited (collection or global) |
| **`id`** | If the doc is a collection, its ID will be returned |
| **`preferencesKey`** | The `preferences` key to use when interacting with document-level user preferences |
| **`versions`** | Versions of the current doc |
| **`unpublishedVersions`** | Unpublished versions of the current doc |
| **`publishedDoc`** | The currently published version of the doc being edited |
| **`getVersions`** | Method to trigger the retrieval of document versions |
**Example:**
```tsx
import { useDocumentInfo } from 'payload/components/utilities';
const LinkFromCategoryToPosts: React.FC = () => {
// highlight-start
const { id } = useDocumentInfo();
// highlight-end
// id will be undefined on the create form
if (!id) {
return null;
}
return (
<a href={`/admin/collections/posts?where[or][0][and][0][category][in][0]=[${id}]`} >
View posts
</a>
)
};
```
### useLocale
In any custom component you can get the selected locale with the `useLocale` hook. Here is a simple example:
```tsx
import { useLocale } from 'payload/components/utilities';
const Greeting: React.FC = () => {
// highlight-start
const locale = useLocale();
// highlight-end
const trans = {
en: 'Hello',
es: 'Hola',
};
return (
<span> { trans[locale] } </span>
);
};
```
### useAuth
Useful to retrieve info about the currently logged in user as well as methods for interacting with it. It sends back an object with the following properties:
| Property | Description |
|---------------------|-----------------------------------------------------------------------------------------|
| **`user`** | The currently logged in user |
| **`logOut`** | A method to log out the currently logged in user |
| **`refreshCookie`** | A method to trigger the silent refreshing of a user's auth token |
| **`setToken`** | Set the token of the user, to be decoded and used to reset the user and token in memory |
| **`token`** | The logged in user's token (useful for creating preview links, etc.) |
| **`permissions`** | The permissions of the current user |
```tsx
import { useAuth } from 'payload/components/utilities';
import { User } from '../payload-types.ts';
const Greeting: React.FC = () => {
// highlight-start
const { user } = useConfig<User>();
// highlight-end
return (
<span>Hi, {user.email}!</span>
);
};
```
### useConfig
Used to easily fetch the full Payload config.
```tsx
import { useConfig } from 'payload/components/utilities';
const MyComponent: React.FC = () => {
// highlight-start
const config = useConfig();
// highlight-end
return (
<span>{config.serverURL}</span>
);
};
```
### usePreferences
Returns methods to set and get user preferences. More info can be found [here](https://payloadcms.com/docs/admin/preferences).

View File

@@ -30,7 +30,8 @@ All options for the Admin panel are defined in your base Payload config file.
| `indexHTML` | Optionally replace the entirety of the `index.html` file used by the Admin panel. Reference the [base index.html file](https://github.com/payloadcms/payload/blob/master/src/admin/index.html) to ensure your replacement has the appropriate HTML elements. |
| `css` | Absolute path to a stylesheet that you can use to override / customize the Admin panel styling. [More](/docs/admin/customizing-css). |
| `scss` | Absolute path to a Sass variables / mixins stylesheet meant to override Payload styles to make for an easy re-skinning of the Admin panel. [More](/docs/admin/customizing-css#overriding-scss-variables). |
| `dateFormat` | Global date format that will be used for all dates in the Admin panel. Any valid [date-fns](https://date-fns.org/) format pattern can be used.
| `dateFormat` | Global date format that will be used for all dates in the Admin panel. Any valid [date-fns](https://date-fns.org/) format pattern can be used. |
| `avatar` | Set account profile picture. Options: `gravatar`, `default` or a custom React component. |
| `components` | Component overrides that affect the entirety of the Admin panel. [More](/docs/admin/components) |
| `webpack` | Customize the Webpack config that's used to generate the Admin panel. [More](/docs/admin/webpack) |
@@ -45,14 +46,14 @@ All options for the Admin panel are defined in your base Payload config file.
To specify which Collection to use to log in to the Admin panel, pass the `admin` options a `user` key equal to the slug of the Collection that you'd like to use.
`payload.config.js`:
```js
```ts
import { buildConfig } from 'payload/config';
const config = buildConfig({
admin: {
user: 'admins', // highlight-line
},
})
});
```
By default, if you have not specified a Collection, Payload will automatically provide you with a `User` Collection which will be used to access the Admin panel. You can customize or override the fields and settings of the default `User` Collection by passing your own collection using `users` as its `slug` to Payload. When this is done, Payload will use your provided `User` Collection instead of its default version.
@@ -66,6 +67,10 @@ For example, you may wish to have two Collections that both support `Authenticat
This is totally possible. For the above scenario, by specifying `admin: { user: 'admins' }`, your Payload Admin panel will use `admins`. Any users logged in as `customers` will not be able to log in via the Admin panel.
### Light and dark modes
Users in the admin panel have access to choosing between light mode and dark mode for their editing experience. The setting is managed while logged into the admin UI within the user account page and will be stored with the browser. By default, the operating system preference is detected and used.
### Restricting user access
If you would like to restrict which users from a single Collection can access the Admin panel, you can use the `admin` access control function. [Click here](/docs/access-control/overview#admin) to learn more.

View File

@@ -1,7 +1,7 @@
---
title: Managing User Preferences
label: Preferences
order: 40
order: 50
desc: Store the preferences of your users as they interact with the Admin panel.
keywords: admin, preferences, custom, customize, documentation, Content Management System, cms, headless, javascript, node, react, express
---

View File

@@ -1,7 +1,7 @@
---
title: Webpack
label: Webpack
order: 50
order: 60
desc: The Payload admin panel uses Webpack 5 and supports many common functionalities such as SCSS and Typescript out of the box to give you more freedom.
keywords: admin, webpack, documentation, Content Management System, cms, headless, javascript, node, react, express
---
@@ -10,8 +10,8 @@ Payload uses Webpack 5 to build the Admin panel. It comes with support for many
To extend the Webpack config, add the `webpack` key to your base Payload config, and provide a function that accepts the default Webpack config as its only argument:
`payload.config.js`
```js
`payload.config.ts`
```ts
import { buildConfig } from 'payload/config';
export default buildConfig({
@@ -24,7 +24,7 @@ export default buildConfig({
}
// highlight-end
}
})
});
```
### Aliasing server-only modules
@@ -52,16 +52,17 @@ You may rely on server-only packages such as the above to perform logic in acces
<br/><br/>
`collections/Subscriptions/index.js`
```js
```ts
import { CollectionConfig } from 'payload/types';
import createStripeSubscription from './hooks/createStripeSubscription';
const Subscription = {
const Subscription: CollectionConfig = {
slug: 'subscriptions',
hooks: {
beforeChange: [
createStripeSubscription,
]
}
},
fields: [
{
name: 'stripeSubscriptionID',
@@ -69,7 +70,7 @@ const Subscription = {
required: true,
}
]
}
};
export default Subscription;
```
@@ -154,6 +155,11 @@ export default {};
Now, when Webpack sees that you're attempting to import your `createStripeSubscriptionPath` file, it'll disregard that actual file and load your mock file instead. Not only will your Admin panel now bundle successfully, you will have optimized its filesize by removing unnecessary code! And you might have learned something about Webpack, too.
<Banner type="success">
<strong>Tip:</strong><br/>
If changes to your Webpack aliases are not surfacing, they might be [cached](https://webpack.js.org/configuration/cache/) in `node_modules/.cache/webpack`. Try deleting that folder and restarting your server.
</Banner>
## Admin environment vars
<Banner type="warning">

View File

@@ -12,16 +12,18 @@ To enable Authentication on a collection, define an `auth` property and set it t
## Options
| Option | Description |
| ---------------------- | -------------|
| **`useAPIKey`** | Payload Authentication provides for API keys to be set on each user within an Authentication-enabled Collection. [More](/docs/authentication/config#api-keys) |
| **`tokenExpiration`** | How long (in seconds) to keep the user logged in. JWTs and HTTP-only cookies will both expire at the same time. |
| **`maxLoginAttempts`** | Only allow a user to attempt logging in X amount of times. Automatically locks out a user from authenticating if this limit is passed. Set to `0` to disable. |
| **`lockTime`** | Set the time that a user should be locked out if they fail authentication more times than `maxLoginAttempts` allows for. |
| **`depth`** | How many levels deep a `user` document should be populated when creating the JWT and binding the `user` to the express `req`. Defaults to `0` and should only be modified if absolutely necessary, as this will affect performance. |
| **`cookies`** | Set cookie options, including `secure`, `sameSite`, and `domain`. For advanced users. |
| **`forgotPassword`** | Customize the way that the `forgotPassword` operation functions. [More](/docs/authentication/config#forgot-password) |
| **`verify`** | Set to `true` or pass an object with verification options to require users to verify by email before they are allowed to log into your app. [More](/docs/authentication/config#email-verification) |
| Option | Description |
| -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`useAPIKey`** | Payload Authentication provides for API keys to be set on each user within an Authentication-enabled Collection. [More](/docs/authentication/config#api-keys) |
| **`tokenExpiration`** | How long (in seconds) to keep the user logged in. JWTs and HTTP-only cookies will both expire at the same time. |
| **`maxLoginAttempts`** | Only allow a user to attempt logging in X amount of times. Automatically locks out a user from authenticating if this limit is passed. Set to `0` to disable. |
| **`lockTime`** | Set the time that a user should be locked out if they fail authentication more times than `maxLoginAttempts` allows for. |
| **`depth`** | How many levels deep a `user` document should be populated when creating the JWT and binding the `user` to the express `req`. Defaults to `0` and should only be modified if absolutely necessary, as this will affect performance. |
| **`cookies`** | Set cookie options, including `secure`, `sameSite`, and `domain`. For advanced users. |
| **`forgotPassword`** | Customize the way that the `forgotPassword` operation functions. [More](/docs/authentication/config#forgot-password) |
| **`verify`** | Set to `true` or pass an object with verification options to require users to verify by email before they are allowed to log into your app. [More](/docs/authentication/config#email-verification) |
| **`disableLocalStrategy`** | Advanced - disable Payload's built-in local auth strategy. Only use this property if you have replaced Payload's auth mechanisms with your own. |
| **`strategies`** | Advanced - an array of PassportJS authentication strategies to extend this collection's authentication with. [More](/docs/authentication/config#strategies) |
### API keys
@@ -37,7 +39,8 @@ Technically, both of these options will work for third-party integrations but th
To enable API keys on a collection, set the `useAPIKey` auth option to `true`. From there, a new interface will appear in the Admin panel for each document within the collection that allows you to generate an API key for each user in the Collection.
<Banner type="success">
User API keys are encrypted within the database, meaning that if your database is compromised, your API keys will not be.
User API keys are encrypted within the database, meaning that if your database
is compromised, your API keys will not be.
</Banner>
##### Authenticating via API Key
@@ -45,14 +48,17 @@ To enable API keys on a collection, set the `useAPIKey` auth option to `true`. F
To utilize your API key while interacting with the REST or GraphQL API, add the `Authorization` header.
**For example, using Fetch:**
```js
const response = await fetch('http://localhost:3000/api/pages', {
```ts
const response = await fetch("http://localhost:3000/api/pages", {
headers: {
Authorization: `${collection.labels.singular} API-Key ${YOUR_API_KEY}`,
},
});
```
Note: The label portion of the header is case-sensitive and will likely have a capitalized first character unless the label has been customized.
### Forgot Password
You can customize how the Forgot Password workflow operates with the following options on the `auth.forgotPassword` property:
@@ -62,14 +68,21 @@ You can customize how the Forgot Password workflow operates with the following o
Function that accepts one argument, containing `{ req, token, user }`, that allows for overriding the HTML within emails that are sent to users attempting to reset their password. The function should return a string that supports HTML, which can be a full HTML email.
<Banner type="success">
<strong>Tip:</strong><br />
HTML templating can be used to create custom email templates, inline CSS automatically, and more. You can make a reusable function that standardizes all email sent from Payload, which makes sending custom emails more DRY. Payload doesn't ship with an HTML templating engine, so you are free to choose your own.
<strong>Tip:</strong>
<br />
HTML templating can be used to create custom email templates, inline CSS
automatically, and more. You can make a reusable function that standardizes
all email sent from Payload, which makes sending custom emails more DRY.
Payload doesn't ship with an HTML templating engine, so you are free to choose
your own.
</Banner>
Example:
```js
{
```ts
import { CollectionConfig } from 'payload/types';
const Customers: CollectionConfig = {
slug: 'customers',
auth: {
forgotPassword: {
@@ -95,12 +108,17 @@ Example:
// highlight-end
}
}
}
};
```
<Banner type="warning">
<strong>Important:</strong><br />
If you specify a different URL to send your users to for resetting their password, such as a page on the frontend of your app or similar, you need to handle making the call to the Payload REST or GraphQL reset-password operation yourself on your frontend, using the token that was provided for you. Above, it was passed via query parameter.
<strong>Important:</strong>
<br />
If you specify a different URL to send your users to for resetting their
password, such as a page on the frontend of your app or similar, you need to
handle making the call to the Payload REST or GraphQL reset-password operation
yourself on your frontend, using the token that was provided for you. Above,
it was passed via query parameter.
</Banner>
**`generateEmailSubject`**
@@ -109,7 +127,7 @@ Similarly to the above `generateEmailHTML`, you can also customize the subject o
Example:
```js
```ts
{
slug: 'customers',
auth: {
@@ -134,8 +152,11 @@ Function that accepts one argument, containing `{ req, token, user }`, that allo
Example:
```js
{
```ts
import { CollectionConfig } from 'payload/types';
const Customers: CollectionConfig = {
slug: 'customers',
auth: {
verify: {
@@ -149,12 +170,17 @@ Example:
// highlight-end
}
}
}
};
```
<Banner type="warning">
<strong>Important:</strong><br />
If you specify a different URL to send your users to for email verification, such as a page on the frontend of your app or similar, you need to handle making the call to the Payload REST or GraphQL verification operation yourself on your frontend, using the token that was provided for you. Above, it was passed via query parameter.
<strong>Important:</strong>
<br />
If you specify a different URL to send your users to for email verification,
such as a page on the frontend of your app or similar, you need to handle
making the call to the Payload REST or GraphQL verification operation yourself
on your frontend, using the token that was provided for you. Above, it was
passed via query parameter.
</Banner>
**`generateEmailSubject`**
@@ -163,7 +189,7 @@ Similarly to the above `generateEmailHTML`, you can also customize the subject o
Example:
```js
```ts
{
slug: 'customers',
auth: {
@@ -177,3 +203,29 @@ Example:
}
}
```
### Strategies
As of Payload `1.0.0`, you can add additional authentication strategies to Payload easily by passing them to your collection's `auth.strategies` array.
Behind the scenes, Payload uses PassportJS to power its local authentication strategy, so most strategies listed on the PassportJS website will work seamlessly. Combined with adding custom components to the admin panel's `Login` view, you can create advanced authentication strategies directly within Payload.
<Banner type="warning">
This is an advanced feature, so only attempt this if you are an experienced
developer. Otherwise, just let Payload's built-in authentication handle user
auth for you.
</Banner>
The `strategies` property is an array that takes objects with the following properties:
**`strategy`**
This property can accept a Passport strategy directly, or you can pass a function that takes a `payload` argument, and returns a Passport strategy.
**`name`**
If you pass a strategy to the `strategy` property directly, the `name` property is optional and allows you to override the strategy's built-in name.
However, if you pass a function to `strategy`, `name` is a required property.
In either case, Payload will prefix the strategy name with the collection `slug` that the strategy is passed to.

Some files were not shown because too many files have changed in this diff Show More