Compare commits

...

379 Commits
v1.9.0 ... 1.x

Author SHA1 Message Date
Elliot DeNolf
465acf0123 chore(release): v1.15.12 2025-03-11 09:23:34 -04:00
Elliot DeNolf
a6524720f5 chore: simplify query parsing 2025-03-10 14:38:52 -04:00
Jonathan Wu
59fb70077d chore(examples/form-builder): improves form input accessibility 2023-11-15 17:06:18 -05:00
Patrik
6b3f20d01b fix: ensures compare-version select field cannot be cleared (#3413) 2023-10-27 12:29:07 -04:00
Aleem Isiaka
5f6a0db869 fix: ctrl s on globals (#3342) 2023-10-10 23:32:57 -04:00
Kári Rögnvaldsson
26fcfba8fd fix: hide rich text toolbar if leaves and elements arrays are empty (#3226) 2023-10-10 13:27:07 -04:00
Jarrod Flesch
88ad2ee1e3 chore: adds example code and README for setting up testing with a payload project (#3333) 2023-10-09 14:37:00 -04:00
Elliot DeNolf
b76aea9b9a chore(release): v1.15.8 2023-10-08 17:21:16 -04:00
Elliot DeNolf
d770b40cc5 chore: update yarn.lock 2023-10-08 17:12:27 -04:00
Calvin Chong
3e6718034f chore(templates/website): adds seeded users to readme (#3412)
Co-authored-by: Jacob Fletcher <jacobsfletch@gmail.com>
2023-10-08 16:46:57 -04:00
dependabot[bot]
a7beb1bb8f chore(deps): bump graphql from 16.8.0 to 16.8.1 (#3380)
Bumps [graphql](https://github.com/graphql/graphql-js) from 16.8.0 to 16.8.1.
- [Release notes](https://github.com/graphql/graphql-js/releases)
- [Commits](https://github.com/graphql/graphql-js/compare/v16.8.0...v16.8.1)

---
updated-dependencies:
- dependency-name: graphql
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-08 15:42:59 -04:00
dependabot[bot]
6a79efc5f5 chore(deps): bump word-wrap in /examples/redirects/nextjs (#3057)
Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.5.
- [Release notes](https://github.com/jonschlinkert/word-wrap/releases)
- [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.5)

---
updated-dependencies:
- dependency-name: word-wrap
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-08 15:41:46 -04:00
dependabot[bot]
9697269816 chore(deps): bump semver in /examples/redirects/nextjs (#3058)
Bumps [semver](https://github.com/npm/node-semver) from 7.3.8 to 7.5.4.
- [Release notes](https://github.com/npm/node-semver/releases)
- [Changelog](https://github.com/npm/node-semver/blob/main/CHANGELOG.md)
- [Commits](https://github.com/npm/node-semver/compare/v7.3.8...v7.5.4)

---
updated-dependencies:
- dependency-name: semver
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-08 15:41:20 -04:00
dependabot[bot]
af375123a8 chore(deps): bump word-wrap in /examples/form-builder/nextjs (#3076)
Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.5.
- [Release notes](https://github.com/jonschlinkert/word-wrap/releases)
- [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.5)

---
updated-dependencies:
- dependency-name: word-wrap
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-08 15:41:07 -04:00
dependabot[bot]
00b66a70c9 chore(deps): bump semver in /examples/draft-preview/next-app (#3111)
Bumps [semver](https://github.com/npm/node-semver) from 6.3.0 to 6.3.1.
- [Release notes](https://github.com/npm/node-semver/releases)
- [Changelog](https://github.com/npm/node-semver/blob/v6.3.1/CHANGELOG.md)
- [Commits](https://github.com/npm/node-semver/compare/v6.3.0...v6.3.1)

---
updated-dependencies:
- dependency-name: semver
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-08 15:40:29 -04:00
dependabot[bot]
b0135a7ee0 chore(deps): bump postcss from 8.4.27 to 8.4.31 in /templates/blank (#3463)
Bumps [postcss](https://github.com/postcss/postcss) from 8.4.27 to 8.4.31.
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/postcss/compare/8.4.27...8.4.31)

---
updated-dependencies:
- dependency-name: postcss
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-08 15:39:17 -04:00
dependabot[bot]
fe2940a447 chore(deps): bump postcss from 8.4.27 to 8.4.31 in /examples/whitelabel (#3464)
Bumps [postcss](https://github.com/postcss/postcss) from 8.4.27 to 8.4.31.
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/postcss/compare/8.4.27...8.4.31)

---
updated-dependencies:
- dependency-name: postcss
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-08 15:36:11 -04:00
dependabot[bot]
c745de15b9 chore(deps): bump postcss in /examples/form-builder/cms (#3465)
Bumps [postcss](https://github.com/postcss/postcss) from 8.4.27 to 8.4.31.
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/postcss/compare/8.4.27...8.4.31)

---
updated-dependencies:
- dependency-name: postcss
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-08 15:35:55 -04:00
dependabot[bot]
4dcf0bcad6 chore(deps): bump postcss in /examples/multi-tenant (#3466)
Bumps [postcss](https://github.com/postcss/postcss) from 8.4.27 to 8.4.31.
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/postcss/compare/8.4.27...8.4.31)

---
updated-dependencies:
- dependency-name: postcss
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-08 15:35:44 -04:00
dependabot[bot]
93f043bc79 chore(deps): bump postcss in /examples/redirects/cms (#3467)
Bumps [postcss](https://github.com/postcss/postcss) from 8.4.27 to 8.4.31.
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/postcss/compare/8.4.27...8.4.31)

---
updated-dependencies:
- dependency-name: postcss
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-08 15:35:32 -04:00
dependabot[bot]
63bceedca4 chore(deps): bump postcss from 8.4.27 to 8.4.31 in /examples/email (#3468)
Bumps [postcss](https://github.com/postcss/postcss) from 8.4.27 to 8.4.31.
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/postcss/compare/8.4.27...8.4.31)

---
updated-dependencies:
- dependency-name: postcss
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-08 15:35:21 -04:00
dependabot[bot]
0bbb5790d5 chore(deps): bump postcss in /examples/auth/payload (#3469)
Bumps [postcss](https://github.com/postcss/postcss) from 8.4.27 to 8.4.31.
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/postcss/compare/8.4.27...8.4.31)

---
updated-dependencies:
- dependency-name: postcss
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-08 15:35:09 -04:00
dependabot[bot]
05c8bdc16a chore(deps): bump postcss in /examples/draft-preview/payload (#3470)
Bumps [postcss](https://github.com/postcss/postcss) from 8.4.27 to 8.4.31.
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/postcss/compare/8.4.27...8.4.31)

---
updated-dependencies:
- dependency-name: postcss
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-08 15:34:53 -04:00
dependabot[bot]
77c14033d6 chore(deps): bump postcss from 8.4.28 to 8.4.31 (#3471)
Bumps [postcss](https://github.com/postcss/postcss) from 8.4.28 to 8.4.31.
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/postcss/compare/8.4.28...8.4.31)

---
updated-dependencies:
- dependency-name: postcss
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-08 15:34:40 -04:00
Jacob Fletcher
0280cdd355 chore: updates README.md (#3430) 2023-10-03 17:54:09 -04:00
Petipois
891ab34a12 chore: updates link to contributing in readme (#3418) 2023-10-03 15:49:49 -04:00
Jarrod Flesch
26939a3331 fix: secures the user response from the me auth route (#3409) 2023-10-03 12:21:41 -04:00
PatrikKozak
9fa4a8fcfb chore(examples/custom-server): updates readme with correct login info (#3422) 2023-10-03 10:08:00 -04:00
Elliot DeNolf
96608a509b chore(release): v1.15.7 2023-10-02 17:38:22 -04:00
Alessio Gravili
8586c85fab fix: hotkey's pressed keys are not unset when window is not focused (#3400)
* fix: hotkey's pressed keys are not unset when window is not focused

* chore: remove unnecessary console.log
2023-10-02 10:41:59 -04:00
dependabot[bot]
1a76e9580f chore(deps): bump graphql from 16.8.0 to 16.8.1 in /templates/ecommerce (#3381)
Bumps [graphql](https://github.com/graphql/graphql-js) from 16.8.0 to 16.8.1.
- [Release notes](https://github.com/graphql/graphql-js/releases)
- [Commits](https://github.com/graphql/graphql-js/compare/v16.8.0...v16.8.1)

---
updated-dependencies:
- dependency-name: graphql
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-24 07:34:18 -07:00
dependabot[bot]
8127fe39e2 chore(deps): bump graphql in /examples/auth/payload (#3379)
Bumps [graphql](https://github.com/graphql/graphql-js) from 16.7.1 to 16.8.1.
- [Release notes](https://github.com/graphql/graphql-js/releases)
- [Commits](https://github.com/graphql/graphql-js/compare/v16.7.1...v16.8.1)

---
updated-dependencies:
- dependency-name: graphql
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-24 07:32:21 -07:00
dependabot[bot]
e42c4dec98 chore(deps): bump graphql in /examples/draft-preview/payload (#3378)
Bumps [graphql](https://github.com/graphql/graphql-js) from 16.7.1 to 16.8.1.
- [Release notes](https://github.com/graphql/graphql-js/releases)
- [Commits](https://github.com/graphql/graphql-js/compare/v16.7.1...v16.8.1)

---
updated-dependencies:
- dependency-name: graphql
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-24 07:31:59 -07:00
dependabot[bot]
2c82ea80de chore(deps): bump graphql from 16.7.1 to 16.8.1 in /examples/email (#3377)
Bumps [graphql](https://github.com/graphql/graphql-js) from 16.7.1 to 16.8.1.
- [Release notes](https://github.com/graphql/graphql-js/releases)
- [Commits](https://github.com/graphql/graphql-js/compare/v16.7.1...v16.8.1)

---
updated-dependencies:
- dependency-name: graphql
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-24 07:31:44 -07:00
dependabot[bot]
428aebd73e chore(deps): bump graphql from 16.7.1 to 16.8.1 in /templates/blank (#3376)
Bumps [graphql](https://github.com/graphql/graphql-js) from 16.7.1 to 16.8.1.
- [Release notes](https://github.com/graphql/graphql-js/releases)
- [Commits](https://github.com/graphql/graphql-js/compare/v16.7.1...v16.8.1)

---
updated-dependencies:
- dependency-name: graphql
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-24 07:31:37 -07:00
dependabot[bot]
712bd6e8b1 chore(deps): bump graphql in /examples/form-builder/cms (#3375)
Bumps [graphql](https://github.com/graphql/graphql-js) from 16.7.1 to 16.8.1.
- [Release notes](https://github.com/graphql/graphql-js/releases)
- [Commits](https://github.com/graphql/graphql-js/compare/v16.7.1...v16.8.1)

---
updated-dependencies:
- dependency-name: graphql
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-24 07:31:31 -07:00
dependabot[bot]
1ca55b41c6 chore(deps): bump graphql in /examples/custom-server (#3374)
Bumps [graphql](https://github.com/graphql/graphql-js) from 16.7.1 to 16.8.1.
- [Release notes](https://github.com/graphql/graphql-js/releases)
- [Commits](https://github.com/graphql/graphql-js/compare/v16.7.1...v16.8.1)

---
updated-dependencies:
- dependency-name: graphql
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-24 07:31:14 -07:00
dependabot[bot]
81352f3d41 chore(deps): bump graphql in /examples/multi-tenant (#3373)
Bumps [graphql](https://github.com/graphql/graphql-js) from 16.7.1 to 16.8.1.
- [Release notes](https://github.com/graphql/graphql-js/releases)
- [Commits](https://github.com/graphql/graphql-js/compare/v16.7.1...v16.8.1)

---
updated-dependencies:
- dependency-name: graphql
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-24 07:29:14 -07:00
dependabot[bot]
6fb60cdbe3 chore(deps): bump graphql from 16.7.1 to 16.8.1 in /templates/website (#3372)
Bumps [graphql](https://github.com/graphql/graphql-js) from 16.7.1 to 16.8.1.
- [Release notes](https://github.com/graphql/graphql-js/releases)
- [Commits](https://github.com/graphql/graphql-js/compare/v16.7.1...v16.8.1)

---
updated-dependencies:
- dependency-name: graphql
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-24 07:29:04 -07:00
dependabot[bot]
e18784dd5b chore(deps): bump graphql in /examples/redirects/cms (#3371)
Bumps [graphql](https://github.com/graphql/graphql-js) from 16.7.1 to 16.8.1.
- [Release notes](https://github.com/graphql/graphql-js/releases)
- [Commits](https://github.com/graphql/graphql-js/compare/v16.7.1...v16.8.1)

---
updated-dependencies:
- dependency-name: graphql
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-24 07:28:57 -07:00
dependabot[bot]
ff417368ff chore(deps): bump graphql from 16.7.1 to 16.8.1 in /examples/whitelabel (#3370)
Bumps [graphql](https://github.com/graphql/graphql-js) from 16.7.1 to 16.8.1.
- [Release notes](https://github.com/graphql/graphql-js/releases)
- [Commits](https://github.com/graphql/graphql-js/compare/v16.7.1...v16.8.1)

---
updated-dependencies:
- dependency-name: graphql
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-24 07:28:50 -07:00
dependabot[bot]
e28c77069e chore(deps): bump graphql in /examples/form-builder/nextjs (#3369)
Bumps [graphql](https://github.com/graphql/graphql-js) from 16.6.0 to 16.8.1.
- [Release notes](https://github.com/graphql/graphql-js/releases)
- [Commits](https://github.com/graphql/graphql-js/compare/v16.6.0...v16.8.1)

---
updated-dependencies:
- dependency-name: graphql
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-24 07:28:40 -07:00
Elliot DeNolf
37fe2df2de chore(release): v1.15.6 2023-09-13 10:30:03 -04:00
Jarrod Flesch
8ca67d5aaa fix(#3289): removes HMR plugin from prod webpack configs (#3319) 2023-09-12 13:09:56 -04:00
Jarrod Flesch
096d33718d fix: fields with relationTo[] correctly load returned data from form submission (#3317) 2023-09-12 11:43:45 -04:00
Jessica Chowdhury
0bd335303d fix: greater than equal admin filter not working (#3306) 2023-09-11 13:08:06 -04:00
James
e8e1ba00fe chore(release): v1.15.5 2023-09-09 09:53:57 -04:00
Jarrod Flesch
a7d47c627d fix: corrects hasMany relationships within addFieldStatePromise (#3300) 2023-09-09 00:32:29 -04:00
Jarrod Flesch
5e1bed3177 chore: fixes console errors for checkboxes (#3291) 2023-09-07 09:11:35 -04:00
Elliot DeNolf
364014a1e9 chore(release): v1.15.4 2023-09-06 17:39:02 -04:00
Jarrod Flesch
9cd5e5aefa fix: appends versions key to incoming where query (#3287) 2023-09-06 15:07:46 -04:00
Bas Dalenoord
429a88a5a1 fix: change scoping of force parameter to prevent false negation; (#3278) 2023-09-06 12:54:39 -04:00
Jarrod Flesch
cf12b5fc70 fix(#3274): sets full user data from fetchFullUser instead of partial jwt data (#3279) 2023-09-06 12:52:48 -04:00
Jarrod Flesch
5096c37874 fix: aligns depth behaviour between local api and admin panel (#3276) 2023-09-06 12:51:59 -04:00
Jacob Fletcher
ac592b6d0d chore(templates/ecommerce): misc cleanup 2023-09-06 11:59:03 -04:00
Jacob Fletcher
007f7e7d18 chore(templates/ecommerce): fixes nextjs hmr 2023-09-06 11:49:59 -04:00
Jacob Fletcher
4ba072b0c6 chore(templates/ecommerce): related products 2023-09-06 11:39:18 -04:00
Jacob Fletcher
8a4db150f0 chore(templates/ecommerce): prevents server from restarting when app files change 2023-09-06 11:11:30 -04:00
Jacob Fletcher
b28b9020ea chore(templates/ecommerce): fixes product published dates 2023-09-06 11:07:59 -04:00
Jacob Fletcher
baa73fae62 chore(templates/ecommerce): wires in redirects 2023-09-06 11:03:30 -04:00
Jacob Fletcher
55c27b6d2f chore(templates/website): builds nextjs front-end (#3282) 2023-09-06 08:38:04 -04:00
James
6d148d7309 chore(release): v1.15.3 2023-09-05 16:53:47 -04:00
James Mikrut
8e10ecae4b Merge pull request #3256 from payloadcms/feat/versions-perf
Feat/versions perf
2023-09-05 16:47:48 -04:00
Jarrod Flesch
ef27b9f641 chore: revert changes related to the status displayed by the Status component 2023-09-05 16:33:01 -04:00
Jarrod Flesch
2dcce0339c chore: simplify logic for global status rendering 2023-09-05 16:04:56 -04:00
Jarrod Flesch
b649ad7bb5 chore: ensure not to update the version doc that was just created 2023-09-05 16:04:12 -04:00
Jarrod Flesch
3cee0be314 chore: remove script file example 2023-09-05 16:01:07 -04:00
Jacob Fletcher
8fc953605a chore(templates/ecommerce): properly formats csp and handles post requests in next app (#3260) 2023-09-01 10:52:05 -04:00
Jarrod Flesch
e28dfc0c93 chore: tweak script 2023-08-31 21:34:25 -04:00
Jarrod Flesch
33561a8ea2 chore: adds feature flag to config 2023-08-31 21:16:50 -04:00
Jarrod Flesch
e500b46576 chore: removes console log 2023-08-31 16:57:49 -04:00
Jarrod Flesch
e79a84d200 chore: migration script 2023-08-31 16:56:21 -04:00
Jarrod Flesch
16e94d401b feat: improves query speed for version enabled collections 2023-08-31 16:50:35 -04:00
Jarrod Flesch
9fbabc8fd6 fix: globals not saving updatedAt and createdAt and version dates correctly 2023-08-31 16:49:33 -04:00
Jarrod Flesch
9bc072ccaf fix: draft globals always displaying unpublish button 2023-08-31 16:48:25 -04:00
Jacob Fletcher
45905c312f chore(templates/ecommerce): bypasses next cache (#3254) 2023-08-31 09:34:10 -04:00
Jacob Fletcher
2c7a15ceca chore(templates/ecommerce): uses svg favicon 2023-08-28 16:11:11 -04:00
Jacob Fletcher
28e128241e chore(examples/custom-server): uses getPayloadClient in default server and removes admin redirect 2023-08-28 16:06:45 -04:00
Jacob Fletcher
21336cd61a chore(examples/custom-server): handles front-end post requests (#3221) 2023-08-28 15:58:56 -04:00
Jarrod Flesch
ff1c10c382 chore(examples): simplify getPayloadClient logic 2023-08-28 13:49:40 -04:00
Jarrod Flesch
6e8aa5e8af Merge branch 'master' of https://github.com/payloadcms/payload 2023-08-28 11:24:28 -04:00
Jarrod Flesch
32e7c56a0d chore(example): adjusts custom server example with pattern to utilize local api 2023-08-28 11:24:24 -04:00
Jacob Fletcher
e5c783df5d chore(templates/ecommerce): migrates to @payloadcms/plugin-stripe v0.0.14 (#3231) 2023-08-25 17:49:51 -04:00
Jacob Fletcher
63698e5e88 chore(templates): correctly sets next images domain (#3230) 2023-08-25 15:40:40 -04:00
Dan Ribbens
016ad3afc9 chore(release): v1.15.2 2023-08-25 11:40:42 -04:00
Dan Ribbens
33e1e15ca9 chore: pins swc v1.3.78 (#3228) 2023-08-25 11:00:43 -04:00
Jarrod Flesch
59918aac91 chore(docs): clarifies reason for returning doc in afterChange collection hook 2023-08-25 10:23:27 -04:00
Dan Ribbens
a0c3cbd68d chore(release): v1.15.1 2023-08-25 06:55:22 -04:00
Tylan Davis
3a15e077c6 fix: correct out of order dark-mode color variables (#3197) 2023-08-24 15:09:31 -04:00
Jessica Chowdhury
90a9e14e9d docs: adds custom select example and video (#3223) 2023-08-24 15:07:06 -04:00
Paul
6d3b8636f4 fix: mutation type with tabs missing previous tabs (#3196) 2023-08-24 14:29:25 -04:00
PatrikKozak
cb8e07f852 fix: arrays in richtext uploads (#3222)
Co-authored-by: Jarrod Flesch <jarrodmflesch@gmail.com>
2023-08-24 14:12:18 -04:00
Jessica Chowdhury
301be0a5d4 docs: adds minRow and maxRow to array and blocks pages (#3203) 2023-08-24 11:19:49 -04:00
Dan Ribbens
466589b483 chore(release): v1.15.0 2023-08-24 10:22:55 -04:00
Alessio Gravili
6754f55ce0 chore: improve filtering for hasMany number field (#3193)
* chore: improve fiiltering for hasMany number field

* chore: add translation for 'items' and replace rows with items

* chore: new exceededLimit key

* Revert "chore: add translation for 'items' and replace rows with items"

This reverts commit 3a91dabdfd.

* chore: undo adding items key in translation schema

* chore: new limitReached key

* chore: remove unnecessary exceededLimit key
2023-08-21 18:01:10 +02:00
Alessio Gravili
84d2bacb56 chore: improve checkboxes (#3191) 2023-08-21 10:39:40 -04:00
Alessio Gravili
739abdcd81 feat: query support for geo within and intersects + dynamic GraphQL operator types (#3183)
Co-authored-by: Lucas Blancas <lablancas@gmail.com>
2023-08-21 10:12:27 -04:00
Jacob Fletcher
c7cf2d3d2c chore(examples): updates draft-preview next-app example to use revalidateTag (#3199) 2023-08-21 08:45:44 -04:00
Jacob Fletcher
79561497f9 Merge pull request #3200 from payloadcms/chore/ecom-deploy
chore(templates): updates e-commerce template
2023-08-21 08:45:31 -04:00
Jacob Fletcher
600306274e chore(templates): renders static cart page fallback 2023-08-20 18:26:53 -04:00
Jacob Fletcher
398378a867 chore(templates): implements draft preview and on-demand revalidation 2023-08-20 13:20:06 -04:00
Jacob Fletcher
4e755dfde2 chore(templates): safely handles bad network requests 2023-08-20 02:09:51 -04:00
Elliot DeNolf
3634e2cc4d chore(templates): default port on website 2023-08-17 15:01:55 -04:00
Jarrod Flesch
294fb5e574 chore: improve ts typing in sanitization functions (#3194) 2023-08-17 10:47:54 -04:00
Dan Ribbens
f5f2332755 chore(release): v1.14.0 2023-08-16 13:58:20 -04:00
Jarrod Flesch
0acd7b8706 chore: file cleanup (#3190) 2023-08-16 13:03:43 -04:00
James Mikrut
d91b44cbb3 feat: improve field ops (#3172)
Co-authored-by: PatrikKozak <patrik@trbl.design>
2023-08-16 11:00:52 -04:00
Greg Willard
e03a8e6b03 feat: Improve admin dashboard accessibility (#3053)
Co-authored-by: Alessio Gravili <alessio@gravili.de>
2023-08-16 10:26:17 -04:00
Jacob Fletcher
846485388a docs: removes auto-formatting from rich-text.mdx (#3188) 2023-08-16 10:15:27 -04:00
Jacob Fletcher
8d83e05948 docs: fixes syntax error in rich-text.mdx that was breaking build 2023-08-16 03:28:19 -04:00
PatrikKozak
7963d04a27 fix: passes in height to resizeOptions upload option to allow height resize (#3171) 2023-08-15 14:58:16 -04:00
Jessica Chowdhury
20b6b29c79 chore(test): adds test to ensure relationship returns over 10 docs (#3181)
* chore(test): adds test to ensure relationship returns over 10 docs

* chore: remove unnecessary movieDocs variable
2023-08-15 19:48:33 +02:00
Alessio Gravili
fdfdfc83f3 fix: WhereBuilder component does not accept all valid Where queries (#3087)
* chore: add jsDocs for ListControls

* chore: add jsDocs for ListView

* chore: add jsDocs for WhereBuilder

* chore: add comment

* chore: remove unnecessary console log

* chore: improve operator type

* fix: transform where queries which aren't necessarily incorrect, and improve their validation

* chore: add type to import

* fix: do not merge existing old query params with new ones if the existing old ones got transformed and are not valid, as that would cause duplicates

* chore: sort imports and remove extra validation

* fix: transformWhereQuery logic

* chore: add back extra validation

* chore: add e2e tests
2023-08-15 19:22:57 +02:00
Jarrod Flesch
c154eb7e2b chore: remove swc version pin (#3179) 2023-08-15 09:19:18 -04:00
Stef Gootzen
33686c6db8 feat: add afterOperation hook (#2697)
* feat: add afterOperation hook for Find operation

* docs: change #afterOperation to #afteroperation

* chore: extract afterOperation in function

* chore: implement afterChange in operations

* docs: use proper CollectionAfterOperationHook

* chore: remove outdated info

* chore: types afterOperation hook

* chore: improves afterOperation tests

* docs: updates description of afterOperation hook

* chore: improve typings

* chore: improve types

* chore: rename index.tsx => index.ts

---------

Co-authored-by: Jacob Fletcher <jacobsfletch@gmail.com>
Co-authored-by: Alessio Gravili <alessio@gravili.de>
2023-08-15 14:37:01 +02:00
Alessio Gravili
6d6acbcfc1 Merge pull request #3176 from payloadcms/chore/docs-design-contributions
chore: add section for design contributions in contributing.md
2023-08-15 14:25:50 +02:00
Alessio Gravili
4e2f2561ff chore: add section for design contributions in contributing.md 2023-08-15 13:34:11 +02:00
Chingiz Mammadov
63e3063b9e feat: Added Azerbaijani language file (#3164)
Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
2023-08-14 15:40:53 -04:00
rpfaeffle
942cfec286 feat: add support for hotkeys (#1821)
Co-authored-by: Jacob Fletcher <jacobsfletch@gmail.com>
Co-authored-by: Alessio Gravili <70709113+AlessioGr@users.noreply.github.com>
Co-authored-by: Alessio Gravili <alessio@gravili.de>
Co-authored-by: Jessica Boezwinkle <jessica@trbl.design>
2023-08-14 15:36:49 -04:00
Jarrod Flesch
35dfaab7c2 chore: works around changes in @swc/core 1.3.76 (#3170) 2023-08-14 14:32:42 -04:00
Jordy Alcides
bad363882c feat: allow async relationship filter options (#2951)
* chore: improving relationship filter options;

Updating prop filterOptions from field type "relationship" to allow async functions;

* chore: add failing test case

* fix: translation followingFieldsInvalid_many not getting triggered

* docs: improve documentation

---------

Co-authored-by: Alessio Gravili <alessio@gravili.de>
2023-08-14 17:29:29 +02:00
Alessio Gravili
20a6ce8823 Merge pull request #3166 from payloadcms/fix/external-website-redirects
fix: do not allow redirects to external sites
2023-08-14 17:20:07 +02:00
Alessio Gravili
6797222733 chore: remove duplicate code 2023-08-14 17:19:19 +02:00
Jarrod Flesch
edcb3933cf fix: DatePicker showing only selected day by default (#3169) 2023-08-14 11:18:13 -04:00
Mark Barton
a0b13a5b01 feat: text alignment for richtext editor (#2803)
* Update isActive.tsx

This change allows us to define toggling of custom types in Slate. Specifically, this fixes the ability to toggle Alignment on nodes that use other active elements.

isElementActive(editor, format, TEXT_ALIGN_TYPES.includes(format) ? 'align' : 'type');

Type is the default for elements, allowing us to use a custom field lets us greater extend the functionality of Slate in Payload without causing any breaking changes

* Update toggle.tsx

Added to toggleElement public function

* Update isActive.tsx

* Update toggle.tsx

Added Rich Text Alignment, updated toggle function, added tests and doc updates

* added margin to void elements

* fix: list alignment

* removed textAlign from elements and added docs

* chore: fix typo

---------

Co-authored-by: Alessio Gravili <alessio@gravili.de>
2023-08-14 17:08:50 +02:00
Alessio Gravili
5744de7ec6 feat: make PAYLOAD_CONFIG_PATH optional (#2839)
* feat: make PAYLOAD_CONFIG_PATH optional

* hardcode common search paths

* docs: update docs regarding PAYLOAD_CONFIG_PATH

* make the tsConfig parser less prone to errors
2023-08-14 16:46:10 +02:00
Alessio Gravili
8a6cbf8a4d Merge pull request #2500 from Elliot67/feat/file-caching 2023-08-14 16:37:00 +02:00
Alessio Gravili
0a4730188b chore: update from master 2023-08-14 15:23:28 +02:00
Alessio Gravili
ea46fadc26 Merge remote-tracking branch 'origin/master' into pr/2500 2023-08-14 15:23:19 +02:00
Alessio Gravili
40db0d0462 chore: improve regex 2023-08-14 15:14:54 +02:00
Alessio Gravili
c0f05a1c38 fix: only allow redirects to /admin sub-routes 2023-08-13 16:25:14 +02:00
Elliot DeNolf
52de1f6ab0 chore(release): v1.13.4 2023-08-11 16:58:06 -04:00
Jarrod Flesch
479293fe6f chore: removes duplicative code for getting parent path (#3163) 2023-08-11 13:04:43 -04:00
Jarrod Flesch
3c60abd61a fix: correctly passes block path inside buildFieldSchemaMap (#3162) 2023-08-11 10:49:52 -04:00
Elliot DeNolf
f9807b5bd5 chore(release): v1.13.3 2023-08-11 09:27:27 -04:00
Jarrod Flesch
cb04d4a82a fix: unable to add arrays inside secondary named tabs (#3158) 2023-08-11 09:02:29 -04:00
James
5f7ea17717 chore(release): v1.13.2 2023-08-10 17:43:46 -04:00
Jarrod Flesch
608ae42eff chore: pins @swc/core to 1.3.75 2023-08-10 16:23:43 -04:00
Jacob Fletcher
1da412a9bf chore(templates): fixes orders access control in ecommerce template (#3150) 2023-08-09 12:27:11 -04:00
Dan Ribbens
324b51e778 chore(release): v1.13.1 2023-08-08 16:00:52 -04:00
Jarrod Flesch
f5cf546e19 fix: updates addFieldRow and replaceFieldRow rowIndex insertion (#3145) 2023-08-08 15:35:59 -04:00
Dan Ribbens
510510cc66 chore: update changelog 2023-08-08 12:54:47 -04:00
Dan Ribbens
69cb015e0b chore(release): v1.13.0 2023-08-08 12:54:14 -04:00
Dan Ribbens
c6e0908076 feat: recursive saveToJWT field support (#3130) 2023-08-08 12:38:44 -04:00
Jarrod Flesch
8e188cfe61 fix: adding and replacing similarly shaped block configs (#3140) 2023-08-08 12:38:14 -04:00
Jessica Chowdhury
8ae98503f5 docs: adds images to each field page (#3137) 2023-08-08 10:00:21 -04:00
Jessica Chowdhury
1039f39c09 fix: absolute staticURL admin thumbnails (#3135) 2023-08-08 09:49:03 -04:00
Hristiyan Dodov
463d6bbec6 fix: setPreference() return type (#3125) 2023-08-08 09:17:17 -04:00
Jarrod Flesch
b117e73464 feat: radio and select fields are filterable by options (#3136) 2023-08-07 16:58:42 -04:00
PatrikKozak
fd0f078586 Merge pull request #3134 from leikoilja/fix-form-builder-example
fix: form-builder buildInitialFormState example
2023-08-07 11:14:20 -04:00
Ilja Leiko
0aa494b339 fix: fix form-builder buildInitialFormState example 2023-08-07 12:36:07 +02:00
Dan Ribbens
e8f05165eb feat: default tab labels from name (#3129) 2023-08-05 13:48:56 -04:00
Dan Ribbens
a776e06111 chore(release): v1.12.0 2023-08-04 14:06:10 -04:00
Dan Ribbens
02fc36e988 chore: update devDependencies for supply chain vulnerabilities (#3127) 2023-08-04 13:53:57 -04:00
Alessio Gravili
c5756ed4a1 feat: option to pre-fill login credentials automatically (#3021)
Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
2023-08-04 13:41:08 -04:00
Dan Ribbens
356f174b9f feat: set JWT token field name with saveToJWT (#3126) 2023-08-04 13:22:05 -04:00
Jarrod Flesch
1c15868b50 chore(translations): removes extra keys from required 2023-08-04 12:59:12 -04:00
Jarrod Flesch
1180c795a3 chore: adds missing translations 2023-08-04 12:52:58 -04:00
Dan Ribbens
da27a8aadb fix: relationship field filter long titles (#3113) 2023-08-04 11:40:47 -04:00
Alessio Gravili
6a189c6548 fix: wrong links in verification and forgot password emails if serverURL not set (#3010) 2023-08-04 11:30:09 -04:00
Jessica Chowdhury
8c4d2514b0 fix: excludes useAsTitle field from searchableFields in collection view (#3105) 2023-08-04 11:27:52 -04:00
Alessio Gravili
a09c4ddc3b chore: improve flaky admin test suite (#3085) 2023-08-04 11:23:17 -04:00
Jarrod Flesch
5ca45987c4 chore: adds error and errors translations (#3121) 2023-08-03 15:14:34 -04:00
Jarrod Flesch
5b07e18ff5 chore: adds missing japanese translations (#3119) 2023-08-03 12:39:10 -04:00
Jessica Chowdhury
ea73e689ac feat: allows for upload relationship drawer to be opened (#3108) 2023-08-03 12:03:27 -04:00
Jacob Fletcher
456f29d689 chore: updates CONTRIBUTING.md (#3073) 2023-08-03 11:57:00 -04:00
Jacob Fletcher
50360b8769 chore: updates PULL_REQUEST_TEMPLATE.md (#3088) 2023-08-03 11:56:38 -04:00
Alessio Gravili
541e41293d chore: add RichTextAdapter interface type (#3117) 2023-08-03 11:31:21 -04:00
Jarrod Flesch
a78c4631b4 feat: programmatic control over array and block rows inside the form (#3110) 2023-08-03 09:39:50 -04:00
Jarrod Flesch
da8ff20616 chore: prevent enter keypress from saving document (#3115) 2023-08-03 08:51:30 -04:00
Jacob Fletcher
037ccdd96e chore(examples): updates preview example (#3099) 2023-08-01 16:53:45 -04:00
Jacob Fletcher
b84496e5da chore(examples): updates auth example (#3100) 2023-08-01 16:53:31 -04:00
dependabot[bot]
62ecf54f85 chore(deps): bump semver in /examples/form-builder/nextjs (#3075)
Bumps [semver](https://github.com/npm/node-semver) from 6.3.0 to 6.3.1.
- [Release notes](https://github.com/npm/node-semver/releases)
- [Changelog](https://github.com/npm/node-semver/blob/v6.3.1/CHANGELOG.md)
- [Commits](https://github.com/npm/node-semver/compare/v6.3.0...v6.3.1)

---
updated-dependencies:
- dependency-name: semver
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-01 15:24:25 -04:00
Sean Zubrickas
3fdaeb875e removes yarn lock from virtual fields example because of merge conflict 2023-08-01 09:26:47 -04:00
Sean Zubrickas
992be4af44 updates top banner copy 2023-08-01 09:25:17 -04:00
Josef Bredreck
144bb81721 feat: add support for sharp resize options (#2844)
* feat(ImageResize): add support for resize options

* fix(ImageUpload): reuse name for accidental duplicate

* fix(ImageResize): e2e tests for added media size

* chore: simplify fileExists method

* fix: typo

* feat(ImageResize): update name to be more transparent

* fix: use fileExists in file removal

* improve names, comments and clarity of needsResize function

* fix: jsDoc params

* fix: incorrect needsResize condition and add failing test case

* chore: improve comment

* fix: merge conflict error

---------

Co-authored-by: Alessio Gravili <70709113+AlessioGr@users.noreply.github.com>
2023-08-01 09:20:50 -04:00
Dan Ribbens
5ef20e3440 docs: mention virtual fields cannot be sorted (#3107) 2023-08-01 05:10:02 -04:00
James Mikrut
88b56d04f5 Update README.md 2023-07-31 18:31:33 -04:00
James
4b00850e41 chore(release): v1.11.8 2023-07-31 15:00:28 -04:00
James
badf2336ee chore: resolves type conflicts introduced with database folder 2023-07-31 14:55:23 -04:00
James
6220c3d6d9 chore: includes database files for adapter build 2023-07-31 14:46:28 -04:00
Dan Ribbens
455b35dc1b chore: remove console log array field 2023-07-28 07:27:14 -04:00
Sean Zubrickas
b7299ab601 increases font size on top banner 2023-07-27 17:27:22 -04:00
Sean Zubrickas
174f83faf7 adds alternate github banner, removes cloud cta 2023-07-27 17:24:45 -04:00
Sean Zubrickas
5e41e0fb9e removes benefits banner & reverts to unordered list 2023-07-27 16:54:55 -04:00
James
129a9e7675 chore(release): v1.11.7 2023-07-26 21:24:27 -04:00
Sean Zubrickas
eb57c2280e removes benefits h3 in favor of benefits image, reorders helpful links 2023-07-26 18:48:58 -04:00
Sean Zubrickas
e2ad0baaaf refactors benefits list into h3 2023-07-26 17:41:56 -04:00
Jarrod Flesch
7542a92104 chore(tests): adds array row manipulation tests (#3086) 2023-07-26 16:34:13 -04:00
Corfitz
0a91950f05 fix: incorrect image rotation after being processed by sharp (#3081)
* Applying rotation fix for sharp image resizing

* fix: make sure original image is rotated correctly

* chore: explain why rotate() is needed in comments

---------

Co-authored-by: Alessio Gravili <alessio@gravili.de>
2023-07-26 20:57:36 +02:00
James
02809532b4 fix: #3062 2023-07-26 11:34:22 -04:00
Alessio Gravili
67ba131cc6 feat: ability to add context to payload's request object (#2796)
Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
2023-07-26 09:07:49 -04:00
Jarrod Flesch
cf9795b8d8 fix: array row deletion (#3062) 2023-07-26 09:01:25 -04:00
James
a5f42e6a08 chore(release): v1.11.6 2023-07-25 17:14:59 -04:00
James Mikrut
23e718d4d1 Merge pull request #3068 from sannajammeh/master
fix(admin:upload): Enable adminThumbnail fn execution on all mime types
2023-07-25 17:01:50 -04:00
Sean Zubrickas
e8d9cab046 updates payload logos, updates top banner + cloud banner, adds line to benefits 2023-07-25 16:14:43 -04:00
Tylan Davis
d43c83dad1 fix: threads hasMaxRows into ArrayAction components within blocks and arrays (#3066) 2023-07-25 15:43:20 -04:00
Jarrod Flesch
916f04cba0 chore: better parity for initing admin routes between dev and build (#3074) 2023-07-25 14:27:01 -04:00
Jarrod Flesch
156c3eeb08 chore: adds updated yarn lock files for examples and templates folders 2023-07-25 14:22:53 -04:00
Jarrod Flesch
9755a55672 chore: sets payload to latest within templates and examples 2023-07-25 14:11:33 -04:00
Jacob Fletcher
774ffa14d3 chore: updates e-commerce template (#3072) 2023-07-25 12:47:08 -04:00
James
e30db30b07 chore(release): v1.11.5 2023-07-25 10:27:03 -04:00
Jarrod Flesch
e71866856f fix: admin route not mounting on production serve (#3071) 2023-07-25 10:16:55 -04:00
Elliot DeNolf
242dac5b8e chore(release): v1.11.4 2023-07-25 08:48:16 -04:00
Sanna Jammeh
dda9ff01ca docs(upload): Modify the note under adminThumbnail to reflect changes 2023-07-25 00:35:19 +00:00
Sanna Jammeh
5b7aac08f5 test(uploads): Add test case for adminThumbnail 2023-07-25 00:29:54 +00:00
Sanna Jammeh
2c74e9396a fix(collections:admin): Enable adminThumbnail fn execution on all types 2023-07-24 22:42:41 +00:00
Sean Zubrickas
62b73250b4 changes e-commerce and saas links to h3s, adds icons to each heading 2023-07-24 14:47:20 -04:00
Sean Zubrickas
9953e36f6b updates cloud cta, updates examples & tempaltes block, adds one-click tempaltes block 2023-07-24 14:17:19 -04:00
Sean Zubrickas
532f08c5b8 updates readme with new images, copy and layout 2023-07-24 13:29:04 -04:00
Jessica Boezwinkle
136298ac86 docs: fix useAuth code snippet on admin/react-hooks 2023-07-24 16:53:56 +01:00
Greg Willard
080e6195ef feat: improve keyboard focus styles (#3011)
* feat: Card: add keyboard focus outline

* feat: Button: add keyboard focus styles

* feat: links: add keyboard focus styles

* feat: CopyToClipboard: fix textarea tabbing issue, add keyboard focus style

* chore: fix text getting darker on keyboard focus

* feat: Pill: add keyboard focus styles

* feat: Paginator: fix disabled state, add keyboard focus styles

* feat: Nav: add keyboard focus styles

* feat: Table: add keyboard focus styles

* chore: add jsDocs to (s)css loaders

* fix: update dependency which fixes css bug

* chore: remove unnecessary Card style

* fix: use Button instead of button for DeleteDocument

* chore: override browser default outline

* chore: remove unnecessary outline rule

* fix: list drawer outline

---------

Co-authored-by: Alessio Gravili <alessio@gravili.de>
2023-07-24 17:04:12 +02:00
Jacob Fletcher
074abf4b7d chore: migrates ecommerce template to next.js app router (#2991) 2023-07-24 08:23:51 -04:00
Jarrod Flesch
08377cc5a7 fix: if arrayFieldType rows are undefined, page would crash (#3049) 2023-07-21 17:24:44 -04:00
Jarrod Flesch
641c765fb9 feat: solidifies bundler adapter pattern (#3044) 2023-07-21 17:20:51 -04:00
Jacob Fletcher
9f06253321 chore: fixes ecommerce template .env.example (#3041) 2023-07-20 17:45:55 -04:00
Elliot DeNolf
5476cdfee2 chore: only needed dependabot security alerts enabled, not all deps 2023-07-20 17:44:03 -04:00
Elliot DeNolf
f232434b9a chore: add dependabot (#3027) 2023-07-20 17:12:05 -04:00
Jacob Fletcher
2a932ea28e chore: updates auth example (#3026) 2023-07-20 14:06:26 -04:00
Elliot DeNolf
41d3eee35f feat: bump mongoose and mongoose-paginate versions (#3025) 2023-07-20 12:51:30 -04:00
Elliot DeNolf
7aa57308be chore(release): v1.11.3 2023-07-19 17:54:16 -04:00
Elliot DeNolf
744a79f286 chore: pin mongoose-paginate-v2 2023-07-19 17:29:27 -04:00
Dominik Zogg
cd0bf68a61 feat: support logger destination (#2896)
* add-pino-destination-stream-support

* destinationStream => loggerDestination
2023-07-19 11:48:13 -04:00
Jarrod Flesch
a69c3ec476 chore: updates example folder mongodb uri's to work with node 18 2023-07-18 16:51:22 -04:00
Alessio Gravili
3ac910bf6d chore: improves datepicker styles and functionality (#2347)
Co-authored-by: Jarrod Flesch <jarrodmflesch@gmail.com>
2023-07-18 14:32:30 -04:00
Jarrod Flesch
60fca40780 fix: rich text link element not validating on create (#3014) 2023-07-18 08:54:22 -04:00
Alessio Gravili
733fc0b2d0 feat: auto-login in config capability (#3009)
This is useful when developing/testing, where logging after every change can be cumbersome.
2023-07-17 16:35:58 -04:00
Jacob Fletcher
2fc03f196e feat: returns queried user alongside refreshed token (#2813)
Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
2023-07-17 09:35:34 -04:00
Jessica Chowdhury
7927dd485a docs: adds auth example for useAPIKey and disableLocalStrategy (#3007) 2023-07-17 09:30:30 -04:00
Jessica Chowdhury
42334263bb fix: adds backdrop blur to button (#3006) 2023-07-17 09:24:39 -04:00
James
75fbec21a9 chore(release): v1.11.2 2023-07-14 10:47:37 -04:00
Ritsu
281239db05 chore: fix typo error ua.json (#2995) 2023-07-13 16:11:20 -04:00
Jarrod Flesch
59bc002aed chore: fix protectRoles in auth example 2023-07-12 08:31:21 -04:00
Jarrod Flesch
70f3e6fc3e chore: explicitly import Tab type as type 2023-07-11 23:40:02 -04:00
Jarrod Flesch
4925f90b5f feat: adds array, collapsible, tab and group error states
Co-authored-by: Jessica Boezwinkle <jessica@trbl.design>
Co-authored-by: James <james@trbl.design>
2023-07-11 23:20:27 -04:00
James
fafec05309 chore(release): v1.11.1 2023-07-11 10:13:40 -04:00
Jacob Fletcher
76a71c1af5 chore: adds use-client directive to label component (#2988) 2023-07-11 10:06:25 -04:00
James Mikrut
2854bfebf7 Merge pull request #2987 from payloadcms/fix/#2980
fix: #2980, locale=all was not iterating through arrays / blocks
2023-07-10 13:32:25 -04:00
James
d6bfba72a6 fix: #2980, locale=all was not iterating through arrays / blocks 2023-07-10 11:47:34 -04:00
PatrikKozak
2b0f65a27f docs: fixes admin panel table (#2986) 2023-07-10 10:16:25 -04:00
Jarrod Flesch
4b60845c67 chore: fix auth example protectRoles function 2023-07-07 12:42:27 -04:00
Jessica Boezwinkle
562cd18622 docs: adds authentication video 2023-07-07 17:05:35 +01:00
Jarrod Flesch
584d865d34 chore: improves error messaging for not found collections (#2982) 2023-07-07 11:56:14 -04:00
Jarrod Flesch
5b7756e266 chore: fixes auth example protectRoles function 2023-07-07 11:34:19 -04:00
Jacob Fletcher
cfeeb9758f chore: adds eject script to custom server example (#2979) 2023-07-06 16:36:22 -04:00
Jacob Fletcher
51058f65e5 chore: builds auth example for next.js app router (#2976) 2023-07-06 14:15:28 -04:00
Jacob Fletcher
6bc4dde23c chore: builds preview example for next.js app router (#2718) 2023-07-06 13:18:31 -04:00
PatrikKozak
40d6fe0b09 chore: adjusts custom components docs (#2908) 2023-07-05 17:33:29 -04:00
Jacob Fletcher
9881d322f3 docs: fixes misc cloud typos (#2975) 2023-07-05 16:31:51 -04:00
Dan Ribbens
1877d2247c fix: anchor Button component respect margins (#2648) 2023-07-05 16:20:25 -04:00
Dan Ribbens
1bf81f56ce chore(release): v1.11.0 2023-07-05 16:15:29 -04:00
Jarrod Flesch
606c3cf021 Merge branch 'master' of https://github.com/payloadcms/payload 2023-07-05 15:26:15 -04:00
Jarrod Flesch
d112159d93 docs: fix mdx formatting 2023-07-05 15:26:10 -04:00
Jacob Fletcher
79393e8cf0 fix: properly threads custom react-select props through relationship field (#2973) 2023-07-05 15:11:46 -04:00
Jarrod Flesch
5b79067cc1 fix: ensures fields within blocks respect field level access control (#2969) 2023-07-05 14:41:39 -04:00
Jessica Chowdhury
04851d0dc9 fix: ensures rows always have id's (#2968)
Co-authored-by: Jarrod Flesch <jarrodmflesch@gmail.com>
2023-07-05 14:40:50 -04:00
Elliot DeNolf
7c47e4b0d3 feat: improve typing of ExtendableError and APIError (#2864) 2023-07-05 13:39:29 -04:00
Alessio Gravili
b734a1c422 feat: narrow endpoint.method type (#1880)
Co-authored-by: Jarrod Flesch <jarrodmflesch@gmail.com>
2023-07-05 13:20:56 -04:00
Jacob Fletcher
9b22c4b654 docs: fixes misc links (#2971) 2023-07-05 12:02:56 -04:00
Elliot DeNolf
03c2b36b84 chore: move cross-env to runtime dep (#2970) 2023-07-05 11:58:19 -04:00
Elliot DeNolf
868823d9e1 chore(templates): change user collection to default access (#2972) 2023-07-05 11:58:07 -04:00
Jessica Boezwinkle
365b91e1b4 docs: misc cloud updates 2023-07-05 16:52:03 +01:00
Jessica Chowdhury
221356f6b9 Merge pull request #2956 from payloadcms/docs/cloud
docs: adds Cloud docs
2023-07-05 16:22:26 +01:00
Jessica Boezwinkle
1db1de1116 docs: misc tweaks to cloud docs 2023-07-05 16:21:22 +01:00
Jessica Chowdhury
801f60939b fix: nested richtext bug and test (#2966)
* fix: nested richtext bug and test

* chore: fix accidentally deleted character
2023-07-05 09:06:02 -04:00
Tylan Davis
dfdd334d16 docs: adds Cloud docs 2023-06-30 19:07:48 -04:00
Jacob Fletcher
a8e47088bb chore: adds front-end to ecommerce template (#2942) 2023-06-30 17:36:58 -04:00
Alessio Gravili
29d8bf0927 fix: GraphQL type for number field (#2954) 2023-06-30 22:52:35 +02:00
Jacob Fletcher
8a32909dcd chore: fixes tsconfig and nodemon in custom server example (#2952) 2023-06-30 11:53:50 -04:00
James
c0eed02924 chore(release): v1.10.5 2023-06-30 10:29:45 -04:00
Alessio Gravili
1d4df99ea7 fix: improve versions test suite (#2941)
* fix: versions test

* fix: restore tests not being effective

* make tests better

* new test: should versions be in correct order
2023-06-30 15:35:59 +02:00
Jarrod Flesch
b36deb4640 fix: incorrect graphql type generation (#2898) 2023-06-30 08:54:19 -04:00
Alessio Gravili
0c2e41c4be fix: fields in drawer cannot be edited (#2949)
Fixes #2945
2023-06-30 14:43:47 +02:00
James
d9dd78ad00 chore(release): v1.10.4 2023-06-29 20:29:09 -04:00
James Mikrut
06711be846 Merge pull request #2939 from AlessioGr/locale-in-apiurl
feat: add locale to displayed API URL
2023-06-29 20:23:19 -04:00
James
bf0b114b70 chore(release): v1.10.3 2023-06-29 20:22:40 -04:00
James Mikrut
68b220ff73 Merge pull request #2943 from payloadcms/fix/#2937
fix: #2937, depth not being respected in graphql rich text fields
2023-06-29 20:13:32 -04:00
James
f84b4323e2 fix: #2937, depth not being respected in graphql rich text fields 2023-06-29 20:08:39 -04:00
Alessio Gravili
064af8acc7 add apiURL for globals 2023-06-29 17:42:49 +02:00
Alessio Gravili
b22d157bd2 feat: add locale to displayed API URL 2023-06-29 17:19:36 +02:00
Jacob Fletcher
0112f4c4ab chore: builds custom server example (#2920) 2023-06-28 16:35:41 -04:00
Jacob Fletcher
6670915323 chore: adds ecommerce template (#2929) 2023-06-28 12:51:17 -04:00
Jacob Fletcher
49f117e220 chore: adds website template (#2928) 2023-06-28 12:48:08 -04:00
James Mikrut
8df4b15116 Merge pull request #2927 from payloadcms/fix/show-updatedAt-date
fix: shows updatedAt date when selecting a version to compare
2023-06-28 12:03:37 -04:00
Jacob Fletcher
766b1b5286 chore: creates templates directory (#2921) 2023-06-28 11:20:59 -04:00
Tylan Davis
3c9dab3b9d fix: shows updatedAt date when selecting a version to compare from dropdown 2023-06-28 10:47:41 -04:00
James Mikrut
7d156ef555 Merge pull request #2910 from payloadcms/chore/error-messages
chore: improves error messaging in unlock/reset/forgot-password
2023-06-28 08:18:28 -04:00
James
1aa38f8fdd chore(release): v1.10.2 2023-06-26 17:58:23 -04:00
Jarrod Flesch
a2d9ef3ca6 fix: adjusts swc loader to only exclude non ts/tsx files - #2888 (#2907) 2023-06-26 13:53:08 -04:00
Jessica Boezwinkle
9fbd7476fb chore: improves error messaging in unlock/reset/forgot-password 2023-06-26 18:39:46 +01:00
Jarrod Flesch
f627277479 fix: correctly scopes data variable within bulk update - #2901 (#2904) 2023-06-26 11:56:53 -04:00
Jessica Chowdhury
0d17d4f38e Merge pull request #2903 from payloadcms/fix/autosave-localized-docs
fix: autosave on localized fields, adds test
2023-06-26 16:00:51 +01:00
Jessica Boezwinkle
7e98cf94f3 chore: remove comments from test 2023-06-26 16:00:21 +01:00
Jessica Boezwinkle
6893231f85 fix: autosave on localized fields, adds test 2023-06-26 15:27:30 +01:00
Elliot DeNolf
8206c0fe8b fix: safely check for tempFilePath when updating media document (#2899) 2023-06-23 15:35:12 -04:00
Teun Mooij
837dcccefe fix: broken export of entityToJSONSchema (#2894) 2023-06-22 16:21:37 -04:00
Dan Ribbens
3e05598b56 chore(release): v1.10.1 2023-06-22 14:38:28 -04:00
Dan Ribbens
8128de64df fix: Relationship hasMany and filterOptions fails above 10 items (#2891) 2023-06-22 14:28:03 -04:00
Jarrod Flesch
b83d788d3c fix: conditional fields perf bug - #2886 (#2890) 2023-06-22 13:51:24 -04:00
PatrikKozak
6e62aab66e Merge pull request #2817 from payloadcms/chore/api-keys-docs
Chore/api keys docs
2023-06-22 11:08:27 -04:00
PatrikKozak
5de3515fc8 chore: re-words portion of api key docs 2023-06-22 10:43:53 -04:00
PatrikKozak
65ac61f300 Merge branch 'master' of https://github.com/payloadcms/payload into chore/api-keys-docs 2023-06-22 10:10:28 -04:00
Jacob Fletcher
10b8d492b3 docs: vercel visual editing (#2883) 2023-06-21 17:56:54 -04:00
Jacob Fletcher
09c6cad3e8 fix: cutoff tooltips in relationship field (#2873) 2023-06-20 17:49:18 -04:00
Dan Ribbens
e4df1293d2 chore(release): v1.10.0 2023-06-20 17:19:31 -04:00
Dan Ribbens
ce84174554 fix: relationship field query pagination (#2871) 2023-06-20 17:03:40 -04:00
Jacob Fletcher
ba9d6336ac fix: mobile loading overlay width #2866 (#2867) 2023-06-20 16:05:48 -04:00
Jacob Fletcher
e90c2c4cb7 chore: simplifies relationship drawer field test (#2872) 2023-06-20 16:04:54 -04:00
Alessio Gravili
8f086e315c feat: hasMany for number field (#2517)
* added custom config extension points

* Added custom field to documentation

* fix: not building due to incorrect typings

* Upload dist

* point to number array test

* feat: hasMany for number field

* fix: types

* Fix: incorrectly styles input for hasMany

* Revert "point to number array test"

This reverts commit 5a5162a803.

* Revert "Merge branch 'production-with-custom' into number-hasmany-v2"

This reverts commit dfc3ac523e, reversing
changes made to a3b1b7dd67.

* test: adds test for numbers with hasMany

* test: add number field e2e

* Fix updated index.tsx

* Fix updated index.tsx

* chore: add jsDocs for hasMany property

* chore: rename isMultiText to isCreatable, as it makes more sense

* fix: incorrect double space in comments

* chore: rename onMultiTextChange to handleHasManyChange

* chore: improve ordering

* docs: add documentation for hasMany

* docs: add more jsdocs for number field

* fix: new value not transformed to number

* improve types

* fix: only allow numbers as input using filterOption

* fix: Option / value type breaking sortable selects

* fix: typings and add id for sorting

* add animation to react select

* undo transitions due to glitches

* fix: keyboard handler for select for empty input values

* fix: validation for hasMany numbers

* feat: perform validation in the filter as well

* attempt to fix duplicate key issue

* add todo

* remove console logs

* fix: stupid key warning

* fix: validation tests

* feat: add filterOption to keydown listener

* feat: numberOnly for react-select

* chore: improve variable naming

* fix: allow numbers for relationship value by stringifying those for sortable react-selects

* feat: generated types for hasMany number field

* graphql typings part 1

* graphql defaults type

* better typing for number in buildObjectType

* fix: default graphql type disregarding hasMany for relationship field

* feat: minRows and maxRows for hasMany numbers

* simplify joi schema

* working minRows and maxRows validation!

* jesus christ: fix incorrect translations for number & relationship fields for greaterThanMax and lessThanMin

* fix weird type error

* move validation tests to validations.spec.ts and fix them

* fix: make sure filterOption only passes a number array to validate function

* fix: adds missing dark-mode styles for version differences view (#2812)

Co-authored-by: Tylan Davis <tylan@Tylans-MacBook-Pro.local>

* fix: #2821 i18n ui field label (#2823)

* chore: version diff styles (#2824)

Co-authored-by: Tylan Davis <tylan@Tylans-MacBook-Pro.local>

* chore: remove --legacy-peer-deps from gh actions workflow (#2814)

* chore: removes cms text from instances of payload name (#2793)

* chore(release): v1.9.2

* chore: update changelog release notes v1.9.2

* chore: cleans up graphql-schema-gen test folder

* fix: adds custom property to ui field in joi validation (#2835)

* adjust validation

* improve isnumber function

* Update number.mdx

---------

Co-authored-by: Teun Mooij <tmooij@infinitaslearning.com>
Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
Co-authored-by: Tylan Davis <89618855+tylandavis@users.noreply.github.com>
Co-authored-by: Tylan Davis <tylan@Tylans-MacBook-Pro.local>
Co-authored-by: Dan Ribbens <DanRibbens@users.noreply.github.com>
Co-authored-by: Jacob Fletcher <jacobsfletch@gmail.com>
Co-authored-by: Jarrod Flesch <jarrodmflesch@gmail.com>
Co-authored-by: Jarrod Flesch <30633324+JarrodMFlesch@users.noreply.github.com>
2023-06-20 20:21:27 +02:00
Alessio Gravili
542b5362d3 fix: drawer fields are read-only if opened from a hasMany relationship (#2843) 2023-06-20 11:22:49 -04:00
Jacob Fletcher
8626dc6b1a fix: fields in relationship drawer not usable #2815 (#2870) 2023-06-20 11:21:23 -04:00
Alessio Gravili
a110ba2dc0 fix: drawer close on backspace (#2869) 2023-06-20 10:10:29 -04:00
James
85d2467d73 fix: #2831, persists payloadAPI through local operations that accept req 2023-06-19 15:57:04 -04:00
Dan Ribbens
99f38098dd fix: default sort with near operator (#2862) 2023-06-19 15:17:22 -04:00
James Mikrut
b1123a4978 Merge pull request #2856 from payloadcms/feat/conditional-logic-perf
feat: optimizes conditional logic performance
2023-06-19 15:03:50 -04:00
James
4af8d56479 chore: ensures conditions are run in all appropriate cases 2023-06-19 15:03:34 -04:00
digitaledge-git
16118960aa fix: near query sorting by distance and pagination (#2861) 2023-06-19 14:54:40 -04:00
James
2c5a737715 chore: fixes initial state for url field 2023-06-19 13:39:11 -04:00
James Mikrut
5fa77d40b9 Merge pull request #2858 from payloadcms/fix/#2842
fix: #2842, querying number custom ids with in
2023-06-19 11:18:58 -04:00
Alessio Gravili
e9106882f7 feat: automatically redirect a user back to their originally requested URL after login (#2838) 2023-06-19 11:15:58 -04:00
James Mikrut
42f0db4251 Merge pull request #2800 from AlessioGr/improve-error
chore: improve error message during webpack load
2023-06-19 11:13:42 -04:00
James Mikrut
c3533dac2a Merge pull request #2846 from dpnolte/chore/disable_eslint_for_generated_types
chore: disable eslint on generated types
2023-06-19 11:11:48 -04:00
James Mikrut
8d52e5f078 Merge pull request #2830 from payloadcms/chore/depth-docs
chore: updates depth docs with N + 1 concept
2023-06-19 11:10:08 -04:00
James
116e9ffe81 fix: #2842, querying number custom ids with in 2023-06-19 11:02:30 -04:00
James
967f217346 feat: optimizes conditional logic performance 2023-06-19 10:48:17 -04:00
James Mikrut
da2a94d0b2 Merge pull request #2850 from AlessioGr/fix-configToJSONSchema
fix: old entityToJSONSchema being exported
2023-06-19 10:28:02 -04:00
James Mikrut
6c2b726fe1 Merge pull request #2855 from payloadcms/fix/#2832
fix: #2832, slow like queries with lots of records
2023-06-19 10:18:49 -04:00
James
4dd703a6bf fix: slow like queries with lots of records 2023-06-19 10:13:47 -04:00
Alessio Gravili
762b572c51 configToJSONSchema 2023-06-18 17:24:58 +02:00
Derk Nolte
6ca371cb8b chore: disable eslint on generated types 2023-06-18 10:14:21 +02:00
Alessio Gravili
0d8d7f358d fix: deprecate min/max in exchange for minRows and maxRows for relationship field (#2826)
* fix: deprecate min/max in exchange for minRows and maxRows for relationship

* fix: update validations unit tests with minRows and maxRows

* fix: incorrect types

* move to sanitize
2023-06-18 02:09:30 +02:00
James
51c2ab1672 chore(release): v1.9.5 2023-06-16 17:41:40 -04:00
James
a88f86cc3f chore: ensures objectid within works properly 2023-06-16 17:37:15 -04:00
James
451c8c7548 chore(release): v1.9.4 2023-06-16 16:43:40 -04:00
James Mikrut
528645d407 Merge pull request #2791 from no-heroes/fix/pagination-false-totaldocs
fix: totalDocs is always 1 when using payload.find({ pagination: false })
2023-06-16 16:37:50 -04:00
James
70cf8487e7 chore(release): v1.9.3 2023-06-16 16:17:34 -04:00
James
aa09e566e0 Merge branch 'master' of github.com:payloadcms/payload 2023-06-16 15:50:16 -04:00
James
c3d6e1b490 fix: ensures relations to object ids can be queried on 2023-06-16 15:50:09 -04:00
Jarrod Flesch
6580f43e53 chore: relocates configToJSON alongside entityToJSON and fieldsToJSON (#2827) 2023-06-16 12:42:59 -04:00
Jarrod Flesch
56d7745139 fix: adds custom property to ui field in joi validation (#2835) 2023-06-16 09:09:31 -04:00
PatrikKozak
ee1c7db915 chore: updates depth docs with N + 1 concept 2023-06-15 16:59:27 -04:00
Jarrod Flesch
b682c76dc7 chore: cleans up graphql-schema-gen test folder 2023-06-15 09:54:53 -04:00
Dan Ribbens
0d035a9c23 chore: update changelog release notes v1.9.2 2023-06-14 11:33:07 -04:00
Dan Ribbens
8310950f7b chore(release): v1.9.2 2023-06-14 11:32:14 -04:00
Jacob Fletcher
120e2936fe chore: removes cms text from instances of payload name (#2793) 2023-06-14 10:31:29 -04:00
Alessio Gravili
884f7991c4 chore: remove --legacy-peer-deps from gh actions workflow (#2814) 2023-06-14 10:23:48 -04:00
Tylan Davis
9664e4b96f chore: version diff styles (#2824)
Co-authored-by: Tylan Davis <tylan@Tylans-MacBook-Pro.local>
2023-06-14 10:21:23 -04:00
Dan Ribbens
63cd7fbd0c fix: #2821 i18n ui field label (#2823) 2023-06-14 08:39:45 -04:00
Tylan Davis
346a48f871 fix: adds missing dark-mode styles for version differences view (#2812)
Co-authored-by: Tylan Davis <tylan@Tylans-MacBook-Pro.local>
2023-06-14 08:29:13 -04:00
Jessica Boezwinkle
8fe3e59e76 Merge branch 'docs/misc-updates' 2023-06-13 17:35:52 +01:00
Jessica Boezwinkle
74d6156e8d chore: adds credentials to rest api examples 2023-06-13 17:35:39 +01:00
PatrikKozak
e834424a4c Merge branch 'master' of https://github.com/payloadcms/payload into chore/api-keys-docs 2023-06-13 12:25:09 -04:00
PatrikKozak
465d8b0245 chore: updates authentication/api-keys docs 2023-06-13 12:25:02 -04:00
Jessica Boezwinkle
25e9c1a50a fix: adds async await to payload.init example 2023-06-13 17:02:35 +01:00
Jessica Boezwinkle
d601cdd29e fix: adds async await to payload.init example 2023-06-13 17:01:55 +01:00
Jessica Chowdhury
5646ce9d8f Merge pull request #2810 from payloadcms/docs/blocks-table
docs: fix blocks table
2023-06-13 09:28:56 +01:00
Jessica Boezwinkle
f7cacbe932 docs: fix blocks table 2023-06-12 17:27:18 +01:00
Alessio Gravili
abe38520aa fix: user can be created without having to specify an email - #2801 2023-06-12 17:35:06 +02:00
Jarrod Flesch
46a5f41721 fix: sanitize reset password result - #2805 (#2808) 2023-06-12 11:23:24 -04:00
Alessio Gravili
2aea4150a0 improve error message 2023-06-10 21:53:30 +02:00
James
4b2b4c3f9f chore(release): v1.9.1 2023-06-09 16:18:47 -04:00
PatrikKozak
b655809903 Merge pull request #2797 from payloadcms/feat/customize-upload-filename
Feat/customize upload filename
2023-06-09 14:58:06 -04:00
PatrikKozak
2e60830f6a Merge branch 'master' of https://github.com/payloadcms/payload into feat/customize-upload-filename 2023-06-09 14:41:45 -04:00
PatrikKozak
752b5456b9 chore: updates test/uploads test to check for value not text 2023-06-09 14:28:27 -04:00
PatrikKozak
35f7677d48 chore: updates test/fields uploads test to check for value not text 2023-06-09 13:34:24 -04:00
PatrikKozak
a3b7da25bc Merge branch 'master' of https://github.com/payloadcms/payload into feat/customize-upload-filename 2023-06-09 12:39:01 -04:00
PatrikKozak
596eea1f0a feat: adds option to customize filename on upload 2023-06-09 12:38:53 -04:00
Jarrod Flesch
725aa3183d chore: stubs out config for field perf testing 2023-06-09 11:27:18 -04:00
Jarrod Flesch
cf49f53809 Merge remote-tracking branch 'origin' into feat/array-rows 2023-06-09 11:03:41 -04:00
Jarrod Flesch
20c7e37345 chore: block array fixes 2023-06-08 11:49:54 -04:00
Alessio Gravili
38e962f2cb feat: collection list view custom components: BeforeList, BeforeListTable, AfterListTable, AfterList (#2792) 2023-06-08 09:33:16 -04:00
Jarrod Flesch
3efb651589 chore: simplifies get/set doc prefs 2023-06-07 22:47:56 -04:00
Jarrod Flesch
589eb3fa15 chore: removes console logs, accounts for initCollapsed 2023-06-07 22:31:36 -04:00
Jarrod Flesch
87554e9b16 chore: builds rows on init, refactors preferences for documents 2023-06-07 22:21:08 -04:00
Richard van Heuven van Staereling
2e73938534 fix: incorrectly return totalDocs=1 instead of the correct count when pagination=false 2023-06-07 23:36:59 +02:00
Richard van Heuven van Staereling
acf2564c73 chore: adds test to check totalDocs count when querying with pagination=false 2023-06-07 23:36:51 +02:00
Jarrod Flesch
551f1bd09f Merge remote-tracking branch 'origin/master' into feat/array-rows 2023-06-06 17:12:28 -04:00
Jarrod Flesch
2b4cf08f3a chore: combines array and block row state into array field attribute 2023-06-05 12:35:20 -04:00
Elliot67
56d48885e1 :feat: Improve admin panel file's caching 2023-04-16 00:55:27 +02:00
1481 changed files with 151571 additions and 21712 deletions

View File

@@ -1,5 +1,5 @@
name: Bug Report
description: Create a bug report for the Payload CMS
description: Create a bug report for Payload
labels: ["possible-bug"]
body:
- type: markdown

View File

@@ -2,15 +2,18 @@
<!-- Please include a summary of the pull request and any related issues it fixes. Please also include relevant motivation and context. -->
- [ ] I have read and understand the CONTRIBUTING.md document in this repository
- [ ] I have read and understand the [CONTRIBUTING.md](../CONTRIBUTING.md) document in this repository.
## Type of change
<!-- Please delete options that are not relevant. -->
- [ ] Chore (non-breaking change which does not add functionality)
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Change to the [templates](../templates/) directory (does not affect core functionality)
- [ ] Change to the [examples](../examples/) directory (does not affect core functionality)
- [ ] This change requires a documentation update
## Checklist:

View File

@@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
node-version: [16.x, 18.x]
steps:
- uses: actions/checkout@v2
@@ -83,6 +83,6 @@ jobs:
${{ runner.os }}-npm-${{ env.cache-name }}-
${{ runner.os }}-npm-
${{ runner.os }}-
- run: npm install --legacy-peer-deps
- run: npm install
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

View File

@@ -2,16 +2,17 @@
"verbose": true,
"git": {
"commitMessage": "chore(release): v${version}",
"requireCleanWorkingDir": true
"requireCleanWorkingDir": false
},
"github": {
"release": true
},
"npm": {
"skipChecks": true
"skipChecks": true,
"tag": "payload-1"
},
"hooks": {
"before:init": ["yarn", "yarn clean", "yarn test"]
"before:init": ["yarn", "yarn clean"]
},
"plugins": {
"@release-it/conventional-changelog": {

View File

@@ -11,7 +11,7 @@
},
"npm": {
"skipChecks": true,
"tag": "canary"
"tag": "payload-1"
},
"hooks": {
"before:init": ["yarn", "yarn clean", "yarn test"]

9
.vscode/launch.json vendored
View File

@@ -18,5 +18,12 @@
"type": "node-terminal",
"cwd": "${workspaceFolder}"
},
{
"command": "yarn run dev versions",
"name": "Debug Versions",
"request": "launch",
"type": "node-terminal",
"cwd": "${workspaceFolder}"
},
]
}
}

View File

@@ -1,5 +1,352 @@
## [1.15.10](https://github.com/payloadcms/payload/compare/v1.15.9...v1.15.10) (2025-03-10)
## [1.15.8](https://github.com/payloadcms/payload/compare/v1.15.7...v1.15.8) (2023-10-08)
### Bug Fixes
* secures the user response from the me auth route ([#3409](https://github.com/payloadcms/payload/issues/3409)) ([26939a3](https://github.com/payloadcms/payload/commit/26939a333135810f2eebd3ebaf05885d152f6f13))
## [1.15.7](https://github.com/payloadcms/payload/compare/v1.15.6...v1.15.7) (2023-10-02)
### Bug Fixes
* hotkey's pressed keys are not unset when window is not focused ([#3400](https://github.com/payloadcms/payload/issues/3400)) ([8586c85](https://github.com/payloadcms/payload/commit/8586c85fab3009a09be9bf86c22952f85aa0ad82))
## [1.15.6](https://github.com/payloadcms/payload/compare/v1.15.5...v1.15.6) (2023-09-13)
### Bug Fixes
* **#3289:** removes HMR plugin from prod webpack configs ([#3319](https://github.com/payloadcms/payload/issues/3319)) ([8ca67d5](https://github.com/payloadcms/payload/commit/8ca67d5aaa99f0f45eac56766fe42e07ab4a41f1)), closes [#3289](https://github.com/payloadcms/payload/issues/3289)
* fields with relationTo[] correctly load returned data from form submission ([#3317](https://github.com/payloadcms/payload/issues/3317)) ([096d337](https://github.com/payloadcms/payload/commit/096d33718d28cb5207027f6737982b29a0ced90d))
* greater than equal admin filter not working ([#3306](https://github.com/payloadcms/payload/issues/3306)) ([0bd3353](https://github.com/payloadcms/payload/commit/0bd335303dff71977b46b373fbee859d11c33337))
## [1.15.5](https://github.com/payloadcms/payload/compare/v1.15.4...v1.15.5) (2023-09-09)
### Bug Fixes
* corrects hasMany relationships within addFieldStatePromise ([#3300](https://github.com/payloadcms/payload/issues/3300)) ([a7d47c6](https://github.com/payloadcms/payload/commit/a7d47c627d064e92ca541f70caf0ff3d903b2d1d))
## [1.15.4](https://github.com/payloadcms/payload/compare/v1.15.3...v1.15.4) (2023-09-06)
### Bug Fixes
* **#3274:** sets full user data from fetchFullUser instead of partial jwt data ([#3279](https://github.com/payloadcms/payload/issues/3279)) ([cf12b5f](https://github.com/payloadcms/payload/commit/cf12b5fc703be6341b2b23efebd8aa85e8602567)), closes [#3274](https://github.com/payloadcms/payload/issues/3274)
* aligns depth behaviour between local api and admin panel ([#3276](https://github.com/payloadcms/payload/issues/3276)) ([5096c37](https://github.com/payloadcms/payload/commit/5096c378743f4c5eb5f4f2f7e67e5e206cc9da40))
* appends versions key to incoming where query ([#3287](https://github.com/payloadcms/payload/issues/3287)) ([9cd5e5a](https://github.com/payloadcms/payload/commit/9cd5e5aefaf0ee2af4f577da9578bb31bf4b0acb))
* change scoping of `force` parameter to prevent false negation; ([#3278](https://github.com/payloadcms/payload/issues/3278)) ([429a88a](https://github.com/payloadcms/payload/commit/429a88a5a18e8905c63dfe00b78b3e71d56758fd))
## [1.15.3](https://github.com/payloadcms/payload/compare/v1.15.2...v1.15.3) (2023-09-05)
### Bug Fixes
* draft globals always displaying unpublish button ([9bc072c](https://github.com/payloadcms/payload/commit/9bc072ccaf318c61b2c4e2a553604a24ff6a188e))
* globals not saving updatedAt and createdAt and version dates correctly ([9fbabc8](https://github.com/payloadcms/payload/commit/9fbabc8fd6a3bea5628bea8d0acc915ddb33bb5c))
### Features
* improves query speed for version enabled collections ([16e94d4](https://github.com/payloadcms/payload/commit/16e94d401bd7cb82de53142c5f9a325abd31a81a))
## [1.15.2](https://github.com/payloadcms/payload/compare/v1.15.1...v1.15.2) (2023-08-25)
## [1.15.1](https://github.com/payloadcms/payload/compare/v1.15.0...v1.15.1) (2023-08-25)
### Bug Fixes
* arrays in richtext uploads ([#3222](https://github.com/payloadcms/payload/issues/3222)) ([cb8e07f](https://github.com/payloadcms/payload/commit/cb8e07f85232a26c265872faf408644424312af6))
* correct out of order dark-mode color variables ([#3197](https://github.com/payloadcms/payload/issues/3197)) ([3a15e07](https://github.com/payloadcms/payload/commit/3a15e077c6914aba3ef26e453fee23c89f3db829))
* mutation type with tabs missing previous tabs ([#3196](https://github.com/payloadcms/payload/issues/3196)) ([6d3b863](https://github.com/payloadcms/payload/commit/6d3b8636f4e14a4e4155279353fa06e86fe2b25c))
# [1.15.0](https://github.com/payloadcms/payload/compare/v1.14.0...v1.15.0) (2023-08-24)
### Features
* query support for geo within and intersects + dynamic GraphQL operator types ([#3183](https://github.com/payloadcms/payload/issues/3183)) ([739abdc](https://github.com/payloadcms/payload/commit/739abdcd81176b3e812470eeea97b1be0d8c4a27))
# [1.14.0](https://github.com/payloadcms/payload/compare/v1.13.4...v1.14.0) (2023-08-16)
### Bug Fixes
* DatePicker showing only selected day by default ([#3169](https://github.com/payloadcms/payload/issues/3169)) ([edcb393](https://github.com/payloadcms/payload/commit/edcb3933cfb4532180c822135ea6a8be928e0fdc))
* only allow redirects to /admin sub-routes ([c0f05a1](https://github.com/payloadcms/payload/commit/c0f05a1c38fb9c958de920fabb698b5ecfb661f0))
* passes in height to resizeOptions upload option to allow height resize ([#3171](https://github.com/payloadcms/payload/issues/3171)) ([7963d04](https://github.com/payloadcms/payload/commit/7963d04a27888eb5a12d0ab37f2082cd33638abd))
* WhereBuilder component does not accept all valid Where queries ([#3087](https://github.com/payloadcms/payload/issues/3087)) ([fdfdfc8](https://github.com/payloadcms/payload/commit/fdfdfc83f36a958971f8e4e4f9f5e51560cb26e0))
### Features
* add afterOperation hook ([#2697](https://github.com/payloadcms/payload/issues/2697)) ([33686c6](https://github.com/payloadcms/payload/commit/33686c6db8373a16d7f6b0192e0701bf15881aa4))
* add support for hotkeys ([#1821](https://github.com/payloadcms/payload/issues/1821)) ([942cfec](https://github.com/payloadcms/payload/commit/942cfec286ff050e13417b037cca64b9d757d868))
* Added Azerbaijani language file ([#3164](https://github.com/payloadcms/payload/issues/3164)) ([63e3063](https://github.com/payloadcms/payload/commit/63e3063b9ecc1afd62d7a287a798d41215008f2a))
* allow async relationship filter options ([#2951](https://github.com/payloadcms/payload/issues/2951)) ([bad3638](https://github.com/payloadcms/payload/commit/bad363882c9d00d3c73547ca3329eba988e728ff))
* Improve admin dashboard accessibility ([#3053](https://github.com/payloadcms/payload/issues/3053)) ([e03a8e6](https://github.com/payloadcms/payload/commit/e03a8e6b030e82a17e1cdae5b4032433cf9c75a4))
* improve field ops ([#3172](https://github.com/payloadcms/payload/issues/3172)) ([d91b44c](https://github.com/payloadcms/payload/commit/d91b44cbb3fd526caca2a6f4bd30fd06ede3a5da))
* make PAYLOAD_CONFIG_PATH optional ([#2839](https://github.com/payloadcms/payload/issues/2839)) ([5744de7](https://github.com/payloadcms/payload/commit/5744de7ec63e3f17df7e02a7cc827818a79dbbb8))
* text alignment for richtext editor ([#2803](https://github.com/payloadcms/payload/issues/2803)) ([a0b13a5](https://github.com/payloadcms/payload/commit/a0b13a5b01fa0d7f4c4dffd1895bfe507e5c676d))
## [1.13.4](https://github.com/payloadcms/payload/compare/v1.13.3...v1.13.4) (2023-08-11)
### Bug Fixes
* correctly passes block path inside buildFieldSchemaMap ([#3162](https://github.com/payloadcms/payload/issues/3162)) ([3c60abd](https://github.com/payloadcms/payload/commit/3c60abd61aaf24d49712c80bcbd0f1113c22b85a))
## [1.13.3](https://github.com/payloadcms/payload/compare/v1.13.2...v1.13.3) (2023-08-11)
### Bug Fixes
* unable to add arrays inside secondary named tabs ([#3158](https://github.com/payloadcms/payload/issues/3158)) ([cb04d4a](https://github.com/payloadcms/payload/commit/cb04d4a82a68a764330582b93882d422b32c2527))
## [1.13.2](https://github.com/payloadcms/payload/compare/v1.13.1...v1.13.2) (2023-08-10)
## [1.13.1](https://github.com/payloadcms/payload/compare/v1.13.0...v1.13.1) (2023-08-08)
### Bug Fixes
* updates addFieldRow and replaceFieldRow rowIndex insertion ([#3145](https://github.com/payloadcms/payload/issues/3145)) ([f5cf546](https://github.com/payloadcms/payload/commit/f5cf546e1918de66998d5f0e5410bfbc1f054567))
# [1.13.0](https://github.com/payloadcms/payload/compare/v1.12.0...v1.13.0) (2023-08-08)
### Bug Fixes
* `setPreference()` return type ([#3125](https://github.com/payloadcms/payload/issues/3125)) ([463d6bb](https://github.com/payloadcms/payload/commit/463d6bbec66e61523bae3869df88bd98e7617390))
* absolute staticURL admin thumbnails ([#3135](https://github.com/payloadcms/payload/issues/3135)) ([1039f39](https://github.com/payloadcms/payload/commit/1039f39c09260537616b22228080466e8df6e981))
* adding and replacing similarly shaped block configs ([#3140](https://github.com/payloadcms/payload/issues/3140)) ([8e188cf](https://github.com/payloadcms/payload/commit/8e188cfe61db808c94d726967affdadf2e5abb9f))
### Features
* default tab labels from name ([#3129](https://github.com/payloadcms/payload/issues/3129)) ([e8f0516](https://github.com/payloadcms/payload/commit/e8f05165eb3a28c00deb11931db01ad1f8c75c74))
* radio and select fields are filterable by options ([#3136](https://github.com/payloadcms/payload/issues/3136)) ([b117e73](https://github.com/payloadcms/payload/commit/b117e7346434bfc8edbfa92f5db45f63c57bab08))
* recursive saveToJWT field support ([#3130](https://github.com/payloadcms/payload/issues/3130)) ([c6e0908](https://github.com/payloadcms/payload/commit/c6e09080767dad2ab8128ba330b2b344bb25ac6f))
# [1.12.0](https://github.com/payloadcms/payload/compare/v1.11.8...v1.12.0) (2023-08-04)
### Bug Fixes
* excludes useAsTitle field from searchableFields in collection view ([#3105](https://github.com/payloadcms/payload/issues/3105)) ([8c4d251](https://github.com/payloadcms/payload/commit/8c4d2514b0f195e0059c6063346199785979c70c))
* relationship field filter long titles ([#3113](https://github.com/payloadcms/payload/issues/3113)) ([da27a8a](https://github.com/payloadcms/payload/commit/da27a8aadbb103c5f6fe0ccc62c032876851b88f))
* wrong links in verification and forgot password emails if serverURL not set ([#3010](https://github.com/payloadcms/payload/issues/3010)) ([6a189c6](https://github.com/payloadcms/payload/commit/6a189c6548b233aba64598af8804a56ec47e45f0))
### Features
* add support for sharp resize options ([#2844](https://github.com/payloadcms/payload/issues/2844)) ([144bb81](https://github.com/payloadcms/payload/commit/144bb81721814c19eb4957d4c8fcc845c73e2aa4))
* allows for upload relationship drawer to be opened ([#3108](https://github.com/payloadcms/payload/issues/3108)) ([ea73e68](https://github.com/payloadcms/payload/commit/ea73e689ac46f2a7ba3b6c34e7a190944b5d5868))
* option to pre-fill login credentials automatically ([#3021](https://github.com/payloadcms/payload/issues/3021)) ([c5756ed](https://github.com/payloadcms/payload/commit/c5756ed4a13b46bc73ae7b23309d6e9980fc81bf))
* programmatic control over array and block rows inside the form ([#3110](https://github.com/payloadcms/payload/issues/3110)) ([a78c463](https://github.com/payloadcms/payload/commit/a78c4631b4aabb5b57448ab21ef98749b1cf1935))
* set JWT token field name with saveToJWT ([#3126](https://github.com/payloadcms/payload/issues/3126)) ([356f174](https://github.com/payloadcms/payload/commit/356f174b9ff601facb0062d0b65db18803ef2aa2))
## [1.11.8](https://github.com/payloadcms/payload/compare/v1.11.7...v1.11.8) (2023-07-31)
## [1.11.7](https://github.com/payloadcms/payload/compare/v1.11.6...v1.11.7) (2023-07-27)
### Bug Fixes
* [#3062](https://github.com/payloadcms/payload/issues/3062) ([0280953](https://github.com/payloadcms/payload/commit/02809532b484d9018c6528cfbbbb43abfd55a540))
* array row deletion ([#3062](https://github.com/payloadcms/payload/issues/3062)) ([cf9795b](https://github.com/payloadcms/payload/commit/cf9795b8d8b53c48335ff4c32c6c51b3de4f7bc9))
* incorrect image rotation after being processed by sharp ([#3081](https://github.com/payloadcms/payload/issues/3081)) ([0a91950](https://github.com/payloadcms/payload/commit/0a91950f052ce40427801e6561a0f676354a2ca4))
### Features
* ability to add context to payload's request object ([#2796](https://github.com/payloadcms/payload/issues/2796)) ([67ba131](https://github.com/payloadcms/payload/commit/67ba131cc61f3d3b30ef9ef7fc150344ca82da2f))
## [1.11.6](https://github.com/payloadcms/payload/compare/v1.11.5...v1.11.6) (2023-07-25)
### Bug Fixes
* **collections:admin:** Enable adminThumbnail fn execution on all types ([2c74e93](https://github.com/payloadcms/payload/commit/2c74e9396a216a033e2bacdf189b7f28a0f97505))
* threads hasMaxRows into ArrayAction components within blocks and arrays ([#3066](https://github.com/payloadcms/payload/issues/3066)) ([d43c83d](https://github.com/payloadcms/payload/commit/d43c83dad1bab5b05f4fcbae7d41de369905797c))
## [1.11.5](https://github.com/payloadcms/payload/compare/v1.11.4...v1.11.5) (2023-07-25)
### Bug Fixes
* admin route not mounting on production serve ([#3071](https://github.com/payloadcms/payload/issues/3071)) ([e718668](https://github.com/payloadcms/payload/commit/e71866856fffefcfb61dd3d29135cccb66939a62))
## [1.11.4](https://github.com/payloadcms/payload/compare/v1.11.3...v1.11.4) (2023-07-25)
### Bug Fixes
* if arrayFieldType rows are undefined, page would crash ([#3049](https://github.com/payloadcms/payload/issues/3049)) ([08377cc](https://github.com/payloadcms/payload/commit/08377cc5a7ea9d02350177e2e1d69390ee97af78))
### Features
* bump mongoose and mongoose-paginate versions ([#3025](https://github.com/payloadcms/payload/issues/3025)) ([41d3eee](https://github.com/payloadcms/payload/commit/41d3eee35f3855798a5c3372f8ad7c742a7810f7))
* improve keyboard focus styles ([#3011](https://github.com/payloadcms/payload/issues/3011)) ([080e619](https://github.com/payloadcms/payload/commit/080e6195ef39ec858fbb115e8f554a8dfc436438))
* solidifies bundler adapter pattern ([#3044](https://github.com/payloadcms/payload/issues/3044)) ([641c765](https://github.com/payloadcms/payload/commit/641c765fb921e162c98f09218929348037dd0f88))
## [1.11.3](https://github.com/payloadcms/payload/compare/v1.11.2...v1.11.3) (2023-07-19)
### Bug Fixes
* adds backdrop blur to button ([#3006](https://github.com/payloadcms/payload/issues/3006)) ([4233426](https://github.com/payloadcms/payload/commit/42334263bbc6219be92c5728f1a4ac6c8d2d1306))
* rich text link element not validating on create ([#3014](https://github.com/payloadcms/payload/issues/3014)) ([60fca40](https://github.com/payloadcms/payload/commit/60fca40780d4ddd8e684a455de55c566ec91e223))
### Features
* auto-login in config capability ([#3009](https://github.com/payloadcms/payload/issues/3009)) ([733fc0b](https://github.com/payloadcms/payload/commit/733fc0b2d0cf0f2d58c8a28e84776f883774b0e0))
* returns queried user alongside refreshed token ([#2813](https://github.com/payloadcms/payload/issues/2813)) ([2fc03f1](https://github.com/payloadcms/payload/commit/2fc03f196e4e5fa0ad3369ec976c0b6889ebda88))
* support logger destination ([#2896](https://github.com/payloadcms/payload/issues/2896)) ([cd0bf68](https://github.com/payloadcms/payload/commit/cd0bf68a6150b1adbdb9ee318ac0a06c4476aa4d))
## [1.11.2](https://github.com/payloadcms/payload/compare/v1.11.1...v1.11.2) (2023-07-14)
### Features
* adds array, collapsible, tab and group error states ([4925f90](https://github.com/payloadcms/payload/commit/4925f90b5f5c8fb8092bf4e8d88d5e0c1846b094))
## [1.11.1](https://github.com/payloadcms/payload/compare/v1.11.0...v1.11.1) (2023-07-11)
### Bug Fixes
* [#2980](https://github.com/payloadcms/payload/issues/2980), locale=all was not iterating through arrays / blocks ([d6bfba7](https://github.com/payloadcms/payload/commit/d6bfba72a6b1a84bc5bb9dd14c7ce31d7afcbc1c))
* anchor Button component respect margins ([#2648](https://github.com/payloadcms/payload/issues/2648)) ([1877d22](https://github.com/payloadcms/payload/commit/1877d2247c89ca5c8e1f0e1f989154d54768fed8))
# [1.11.0](https://github.com/payloadcms/payload/compare/v1.10.5...v1.11.0) (2023-07-05)
### Bug Fixes
* ensures fields within blocks respect field level access control ([#2969](https://github.com/payloadcms/payload/issues/2969)) ([5b79067](https://github.com/payloadcms/payload/commit/5b79067cc14874abbd1e1a5b6e619d41571b187f))
* ensures rows always have id's ([#2968](https://github.com/payloadcms/payload/issues/2968)) ([04851d0](https://github.com/payloadcms/payload/commit/04851d0dc99e4a3df0a1ac642e9a4b9a3c06d8a1))
* GraphQL type for number field ([#2954](https://github.com/payloadcms/payload/issues/2954)) ([29d8bf0](https://github.com/payloadcms/payload/commit/29d8bf0927038d2305218e5a6b811e0c4039d617))
* nested richtext bug and test ([#2966](https://github.com/payloadcms/payload/issues/2966)) ([801f609](https://github.com/payloadcms/payload/commit/801f60939b1bb4e33fbabe1f9a3c4a04a47912db))
* properly threads custom react-select props through relationship field ([#2973](https://github.com/payloadcms/payload/issues/2973)) ([79393e8](https://github.com/payloadcms/payload/commit/79393e8cf0b79b31fa711536e0bc22b1a251468a))
### Features
* improve typing of ExtendableError and APIError ([#2864](https://github.com/payloadcms/payload/issues/2864)) ([7c47e4b](https://github.com/payloadcms/payload/commit/7c47e4b0d3c63f6f7800daaf424935d6067ffcc4))
* narrow endpoint.method type ([#1880](https://github.com/payloadcms/payload/issues/1880)) ([b734a1c](https://github.com/payloadcms/payload/commit/b734a1c422d200cad1085b7e92f8540df4238e32))
## [1.10.5](https://github.com/payloadcms/payload/compare/v1.10.4...v1.10.5) (2023-06-30)
### Bug Fixes
* fields in drawer cannot be edited ([#2949](https://github.com/payloadcms/payload/issues/2949)) ([0c2e41c](https://github.com/payloadcms/payload/commit/0c2e41c4bef9333c47a9b1db0de807696b3f3872)), closes [#2945](https://github.com/payloadcms/payload/issues/2945)
* improve versions test suite ([#2941](https://github.com/payloadcms/payload/issues/2941)) ([1d4df99](https://github.com/payloadcms/payload/commit/1d4df99ea78c5f682074ae824dcd8dea18b774e0))
* incorrect graphql type generation ([#2898](https://github.com/payloadcms/payload/issues/2898)) ([b36deb4](https://github.com/payloadcms/payload/commit/b36deb4640cad4f494a12ab74b4e4d9a918cd94b))
## [1.10.4](https://github.com/payloadcms/payload/compare/v1.10.3...v1.10.4) (2023-06-30)
### Features
* add locale to displayed API URL ([b22d157](https://github.com/payloadcms/payload/commit/b22d157bd2f1c1a857e2d42bdc5b893549e3db9e))
## [1.10.3](https://github.com/payloadcms/payload/compare/v1.10.2...v1.10.3) (2023-06-30)
### Bug Fixes
* [#2937](https://github.com/payloadcms/payload/issues/2937), depth not being respected in graphql rich text fields ([f84b432](https://github.com/payloadcms/payload/commit/f84b4323e2fce57e2e14b181e486ed72cc09ded5))
* shows updatedAt date when selecting a version to compare from dropdown ([3c9dab3](https://github.com/payloadcms/payload/commit/3c9dab3b9d5302d8bdf5792f0384cd5aeeb13839))
## [1.10.2](https://github.com/payloadcms/payload/compare/v1.10.1...v1.10.2) (2023-06-26)
### Bug Fixes
* adjusts swc loader to only exclude non ts/tsx files - [#2888](https://github.com/payloadcms/payload/issues/2888) ([#2907](https://github.com/payloadcms/payload/issues/2907)) ([a2d9ef3](https://github.com/payloadcms/payload/commit/a2d9ef3ca618934df58102a7e02e86dbe0ed63da))
* autosave on localized fields, adds test ([6893231](https://github.com/payloadcms/payload/commit/6893231f85f702189089a6d78d3f3af63aaa0d82))
* broken export of entityToJSONSchema ([#2894](https://github.com/payloadcms/payload/issues/2894)) ([837dccc](https://github.com/payloadcms/payload/commit/837dcccefeffe7bb6e674713b4184c4eb92db8dc))
* correctly scopes data variable within bulk update - [#2901](https://github.com/payloadcms/payload/issues/2901) ([#2904](https://github.com/payloadcms/payload/issues/2904)) ([f627277](https://github.com/payloadcms/payload/commit/f627277479e6a4a847e79f54c545712a7186abb9))
* safely check for tempFilePath when updating media document ([#2899](https://github.com/payloadcms/payload/issues/2899)) ([8206c0f](https://github.com/payloadcms/payload/commit/8206c0fe8be78a5e0f7c8e64996d73d135b1fcc2))
## [1.10.1](https://github.com/payloadcms/payload/compare/v1.10.0...v1.10.1) (2023-06-22)
### Bug Fixes
* conditional fields perf bug - [#2886](https://github.com/payloadcms/payload/issues/2886) ([#2890](https://github.com/payloadcms/payload/issues/2890)) ([b83d788](https://github.com/payloadcms/payload/commit/b83d788d3cfe12f87dcd63a9df20b939a6f4681e))
* cutoff tooltips in relationship field ([#2873](https://github.com/payloadcms/payload/issues/2873)) ([09c6cad](https://github.com/payloadcms/payload/commit/09c6cad3e8462dc3d8b1b6424aafd336c1d7828c))
* Relationship hasMany and filterOptions fails above 10 items ([#2891](https://github.com/payloadcms/payload/issues/2891)) ([8128de6](https://github.com/payloadcms/payload/commit/8128de64dff98fdbcf053faef9de3c3f9a733071))
# [1.10.0](https://github.com/payloadcms/payload/compare/v1.9.5...v1.10.0) (2023-06-20)
### Bug Fixes
* [#2831](https://github.com/payloadcms/payload/issues/2831), persists payloadAPI through local operations that accept req ([85d2467](https://github.com/payloadcms/payload/commit/85d2467d73582a372ee34e3ce93403847a1f0689))
* [#2842](https://github.com/payloadcms/payload/issues/2842), querying number custom ids with in ([116e9ff](https://github.com/payloadcms/payload/commit/116e9ffe81f44c4b40fa578b4a8fe4bb70fd110c))
* default sort with near operator ([#2862](https://github.com/payloadcms/payload/issues/2862)) ([99f3809](https://github.com/payloadcms/payload/commit/99f38098dd4a386437c469becc975ca86c54601f))
* deprecate min/max in exchange for minRows and maxRows for relationship field ([#2826](https://github.com/payloadcms/payload/issues/2826)) ([0d8d7f3](https://github.com/payloadcms/payload/commit/0d8d7f358d390184f6f888d77858b4a145e94214))
* drawer close on backspace ([#2869](https://github.com/payloadcms/payload/issues/2869)) ([a110ba2](https://github.com/payloadcms/payload/commit/a110ba2dc09cd0824a9b1eb8e011604388277bd8))
* drawer fields are read-only if opened from a hasMany relationship ([#2843](https://github.com/payloadcms/payload/issues/2843)) ([542b536](https://github.com/payloadcms/payload/commit/542b5362d3ec8741aff6b1672fab7d2250e7b854))
* fields in relationship drawer not usable [#2815](https://github.com/payloadcms/payload/issues/2815) ([#2870](https://github.com/payloadcms/payload/issues/2870)) ([8626dc6](https://github.com/payloadcms/payload/commit/8626dc6b1a926143e7ba505f3edd924432168675))
* mobile loading overlay width [#2866](https://github.com/payloadcms/payload/issues/2866) ([#2867](https://github.com/payloadcms/payload/issues/2867)) ([ba9d633](https://github.com/payloadcms/payload/commit/ba9d6336acc779cfec0db312c8e2da912ce58cd4))
* near query sorting by distance and pagination ([#2861](https://github.com/payloadcms/payload/issues/2861)) ([1611896](https://github.com/payloadcms/payload/commit/16118960aa6d63f7a429f168ff4305f336b1b1e6))
* relationship field query pagination ([#2871](https://github.com/payloadcms/payload/issues/2871)) ([ce84174](https://github.com/payloadcms/payload/commit/ce84174554d9d828cbaaaa9548e5defc0feb4e2b))
* slow like queries with lots of records ([4dd703a](https://github.com/payloadcms/payload/commit/4dd703a6bff0ab7d06af234baa975553bd62f176))
### Features
* automatically redirect a user back to their originally requested URL after login ([#2838](https://github.com/payloadcms/payload/issues/2838)) ([e910688](https://github.com/payloadcms/payload/commit/e9106882f721d43bcc05a1690bda7754b450404e))
* hasMany for number field ([#2517](https://github.com/payloadcms/payload/issues/2517)) ([8f086e3](https://github.com/payloadcms/payload/commit/8f086e315cb30be9d399fd3022c16952fb81cb2e)), closes [#2812](https://github.com/payloadcms/payload/issues/2812) [#2821](https://github.com/payloadcms/payload/issues/2821) [#2823](https://github.com/payloadcms/payload/issues/2823) [#2824](https://github.com/payloadcms/payload/issues/2824) [#2814](https://github.com/payloadcms/payload/issues/2814) [#2793](https://github.com/payloadcms/payload/issues/2793) [#2835](https://github.com/payloadcms/payload/issues/2835)
* optimizes conditional logic performance ([967f217](https://github.com/payloadcms/payload/commit/967f21734600de1fec8c1227a354ef5a417e54c5))
## [1.9.5](https://github.com/payloadcms/payload/compare/v1.9.4...v1.9.5) (2023-06-16)
## [1.9.4](https://github.com/payloadcms/payload/compare/v1.9.3...v1.9.4) (2023-06-16)
### Bug Fixes
* incorrectly return totalDocs=1 instead of the correct count when pagination=false ([2e73938](https://github.com/payloadcms/payload/commit/2e7393853447d2da41ddef79f73e9026719a674b))
## [1.9.3](https://github.com/payloadcms/payload/compare/v1.9.2...v1.9.3) (2023-06-16)
### Bug Fixes
* adds custom property to ui field in joi validation ([#2835](https://github.com/payloadcms/payload/issues/2835)) ([56d7745](https://github.com/payloadcms/payload/commit/56d7745139e31c5d42c5191477f409f12589a952))
* ensures relations to object ids can be queried on ([c3d6e1b](https://github.com/payloadcms/payload/commit/c3d6e1b490a69f0aadb00e54e46a8774732e6658))
## [1.9.2](https://github.com/payloadcms/payload/compare/v1.9.1...v1.9.2) (2023-06-14)
### Bug Fixes
* [#2821](https://github.com/payloadcms/payload/issues/2821) i18n ui field label ([#2823](https://github.com/payloadcms/payload/issues/2823)) ([63cd7fb](https://github.com/payloadcms/payload/commit/63cd7fbd0c91bbf5120e95fd33388a38e593b341))
* adds missing dark-mode styles for version differences view ([#2812](https://github.com/payloadcms/payload/issues/2812)) ([346a48f](https://github.com/payloadcms/payload/commit/346a48f871e09a3d5e25b7ff9e45689a104b0f9f))
* sanitize reset password result - [#2805](https://github.com/payloadcms/payload/issues/2805) ([#2808](https://github.com/payloadcms/payload/issues/2808)) ([46a5f41](https://github.com/payloadcms/payload/commit/46a5f417217313b049f4b412abb3319634f27262))
* user can be created without having to specify an email - [#2801](https://github.com/payloadcms/payload/issues/2801) ([abe3852](https://github.com/payloadcms/payload/commit/abe38520aaaefdfaea4c47130eea04a42a82627b))
## [1.9.1](https://github.com/payloadcms/payload/compare/v1.9.0...v1.9.1) (2023-06-09)
### Features
* adds option to customize filename on upload ([596eea1](https://github.com/payloadcms/payload/commit/596eea1f0a42628464e5269c496360b808c35f97))
* collection list view custom components: BeforeList, BeforeListTable, AfterListTable, AfterList ([#2792](https://github.com/payloadcms/payload/issues/2792)) ([38e962f](https://github.com/payloadcms/payload/commit/38e962f2cbcaf9eaa72276969289efdbf670c7c7))
# [1.9.0](https://github.com/payloadcms/payload/compare/v1.8.6...v1.9.0) (2023-06-07)

View File

@@ -1,6 +1,6 @@
# Contributing to Payload CMS
# Contributing to Payload
Below you'll find a set of guidelines for how to contribute to Payload CMS.
Below you'll find a set of guidelines for how to contribute to Payload.
## Opening issues
@@ -20,6 +20,12 @@ 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.
## Design Contributions
When it comes to design-related changes or additions, it's crucial for us to ensure a cohesive user experience and alignment with our broader design vision. Before embarking on any implementation that would affect the design or UI/UX, we ask that you **first share your design proposal** with us for review and approval.
Our design review ensures that proposed changes fit seamlessly with other components, both existing and planned. This step is meant to prevent unintentional design inconsistencies and to save you from investing time in implementing features that might need significant design alterations later.
### 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/payload). 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.
@@ -49,6 +55,8 @@ The directory split up in this way specifically to reduce friction when creating
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.
By default, it will automatically log you in with the default credentials. To disable that, you can either pass in the --no-auto-login flag (example: `yarn dev my-test-dir --no-auto-login`) or set the `PAYLOAD_PUBLIC_DISABLE_AUTO_LOGIN` environment variable to `false`.
If you wish to use to your own Mongo database for the `test` directory instead of using the in memory database, all you need to do is add the following env vars to the `test/dev.ts` file:
- `process.env.NODE_ENV`
@@ -57,6 +65,27 @@ If you wish to use to your own Mongo database for the `test` directory instead o
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. The default credentials are `dev@payloadcms.com` as E-Mail and `test` as password.
### Commits
We use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) for our commit messages. Please follow this format when creating commits. Here are some examples:
- `feat: adds new feature`
- `fix: fixes bug`
- `docs: adds documentation`
- `chore: does chore`
Here's a breakdown of the format. At the top-level, we use the following types to categorize our commits:
- `feat`: new feature that adds functionality. These are automatically added to the changelog when creating new releases.
- `fix`: a fix to an existing feature. These are automatically added to the changelog when creating new releases.
- `docs`: changes to [docs](./docs) only. These do not appear in the changelog.
- `chore`: changes to code that is neither a fix nor a feature (e.g. refactoring, adding tests, etc.). These do not appear in the changelog.
If you are committing to [templates](./templates) or [examples](./examples), use the `chore` type with the proper scope, like this:
- `chore(templates): adds feature to template`
- `chore(examples): fixes bug in example`
## 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.

110
README.md
View File

@@ -1,37 +1,13 @@
<p style="border: none; margin-bottom:0; padding-bottom: 0;" align="center">
<a href="https://payloadcms.com">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/payloadcms/payload/master/src/admin/assets/images/payload-logo-light.svg">
<img width="350" alt="payload cms logo" src="https://raw.githubusercontent.com/payloadcms/payload/master/src/admin/assets/images/payload-logo-dark.svg">
</picture>
</a>
</p>
<h3 align="center">The most powerful TypeScript CMS</h3>
<p align="center">Code-first Headless CMS that bridges the gap between CMS and application framework</p>
<h3 align="center">
<a target="_blank" href="https://payloadcms.com/docs/getting-started/what-is-payload" rel="dofollow"><strong>Explore the docs</strong></a>
·
<a target="_blank" href="https://demo.payloadcms.com/" rel="dofollow"><strong>Try Live Demo</strong></a>
<br />
</h3>
<a href="https://payloadcms.com">
<img width="100%" src="src/admin/assets/images/github-banner-alt.jpg" alt="Payload headless CMS Admin panel built with React" />
</a>
<br />
<p align="center">
<a href="https://opensource.org/licenses/MIT">
<img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square" />
</a>
&nbsp;
<br />
<p align="left">
<a href="https://github.com/payloadcms/payload/actions">
<img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/payloadcms/payload/tests.yml?style=flat-square">
</a>
&nbsp;
<a href="https://github.com/payloadcms/payload/commits">
<img src="https://img.shields.io/github/commit-activity/m/payloadcms/payload?style=flat-square" alt="git commit activity"/>
</a>
&nbsp;
<a href="https://discord.gg/payload">
<img alt="Discord" src="https://img.shields.io/discord/967097582721572934?label=Discord&color=7289da&style=flat-square" />
</a>
@@ -41,28 +17,56 @@
</a>
&nbsp;
<a href="https://twitter.com/payloadcms">
<img src="https://img.shields.io/badge/follow-payloadcms-1DA1F2?logo=twitter&style=flat-square" alt="Payload CMS Twitter" />
<img src="https://img.shields.io/badge/follow-payloadcms-1DA1F2?logo=twitter&style=flat-square" alt="Payload Twitter" />
</a>
</p>
<hr/>
<h4>
<a target="_blank" href="https://payloadcms.com/docs/getting-started/what-is-payload" rel="dofollow"><strong>Explore the Docs</strong></a>&nbsp;·&nbsp;<a target="_blank" href="https://payloadcms.com/community-help" rel="dofollow"><strong>Community Help</strong></a>&nbsp;·&nbsp;<a target="_blank" href="https://demo.payloadcms.com/" rel="dofollow"><strong>Try Live Demo</strong></a>&nbsp;·&nbsp;<a target="_blank" href="https://github.com/payloadcms/payload/discussions/1539" rel="dofollow"><strong>Roadmap</strong></a>&nbsp;·&nbsp;<a target="_blank" href="https://www.g2.com/products/payload-cms/reviews#reviews" rel="dofollow"><strong>View G2 Reviews</strong></a>
</h4>
<hr/>
<h3>Benefits over a regular CMS</h3>
<ul>
<li>Dont hit some third-party SaaS API, hit your own API</li>
<li>Use your own database and own your data</li>
<li>It's just Express - do what you want outside of Payload</li>
<li>No need to learn how Payload works - if you know JS, you know Payload</li>
<li>No vendor lock-in</li>
<li>Avoid microservices hell - get everything (even auth) in one place</li>
<li>Never touch ancient WP code again</li>
<li>Build faster, never hit a roadblock</li>
<li>Both admin and backend are 100% extensible</li>
</ul>
<br />
## ☁️ Deploy instantly with Payload Cloud.
Create a cloud account, connect your GitHub, and [deploy in minutes](https://payloadcms.com/new).
<a href="https://payloadcms.com">
<img src="https://cms.payloadcms.com/media/payload-github-header.jpg" alt="Payload headless CMS Admin panel built with React" />
</a>
## 🚀 Get started by self-hosting completely free, forever.
<br />
Before beginning to work with Payload, make sure you have all of the [required software](https://payloadcms.com/docs/getting-started/installation).
## ⭐ Why Payload?
```text
npx create-payload-app
```
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:
Alternatively, it only takes about five minutes to [create an app from scratch](https://payloadcms.com/docs/getting-started/installation#from-scratch).
- 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.
## 🖱️ One-click templates
<a target="_blank" href="https://payloadcms.com/" rel="dofollow"><strong>Read more on our website</strong></a>
Jumpstart your next project by starting with a pre-made template. These are production-ready, end-to-end solutions designed to get you to market as fast as possible.
### [🛒 E-Commerce](https://github.com/payloadcms/payload/tree/master/templates/ecommerce)
Eliminate the need to combine Shopify and a CMS, and instead do it all with Payload + Stripe. Comes with a beautiful, fully functional front-end complete with shopping cart, checkout, orders, and much more.
### [🌐 Website](https://github.com/payloadcms/payload/tree/master/templates/website)
Build any kind of website, blog, or portfolio from small to enterprise. Comes with a beautiful, fully functional front-end complete with posts, projects, comments, and much more.
We're constantly adding more templates to our [Templates Directory](https://github.com/payloadcms/payload/tree/master/templates). If you maintain your own template, consider adding the `payload-template` topic to your GitHub repository for others to find.
- [Official Templates](https://github.com/payloadcms/payload/tree/master/templates)
- [Community Templates](https://github.com/topics/payload-template)
## ✨ Features
@@ -86,33 +90,21 @@ Payload is a CMS that has been designed for developers from the ground up to del
<a target="_blank" href="https://github.com/payloadcms/payload/discussions"><strong>Request Feature</strong></a>
## 🚀 Quick Start
Before beginning to work with Payload, make sure you have all of the [required software](https://payloadcms.com/docs/getting-started/installation).
From there, the easiest way to get started with Payload is to use the `create-payload-app` package:
```text
npx create-payload-app
```
Alternatively, it only takes about five minutes to [create an app from scratch](https://payloadcms.com/docs/getting-started/installation#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).
If you want to add contributions to this repository, please follow the instructions in [contributing.md](./CONTRIBUTING.md).
## 📚 Examples and Templates
## 📚 Examples
The examples directory is a great resource for learning how to setup Payload in a variety of different ways. There are also a number of templates to help get you going very quickly. If you maintain your own template, consider adding the `payload-template` topic to your GitHub repository for others to find.
The [Examples Directory](./examples) is a great resource for learning how to setup Payload in a variety of different ways, but you can also find great examples in our blog and throughout our social media.
- [Examples Directory](./examples)
- [Official Templates](https://github.com/orgs/payloadcms/repositories?q=topic%3Apayload-template)
- [Community Templates](https://github.com/topics/payload-template)
- [Payload Blog](https://payloadcms.com/blog)
- [Payload YouTube](https://www.youtube.com/@payloadcms)
## 🔌 Plugins

View File

@@ -1,2 +1,2 @@
export { default as List } from '../../dist/admin/components/views/collections/List/Default';
export type { Props } from '../../dist/admin/components/views/collections/Edit/types';
export type { Props } from '../../dist/admin/components/views/collections/List/types';

View File

@@ -11,10 +11,8 @@ While designing the Payload Admin panel, we determined it should be as minimal a
To swap in your own React component, first, consult the list of available component overrides below. Determine the scope that corresponds to what you are trying to accomplish, and then author your React component accordingly.
<Banner type="success">
<strong>Tip:</strong>
<br />
Custom components will automatically be provided with all props that the
default component would accept.
<strong>Tip:</strong><br />
Custom components will automatically be provided with all props that the default component would accept.
</Banner>
### Base Component Overrides
@@ -85,6 +83,10 @@ You can override components on a Collection-by-Collection basis via each Collect
| **`edit.SaveDraftButton`** | Replace the default `Save Draft` button with a custom component. Drafts must be enabled and autosave must be disabled. |
| **`edit.PublishButton`** | Replace the default `Publish` button with a custom component. Drafts must be enabled. |
| **`edit.PreviewButton`** | Replace the default `Preview` button with a custom component. |
| **`BeforeList`** | Array of components to inject _before_ the built-in List view |
| **`BeforeListTable`** | Array of components to inject _before_ the built-in List view's table |
| **`AfterListTable`** | Array of components to inject _after_ the built-in List view's table |
| **`AfterList`** | Array of components to inject _after_ the built-in List view |
#### Examples
@@ -136,6 +138,43 @@ export const CustomPreviewButton: CustomPreviewButtonProps = ({
};
```
##### Custom Collection List View Example
Collection.ts
```tsx
import { MyListComponent } from './MyListComponent';
export const MyCollection: CollectionConfig = {
slug: 'mycollection',
admin: {
components: {
views: {
List: MyListComponent,
},
},
},
fields: [
...
],
};
```
MyListComponent.tsx
```tsx
import React from "react";
import { List, type Props } from "payload/components/views/List"; // Payload's default List view component and its props
export const MyListComponent: React.FC<Props> = (props) => (
<div>
<p>
Some text before the default list view component. If you just want to do
that, you can also use the admin.components.list.BeforeList hook
</p>
<List {...props} />
</div>
);
```
### Globals
As with Collections, You can override components on a global-by-global basis via their `admin` property.
@@ -221,11 +260,8 @@ const CustomTextField: React.FC<Props> = ({ path }) => {
<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>
.
build custom components, including the <strong>useField</strong> hook, [click
here](/docs/admin/hooks).
</Banner>
## Custom routes

View File

@@ -138,25 +138,487 @@ The `useForm` hook can be used to interact with the form itself, and sends back
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:
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 |
<TableWithDrawers
columns={[
'Action',
'Description',
'Example',
]}
rows={[
[
{
value: <strong><code>fields</code></strong>,
},
{
value: "Deprecated. This property cannot be relied on as up-to-date.",
},
{
value: ''
}
],
[
{
value: <strong><code>submit</code></strong>,
},
{
value: "Method to trigger the form to submit",
},
{
value: ''
}
],
[
{
value: <strong><code>dispatchFields</code></strong>,
},
{
value: "Dispatch actions to the form field state",
},
{
value: ''
}
],
[
{
value: <strong><code>validateForm</code></strong>,
},
{
value: "Trigger a validation of the form state",
},
{
value: ''
}
],
[
{
value: <strong><code>createFormData</code></strong>,
},
{
value: <>Create a <code>multipart/form-data</code> object from the current form's state</>,
},
{
value: ''
}
],
[
{
value: <strong><code>disabled</code></strong>,
},
{
value: "Boolean denoting whether or not the form is disabled",
},
{
value: ''
}
],
[
{
value: <strong><code>getFields</code></strong>,
},
{
value: 'Gets all fields from state',
},
{
value: '',
}
],
[
{
value: <strong><code>getField</code></strong>,
},
{
value: 'Gets a single field from state by path',
},
{
value: '',
},
],
[
{
value: <strong><code>getData</code></strong>,
},
{
value: 'Returns the data stored in the form',
},
{
value: '',
},
],
[
{
value: <strong><code>getSiblingData</code></strong>,
},
{
value: 'Returns form sibling data for the given field path',
},
{
value: '',
},
],
[
{
value: <strong><code>setModified</code></strong>,
},
{
value: <>Set the form\'s <code>modified</code> state</>,
},
{
value: '',
},
],
[
{
value: <strong><code>setProcessing</code></strong>,
},
{
value: <>Set the form\'s <code>processing</code> state</>,
},
{
value: '',
},
],
[
{
value: <strong><code>setSubmitted</code></strong>,
},
{
value: <>Set the form\'s <code>submitted</code> state</>,
},
{
value: '',
},
],
[
{
value: <strong><code>formRef</code></strong>,
},
{
value: 'The ref from the form HTML element',
},
{
value: '',
},
],
[
{
value: <strong><code>reset</code></strong>,
},
{
value: 'Method to reset the form to its initial state',
},
{
value: '',
},
],
[
{
value: <strong><code>addFieldRow</code></strong>,
},
{
value: "Method to add a row on an array or block field",
},
{
drawerTitle: 'addFieldRow',
drawerDescription: 'A useful method to programtically add a row to an array or block field.',
drawerSlug: 'addFieldRow',
drawerContent: (
<>
<TableWithDrawers
columns={[
'Prop',
'Description',
]}
rows={[
[
{
value: <strong><code>path</code></strong>,
},
{
value: "The path to the array or block field",
},
],
[
{
value: <strong><code>rowIndex</code></strong>,
},
{
value: "The index of the row to add",
},
],
[
{
value: <strong><code>data</code></strong>,
},
{
value: "The data to add to the row",
},
],
]}
/>
<br />
<pre>
{`import { useForm } from "payload/components/forms";
export const CustomArrayManager = () => {
const { addFieldRow } = useForm()
return (
<button
type="button"
onClick={() => {
addFieldRow({
path: "arrayField",
rowIndex: 0,
data: {
textField: "text",
// blockType: "yourBlockSlug",
// ^ if managing a block array, you need to specify the block type
},
})
}}
>
Add Row
</button>
)
}`}
</pre>
<p>An example config to go along with the custom component</p>
<pre>
{`const ExampleCollection = {
slug: "example-collection",
fields: [
{
name: "arrayField",
type: "array",
fields: [
{
name: "textField",
type: "text",
},
],
},
{
type: "ui",
name: "customArrayManager",
admin: {
components: {
Field: CustomArrayManager,
},
},
},
],
}`}
</pre>
</>
)
}
],
[
{
value: <strong><code>removeFieldRow</code></strong>,
},
{
value: "Method to remove a row from an array or block field",
},
{
drawerTitle: 'removeFieldRow',
drawerDescription: 'A useful method to programtically remove a row from an array or block field.',
drawerSlug: 'removeFieldRow',
drawerContent: (
<>
<TableWithDrawers
columns={[
'Prop',
'Description',
]}
rows={[
[
{
value: <strong><code>path</code></strong>,
},
{
value: "The path to the array or block field",
},
],
[
{
value: <strong><code>rowIndex</code></strong>,
},
{
value: "The index of the row to remove",
},
],
]}
/>
<br />
<pre>
{`import { useForm } from "payload/components/forms";
export const CustomArrayManager = () => {
const { removeFieldRow } = useForm()
return (
<button
type="button"
onClick={() => {
removeFieldRow({
path: "arrayField",
rowIndex: 0,
})
}}
>
Remove Row
</button>
)
}`}
</pre>
<p>An example config to go along with the custom component</p>
<pre>
{`const ExampleCollection = {
slug: "example-collection",
fields: [
{
name: "arrayField",
type: "array",
fields: [
{
name: "textField",
type: "text",
},
],
},
{
type: "ui",
name: "customArrayManager",
admin: {
components: {
Field: CustomArrayManager,
},
},
},
],
}`}
</pre>
</>
)
}
],
[
{
value: <strong><code>replaceFieldRow</code></strong>,
},
{
value: "Method to replace a row from an array or block field",
},
{
drawerTitle: 'replaceFieldRow',
drawerDescription: 'A useful method to programtically replace a row from an array or block field.',
drawerSlug: 'replaceFieldRow',
drawerContent: (
<>
<TableWithDrawers
columns={[
'Prop',
'Description',
]}
rows={[
[
{
value: <strong><code>path</code></strong>,
},
{
value: "The path to the array or block field",
},
],
[
{
value: <strong><code>rowIndex</code></strong>,
},
{
value: "The index of the row to replace",
},
],
[
{
value: <strong><code>data</code></strong>,
},
{
value: "The data to replace within the row",
},
],
]}
/>
<br />
<pre>
{`import { useForm } from "payload/components/forms";
export const CustomArrayManager = () => {
const { replaceFieldRow } = useForm()
return (
<button
type="button"
onClick={() => {
replaceFieldRow({
path: "arrayField",
rowIndex: 0,
data: {
textField: "updated text",
// blockType: "yourBlockSlug",
// ^ if managing a block array, you need to specify the block type
},
})
}}
>
Replace Row
</button>
)
}`}
</pre>
<p>An example config to go along with the custom component</p>
<pre>
{`const ExampleCollection = {
slug: "example-collection",
fields: [
{
name: "arrayField",
type: "array",
fields: [
{
name: "textField",
type: "text",
},
],
},
{
type: "ui",
name: "customArrayManager",
admin: {
components: {
Field: CustomArrayManager,
},
},
},
],
}`}
</pre>
</>
)
}
],
]}
/>
### useDocumentInfo
@@ -241,7 +703,7 @@ import { User } from '../payload-types.ts';
const Greeting: React.FC = () => {
// highlight-start
const { user } = useConfig<User>();
const { user } = useAuth<User>();
// highlight-end
return (

View File

@@ -25,7 +25,7 @@ _Screenshot of the Admin panel while editing a document from an example `AllFiel
All options for the Admin panel are defined in your base Payload config file.
| Option | Description |
| --------------------- | -------------------------------------------------------------------------------------------------- |
|-----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `user` | The `slug` of a Collection that you want be used to log in to the Admin dashboard. [More](/docs/admin/overview#the-admin-user-collection) |
| `buildPath` | Specify an absolute path for where to store the built Admin panel bundle used in production. Defaults to `path.resolve(process.cwd(), 'build')`. |
| `meta` | Base meta data to use for the Admin panel. Included properties are `titleSuffix`, `ogImage`, and `favicon`. |
@@ -35,8 +35,9 @@ All options for the Admin panel are defined in your base Payload config file.
| `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. |
| `avatar` | Set account profile picture. Options: `gravatar`, `default` or a custom React component. |
| `autoLogin` | Used to automate admin log-in for dev and demonstration convenience. [More](/docs/authentication/config). |
| `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) | |
| `webpack` | Customize the Webpack config that's used to generate the Admin panel. [More](/docs/admin/webpack) |
| **`logoutRoute`** | The route for the `logout` page. |
| **`inactivityRoute`** | The route for the `logout` inactivity page. |
@@ -45,8 +46,8 @@ All options for the Admin panel are defined in your base Payload config file.
<Banner type="warning">
<strong>Important:</strong>
<br />
The Payload Admin panel can only be used by one Collection that supports{" "}
<a href="/docs/authentication/overview">Authentication</a>.
The Payload Admin panel can only be used by one Collection that supports
[Authentication](/docs/authentication/overview).
</Banner>
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.

View File

@@ -17,7 +17,7 @@ To enable Authentication on a collection, define an `auth` property and set it t
| **`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 (in milliseconds) that a user should be locked out if they fail authentication more times than `maxLoginAttempts` allows for. |
| **`lockTime`** | Set the time (in milliseconds) 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) |
@@ -29,10 +29,12 @@ To enable Authentication on a collection, define an `auth` property and set it t
To integrate with third-party APIs or services, you might need the ability to generate API keys that can be used to identify as a certain user within Payload.
In Payload, users are essentially documents within a collection. Just like you can authenticate as a user with an email and password, which is considered as our default local auth strategy, you can also authenticate as a user with an API key. API keys are generated on a user-by-user basis, similar to email and passwords, and are meant to represent a single user.
For example, if you have a third-party service or external app that needs to be able to perform protected actions at its discretion, you have two options:
1. Create a user for the third-party app, and log in each time to receive a token before you attempt to access any protected actions
1. Enable API key support for the Collection, where you can generate a non-expiring API key per user in the collection
1. Enable API key support for the Collection, where you can generate a non-expiring API key per user in the collection. This is particularly useful as you can create a "user" that reflects an integration with a specific external service and assign a "role" or specific access only needed by that service/integration. Alternatively, you could create a "super admin" user and assign an API key to that user so that any requests made with that API key are considered as being made by that super user.
Technically, both of these options will work for third-party integrations but the second option with API key is simpler, because it reduces the amount of work that your integrations need to do to be authenticated properly.
@@ -45,7 +47,7 @@ To enable API keys on a collection, set the `useAPIKey` auth option to `true`. F
#### Authenticating via API Key
To authenticate REST or GraphQL API requests using an API key, set the `Authorization` header. The header is case-sensitive and needs the slug of the `auth.useAPIKey` enabled collection, then " API-Key ", followed by the `apiKey` that has been assigned. Payload's built-in middleware will then assign the user document to `req.user` and handle requests with the proper access control.
To authenticate REST or GraphQL API requests using an API key, set the `Authorization` header. The header is case-sensitive and needs the slug of the `auth.useAPIKey` enabled collection, then " API-Key ", followed by the `apiKey` that has been assigned. Payload's built-in middleware will then assign the user document to `req.user` and handle requests with the proper access control. By doing this, Payload recognizes the request being made as a request by the user associated with that API key.
**For example, using Fetch:**
@@ -59,6 +61,24 @@ const response = await fetch("http://localhost:3000/api/pages", {
});
```
Payload ensures that the same, uniform access control is used across all authentication strategies. This enables you to utilize your existing access control configurations with both API keys and the standard email/password authentication. This consistency can aid in maintaining granular control over your API keys.
#### API Key *Only* Authentication
If you want to use API keys as the only authentication method for a collection, you can disable the default local strategy by setting `disableLocalStrategy` to `true` on the collection's `auth` property. This will disable the ability to authenticate with email and password, and will only allow for authentication via API key.
```ts
import { CollectionConfig } from 'payload/types';
export const Customers: CollectionConfig = {
slug: 'customers',
auth: {
useAPIKey: true,
disableLocalStrategy: true,
}
};
```
### Forgot Password
You can customize how the Forgot Password workflow operates with the following options on the `auth.forgotPassword` property:
@@ -229,3 +249,39 @@ If you pass a strategy to the `strategy` property directly, the `name` property
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.
### Admin autologin
For testing and demo purposes you may want to skip forcing the admin user to login in order to access the panel.
The `admin.autologin` property is used to configure the how visitors are handled when accessing the admin panel.
The default is that all users will have to login and this should not be enabled for environments where data needs to protected.
#### autoLogin Options
| Option | Description |
| -------------------------- |---------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **`email`** | The email address of the user to login as |
| **`password`** | The password of the user to login as |
| **`prefillOnly`** | If set to true, the login credentials will be prefilled but the user will still need to click the login button. |
The recommended way to use this feature is behind an environment variable to ensure it is disabled when in production.
**Example:**
```ts
export default buildConfig({
admin: {
user: 'users',
// highlight-start
autoLogin: process.env.PAYLOAD_PUBLIC_ENABLE_AUTOLOGIN === 'true' ? {
email: 'test@example.com',
password: 'test',
prefillOnly: true,
} : false,
// highlight-end
},
collections: [ /** */],
})
```

View File

@@ -6,6 +6,11 @@ desc: Payload provides highly secure user Authentication out of the box, and you
keywords: authentication, config, configuration, overview, documentation, Content Management System, cms, headless, javascript, node, react, express
---
<YouTube
id="CT4KafeJjTI"
title="Simplified Authentication for Headless CMS: Unlocking Reusability in One Line"
/>
<Banner>
Payload provides for highly secure and customizable user Authentication out of the box, which allows for users to identify themselves to Payload.
</Banner>
@@ -78,9 +83,11 @@ Once enabled, each document that is created within the Collection can be thought
Successfully logging in returns a `JWT` (JSON web token) which is how a user will identify themselves to Payload. By providing this JWT via either an HTTP-only cookie or an `Authorization` header, Payload will automatically identify the user and add its user JWT data to the Express `req`, which is available throughout Payload including within access control, hooks, and more.
You can specify what data gets encoded to the JWT token by setting `saveToJWT` to true in your auth collection fields. If you wish to use a different key other than the field `name`, you can provide it to `saveToJWT` as a string. It is also possible to use `saveToJWT` on fields that are nested in inside groups and tabs. If a group has a `saveToJWT` set it will include the object with all sub-fields in the token. You can set `saveToJWT: false` for any fields you wish to omit. If a field inside a group has `saveToJWT` set, but the group does not, the field will be included at the top level of the token.
<Banner type="success">
<strong>Tip:</strong><br/>
You can access the logged in user from access control functions and hooks via the Express <strong>req</strong>. The logged in user is automatically added as the <strong>user</strong> property.
You can access the logged-in user from access control functions and hooks via the Express <strong>req</strong>. The logged-in user is automatically added as the <strong>user</strong> property.
</Banner>
### HTTP-only cookies

View File

@@ -29,28 +29,30 @@ import payload from "payload";
const app = express();
payload.init({
secret: "PAYLOAD_SECRET_KEY",
mongoURL: "mongodb://localhost/payload",
express: app,
});
const start = async () => {
await payload.init({
secret: "PAYLOAD_SECRET_KEY",
mongoURL: "mongodb://localhost/payload",
express: app,
});
const router = express.Router();
const router = express.Router();
// Note: Payload must be initialized before the `payload.authenticate` middleware can be used
router.use(payload.authenticate); // highlight-line
// Note: Payload must be initialized before the `payload.authenticate` middleware can be used
router.use(payload.authenticate); // highlight-line
router.get("/", (req, res) => {
if (req.user) {
return res.send(`Authenticated successfully as ${req.user.email}.`);
}
router.get("/", (req, res) => {
if (req.user) {
return res.send(`Authenticated successfully as ${req.user.email}.`);
}
return res.send("Not authenticated");
});
return res.send("Not authenticated");
});
app.use("/some-route-here", router);
app.use("/some-route-here", router);
app.listen(3000, async () => {
payload.logger.info(`listening on ${3000}...`);
});
app.listen(3000);
};
start();
```

View File

@@ -0,0 +1,62 @@
---
title: Project Configuration
label: Configuration
order: 20
desc: Quickly configure and deploy your Payload Cloud project in a few simple steps.
keywords: configuration, config, settings, project, cloud, payload cloud, deploy, deployment
---
### Select your plan
Once you have created a project, you will need to select your plan. This will determine the resources that are allocated to your project and the features that are available to you.
<Banner type="success">
Note: All Payload Cloud teams that deploy a project require a card on file.
This helps us prevent fraud and abuse on our platform. If you select a plan
with a free trial, you will not be charged until your trial period is over.
Well remind you 7 days before your trial ends and you can cancel anytime.
</Banner>
### Project Details
| Option | Description |
| ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Region** | Select the region closest to your audience. This will ensure the fastest communication between your data and your client. |
| **Project Name** | A name for your project. You can change this at any time. |
| **Project Slug** | Choose a unique slug to identify your project. This needs to be unique for your team and you can change it any time. |
| **Team** | Select the team you want to create the project under. If this is your first project, a personal team will be created for you automatically. You can modify your team settings and invite new members at any time from the Team Settings page. |
### Build Settings
If you are deploying a new project from a template, the following settings will be automatically configured for you. If you are using your own repository, you need to make sure your build settings are accurate for your project to deploy correctly.
| Option | Description |
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Root Directory** | The folder where your `package.json` file lives. |
| **Install Command** | The command used to install your modules, for example: `yarn install` or `npm install` |
| **Build Command** | The command used to build your application, for example: `yarn build` or `npm run build` |
| **Serve Command** | The command used to serve your application, for example: `yarn serve` or `npm run serve` |
| **Branch to Deploy** | Select the branch of your repository that you want to deploy from. This is the branch that will be used to build your project when you commit new changes. |
| **Default Domain** | Set a default domain for your project. This must be unique and you will not able to change it. You can always add a custom domain later in your project settings. |
### Environment Variables
Any of the features in Payload Cloud that require environment variables will automatically be provided to your application. If your app requires any custom environment variables, you can set them here.
<Banner type="warning">
Note: For security reasons, any variables you wish to provide to the Admin
panel must be prefixed with `PAYLOAD_PUBLIC_`.  Learn more
[here](https://payloadcms.com/docs/admin/webpack#admin-environment-vars).
</Banner>
### Payment
Payment methods can be set per project and can be updated any time. You can use teams default payment method, or add a new one. Modify your payment methods in your Project settings / Team settings.
<Banner type="success">
<strong>Note:</strong> All Payload Cloud teams that deploy a project require a
card on file. This helps us prevent fraud and abuse on our platform. If you
select a plan with a free trial, you will not be charged until your trial
period is over. Well remind you 7 days before your trial ends and you can
cancel anytime.
</Banner>

View File

@@ -0,0 +1,53 @@
---
title: Getting Started
label: Getting Started
order: 10
desc: Get started with Payload Cloud, a deployment solution specifically designed for Node + MongoDB applications.
keywords: cloud, hosted, database, storage, email, deployment, serverless, node, mongodb, s3, aws, cloudflare, atlas, resend, payload, cms
---
A deployment solution specifically designed for Node.js + MongoDB applications, offering seamless deployment of your entire stack in one place. You can get started in minutes with a one-click template or bring your own codebase with you.
Payload Cloud offers various plans tailored to meet your specific needs, including a MongoDB Atlas database, S3 file storage, and email delivery powered by [Resend](https://resend.com). To see a full breakdown of features and plans, see our [Cloud Pricing page](https://payloadcms.com/cloud-pricing).
To get started, you first need to create an account. Head over to [the login screen](https://payloadcms.com/login) and **Register for Free**.
<Banner type="success">
To create your first project, you can either select [a
template](#starting-from-a-template) or [import an existing
project](#importing-from-an-existing-codebase) from GitHub.
</Banner>
## Starting from a Template
Templates come preconfigured and provide a one-click solution to quickly deploy a new application.
![Screen for creating a new project from a template](https://payloadcms.com/images/docs/cloud/create-from-template.jpg)
_Creating a new project from a template._
After creating an account, select your desired template from the Projects page. At this point, you need to connect to authorize the Payload Cloud application with your GitHub account. Click Continue with GitHub and follow the prompts to authorize the app.
Next, select your `GitHub Scope`. If you belong to multiple organizations, they will show up here. If you do not see the organization you are looking for, you may need to adjust your GitHub app permissions.
After selecting your scope, create a unique `repository name` and select whether you want your repository to be public or private on GitHub.
<Banner type="warning">
<strong>Note:</strong> Public repositories can be accessed by anyone online,
while private repositories grant access only to you and anyone you explicitly
authorize.
</Banner>
Once you are ready, click **Create Project**. This will clone the selected template to a new repository in your GitHub account, and take you to the configuration page to set up your project for deployment.
## Importing from an Existing Codebase
Payload Cloud works for any Node.js + MongoDB app. From the New Project page, select **import an existing Git codebase**. Choose the organization and select the repository you want to import. From here, you will be taken to the configuration page to set up your project for deployment.
![Screen for creating a new project from an existing repository](https://payloadcms.com/images/docs/cloud/create-from-existing.jpg)
_Creating a new project from an existing repository._
<Banner type="warning">
<strong>Note:</strong> In order to make use of the features of Payload Cloud
in your own codebase, you will need to add the [Cloud
Plugin](https://github.com/payloadcms/plugin-cloud) to your Payload app.
</Banner>

110
docs/cloud/projects.mdx Normal file
View File

@@ -0,0 +1,110 @@
---
title: Cloud Projects
label: Projects
order: 40
desc: Manage your Payload Cloud projects.
keywords: cloud, payload cloud, projects, project, overview, database, file storage, build settings, environment variables, custom domains, email, developing locally
---
### Overview
<Banner>
The overview tab shows your most recent deployment, along with build and
deployment logs. From here, you can see your live URL, deployment details like
timestamps and commit hash, as well as the status of your deployment. You can
also trigger a redeployment manually, which will rebuild your project using
the current configuration.
</Banner>
![Payload Cloud Overview Page](https://payloadcms.com/images/docs/cloud/overview-page.jpg)
_A screenshot of the Overview page for a Cloud project._
### Database
Your Payload Cloud project comes with a MongoDB serverless Atlas DB instance or a Dedicated Atlas cluster, depending on your plan. To interact with your cloud database, you will be provided with a MongoDB connection string. This can be found under the **Database** tab of your project.
`mongodb+srv://your_connection_string`
### File Storage
Payload Cloud gives you S3 file storage backed by Cloudflare as a CDN, and this plugin extends Payload so that all of your media will be stored in S3 rather than locally.
AWS Cognito is used for authentication to your S3 bucket. The [Payload Cloud Plugin](https://github.com/payloadcms/plugin-cloud) will automatically pick up these values. These values are only if you'd like to access your files directly, outside of Payload Cloud.
### Build Settings
You can update settings from your Projects Settings tab. Changes to your build settings will trigger a redeployment of your project.
### Environment Variables
From the Environment Variables page of the Settings tab, you can add, update and delete variables for use in your project. Like build settings, these changes will trigger a redeployment of your project.
<Banner>
Note: For security reasons, any variables you wish to provide to the Admin
panel must be prefixed with `PAYLOAD_PUBLIC_`.  Learn more
[here](https://payloadcms.com/docs/admin/webpack#admin-environment-vars).
</Banner>
### Custom Domains
With Payload Cloud, you can add custom domain names to your project. To do so, first go to the Domains page of the Settings tab of your project. Here you can see your default domain. To add a new domain, type in the domain name you wish to use.
<Banner>
Note: do not include the protocol (http:// or https://) or any routes (/page).
Only include the domain name and extension, and optionally a subdomain. -
your-domain.com - backend.your-domain.com
</Banner>
Once you click save, a DNS record will be generated for your domain name to point to your live project. Add this record into your DNS providers records, and once the records are resolving properly (this can take 1hr to 48hrs in some cases), your domain will now to point to your live project.
You will also need to configure your Payload project to use your specified domain. In your `payload.config.ts` file, specify your `serverURL` with your domain:
```ts
export default buildConfig({
serverURL: "https://example.com",
// the rest of your config,
});
```
### Email
Powered by [Resend](https://resend.com), Payload Cloud comes with integrated email support out of the box. No configuration is needed, and you can use `payload.sendEmail()` to send email right from your Payload app. To learn more about sending email with Payload, checkout the [Email Configuration](https://payloadcms.com/docs/email/overview) overview.
If you are on the Pro or Enterprise plan, you can add your own custom Email domain name. From the Email page of your projects Settings, add the domain you wish to use for email delivery. This will generate a set of DNS records. Add these records to your DNS provider and click verify to check that your records are resolving properly. Once verified, your emails will now be sent from your custom domain name.
### Developing Locally
To make changes to your project, you will need to clone the repository defined in your project settings to your local machine. In order to run your project locally, you will need configure your local environment first. Refer to your repositorys `README.md` file to see the steps needed for your specific template.
From there, you are ready to make updates to your project. When you are ready to make your changes live, commit your changes to the branch you specified in your Project settings, and your application will automatically trigger a redeploy and build from your latest commit.
### Cloud Plugin
Projects generated from a template will come pre-configured with the official Cloud Plugin, but if you are using your own repository you will need to add this into your project. To do so, add the plugin to your Payload config:
`yarn add @payloadcms/plugin-cloud`
```js
import { payloadCloud } from "@payloadcms/plugin-cloud";
import { buildConfig } from "payload/config";
export default buildConfig({
plugins: [payloadCloud()],
// rest of config
});
```
<Banner type="warning">
**Note:** If your Payload config already has an email with transport, this
will take precedence over Payload Cloud's email service.
</Banner>
##### **Optional configuration**
If you wish to opt-out of any Payload cloud features, the plugin also accepts options to do so.
```js
payloadCloud({
storage: false, // Disable file storage
email: false, // Disable email delivery
});
```

35
docs/cloud/teams.mdx Normal file
View File

@@ -0,0 +1,35 @@
---
title: Cloud Teams
label: Teams
order: 30
desc: Manage your Payload Cloud team and billing settings.
keywords: team, teams, billing, subscription, payment, plan, plans, cloud, payload cloud
---
<Banner>
Within Payload Cloud, the team management feature offers you the ability to
manage your organization, team members, billing, and subscription settings.
</Banner>
![Payload Cloud Team Settings](https://payloadcms.com/images/docs/cloud/team-settings.jpg)
_A screenshot of the Team Settings page._
### Members
Each team has members that can interact with your projects. You can invite multiple people to your team and each individual can belong to more than one team. You can assign them either `owner` or `user` permissions. Owners are able to make admin-only changes, such as deleting projects, and editing billing information.
### Adding Members
To add a new member to your team, visit your Teams Settings page, and click “Invite Teammate”. You can then add their email address, and assign their role. Press “Save” to send the invitations, which will send an email to the invited team member where they can create a new account.
### Billing
Users can update billing settings and subscriptions for any teams where they are designated as an `owner`. To make updates to the teams payment methods, visit the Billing page under the Team Settings tab. You can add new cards, delete cards, and set a payment method as a default. The default payment method will be used in the event that another payment method fails.
### Subscriptions
From the Subscriptions page, a team owner can see all current plans for their team. From here, you can see the price of each plan, if there is an active trial, and when you will be billed next.
### Invoices
The Invoices page will you show you the invoices for your account, as well as the status on their payment.

View File

@@ -11,44 +11,49 @@ Not only does Payload support managing localized content, it also has internatio
While Payload's built-in features come translated, you may want to also translate parts of your project's configuration too. This is possible in places like collections and globals labels and groups, field labels, descriptions and input placeholder text. The admin UI will display all the correct translations you provide based on the user's language.
Here is an example of a simple collection supporting both English and Spanish editors:
```ts
import { CollectionConfig } from 'payload/types';
import { CollectionConfig } from "payload/types";
export const Articles: CollectionConfig = {
slug: 'articles',
slug: "articles",
labels: {
singular: {
en: 'Article', es: 'Artículo',
en: "Article",
es: "Artículo",
},
plural: {
en: 'Articles', es: 'Artículos',
en: "Articles",
es: "Artículos",
},
},
admin: {
group: { en: 'Content', es: 'Contenido' },
group: { en: "Content", es: "Contenido" },
},
fields: [
{
name: 'title',
type: 'text',
name: "title",
type: "text",
label: {
en: 'Title', es: 'Título',
en: "Title",
es: "Título",
},
admin: {
placeholder: { en: 'Enter title', es: 'Introduce el título' }
}
placeholder: { en: "Enter title", es: "Introduce el título" },
},
},
{
name: 'type',
type: 'radio',
options: [{
value: 'news',
label: { en: 'News', es: 'Noticias' },
}, // etc...
name: "type",
type: "radio",
options: [
{
value: "news",
label: { en: "News", es: "Noticias" },
}, // etc...
],
},
],
}
};
```
### Admin UI
@@ -57,8 +62,8 @@ The Payload admin panel reads the language settings of a user's browser and disp
After a user logs in, they can change their language selection in the `/account` view.
<Banner>
<strong>Note:</strong><br/>
If there is a language that Payload does not yet support, we accept code <a href="https://github.com/payloadcms/payload/blob/master/contributing.md">contributions</a>.
<strong>Note:</strong><br />
If there is a language that Payload does not yet support, we accept code [contributions](https://github.com/payloadcms/payload/blob/master/contributing.md).
</Banner>
### Node Express
@@ -76,21 +81,22 @@ In your Payload config, you can add translations and customize the settings in `
**Example Payload config extending i18n:**
```ts
import { buildConfig } from 'payload/config'
import { buildConfig } from "payload/config";
export default buildConfig({
//...
i18n: {
fallbackLng: 'en', // default
fallbackLng: "en", // default
debug: false, // default
resources: {
en: {
custom: { // namespace can be anything you want
key1: 'Translation with {{variable}}', // translation
custom: {
// namespace can be anything you want
key1: "Translation with {{variable}}", // translation
},
// override existing translation keys
general: {
dashboard: 'Home',
dashboard: "Home",
},
},
},

View File

@@ -122,27 +122,36 @@ project-name
<br />
If you use an environment variable to configure any properties that are
required for the Admin panel to function (ex. serverURL or any routes), you
need to make sure that your Admin panel code can access it.{" "}
<a href="/docs/admin/webpack#admin-environment-vars">Click here</a> for more
info.
need to make sure that your Admin panel code can access it. [Click
here](/docs/admin/webpack#admin-environment-vars) for more info.
</Banner>
### Customizing & overriding the config location
### Customizing & Automating Config Location Detection
By default, the Payload config must be in the root of your current working directory and named either `payload.config.js` or `payload.config.ts` if you're using TypeScript.
Payload is designed to automatically locate your configuration file. By default, it will first look in the root of your current working directory for a file named `payload.config.js` or `payload.config.ts` if you're using TypeScript.
But, you can specify where your Payload config is located as well as what it's named by using the environment variable `PAYLOAD_CONFIG_PATH`. The path you provide via this environment variable can either be absolute or relative to your current working directory.
In development mode, if the configuration file is not found at the root, Payload will attempt to read your `tsconfig.json`, and search in the directory specified in `compilerOptions.rootDir` (typically "src").
In production mode, Payload will first attempt to find the config file in the output directory specified in `compilerOptions.outDir` of your `tsconfig.json`, then fallback to the source directory (`compilerOptions.rootDir`), and finally will check the 'dist' directory.
Please ensure your `tsconfig.json` is properly configured if you want Payload to accurately auto-detect your configuration file location. If `tsconfig.json` does not exist or doesn't specify `rootDir` or `outDir`, Payload will default to the current working directory.
#### Overriding the Config Location
In addition to the above automated detection, you can specify your own location for the Payload config file. This is done by using the environment variable `PAYLOAD_CONFIG_PATH`. The path you provide via this environment variable can either be absolute or relative to your current working directory. This can be useful in situations where your Payload config is not in a standard location, or you wish to switch between multiple configurations.
**Example in package.json:**
```
```json
{
"scripts": {
"dev": "PAYLOAD_CONFIG_PATH=path/to/custom-config.js node server.js",
}
"scripts": {
"dev": "PAYLOAD_CONFIG_PATH=path/to/custom-config.js node server.js",
}
}
```
When `PAYLOAD_CONFIG_PATH` is set, Payload will use this path to load the configuration, bypassing all automated detection.
### Developing within the Config
Payload comes with `isomorphic-fetch` installed which means that even in Node, you can use the `fetch` API just as you would within the browser. No need to import `axios` or similar, unless you want to!

View File

@@ -25,21 +25,22 @@ in the `email` property object of your payload init call. Payload will make use
The following options are configurable in the `email` property object as part of the options object when calling payload.init().
| Option | Description |
| ---------------------------- | -------------|
| **`fromName`** * | The name part of the From field that will be seen on the delivered email |
| **`fromAddress`** * | The email address part of the From field that will be used when delivering email |
| **`transport`** | The NodeMailer transport object for when you want to do it yourself, not needed when transportOptions is set |
| **`transportOptions`** | An object that configures the transporter that Payload will create. For all the available options see the [NodeMailer documentation](https://nodemailer.com/smtp/) or see the examples below |
| **`logMockCredentials`** | If set to true and no transport/transportOptions, ethereal credentials will be logged to console on startup |
| Option | Description |
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`fromName`** \* | The name part of the From field that will be seen on the delivered email |
| **`fromAddress`** \* | The email address part of the From field that will be used when delivering email |
| **`transport`** | The NodeMailer transport object for when you want to do it yourself, not needed when transportOptions is set |
| **`transportOptions`** | An object that configures the transporter that Payload will create. For all the available options see the [NodeMailer documentation](https://nodemailer.com/smtp/) or see the examples below |
| **`logMockCredentials`** | If set to true and no transport/transportOptions, ethereal credentials will be logged to console on startup |
*\* An asterisk denotes that a property is required.*
_\* An asterisk denotes that a property is required._
### Use SMTP
Simple Mail Transfer Protocol, also known as SMTP can be passed in using the `transportOptions` object on the `email` options.
**Example email part using SMTP:**
```ts
payload.init({
email: {
@@ -47,24 +48,24 @@ payload.init({
host: process.env.SMTP_HOST,
auth: {
user: process.env.SMTP_USER,
pass: process.env.SMTP_PASS
pass: process.env.SMTP_PASS,
},
port: 587,
secure: true, // use TLS
tls: {
// do not fail on invalid certs
rejectUnauthorized: false
}
rejectUnauthorized: false,
},
fromName: 'hello',
fromAddress: 'hello@example.com'
}
},
fromName: "hello",
fromAddress: "hello@example.com",
},
// ...
})
});
```
<Banner type="warning">
It is best practice to avoid saving credentials or API keys directly in your code, use <a href="/docs/configuration/overview#using-environment-variables-in-your-config">environment variables</a>.
It is best practice to avoid saving credentials or API keys directly in your code, use [environment variables](/docs/configuration/overview#using-environment-variables-in-your-config).
</Banner>
### Use an email service
@@ -72,57 +73,62 @@ payload.init({
Many third party mail providers are available and offer benefits beyond basic SMTP. As an example your payload init could look this if you wanted to use SendGrid.com though the same approach would work for any other [NodeMailer transports](https://nodemailer.com/transports/) shown here or provided by another third party.
```ts
import payload from 'payload'
import nodemailerSendgrid from 'nodemailer-sendgrid'
import payload from "payload";
import nodemailerSendgrid from "nodemailer-sendgrid";
const sendGridAPIKey = process.env.SENDGRID_API_KEY;
payload.init({
...sendGridAPIKey ? {
email: {
transportOptions: nodemailerSendgrid({
apiKey: sendGridAPIKey,
}),
fromName: 'Admin',
fromAddress: 'admin@example.com',
},
} : {},
...(sendGridAPIKey
? {
email: {
transportOptions: nodemailerSendgrid({
apiKey: sendGridAPIKey,
}),
fromName: "Admin",
fromAddress: "admin@example.com",
},
}
: {}),
});
```
### Use a custom NodeMailer transport
To take full control of the mail transport you may wish to use `nodemailer.createTransport()` on your server and provide it to Payload init.
```ts
import payload from 'payload'
import nodemailer from 'nodemailer'
import payload from "payload";
import nodemailer from "nodemailer";
const payload = require('payload');
const nodemailer = require('nodemailer');
const payload = require("payload");
const nodemailer = require("nodemailer");
const transport = await nodemailer.createTransport({
host: process.env.SMTP_HOST,
port: 587,
auth: {
user: process.env.SMTP_USER,
pass: process.env.SMTP_PASS
pass: process.env.SMTP_PASS,
},
});
payload.init({
email: {
fromName: 'Admin',
fromAddress: 'admin@example.com',
transport
fromName: "Admin",
fromAddress: "admin@example.com",
transport,
},
// ...
});
```
### Sending Mail
With a working transport you can call it anywhere you have access to payload by calling `payload.sendEmail(message)`. The `message` will contain the `to`, `subject` and `email` or `text` for the email being sent. To see all available message configuration options see [NodeMailer](https://nodemailer.com/message).
### Mock transport
By default, Payload uses a mock implementation that only sends mail to the [ethereal](https://ethereal.email) capture service that will never reach a user's inbox. While in development you may wish to make use of the captured messages which is why the payload output during server output helpfully logs this out on the server console.
To see ethereal credentials, add `logMockCredentials: true` to the email options. This will cause them to be logged to console on startup.
@@ -130,8 +136,8 @@ To see ethereal credentials, add `logMockCredentials: true` to the email options
```ts
payload.init({
email: {
fromName: 'Admin',
fromAddress: 'admin@example.com',
fromName: "Admin",
fromAddress: "admin@example.com",
logMockCredentials: true, // Optional
},
// ...
@@ -139,6 +145,7 @@ payload.init({
```
**Console output when starting payload with a mock email instance and logMockCredentials: true**
```
[06:37:21] INFO (payload): Starting Payload...
[06:37:22] INFO (payload): Payload Demo Initialized

View File

@@ -12,23 +12,29 @@ keywords: array, fields, config, configuration, documentation, Content Managemen
Its uses can be simple or highly complex.
</Banner>
<LightDarkImage
srcLight="https://payloadcms.com/images/docs/fields/array.png"
srcDark="https://payloadcms.com/images/docs/fields/array-dark.png"
alt="Array field with two Rows in Payload admin panel"
caption="Admin panel screenshot of an Array field with two Rows"
/>
**Example uses:**
- A "slider" with an image ([upload field](/docs/fields/upload)) and a caption ([text field](/docs/fields/text))
- Navigational structures where editors can specify nav items containing pages ([relationship field](/docs/fields/relationship)), an "open in new tab" [checkbox field](/docs/fields/checkbox)
- Event agenda "timeslots" where you need to specify start & end time ([date field](/docs/fields/date)), label ([text field](/docs/fields/text)), and Learn More page [relationship](/docs/fields/relationship)
![Array field in Payload admin panel](https://payloadcms.com/images/docs/fields/array.jpg)
_Admin panel screenshot of an Array field with a Row containing two text fields, a read-only text field and a checkbox_
### Config
| Option | Description |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
| **`label`** | Text used as the heading in the Admin panel or an object with keys for each language. Auto-generated from name if not defined. |
| **`fields`** \* | Array of field types to correspond to each row of the Array. |
| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
| **`fields`** \* | Array of field types to correspond to each row of the Array. |
| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation)
| **`minRows`** | A number for the fewest allowed items during validation when a value is present. |
| **`maxRows`** | A number for the most allowed items during validation when a value is present. |
| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |

View File

@@ -13,33 +13,39 @@ keywords: blocks, fields, config, configuration, documentation, Content Manageme
match the shape of one of your provided block configs.
</Banner>
<LightDarkImage
srcLight="https://payloadcms.com/images/docs/fields/blocks.png"
srcDark="https://payloadcms.com/images/docs/fields/blocks-dark.png"
alt="Admin panel screenshot of add Blocks drawer view"
caption="Admin panel screenshot of add Blocks drawer view"
/>
**Example uses:**
- A layout builder tool that grants editors to design highly customizable page or post layouts. Blocks could include configs such as `Quote`, `CallToAction`, `Slider`, `Content`, `Gallery`, or others.
- A form builder tool where available block configs might be `Text`, `Select`, or `Checkbox`.
- Virtual event agenda "timeslots" where a timeslot could either be a `Break`, a `Presentation`, or a `BreakoutSession`.
![Blocks field in Payload admin panel](https://payloadcms.com/images/docs/fields/blocks.jpg)
_Admin panel screenshot of a Blocks field type with Call to Action and Number block examples_
### Field config
| Option | Description |
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | -------------- | ----------------------------------- |
| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
| **`label`** | Text used as the heading in the Admin panel or an object with keys for each language. Auto-generated from name if not defined. |
| **`blocks`** \* | Array of [block configs](/docs/fields/blocks#block-configs) to be made available to this field. |
| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
| **`hooks`** | Provide field-level hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
| **`access`** | Provide field-level access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API response or the Admin panel. |
| **`defaultValue`** | Provide an array of block data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. If enabled, a separate, localized set of all data within this field will be kept, so there is no need to specify each nested field as `localized`. | | **`required`** | Require this field to have a value. |
| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
| **`labels`** | Customize the block row labels appearing in the Admin dashboard. |
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
| Option | Description |
|-------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **`name`** * | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
| **`label`** | Text used as the heading in the Admin panel or an object with keys for each language. Auto-generated from name if not defined. |
| **`blocks`** * | Array of [block configs](/docs/fields/blocks#block-configs) to be made available to this field. |
| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation)
| **`minRows`** | A number for the fewest allowed items during validation when a value is present. |
| **`maxRows`** | A number for the most allowed items during validation when a value is present. |
| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
| **`hooks`** | Provide field-level hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
| **`access`** | Provide field-level access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API response or the Admin panel. |
| **`defaultValue`** | Provide an array of block data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. If enabled, a separate, localized set of all data within this field will be kept, so there is no need to specify each nested field as `localized`. |
| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
| **`labels`** | Customize the block row labels appearing in the Admin dashboard. |
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
_\* An asterisk denotes that a property is required._
@@ -93,33 +99,33 @@ The Admin panel provides each block with a `blockName` field which optionally al
`collections/ExampleCollection.js`
```ts
import { Block, CollectionConfig } from "payload/types";
import { Block, CollectionConfig } from 'payload/types';
const QuoteBlock: Block = {
slug: "Quote", // required
imageURL: "https://google.com/path/to/image.jpg",
imageAltText: "A nice thumbnail image to show what this block looks like",
interfaceName: "QuoteBlock", // optional
slug: 'Quote', // required
imageURL: 'https://google.com/path/to/image.jpg',
imageAltText: 'A nice thumbnail image to show what this block looks like',
interfaceName: 'QuoteBlock', // optional
fields: [
// required
{
name: "quoteHeader",
type: "text",
name: 'quoteHeader',
type: 'text',
required: true,
},
{
name: "quoteText",
type: "text",
name: 'quoteText',
type: 'text',
},
],
};
export const ExampleCollection: CollectionConfig = {
slug: "example-collection",
slug: 'example-collection',
fields: [
{
name: "layout", // required
type: "blocks", // required
name: 'layout', // required
type: 'blocks', // required
minRows: 1,
maxRows: 20,
blocks: [
@@ -136,5 +142,5 @@ export const ExampleCollection: CollectionConfig = {
As you build your own Block configs, you might want to store them in separate files but retain typing accordingly. To do so, you can import and use Payload's `Block` type:
```ts
import type { Block } from "payload/types";
import type { Block } from 'payload/types';
```

View File

@@ -10,6 +10,13 @@ keywords: checkbox, fields, config, configuration, documentation, Content Manage
The Checkbox field type saves a boolean in the database.
</Banner>
<LightDarkImage
srcLight='https://payloadcms.com/images/docs/fields/checkbox.png'
srcDark='https://payloadcms.com/images/docs/fields/checkbox-dark.png'
alt='Checkbox field with text field in Payload admin panel'
caption='Admin panel screenshot of Checkbox field with Text field below'
/>
### Config
| Option | Description |

View File

@@ -11,6 +11,13 @@ keywords: code, fields, config, configuration, documentation, Content Management
The Code field type saves a string in the database, but provides the Admin panel with a code editor styled interface.
</Banner>
<LightDarkImage
srcLight='https://payloadcms.com/images/docs/fields/code.png'
srcDark='https://payloadcms.com/images/docs/fields/code-dark.png'
alt='Shows a Code field in the Payload admin panel'
caption='Admin panel screenshot of a Code field'
/>
This field uses the `monaco-react` editor syntax highlighting.
### Config

View File

@@ -10,6 +10,13 @@ keywords: row, fields, config, configuration, documentation, Content Management
The Collapsible field is presentational-only and only affects the Admin panel. By using it, you can place fields within a nice layout component that can be collapsed / expanded.
</Banner>
<LightDarkImage
srcLight='https://payloadcms.com/images/docs/fields/collapsible.png'
srcDark='https://payloadcms.com/images/docs/fields/collapsible-dark.png'
alt='Shows a Collapsible field in the Payload admin panel'
caption='Admin panel screenshot of a Collapsible field'
/>
### Config
| Option | Description |

View File

@@ -11,6 +11,13 @@ keywords: date, fields, config, configuration, documentation, Content Management
with a customizable time picker interface.
</Banner>
<LightDarkImage
srcLight='https://payloadcms.com/images/docs/fields/date.png'
srcDark='https://payloadcms.com/images/docs/fields/date-dark.png'
alt='Shows a Date field in the Payload admin panel'
caption='Admin panel screenshot of a Date field'
/>
This field uses [`react-datepicker`](https://www.npmjs.com/package/react-datepicker) for the Admin panel component.
### Config

View File

@@ -6,10 +6,17 @@ desc: The Email field enforces that the value provided is a valid email address.
keywords: email, fields, config, configuration, documentation, Content Management System, cms, headless, javascript, node, react, express
---
<Banner >
<Banner>
The Email field enforces that the value provided is a valid email address.
</Banner>
<LightDarkImage
srcLight='https://payloadcms.com/images/docs/fields/email.png'
srcDark='https://payloadcms.com/images/docs/fields/email-dark.png'
alt='Shows an Email field in the Payload admin panel'
caption='Admin panel screenshot of an Email field'
/>
### Config
| Option | Description |

View File

@@ -11,6 +11,13 @@ keywords: group, fields, config, configuration, documentation, Content Managemen
also groups fields together visually in the Admin panel.
</Banner>
<LightDarkImage
srcLight='https://payloadcms.com/images/docs/fields/group.png'
srcDark='https://payloadcms.com/images/docs/fields/group-dark.png'
alt='Shows a Group field in the Payload admin panel'
caption='Admin panel screenshot of a Group field'
/>
### Config
| Option | Description |

View File

@@ -11,6 +11,13 @@ keywords: json, fields, config, configuration, documentation, Content Management
The JSON field type saves actual JSON in the database, which differs from the Code field that saves the value as a string in the database.
</Banner>
<LightDarkImage
srcLight='https://payloadcms.com/images/docs/fields/json.png'
srcDark='https://payloadcms.com/images/docs/fields/json-dark.png'
alt='Shows a JSON field in the Payload admin panel'
caption='Admin panel screenshot of a JSON field'
/>
This field uses the `monaco-react` editor syntax highlighting.
### Config

View File

@@ -10,6 +10,13 @@ keywords: number, fields, config, configuration, documentation, Content Manageme
The Number field stores and validates numeric entry and supports additional numerical validation and formatting features.
</Banner>
<LightDarkImage
srcLight='https://payloadcms.com/images/docs/fields/number.png'
srcDark='https://payloadcms.com/images/docs/fields/number-dark.png'
alt='Shows a Number field in the Payload admin panel'
caption='Admin panel screenshot of a Number field'
/>
### Config
| Option | Description |
@@ -18,6 +25,9 @@ keywords: number, fields, config, configuration, documentation, Content Manageme
| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
| **`min`** | Minimum value accepted. Used in the default `validation` function. |
| **`max`** | Maximum value accepted. Used in the default `validation` function. |
| **`hasMany`** | Makes this field an ordered array of numbers instead of just a single number. |
| **`minRows`** | Minimum number of numbers in the numbers array, if `hasMany` is set to true. |
| **`maxRows`** | Maximum number of numbers in the numbers array, if `hasMany` is set to true. |
| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
| **`index`** | Build a [MongoDB index](https://docs.mongodb.com/manual/indexes/) for this field to produce faster queries. Set this field to `true` if your users will perform queries on this field's data often. |
| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |

View File

@@ -11,6 +11,13 @@ keywords: point, geolocation, geospatial, geojson, 2dsphere, config, configurati
The Point field type saves a pair of coordinates in the database and assigns an index for location related queries.
</Banner>
<LightDarkImage
srcLight='https://payloadcms.com/images/docs/fields/point.png'
srcDark='https://payloadcms.com/images/docs/fields/point-dark.png'
alt='Shows a Point field in the Payload admin panel'
caption='Admin panel screenshot of a Point field'
/>
The data structure in the database matches the GeoJSON structure to represent point. The Payload APIs simplifies the object data to only the [longitude, latitude] location.
### Config

View File

@@ -10,6 +10,13 @@ keywords: radio, fields, config, configuration, documentation, Content Managemen
The Radio Group field type allows for the selection of one value from a predefined set of possible values and presents a radio group-style set of inputs to the Admin panel.
</Banner>
<LightDarkImage
srcLight='https://payloadcms.com/images/docs/fields/radio.png'
srcDark='https://payloadcms.com/images/docs/fields/radio-dark.png'
alt='Shows a Radio field in the Payload admin panel'
caption='Admin panel screenshot of a Radio field'
/>
### Config
| Option | Description |

View File

@@ -11,6 +11,13 @@ keywords: relationship, fields, config, configuration, documentation, Content Ma
provides for the ability to easily relate documents together.
</Banner>
<LightDarkImage
srcLight='https://payloadcms.com/images/docs/fields/relationship.png'
srcDark='https://payloadcms.com/images/docs/fields/relationship-dark.png'
alt='Shows a relationship field in the Payload admin panel'
caption='Admin panel screenshot of a Relationship field'
/>
**Example uses:**
- To add `Product` documents to an `Order` document
@@ -25,8 +32,8 @@ keywords: relationship, fields, config, configuration, documentation, Content Ma
| **`relationTo`** \* | Provide one or many collection `slug`s to be able to assign relationships to. |
| **`filterOptions`** | A query to filter which options appear in the UI and validate against. [More](#filtering-relationship-options). |
| **`hasMany`** | Boolean when, if set to `true`, allows this field to have many relations instead of only one. |
| **`min`** | A number for the fewest allowed items during validation when a value is present. Used with `hasMany`. |
| **`max`** | A number for the most allowed items during validation when a value is present. Used with `hasMany`. |
| **`minRows`** | A number for the fewest allowed items during validation when a value is present. Used with `hasMany`. |
| **`maxRows`** | A number for the most allowed items during validation when a value is present. Used with `hasMany`. |
| **`maxDepth`** | Sets a number limit on iterations of related documents to populate when queried. [Depth](/docs/getting-started/concepts#depth) |
| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
| **`unique`** | Enforce that each entry in the Collection has a unique value for this field. |
@@ -47,8 +54,8 @@ _\* An asterisk denotes that a property is required._
<Banner type="success">
<strong>Tip:</strong>
<br />
The <a href="/docs/getting-started/concepts#depth">Depth</a> parameter can be
used to automatically populate related documents that are returned by the API.
The [Depth](/docs/getting-started/concepts#depth) parameter can be used to
automatically populate related documents that are returned by the API.
</Banner>
### Admin config
@@ -67,7 +74,7 @@ Set to `false` if you'd like to disable the ability to create new documents from
Options can be dynamically limited by supplying a [query constraint](/docs/queries/overview), which will be used both for validating input and filtering available relationships in the UI.
The `filterOptions` property can either be a `Where` query directly, or a function that returns one. When using a function, it will be called with an argument object with the following properties:
The `filterOptions` property can either be a `Where` query directly, or a function (synchronous or asynchronous) that returns one. When using a function, it will be called with an argument object containing the following properties:
| Property | Description |
| ------------- | ------------------------------------------------------------------------------------ |

View File

@@ -6,10 +6,17 @@ desc: The Rich Text field allows dynamic content to be written through the Admin
keywords: rich text, fields, config, configuration, documentation, Content Management System, cms, headless, javascript, node, react, express
---
<Banner >
<Banner>
The Rich Text field is a powerful way to allow editors to write dynamic content. The content is saved as JSON in the database and can be converted into any format, including HTML, that you need.
</Banner>
<LightDarkImage
srcLight='https://payloadcms.com/images/docs/fields/richtext.png'
srcDark='https://payloadcms.com/images/docs/fields/richtext-dark.png'
alt='Shows a Rich Text field in the Payload admin panel'
caption='Admin panel screenshot of a Rich Text field'
/>
The Admin component is built on the powerful [`slatejs`](https://docs.slatejs.org/) editor and is meant to be as extensible and customizable as possible.
<Banner type="success">
@@ -18,22 +25,22 @@ The Admin component is built on the powerful [`slatejs`](https://docs.slatejs.or
### Config
| Option | Description |
| ---------------- | ----------- |
| **`name`** * | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
| **`required`** | Require this field to have a value. |
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
| Option | Description |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
| **`hooks`** | Provide field-based hooks to control logic for this field. [More](/docs/fields/overview#field-level-hooks) |
| **`access`** | Provide field-based access control to denote what users can see and do with this field's data. [More](/docs/fields/overview#field-level-access-control) |
| **`hidden`** | Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel. |
| **`defaultValue`** | Provide data to be used for this field's default value. [More](/docs/fields/overview#default-values) |
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
| **`required`** | Require this field to have a value. |
| **`admin`** | Admin-specific configuration. See below for [more detail](#admin-config). |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
*\* An asterisk denotes that a property is required.*
_\* An asterisk denotes that a property is required._
### Admin config
@@ -59,9 +66,11 @@ The default `elements` available in Payload are:
- `link`
- `ol`
- `ul`
- `textAlign`
- `indent`
- [`relationship`](#relationship-element)
- [`upload`](#upload-element)
- [`textAlign`](#text-align)
**`leaves`**
@@ -86,17 +95,17 @@ This allows [fields](/docs/fields/overview) to be saved as extra fields on a lin
`link.fields` may either be an array of fields (in which case all fields defined in it will be appended below the default fields) or a function that accepts the default fields as only argument and returns an array defining the entirety of fields to be used (thus providing a mechanism of overriding the default fields).
![RichText link fields](https://payloadcms.com/images/docs/fields/richText/rte-link-fields-modal.jpg)
*RichText link with custom fields*
_RichText link with custom fields_
**`upload.collections[collection-name].fields`**
This allows [fields](/docs/fields/overview) to be saved as meta data on an upload field inside the Rich Text Editor. When this is present, the fields will render inside a modal that can be opened by clicking the "edit" button on the upload element.
![RichText upload element](https://payloadcms.com/images/docs/fields/richText/rte-upload-element.jpg)
*RichText field using the upload element*
_RichText field using the upload element_
![RichText upload element modal](https://payloadcms.com/images/docs/fields/richText/rte-upload-fields-modal.jpg)
*RichText upload element modal displaying fields from the config*
_RichText upload element modal displaying fields from the config_
### Relationship element
@@ -107,12 +116,15 @@ The built-in `relationship` element is a powerful way to reference other Documen
Similar to the `relationship` element, the `upload` element is a user-friendly way to reference [Upload-enabled collections](/docs/upload/overview) with a UI specifically designed for media / image-based uploads.
<Banner type="success">
<strong>Tip:</strong><br/>
Collections are automatically allowed to be selected within the Rich Text relationship and upload elements by default. If you want to disable a collection from being able to be referenced in Rich Text fields, set the collection admin options of <strong>enableRichTextLink</strong> and <strong>enableRichTextRelationship</strong> to false.
<strong>Tip:</strong><br />Collections are automatically allowed to be selected within the Rich Text relationship and upload elements by default. If you want to disable a collection from being able to be referenced in Rich Text fields, set the collection admin options of <strong>enableRichTextLink</strong> and <strong>enableRichTextRelationship</strong> to false.
</Banner>
Relationship and Upload elements are populated dynamically into your Rich Text field' content. Within the REST and Local APIs, any present RichText `relationship` or `upload` elements will respect the `depth` option that you pass, and will be populated accordingly. In GraphQL, each `richText` field accepts an argument of `depth` for you to utilize.
### TextAlign element
Text Alignment is not included by default and can be added to a Rich Text Editor by adding `textAlign` to the list of elements. TextAlign will alter the existing element to include a new `textAlign` field in the resulting JSON. This field can be used in combination with other elements and leaves to position content to the left, center or right.
### Specifying which elements and leaves to allow
To specify which default elements or leaves should be allowed to be used for this field, define arrays that contain string names for each element or leaf you wish to enable. To specify a custom element or leaf, pass an object with all corresponding properties as outlined below. View the [example](#example) to reference how this all works.
@@ -125,71 +137,75 @@ Once you're up to speed with the general concepts involved, you can pass in your
**Both custom elements and leaves are defined via the following config:**
| Property | Description |
| ---------------- | ----------- |
| **`name`** * | The name to be used as a `type` for this element. |
| **`Button`** * | A React component to be rendered in the Rich Text toolbar. |
| **`plugins`** | An array of plugins to provide to the Rich Text editor. |
| Property | Description |
| --------------- | ---------------------------------------------------------- |
| **`name`** \* | The default name to be used as a `type` for this element. |
| **`Button`** \* | A React component to be rendered in the Rich Text toolbar. |
| **`plugins`** | An array of plugins to provide to the Rich Text editor. |
| **`type`** | A type that overrides the default type used by `name` |
Custom `Element`s also require the `Element` property set to a React component to be rendered as the `Element` within the rich text editor itself.
Custom `Leaf` objects follow a similar pattern but require you to define the `Leaf` property instead.
Specifying custom `Type`s let you extend your custom elements by adding additional fields to your JSON object.
### Example
`collections/ExampleCollection.ts`
```ts
import { CollectionConfig } from 'payload/types';
import { CollectionConfig } from "payload/types";
export const ExampleCollection: CollectionConfig = {
slug: 'example-collection',
slug: "example-collection",
fields: [
{
name: 'content', // required
type: 'richText', // required
defaultValue: [{
children: [{ text: 'Here is some default content for this field' }],
}],
name: "content", // required
type: "richText", // required
defaultValue: [
{
children: [{ text: "Here is some default content for this field" }],
},
],
required: true,
admin: {
elements: [
'h2',
'h3',
'h4',
'link',
'blockquote',
"h2",
"h3",
"h4",
"link",
"blockquote",
{
name: 'cta',
name: "cta",
Button: CustomCallToActionButton,
Element: CustomCallToActionElement,
plugins: [
// any plugins that are required by this element go here
]
}
],
},
],
leaves: [
'bold',
'italic',
"bold",
"italic",
{
name: 'highlight',
name: "highlight",
Button: CustomHighlightButton,
Leaf: CustomHighlightLeaf,
plugins: [
// any plugins that are required by this leaf go here
]
}
],
},
],
link: {
// Inject your own fields into the Link element
fields: [
{
name: 'rel',
label: 'Rel Attribute',
type: 'select',
name: "rel",
label: "Rel Attribute",
type: "select",
hasMany: true,
options: [
'noopener', 'noreferrer', 'nofollow',
],
options: ["noopener", "noreferrer", "nofollow"],
},
],
},
@@ -203,9 +219,9 @@ export const ExampleCollection: CollectionConfig = {
},
},
},
}
}
]
},
},
],
};
```
@@ -216,112 +232,67 @@ For more examples regarding how to define your own elements and leaves, check ou
As the Rich Text field saves its content in a JSON format, you'll need to render it as HTML yourself. Here is an example for how to generate JSX / HTML from Rich Text content:
```ts
import React, { Fragment } from 'react';
import escapeHTML from 'escape-html';
import { Text } from 'slate';
import React, { Fragment } from "react";
import escapeHTML from "escape-html";
import { Text } from "slate";
const serialize = (children) => children.map((node, i) => {
if (Text.isText(node)) {
let text = <span dangerouslySetInnerHTML={{ __html: escapeHTML(node.text) }} />;
if (node.bold) {
text = (
<strong key={i}>
{text}
</strong>
const serialize = (children) =>
children.map((node, i) => {
if (Text.isText(node)) {
let text = (
<span dangerouslySetInnerHTML={{ __html: escapeHTML(node.text) }} />
);
if (node.bold) {
text = <strong key={i}>{text}</strong>;
}
if (node.code) {
text = <code key={i}>{text}</code>;
}
if (node.italic) {
text = <em key={i}>{text}</em>;
}
// Handle other leaf types here...
return <Fragment key={i}>{text}</Fragment>;
}
if (node.code) {
text = (
<code key={i}>
{text}
</code>
);
if (!node) {
return null;
}
if (node.italic) {
text = (
<em key={i}>
{text}
</em>
);
switch (node.type) {
case "h1":
return <h1 key={i}>{serialize(node.children)}</h1>;
// Iterate through all headings here...
case "h6":
return <h6 key={i}>{serialize(node.children)}</h6>;
case "blockquote":
return <blockquote key={i}>{serialize(node.children)}</blockquote>;
case "ul":
return <ul key={i}>{serialize(node.children)}</ul>;
case "ol":
return <ol key={i}>{serialize(node.children)}</ol>;
case "li":
return <li key={i}>{serialize(node.children)}</li>;
case "link":
return (
<a href={escapeHTML(node.url)} key={i}>
{serialize(node.children)}
</a>
);
default:
return <p key={i}>{serialize(node.children)}</p>;
}
// Handle other leaf types here...
return (
<Fragment key={i}>
{text}
</Fragment>
);
}
if (!node) {
return null;
}
switch (node.type) {
case 'h1':
return (
<h1 key={i}>
{serialize(node.children)}
</h1>
);
// Iterate through all headings here...
case 'h6':
return (
<h6 key={i}>
{serialize(node.children)}
</h6>
);
case 'blockquote':
return (
<blockquote key={i}>
{serialize(node.children)}
</blockquote>
);
case 'ul':
return (
<ul key={i}>
{serialize(node.children)}
</ul>
);
case 'ol':
return (
<ol key={i}>
{serialize(node.children)}
</ol>
);
case 'li':
return (
<li key={i}>
{serialize(node.children)}
</li>
);
case 'link':
return (
<a
href={escapeHTML(node.url)}
key={i}
>
{serialize(node.children)}
</a>
);
default:
return (
<p key={i}>
{serialize(node.children)}
</p>
);
}
});
});
```
<Banner>
<strong>Note:</strong><br/>
The above example is for how to render to JSX, although for plain HTML the pattern is similar. Just remove the JSX and return HTML strings instead!
<strong>Note:</strong><br />The above example is for how to render to JSX, although for plain HTML the pattern is similar. Just remove the JSX and return HTML strings instead!
</Banner>
### Built-in SlateJS Plugins
@@ -337,12 +308,12 @@ If you want to utilize this functionality within your own custom elements, you c
`customLargeBodyElement.js`:
```ts
import Button from './Button';
import Element from './Element';
import withLargeBody from './plugin';
import Button from "./Button";
import Element from "./Element";
import withLargeBody from "./plugin";
export default {
name: 'large-body',
name: "large-body",
Button,
Element,
plugins: [
@@ -350,10 +321,11 @@ export default {
const editor = incomingEditor;
const { shouldBreakOutOnEnter } = editor;
editor.shouldBreakOutOnEnter = (element) => (element.type === 'large-body' ? true : shouldBreakOutOnEnter(element));
editor.shouldBreakOutOnEnter = (element) =>
element.type === "large-body" ? true : shouldBreakOutOnEnter(element);
return editor;
}
},
],
};
```
@@ -367,8 +339,5 @@ The plugin itself extends Payload's built-in `shouldBreakOutOnEnter` Slate funct
If you are building your own custom Rich Text elements or leaves, you may benefit from importing the following types:
```ts
import type {
RichTextCustomElement,
RichTextCustomLeaf,
} from 'payload/types';
import type { RichTextCustomElement, RichTextCustomLeaf } from "payload/types";
```

View File

@@ -10,6 +10,13 @@ keywords: row, fields, config, configuration, documentation, Content Management
The Row field is presentational-only and only affects the Admin panel. By using it, you can arrange fields next to each other horizontally.
</Banner>
<LightDarkImage
srcLight='https://payloadcms.com/images/docs/fields/row.png'
srcDark='https://payloadcms.com/images/docs/fields/row-dark.png'
alt='Shows a row field in the Payload admin panel'
caption='Admin panel screenshot of a Row field'
/>
### Config
| Option | Description |

View File

@@ -10,6 +10,12 @@ keywords: select, multi-select, fields, config, configuration, documentation, Co
The Select field provides a dropdown-style interface for choosing options from
a predefined list as an enumeration.
</Banner>
<LightDarkImage
srcLight='https://payloadcms.com/images/docs/fields/select.png'
srcDark='https://payloadcms.com/images/docs/fields/select-dark.png'
alt='Shows a Select field in the Payload admin panel'
caption='Admin panel screenshot of a Select field'
/>
### Config
@@ -92,3 +98,85 @@ export const ExampleCollection: CollectionConfig = {
}
```
### Customization
The Select field UI component can be customized by providing a custom React component to the `components` object in the Base config.
```ts
export const CustomSelectField: Field = {
name: 'customSelectField',
type: 'select', // or 'text' if you have dynamic options
admin: {
components: {
Field: CustomSelectComponent({
options: [
{
label: 'Option 1',
value: '1',
},
{
label: 'Option 2',
value: '2',
},
],
}),
},
}
}
```
You can import the existing Select component directly from Payload, then extend and customize it as needed.
```ts
import * as React from 'react';
import { SelectInput, useField } from 'payload/components/forms';
import { useAuth } from 'payload/components/utilities';
type customSelectProps = {
path: string;
options: {
label: string;
value: string;
}[];
}
export const CustomSelectComponent: React.FC<CustomSelectProps> = ({ path, options }) => {
const { value, setValue } = useField<string>({ path });
const { user } = useAuth();
const adjustedOptions = options.filter((option) => {
/*
A common use case for a custom select
is to show different options based on
the current user's role.
*/
return option;
});
return (
<div>
<label className="field-label">
Custom Select
</label>
<SelectInput
path={path}
name={path}
options={adjustedOptions}
value={value}
onChange={() => setValue(e.value)}
/>
</div>
);
};
```
If you are looking to create a dynamic select field, the following tutorial will walk you through the process of creating a custom select field that fetches its options from an external API.
<VideoDrawer
id='Efn9OxSjA6Y'
label='How to Create a Custom Select Field'
drawerTitle='How to Create a Custom Select Field: A Step-by-Step Guide'
/>
If you want to learn more about custom components check out the [Admin > Custom Component](/docs/admin/components#field-component) docs.

View File

@@ -12,8 +12,13 @@ keywords: tabs, fields, config, configuration, documentation, Content Management
component that separates certain sub-fields by a tabbed interface.
</Banner>
![Tabs field type used to separate Hero fields from Page Layout](https://payloadcms.com/images/docs/fields/tabs/tabs.jpg)
_Tabs field type used to separate Hero fields from Page Layout_
<LightDarkImage
srcLight='https://payloadcms.com/images/docs/fields/tabs.png'
srcDark='https://payloadcms.com/images/docs/fields/tabs-dark.png'
alt='Shows a tabs field used to separate Hero and Page layout in the Payload admin panel'
caption='Tabs field type used to separate Hero fields from Page Layout'
/>
### Config
@@ -25,14 +30,14 @@ _Tabs field type used to separate Hero fields from Page Layout_
#### Tab-specific Config
Each tab has its own required `label` and `fields` array. You can also optionally pass a `description` to render within each individual tab.
Each tab must have either a `name` or `label` and the required `fields` array. You can also optionally pass a `description` to render within each individual tab.
| Option | Description |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **`name`** | An optional property name to be used when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
| **`label`** \* | The label to render on the tab itself. |
| **`fields`** \* | The fields to render within this tab. |
| **`description`** | Optionally render a description within this tab to describe the contents of the tab itself. |
| Option | Description |
| ---------------- |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **`name`** | Groups field data into an object when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
| **`label`** | The label to render on the tab itself. Required when name is undefined, defaults to name converted to words. |
| **`fields`** \* | The fields to render within this tab. |
| **`description`** | Optionally render a description within this tab to describe the contents of the tab itself. |
| **`interfaceName`** | Create a top level, reusable [Typescript interface](/docs/typescript/generating-types#custom-field-interfaces) & [GraphQL type](/docs/graphql/graphql-schema#custom-field-schemas). (`name` must be present) |
_\* An asterisk denotes that a property is required._

View File

@@ -10,6 +10,13 @@ keywords: text, fields, config, configuration, documentation, Content Management
The Text field type is one of the most commonly used fields. It saves a string to the database and provides the Admin panel with a simple text input.
</Banner>
<LightDarkImage
srcLight='https://payloadcms.com/images/docs/fields/text.png'
srcDark='https://payloadcms.com/images/docs/fields/text-dark.png'
alt='Shows a text field and read-only text field in the Payload admin panel'
caption='Admin panel screenshot of a Text field and read-only Text field'
/>
### Config
| Option | Description |

View File

@@ -10,6 +10,13 @@ keywords: textarea, fields, config, configuration, documentation, Content Manage
The Textarea field is almost identical to the Text field but it features a slightly larger input that is better suited to edit longer text.
</Banner>
<LightDarkImage
srcLight='https://payloadcms.com/images/docs/fields/textarea.png'
srcDark='https://payloadcms.com/images/docs/fields/textarea-dark.png'
alt='Shows a textarea field and read-only textarea field in the Payload admin panel'
caption='Admin panel screenshot of a Textarea field and read-only Textarea field'
/>
### Config
| Option | Description |

View File

@@ -6,15 +6,22 @@ desc: Upload fields will allow a file to be uploaded, only from a collection sup
keywords: upload, images media, fields, config, configuration, documentation, Content Management System, cms, headless, javascript, node, react, express
---
<Banner >
<Banner>
The Upload field allows for the selection of a Document from a collection supporting Uploads, and formats the selection as a thumbnail in the Admin panel.
</Banner>
<Banner type="warning">
<strong>Important:</strong><br/>
To use this field, you need to have a Collection configured to allow Uploads. For more information, <a href="/docs/upload/overview">click here</a> to read about how to enable Uploads on a collection by collection basis.
<strong>Important:</strong><br />
To use this field, you need to have a Collection configured to allow Uploads. For more information, [click here](/docs/upload/overview) to read about how to enable Uploads on a collection by collection basis.
</Banner>
<LightDarkImage
srcLight='https://payloadcms.com/images/docs/fields/upload.png'
srcDark='https://payloadcms.com/images/docs/fields/upload-dark.png'
alt='Shows an upload field in the Payload admin panel'
caption='Admin panel screenshot of an Upload field'
/>
**Example uses:**
- To provide a `Page` with a featured image
@@ -23,10 +30,10 @@ keywords: upload, images media, fields, config, configuration, documentation, Co
### Config
| Option | Description |
| ---------------- |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **`name`** * | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
| **`*relationTo`** * | Provide a single collection `slug` to allow this field to accept a relation to. <strong>Note: the related collection must be configured to support Uploads.</strong> |
| Option | Description |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`name`** \* | To be used as the property name when stored and retrieved from the database. [More](/docs/fields/overview#field-names) |
| **`*relationTo`** \* | Provide a single collection `slug` to allow this field to accept a relation to. <strong>Note: the related collection must be configured to support Uploads.</strong> |
| **`filterOptions`** | A query to filter which options appear in the UI and validate against. [More](#filtering-upload-options). |
| **`maxDepth`** | Sets a number limit on iterations of related documents to populate when queried. [Depth](/docs/getting-started/concepts#depth) |
| **`label`** | Text used as a field label in the Admin panel or an object with keys for each language. |
@@ -41,28 +48,28 @@ keywords: upload, images media, fields, config, configuration, documentation, Co
| **`localized`** | Enable localization for this field. Requires [localization to be enabled](/docs/configuration/localization) in the Base config. |
| **`required`** | Require this field to have a value. |
| **`admin`** | Admin-specific configuration. See the [default field admin config](/docs/fields/overview#admin-config) for more details. |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
| **`custom`** | Extension point for adding custom data (e.g. for plugins) |
*\* An asterisk denotes that a property is required.*
_\* An asterisk denotes that a property is required._
### Example
`collections/ExampleCollection.ts`
```ts
import { CollectionConfig } from 'payload/types';
import { CollectionConfig } from "payload/types";
export const ExampleCollection: CollectionConfig = {
slug: 'example-collection',
slug: "example-collection",
fields: [
{
name: 'backgroundImage', // required
type: 'upload', // required
relationTo: 'media', // required
name: "backgroundImage", // required
type: "upload", // required
relationTo: "media", // required
required: true,
}
]
}
},
],
};
```
### Filtering upload options
@@ -71,23 +78,23 @@ Options can be dynamically limited by supplying a [query constraint](/docs/queri
The `filterOptions` property can either be a `Where` query directly, or a function that returns one. When using a function, it will be called with an argument object with the following properties:
| Property | Description |
| ------------- | -------------|
| `relationTo` | The `relationTo` to filter against (as defined on the field) |
| `data` | An object of the full collection or global document currently being edited |
| `siblingData` | An object of the document data limited to fields within the same parent to the field |
| `id` | The value of the collection `id`, will be `undefined` on create request |
| `user` | The currently authenticated user object |
| Property | Description |
| ------------- | ------------------------------------------------------------------------------------ |
| `relationTo` | The `relationTo` to filter against (as defined on the field) |
| `data` | An object of the full collection or global document currently being edited |
| `siblingData` | An object of the document data limited to fields within the same parent to the field |
| `id` | The value of the collection `id`, will be `undefined` on create request |
| `user` | The currently authenticated user object |
**Example:**
```ts
const uploadField = {
name: 'image',
type: 'upload',
relationTo: 'media',
name: "image",
type: "upload",
relationTo: "media",
filterOptions: {
mimeType: { contains: 'image' },
mimeType: { contains: "image" },
},
};
```
@@ -95,6 +102,6 @@ const uploadField = {
You can learn more about writing queries [here](/docs/queries/overview).
<Banner type="warning">
<strong>Note:</strong><br/>
<strong>Note:</strong><br />
When an upload field has both <strong>filterOptions</strong> and a custom <strong>validate</strong> function, the api will not validate <strong>filterOptions</strong> unless you call the default upload field validation function imported from <strong>payload/fields/validations</strong> in your validate function.
</Banner>

View File

@@ -117,7 +117,7 @@ It is also possible to limit the depth for specific `relation` and `upload` fiel
}
```
If you were to query the Posts endpoint at, say, `http://localhost:3000/api/posts?depth=1`, you will retrieve Posts with populations one level deep. A returned result may look like the following:
If you were to query the Posts endpoint at, say, `http://localhost:3000/api/posts?depth=1`, you will retrieve Posts with populations one level deep. This depth parameter can be thought of as N, where N is the number of levels you want to populate. To populate one level further, you would simply specify N+1 as the depth. A returned result may look like the following:
```
// ?depth=1

View File

@@ -140,6 +140,10 @@ A boolean that when set to `true` tells Payload to start in local-only mode whic
Specify options for the built-in Pino logger that Payload uses for internal logging. See [Pino Docs](https://getpino.io/#/docs/api?id=options) for more info on what is available.
##### `loggerDestination`
Specify destination stream for the built-in Pino logger that Payload uses for internal logging. See [Pino Docs](https://getpino.io/#/docs/api?id=pino-destination) for more info on what is available.
##### `onInit`
A function that is called immediately following startup that receives the Payload instance as it's only argument.

View File

@@ -8,7 +8,7 @@ keywords: documentation, getting started, guide, Content Management System, cms,
<YouTube
id="In_lFhzmbME"
title="Payload CMS Introduction - Closing the Gap Between Headless CMS and Application Frameworks"
title="Payload Introduction - Closing the Gap Between Headless CMS and Application Frameworks"
/>
<Banner type="success">

View File

@@ -115,16 +115,8 @@ GraphQL Playground is enabled by default for development purposes, but disabled
You can even log in using the `login[collection-singular-label-here]` mutation to use the Playground as an authenticated user.
<Banner type="success">
<strong>Tip:</strong>
<br />
To see more regarding how the above queries and mutations are used, visit your
GraphQL playground (by default at{" "}
<a href="http://localhost:3000/api/graphql-playground">
(http://localhost:3000/api/graphql-playground
</a>
) while your server is running. There, you can use the "Schema" and "Docs"
buttons on the right to see a ton of detail about how GraphQL operates within
Payload.
<strong>Tip:</strong><br />
To see more regarding how the above queries and mutations are used, visit your GraphQL playground (by default at [http://localhost:3000/api/graphql-playground](http://localhost:3000/api/graphql-playground)) while your server is running. There, you can use the "Schema" and "Docs" buttons on the right to see a ton of detail about how GraphQL operates within Payload.
</Banner>
## Query complexity limits

View File

@@ -16,6 +16,7 @@ Collections feature the ability to define the following hooks:
- [afterRead](#afterread)
- [beforeDelete](#beforedelete)
- [afterDelete](#afterdelete)
- [afterOperation](#afteroperation)
Additionally, `auth`-enabled collections feature the following hooks:
@@ -31,6 +32,7 @@ Additionally, `auth`-enabled collections feature the following hooks:
All collection Hook properties accept arrays of synchronous or asynchronous functions. Each Hook type receives specific arguments and has the ability to modify specific outputs.
`collections/exampleHooks.js`
```ts
import { CollectionConfig } from 'payload/types';
@@ -48,6 +50,7 @@ export const ExampleHooks: CollectionConfig = {
afterChange: [(args) => {...}],
afterRead: [(args) => {...}],
afterDelete: [(args) => {...}],
afterOperation: [(args) => {...}],
// Auth-enabled hooks
beforeLogin: [(args) => {...}],
@@ -62,19 +65,19 @@ export const ExampleHooks: CollectionConfig = {
### beforeOperation
The `beforeOperation` Hook type can be used to modify the arguments that operations accept or execute side-effects that run before an operation begins.
The `beforeOperation` hook can be used to modify the arguments that operations accept or execute side-effects that run before an operation begins.
Available Collection operations include `create`, `read`, `update`, `delete`, `login`, `refresh` and `forgotPassword`.
Available Collection operations include `create`, `read`, `update`, `delete`, `login`, `refresh`, and `forgotPassword`.
```ts
import { CollectionBeforeOperationHook } from 'payload/types';
import { CollectionBeforeOperationHook } from "payload/types";
const beforeOperationHook: CollectionBeforeOperationHook = async ({
args, // Original arguments passed into the operation
args, // original arguments passed into the operation
operation, // name of the operation
}) => {
return args; // Return operation arguments as necessary
}
return args; // return modified operation arguments as necessary
};
```
### beforeValidate
@@ -88,7 +91,7 @@ Please do note that this does not run before the client-side validation. If you
3. `validate` runs on the server
```ts
import { CollectionBeforeOperationHook } from 'payload/types';
import { CollectionBeforeOperationHook } from "payload/types";
const beforeValidateHook: CollectionBeforeValidateHook = async ({
data, // incoming data to update or create with
@@ -97,7 +100,7 @@ const beforeValidateHook: CollectionBeforeValidateHook = async ({
originalDoc, // original document
}) => {
return data; // Return data to either create or update a document with
}
};
```
### beforeChange
@@ -105,7 +108,7 @@ const beforeValidateHook: CollectionBeforeValidateHook = async ({
Immediately following validation, `beforeChange` hooks will run within `create` and `update` operations. At this stage, you can be confident that the data that will be saved to the document is valid in accordance to your field validations. You can optionally modify the shape of data to be saved.
```ts
import { CollectionBeforeChangeHook } from 'payload/types';
import { CollectionBeforeChangeHook } from "payload/types";
const beforeChangeHook: CollectionBeforeChangeHook = async ({
data, // incoming data to update or create with
@@ -114,7 +117,7 @@ const beforeChangeHook: CollectionBeforeChangeHook = async ({
originalDoc, // original document
}) => {
return data; // Return data to either create or update a document with
}
};
```
### afterChange
@@ -122,7 +125,7 @@ const beforeChangeHook: CollectionBeforeChangeHook = async ({
After a document is created or updated, the `afterChange` hook runs. This hook is helpful to recalculate statistics such as total sales within a global, syncing user profile changes to a CRM, and more.
```ts
import { CollectionAfterChangeHook } from 'payload/types';
import { CollectionAfterChangeHook } from "payload/types";
const afterChangeHook: CollectionAfterChangeHook = async ({
doc, // full document data
@@ -130,8 +133,8 @@ const afterChangeHook: CollectionAfterChangeHook = async ({
previousDoc, // document data before updating the collection
operation, // name of the operation ie. 'create', 'update'
}) => {
return doc;
}
return doc; // value to be used in subsequent afterChange hooks
};
```
### beforeRead
@@ -139,7 +142,7 @@ const afterChangeHook: CollectionAfterChangeHook = async ({
Runs before `find` and `findByID` operations are transformed for output by `afterRead`. This hook fires before hidden fields are removed and before localized fields are flattened into the requested locale. Using this Hook will provide you with all locales and all hidden fields via the `doc` argument.
```ts
import { CollectionBeforeReadHook } from 'payload/types';
import { CollectionBeforeReadHook } from "payload/types";
const beforeReadHook: CollectionBeforeReadHook = async ({
doc, // full document data
@@ -147,7 +150,7 @@ const beforeReadHook: CollectionBeforeReadHook = async ({
query, // JSON formatted query
}) => {
return doc;
}
};
```
### afterRead
@@ -155,7 +158,7 @@ const beforeReadHook: CollectionBeforeReadHook = async ({
Runs as the last step before documents are returned. Flattens locales, hides protected fields, and removes fields that users do not have access to.
```ts
import { CollectionAfterReadHook } from 'payload/types';
import { CollectionAfterReadHook } from "payload/types";
const afterReadHook: CollectionAfterReadHook = async ({
doc, // full document data
@@ -164,7 +167,7 @@ const afterReadHook: CollectionAfterReadHook = async ({
findMany, // boolean to denote if this hook is running against finding one, or finding many
}) => {
return doc;
}
};
```
### beforeDelete
@@ -194,19 +197,37 @@ const afterDeleteHook: CollectionAfterDeleteHook = async ({
}) => {...}
```
### afterOperation
The `afterOperation` hook can be used to modify the result of operations or execute side-effects that run after an operation has completed.
Available Collection operations include `create`, `find`, `findByID`, `update`, `updateByID`, `delete`, `deleteByID`, `login`, `refresh`, and `forgotPassword`.
```ts
import { CollectionAfterOperationHook } from "payload/types";
const afterOperationHook: CollectionAfterOperationHook = async ({
args, // arguments passed into the operation
operation, // name of the operation
result, // the result of the operation, before modifications
}) => {
return result; // return modified result as necessary
};
```
### beforeLogin
For auth-enabled Collections, this hook runs during `login` operations where a user with the provided credentials exist, but before a token is generated and added to the response. You can optionally modify the user that is returned, or throw an error in order to deny the login operation.
```ts
import { CollectionBeforeLoginHook } from 'payload/types';
import { CollectionBeforeLoginHook } from "payload/types";
const beforeLoginHook: CollectionBeforeLoginHook = async ({
req, // full express request
user, // user being logged in
}) => {
return user;
}
};
```
### afterLogin
@@ -267,7 +288,7 @@ const afterMeHook: CollectionAfterMeHook = async ({
For auth-enabled Collections, this hook runs after successful `forgotPassword` operations. Returned values are discarded.
```ts
import { CollectionAfterForgotPasswordHook } from 'payload/types';
import { CollectionAfterForgotPasswordHook } from "payload/types";
const afterLoginHook: CollectionAfterForgotPasswordHook = async ({
req, // full express request
@@ -275,7 +296,7 @@ const afterLoginHook: CollectionAfterForgotPasswordHook = async ({
token, // user token
}) => {
return user;
}
};
```
## TypeScript
@@ -298,5 +319,5 @@ import type {
CollectionAfterRefreshHook,
CollectionAfterMeHook,
CollectionAfterForgotPasswordHook,
} from 'payload/types';
} from "payload/types";
```

127
docs/hooks/context.mdx Normal file
View File

@@ -0,0 +1,127 @@
---
title: Context
label: Context
order: 50
desc: Context allows you to pass in extra data that can be shared between hooks
keywords: hooks, context, payload context, payloadcontext, data, extra data, shared data, shared, extra
---
The `context` object in hooks is used to share data across different hooks. The persists throughout the entire lifecycle of a request and is available within every hook. This allows you to add logic to your hooks based on the request state by setting properties to `req.context` and using them elsewhere.
## When to use Context
Context gives you a way forward on otherwise difficult problems such as:
1. **Passing data between hooks**: Needing data in multiple hooks from a 3rd party API, it could be retrieved and used in `beforeChange` and later used again in an `afterChange` hook without having to fetch it twice.
2. **Preventing infinite loops**: Calling `payload.update()` on the same document that triggered an `afterChange` hook will create an infinite loop, control the flow by assigning a no-op condition to context
3. **Passing data to local API**: Setting values on the `req.context` and pass it to `payload.create()` you can provide additional data to hooks without adding extraneous fields.
4. **Passing data between hooks and middleware or custom endpoints**: Hooks could set context across multiple collections and then be used in a final `postMiddleware`.
## How to Use Context
Let's see examples on how context can be used in the first two scenarios mentioned above:
### Passing data between hooks
To pass data between hooks, you can assign values to context in an earlier hook in the lifecycle of a request and expect it the context in a later hook.
For example:
```ts
const Customer: CollectionConfig = {
slug: 'customers',
hooks: {
beforeChange: [async ({ context, data }) => {
// assign the customerData to context for use later
context.customerData = await fetchCustomerData(data.customerID);
return {
...data,
// some data we use here
name: context.customerData.name
};
}],
afterChange: [async ({ context, doc, req }) => {
// use context.customerData without needing to fetch it again
if (context.customerData.contacted === false) {
createTodo('Call Customer', context.customerData)
}
}],
},
fields: [ /* ... */ ],
};
```
### Preventing infinite loops
Let's say you have an `afterChange` hook, and you want to do a calculation inside the hook (as the document ID needed for the calculation is available in the `afterChange` hook, but not in the `beforeChange` hook). Once that's done, you want to update the document with the result of the calculation.
Bad example:
```ts
const Customer: CollectionConfig = {
slug: 'customers',
hooks: {
afterChange: [async ({ doc }) => {
await payload.update({
// DANGER: updating the same slug as the collection in an afterChange will create an infinite loop!
collection: 'customers',
id: doc.id,
data: {
...(await fetchCustomerData(data.customerID))
},
});
}],
},
fields: [ /* ... */ ],
};
```
Instead of the above, we need to tell the `afterChange` hook to not run again if it performs the update (and thus not update itself again). We can solve that with context.
Fixed example:
```ts
const MyCollection: CollectionConfig = {
slug: 'slug',
hooks: {
afterChange: [async ({ context, doc }) => {
// return if flag was previously set
if (context.triggerAfterChange === false) {
return;
}
await payload.update({
collection: contextHooksSlug,
id: doc.id,
data: {
...(await fetchCustomerData(data.customerID))
},
context: {
// set a flag to prevent from running again
triggerAfterChange: false,
},
});
}],
},
fields: [ /* ... */ ],
};
```
## Typing context
The default typescript interface for `context` is `{ [key: string]: unknown }`. If you prefer a more strict typing in your project or when authoring plugins for others, you can override this using the `declare` syntax.
This is known as "type augmentation" - a TypeScript feature which allows us to add types to existing objects. Simply put this in any .ts or .d.ts file:
```ts
import { RequestContext as OriginalRequestContext } from 'payload';
declare module 'payload' {
// Create a new interface that merges your additional fields with the original one
export interface RequestContext extends OriginalRequestContext {
myObject?: string;
// ...
}
}
```
This will add a the property `myObject` with a type of string to every context object. Make sure to follow this example correctly, as type augmentation can mess up your types if you do it wrong.

View File

@@ -0,0 +1,104 @@
---
title: Vercel Visual Editing
label: Vercel Visual Editing
order: 10
desc: Payload + Vercel Visual Editing allows yours editors to navigate directly from the content rendered on your front-end to the fields in Payload that control it.
keywords: vercel, vercel visual editing, visual editing, content source maps, Content Management System, cms, headless, javascript, node, react, express
---
[Vercel Visual Editing](https://vercel.com/docs/workflow-collaboration/visual-editing) will allow your editors to navigate directly from the content rendered on your front-end to the fields in Payload that control it. This requires no changes to your front-end code and very few changes to your Payload config.
![Versions](/images/docs/vercel-visual-editing.jpg)
<Banner type="warning">
Vercel Visual Editing is an enterprise-only feature and only available for
deployments hosted on Vercel. If you are an existing enterprise customer,
[contact our sales team](https://payloadcms.com/for-enterprise) for help with
your integration.
</Banner>
### How it works
To power Vercel Visual Editing, Payload embeds Content Source Maps into its API responses. Content Source Maps are invisible, encoded JSON values that include a link back to the field in the CMS that generated the content. When rendered on the page, Vercel detects and decodes these values to display the Visual Editing interface.
For full details on how the encoding and decoding algorithm works, check out [`@vercel/stega`](https://www.npmjs.com/package/@vercel/stega).
### Getting Started
Setting up Payload with Vercel Visual Editing is easy. First, install the `@payloadcms/plugin-csm` plugin into your project. This plugin requires an API key to install, [contact our sales team](https://payloadcms.com/for-enterprise) if you don't already have one.
```bash
npm i @payloadcms/plugin-csm
```
Then in the `plugins` array of your Payload config, call the plugin and enable any collections that require Content Source Maps.
```ts
import { buildConfig } from "payload/config"
import contentSourceMaps from "@payloadcms/plugin-csm"
const config = buildConfig({
collections: [
{
slug: "pages",
fields: [
{
name: 'slug',
type: 'text',
},
{
name: 'title,'
type: 'text',
},
],
},
],
plugins: [
contentSourceMaps({
collections: ["pages"],
}),
],
})
export default config
```
Now in your Next.js app, include the `?encodeSourceMaps=true` parameter in any of your API requests. For performance reasons, this should only be done when in draft mode or on preview deployments.
```ts
if (isDraftMode || process.env.VERCEL_ENV === "preview") {
const res = await fetch(
`${process.env.NEXT_PUBLIC_PAYLOAD_CMS_URL}/api/pages?where[slug][equals]=${slug}&encodeSourceMaps=true`
);
}
```
And that's it! You are now ready to enter Edit Mode and begin visually editing your content.
##### Edit Mode
To see Visual Editing on your site, you first need to visit any preview deployment on Vercel and login using the Vercel Toolbar. When Content Source Maps are detected on the page, a pencil icon will appear in the toolbar. Clicking this icon will enable Edit Mode, highlighting all editable fields on the page in blue.
![Versions](/images/docs/vercel-toolbar.jpg)
### Troubleshooting
##### Dates
The plugin does not encode `date` fields by default, but for some cases like text that uses negative CSS letter-spacing, it may be necessary to split the encoded data out from the rendered text. This way you can safely use the cleaned data as expected.
```ts
import { vercelStegaSplit } from "@vercel/stega";
const { cleaned, encoded } = vercelStegaSplit(text);
```
##### Blocks
All `blocks` fields by definition do not have plain text strings to encode. For this reason, blocks are given an additional `encodedSourceMap` key, which you can use to enable Visual Editing on entire sections of your site. You can then specify the editing container by adding the `data-vercel-edit-target` HTML attribute to any top-level element of your block.
```ts
<div data-vercel-edit-target>
<span style={{ display: "none" }}>{encodedSourceMap}</span>
{children}
</div>
```

View File

@@ -77,6 +77,7 @@ You can specify more options within the Local API vs. REST or GraphQL due to the
| `user` | If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks. |
| `showHiddenFields` | Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config. |
| `pagination` | Set to false to return all documents and avoid querying for document counts. |
| `context` | [Context](/docs/hooks/context), which will then be passed to `context` and `req.context`, which can be read by hooks. Useful if you want to pass additional information to the hooks which shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook to determine if it should run or not. |
_There are more options available on an operation by operation basis outlined below._

View File

@@ -43,6 +43,7 @@ Because _**you**_ are in complete control of who can do what with your data, you
Before running in Production, you need to have built a production-ready copy of the Payload Admin panel. To do this, Payload provides the `build` NPM script. You can use it by adding a `script` to your `package.json` file like this:
`package.json`:
```json
{
"name": "project-name-here",
@@ -51,7 +52,8 @@ Before running in Production, you need to have built a production-ready copy of
},
"dependencies": {
// your dependencies
},
}
}
```
Then, to build Payload, you would run `npm run build` in your project folder. A production-ready Admin bundle will be created in the `build` directory.
@@ -81,16 +83,16 @@ If you are using a [persistent filesystem-based cloud host](#persistent-vs-ephem
Alternatively, you can rely on a third-party MongoDB host such as [MongoDB Atlas](https://www.mongodb.com/). With Atlas or a similar cloud provider, you can trust them to take care of your database's availability, security, redundancy, and backups.
<Banner type="warning">
<strong>Note:</strong>
<br />
If versions are enabled and a collection has many documents you may need a minimum of an m10 mongoDB atlas cluster if you reach a sorting `exceeded memory limit` error to view a collection list in the admin UI. The limitations of the m2 and m5 tier clusters are here:
<a href="https://www.mongodb.com/docs/atlas/reference/free-shared-limitations/?_ga=2.176267877.1329169847.1677683154-860992573.1647438381#operational-limitations">Atlas M0 (Free Cluster), M2, and M5 Limitations</a>
<strong>Note:</strong><br />
If versions are enabled and a collection has many documents you may need a minimum of an m10 mongoDB atlas cluster if you reach a sorting `exceeded memory limit` error to view a collection list in the admin UI. The limitations of the m2 and m5 tier clusters are here: [Atlas M0 (Free Cluster), M2, and M5 Limitations](https://www.mongodb.com/docs/atlas/reference/free-shared-limitations/?_ga=2.176267877.1329169847.1677683154-860992573.1647438381#operational-limitations).
</Banner>
##### DocumentDB
When using AWS DocumentDB, you will need to configure connection options for authentication in the `mongoOptions` passed to `payload.init`. You also need to set `mongoOptions.useFacet` to `false` to disable use of the unsupported `$facet` aggregation.
##### CosmosDB
When using Azure Cosmos DB, an index is needed for any field you may want to sort on. To add the sort index for all fields that may be sorted in the admin UI use the <a href="/docs/configuration/overview">indexSortableFields</a> configuration option.
## File storage
@@ -116,7 +118,7 @@ Alternatively, persistent filesystems will never delete your files and can be tr
- Many other more traditional web hosts
<Banner type="error">
<strong>Warning:</strong><br/>
<strong>Warning:</strong><br />
If you rely on Payload's <strong>Upload</strong> functionality, make sure you either use a host with a persistent filesystem or have an integration with a third-party file host like Amazon S3.
</Banner>
@@ -124,7 +126,7 @@ Alternatively, persistent filesystems will never delete your files and can be tr
If you don't use Payload's `upload` functionality, you can go ahead and use Heroku or similar platform easily. Everything will work exactly as you want it to.
But, if you do, and you still want to use an ephemeral filesystem provider, you can write a hook-based solution to *copy* the files your users upload to a more permanent storage solution like Amazon S3 or DigitalOcean Spaces.
But, if you do, and you still want to use an ephemeral filesystem provider, you can write a hook-based solution to _copy_ the files your users upload to a more permanent storage solution like Amazon S3 or DigitalOcean Spaces.
**To automatically send uploaded files to S3 or similar, you could:**
@@ -182,10 +184,9 @@ CMD ["node", "dist/server.js"]
Here is an example of a docker-compose.yml file that can be used for development
```yml
version: '3'
version: "3"
services:
payload:
image: node:18-alpine
ports:

View File

@@ -9,7 +9,7 @@ keywords: query, documents, overview, documentation, Content Management System,
Payload provides an extremely granular querying language through all APIs. Each API takes the same syntax and fully supports all options.
<Banner>
<strong>Here, "querying" relates to filtering or searching through documents within a Collection.</strong> You can build queries to pass to Find operations as well as to <a href="/docs/access-control/overview">restrict which documents certain users can access</a> via access control functions.
<strong>Here, "querying" relates to filtering or searching through documents within a Collection.</strong> You can build queries to pass to Find operations as well as to [restrict which documents certain users can access](/docs/access-control/overview) via access control functions.
</Banner>
### Simple queries
@@ -67,7 +67,7 @@ The above example demonstrates a simple query but you can get much more complex.
| `near` | For distance related to a [point field](/docs/fields/point) comma separated as `<longitude>, <latitude>, <maxDistance in meters (nullable)>, <minDistance in meters (nullable)>`. |
<Banner type="success">
<strong>Tip</strong>:<br/>
<strong>Tip</strong>:<br />
If you know your users will be querying on certain fields a lot, you can add <strong>index: true</strong> to a field's config which will speed up searches using that field immensely.
</Banner>
@@ -194,7 +194,7 @@ const getPosts = async () => {
## Sort
Payload `find` queries support a `sort` parameter through all APIs. Pass the `name` of a top-level field to sort by that field in ascending order. Prefix the name of the field with a minus symbol ("-") to sort in descending order.
Payload `find` queries support a `sort` parameter through all APIs. Pass the `name` of a top-level field to sort by that field in ascending order. Prefix the name of the field with a minus symbol ("-") to sort in descending order. Because sorting is handled by the database, the field you wish to sort on must be stored in the database to work; not a [virtual field](https://payloadcms.com/blog/learn-how-virtual-fields-can-help-solve-common-cms-challenges). It is recommended to enable indexing for the fields where sorting is used.
**REST example:**
**`https://localhost:3000/api/posts?sort=-createdAt`**

View File

@@ -99,6 +99,7 @@ Note: Collection slugs must be formatted in kebab-case
example: {
slug: "createDocument",
req: {
credentials: true,
headers: true,
body: {
title: "New page",
@@ -126,6 +127,7 @@ Note: Collection slugs must be formatted in kebab-case
example: {
slug: "updateDocument",
req: {
credentials: true,
query: true,
headers: true,
body: {
@@ -155,6 +157,7 @@ Note: Collection slugs must be formatted in kebab-case
example: {
slug: "updateDocumentByID",
req: {
credentials: true,
headers: true,
body: {
title: "I have been updated by ID!",
@@ -199,6 +202,7 @@ Note: Collection slugs must be formatted in kebab-case
example: {
slug: "deleteDocuments",
req: {
credentials: true,
query: true,
headers: true,
},
@@ -225,6 +229,7 @@ Note: Collection slugs must be formatted in kebab-case
example: {
slug: "deleteByID",
req: {
credentials: true,
headers: true,
},
res: {
@@ -255,6 +260,7 @@ Auth enabled collections are also given the following endpoints:
example: {
slug: "login",
req: {
credentials: true,
headers: true,
body: {
email: "dev@payloadcms.com",
@@ -284,6 +290,7 @@ Auth enabled collections are also given the following endpoints:
slug: "logout",
req: {
headers: true,
credentials: true,
},
res: {
message: "You have been logged out successfully.",
@@ -298,6 +305,7 @@ Auth enabled collections are also given the following endpoints:
example: {
slug: "unlockCollection",
req: {
credentials: true,
headers: true,
body: {
email: "dev@payloadcms.com",
@@ -316,6 +324,7 @@ Auth enabled collections are also given the following endpoints:
example: {
slug: "refreshToken",
req: {
credentials: true,
headers: true,
},
res: {
@@ -338,7 +347,7 @@ Auth enabled collections are also given the following endpoints:
example: {
slug: "verifyUser",
req: {
prop: "token: string, user-collection: string",
credentials: true,
headers: true,
},
res: {
@@ -354,6 +363,7 @@ Auth enabled collections are also given the following endpoints:
example: {
slug: "currentUser",
req: {
credentials: true,
headers: true,
},
res: {
@@ -380,6 +390,7 @@ Auth enabled collections are also given the following endpoints:
slug: "forgotPassword",
req: {
headers: true,
credentials: true,
body: {
email: "dev@payloadcms.com",
},
@@ -397,6 +408,7 @@ Auth enabled collections are also given the following endpoints:
example: {
slug: "resetPassword",
req: {
credentials: true,
headers: true,
body: {
token: "7eac3830ffcfc7f9f66c00315dabeb11575dba91",
@@ -434,6 +446,7 @@ Globals cannot be created or deleted, so there are only two REST endpoints opene
example: {
slug: "getGlobal",
req: {
credentials: true,
headers: true,
},
res: {
@@ -454,6 +467,7 @@ Globals cannot be created or deleted, so there are only two REST endpoints opene
slug: "updateGlobal",
req: {
headers: true,
credentials: true,
body: {
announcement: "Paging Doctor Scrunt",
},
@@ -485,6 +499,7 @@ In addition to the dynamically generated endpoints above Payload also has REST e
slug: "getPreference",
req: {
headers: true,
credentials: true,
},
res: {
_id: "644bb7a8307b3d363c6edf2c",
@@ -507,6 +522,7 @@ In addition to the dynamically generated endpoints above Payload also has REST e
slug: "createPreference",
req: {
headers: true,
credentials: true,
body: {
value: "Europe/London",
},

View File

@@ -190,9 +190,7 @@ export const Media: CollectionConfig = {
<Banner>
<strong>Note:</strong>
<br />
If you specify a function to return an admin thumbnail, but your upload is not
an image file type (for example, PDF or TXT) your function will not be used.
Instead, Payload will display its generic file upload graphic.
This function runs in the browser. If your function returns `null` or `false` Payload will show the default generic file thumbnail instead.
</Banner>
### MimeTypes

View File

@@ -1,7 +0,0 @@
PAYLOAD_PUBLIC_SITE_URL=http://localhost:3000
PAYLOAD_PUBLIC_SERVER_URL=http://localhost:8000
MONGODB_URI=mongodb://localhost/payload-example-auth
PAYLOAD_SECRET=PAYLOAD_AUTH_EXAMPLE_SECRET_KEY
COOKIE_DOMAIN=localhost

View File

@@ -1 +0,0 @@
legacy-peer-deps=true

View File

@@ -1,27 +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 {
collections: {
users: User
}
globals: {}
}
export interface User {
id: string
firstName?: string
lastName?: string
roles?: Array<'admin' | 'user'>
email?: string
resetPasswordToken?: string
resetPasswordExpiration?: string
loginAttempts?: number
lockUntil?: string
createdAt: string
updatedAt: string
password?: string
}

View File

@@ -1,13 +0,0 @@
import path from 'path'
import { buildConfig } from 'payload/config'
import { Users } from './collections/Users'
export default buildConfig({
collections: [Users],
cors: [process.env.PAYLOAD_PUBLIC_SERVER_URL, process.env.PAYLOAD_PUBLIC_SITE_URL],
csrf: [process.env.PAYLOAD_PUBLIC_SERVER_URL, process.env.PAYLOAD_PUBLIC_SITE_URL],
typescript: {
outputFile: path.resolve(__dirname, 'payload-types.ts'),
},
})

View File

@@ -0,0 +1 @@
NEXT_PUBLIC_CMS_URL=http://localhost:3000

View File

@@ -0,0 +1,7 @@
module.exports = {
root: true,
extends: ['plugin:@next/next/recommended', '@payloadcms'],
rules: {
'import/extensions': 'off',
},
}

View File

@@ -0,0 +1,41 @@
# Payload Auth Example Front-End
This is a [Payload](https://payloadcms.com) + [Next.js](https://nextjs.org) app using the [App Router](https://nextjs.org/docs/app) made explicitly for the [Payload Auth Example](https://github.com/payloadcms/payload/tree/master/examples/auth). It demonstrates how to authenticate your Next.js app using [Payload Authentication](https://payloadcms.com/docs/authentication/overview).
> This example uses the App Router, the latest API of Next.js. If your app is using the legacy [Pages Router](https://nextjs.org/docs/pages), check out the official [Pages Router Example](https://github.com/payloadcms/payload/tree/master/examples/auth/next-pages).
## Getting Started
### Payload
First you'll need a running Payload app. There is one made explicitly for this example and [can be found here](https://github.com/payloadcms/payload/tree/master/examples/auth/payload). If you have not done so already, clone it down and follow the setup instructions there. This will provide all the necessary APIs that your Next.js app requires for authentication.
### Next.js
1. Clone this repo
2. `cd` into this directory and run `yarn` or `npm install`
3. `cp .env.example .env` to copy the example environment variables
4. `yarn dev` or `npm run dev` to start the server
5. `open http://localhost:3001` to see the result
Once running, a user is automatically seeded in your local environment with some basic instructions. See the [Payload Auth Example](https://github.com/payloadcms/payload/tree/master/examples/auth) for full details.
## Learn More
To learn more about Payload and Next.js, take a look at the following resources:
- [Payload Documentation](https://payloadcms.com/docs) - learn about Payload features and API.
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
You can check out [the Payload GitHub repository](https://github.com/payloadcms/payload) as well as [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
## Deployment
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new) from the creators of Next.js. You could also combine this app into a [single Express server](https://github.com/payloadcms/payload/tree/master/examples/custom-server) and deploy in to [Payload Cloud](https://payloadcms.com/new/import).
Check out our [Payload deployment documentation](https://payloadcms.com/docs/production/deployment) or the [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
## Questions
If you have any issues or questions, reach out to us on [Discord](https://discord.com/invite/payload) or start a [GitHub discussion](https://github.com/payloadcms/payload/discussions).

View File

@@ -0,0 +1,40 @@
@import '../../_css/type.scss';
.button {
border: none;
cursor: pointer;
display: inline-flex;
justify-content: center;
background-color: transparent;
text-decoration: none;
display: inline-flex;
padding: 12px 24px;
}
.content {
display: flex;
align-items: center;
justify-content: space-around;
}
.label {
@extend %label;
text-align: center;
display: flex;
align-items: center;
}
.appearance--primary {
background-color: var(--theme-elevation-1000);
color: var(--theme-elevation-0);
}
.appearance--secondary {
background-color: transparent;
box-shadow: inset 0 0 0 1px var(--theme-elevation-1000);
}
.appearance--default {
padding: 0;
color: var(--theme-text);
}

View File

@@ -0,0 +1,75 @@
'use client'
import React, { ElementType } from 'react'
import Link from 'next/link'
import classes from './index.module.scss'
export type Props = {
label?: string
appearance?: 'default' | 'primary' | 'secondary'
el?: 'button' | 'link' | 'a'
onClick?: () => void
href?: string
newTab?: boolean
className?: string
type?: 'submit' | 'button'
disabled?: boolean
invert?: boolean
}
export const Button: React.FC<Props> = ({
el: elFromProps = 'link',
label,
newTab,
href,
appearance,
className: classNameFromProps,
onClick,
type = 'button',
disabled,
invert,
}) => {
let el = elFromProps
const newTabProps = newTab ? { target: '_blank', rel: 'noopener noreferrer' } : {}
const className = [
classes.button,
classNameFromProps,
classes[`appearance--${appearance}`],
invert && classes[`${appearance}--invert`],
]
.filter(Boolean)
.join(' ')
const content = (
<div className={classes.content}>
<span className={classes.label}>{label}</span>
</div>
)
if (onClick || type === 'submit') el = 'button'
if (el === 'link') {
return (
<Link href={href || ''} className={className} {...newTabProps} onClick={onClick}>
{content}
</Link>
)
}
const Element: ElementType = el
return (
<Element
href={href}
className={className}
type={type}
{...newTabProps}
onClick={onClick}
disabled={disabled}
>
{content}
</Element>
)
}

View File

@@ -0,0 +1,13 @@
.gutter {
max-width: 1920px;
margin-left: auto;
margin-right: auto;
}
.gutterLeft {
padding-left: var(--gutter-h);
}
.gutterRight {
padding-right: var(--gutter-h);
}

View File

@@ -16,7 +16,12 @@ export const Gutter: React.FC<Props> = forwardRef<HTMLDivElement, Props>((props,
return (
<div
ref={ref}
className={[left && classes.gutterLeft, right && classes.gutterRight, className]
className={[
classes.gutter,
left && classes.gutterLeft,
right && classes.gutterRight,
className,
]
.filter(Boolean)
.join(' ')}
>

View File

@@ -0,0 +1,20 @@
@use '../../../_css/queries.scss' as *;
.nav {
display: flex;
gap: calc(var(--base) / 4) var(--base);
align-items: center;
flex-wrap: wrap;
opacity: 1;
transition: opacity 100ms linear;
visibility: visible;
> * {
text-decoration: none;
}
}
.hide {
opacity: 0;
visibility: hidden;
}

View File

@@ -0,0 +1,38 @@
'use client'
import React from 'react'
import Link from 'next/link'
import { useAuth } from '../../../_providers/Auth'
import classes from './index.module.scss'
export const HeaderNav: React.FC = () => {
const { user } = useAuth()
return (
<nav
className={[
classes.nav,
// fade the nav in on user load to avoid flash of content and layout shift
// Vercel also does this in their own website header, see https://vercel.com
user === undefined && classes.hide,
]
.filter(Boolean)
.join(' ')}
>
{user && (
<React.Fragment>
<Link href="/account">Account</Link>
<Link href="/logout">Logout</Link>
</React.Fragment>
)}
{!user && (
<React.Fragment>
<Link href="/login">Login</Link>
<Link href="/create-account">Create Account</Link>
</React.Fragment>
)}
</nav>
)
}

View File

@@ -0,0 +1,22 @@
@use '../../_css/queries.scss' as *;
.header {
padding: var(--base) 0;
}
.wrap {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
gap: calc(var(--base) / 2) var(--base);
}
.logo {
width: 150px;
}
:global([data-theme="light"]) {
.logo {
filter: invert(1);
}
}

View File

@@ -0,0 +1,34 @@
import React from 'react'
import Image from 'next/image'
import Link from 'next/link'
import { Gutter } from '../Gutter'
import { HeaderNav } from './Nav'
import classes from './index.module.scss'
export function Header() {
return (
<header className={classes.header}>
<Gutter className={classes.wrap}>
<Link href="/" className={classes.logo}>
<picture>
<source
srcSet="https://raw.githubusercontent.com/payloadcms/payload/master/src/admin/assets/images/payload-logo-light.svg"
media="(prefers-color-scheme: dark)"
/>
<Image
width={150}
height={30}
alt="Payload Logo"
src="https://raw.githubusercontent.com/payloadcms/payload/master/src/admin/assets/images/payload-logo-dark.svg"
/>
</picture>
</Link>
<HeaderNav />
</Gutter>
</header>
)
}
export default Header

View File

@@ -0,0 +1,56 @@
@import '../../_css/common';
.inputWrap {
width: 100%;
}
.input {
width: 100%;
font-family: system-ui;
border-radius: 0;
box-shadow: none;
border: none;
background: none;
background-color: var(--theme-elevation-100);
color: var(--theme-elevation-1000);
height: calc(var(--base) * 2);
line-height: calc(var(--base) * 2);
padding: 0 calc(var(--base) / 2);
&:focus {
border: none;
outline: none;
}
&:-webkit-autofill,
&:-webkit-autofill:hover,
&:-webkit-autofill:focus {
-webkit-text-fill-color: var(--theme-text);
-webkit-box-shadow: 0 0 0px 1000px var(--theme-elevation-150) inset;
transition: background-color 5000s ease-in-out 0s;
}
}
@media (prefers-color-scheme: dark) {
.input {
background-color: var(--theme-elevation-150);
}
}
.error {
background-color: var(--theme-error-150);
}
.label {
margin-bottom: 0;
display: block;
line-height: 1;
margin-bottom: calc(var(--base) / 2);
}
.errorMessage {
font-size: small;
line-height: 1.25;
margin-top: 4px;
color: red;
}

View File

@@ -0,0 +1,55 @@
import React from 'react'
import { FieldValues, UseFormRegister, Validate } from 'react-hook-form'
import classes from './index.module.scss'
type Props = {
name: string
label: string
register: UseFormRegister<FieldValues & any>
required?: boolean
error: any
type?: 'text' | 'number' | 'password' | 'email'
validate?: (value: string) => boolean | string
}
export const Input: React.FC<Props> = ({
name,
label,
required,
register,
error,
type = 'text',
validate,
}) => {
return (
<div className={classes.inputWrap}>
<label htmlFor="name" className={classes.label}>
{`${label} ${required ? '*' : ''}`}
</label>
<input
className={[classes.input, error && classes.error].filter(Boolean).join(' ')}
{...{ type }}
{...register(name, {
required,
validate,
...(type === 'email'
? {
pattern: {
value: /\S+@\S+\.\S+/,
message: 'Please enter a valid email',
},
}
: {}),
})}
/>
{error && (
<div className={classes.errorMessage}>
{!error?.message && error?.type === 'required'
? 'This field is required'
: error?.message}
</div>
)}
</div>
)
}

View File

@@ -0,0 +1,46 @@
@import '../../_css/common';
.message {
padding: calc(var(--base) / 2) calc(var(--base) / 2);
line-height: 1.25;
width: 100%;
}
.default {
background-color: var(--theme-elevation-100);
color: var(--theme-elevation-1000);
}
.warning {
background-color: var(--theme-warning-500);
color: var(--theme-warning-900);
}
.error {
background-color: var(--theme-error-500);
color: var(--theme-error-900);
}
.success {
background-color: var(--theme-success-500);
color: var(--theme-success-900);
}
@media (prefers-color-scheme: dark) {
.default {
background-color: var(--theme-elevation-900);
color: var(--theme-elevation-100);
}
.warning {
color: var(--theme-warning-100);
}
.error {
color: var(--theme-error-100);
}
.success {
color: var(--theme-success-100);
}
}

View File

@@ -0,0 +1,33 @@
import React from 'react'
import classes from './index.module.scss'
export const Message: React.FC<{
message?: React.ReactNode
error?: React.ReactNode
success?: React.ReactNode
warning?: React.ReactNode
className?: string
}> = ({ message, error, success, warning, className }) => {
const messageToRender = message || error || success || warning
if (messageToRender) {
return (
<div
className={[
classes.message,
className,
error && classes.error,
success && classes.success,
warning && classes.warning,
!error && !success && !warning && classes.default,
]
.filter(Boolean)
.join(' ')}
>
{messageToRender}
</div>
)
}
return null
}

View File

@@ -0,0 +1,29 @@
'use client'
import { useSearchParams } from 'next/navigation'
import { Message } from '../Message'
export const RenderParams: React.FC<{
params?: string[]
message?: string
className?: string
}> = ({ params = ['error', 'message', 'success'], message, className }) => {
const searchParams = useSearchParams()
const paramValues = params.map(param => searchParams.get(param)).filter(Boolean)
if (paramValues.length) {
return (
<div className={className}>
{paramValues.map(paramValue => (
<Message
key={paramValue}
message={(message || 'PARAM')?.replace('PARAM', paramValue || '')}
/>
))}
</div>
)
}
return null
}

View File

@@ -0,0 +1,9 @@
.richText {
:first-child {
margin-top: 0;
}
a {
text-decoration: underline;
}
}

View File

@@ -0,0 +1,92 @@
import React, { Fragment } from 'react'
import escapeHTML from 'escape-html'
import { Text } from 'slate'
// eslint-disable-next-line no-use-before-define
type Children = Leaf[]
type Leaf = {
type: string
value?: {
url: string
alt: string
}
children: Children
url?: string
[key: string]: unknown
}
const serialize = (children: Children): React.ReactNode[] =>
children.map((node, i) => {
if (Text.isText(node)) {
let text = <span dangerouslySetInnerHTML={{ __html: escapeHTML(node.text) }} />
if (node.bold) {
text = <strong key={i}>{text}</strong>
}
if (node.code) {
text = <code key={i}>{text}</code>
}
if (node.italic) {
text = <em key={i}>{text}</em>
}
if (node.underline) {
text = (
<span style={{ textDecoration: 'underline' }} key={i}>
{text}
</span>
)
}
if (node.strikethrough) {
text = (
<span style={{ textDecoration: 'line-through' }} key={i}>
{text}
</span>
)
}
return <Fragment key={i}>{text}</Fragment>
}
if (!node) {
return null
}
switch (node.type) {
case 'h1':
return <h1 key={i}>{serialize(node.children)}</h1>
case 'h2':
return <h2 key={i}>{serialize(node.children)}</h2>
case 'h3':
return <h3 key={i}>{serialize(node.children)}</h3>
case 'h4':
return <h4 key={i}>{serialize(node.children)}</h4>
case 'h5':
return <h5 key={i}>{serialize(node.children)}</h5>
case 'h6':
return <h6 key={i}>{serialize(node.children)}</h6>
case 'blockquote':
return <blockquote key={i}>{serialize(node.children)}</blockquote>
case 'ul':
return <ul key={i}>{serialize(node.children)}</ul>
case 'ol':
return <ol key={i}>{serialize(node.children)}</ol>
case 'li':
return <li key={i}>{serialize(node.children)}</li>
case 'link':
return (
<a href={escapeHTML(node.url)} key={i}>
{serialize(node.children)}
</a>
)
default:
return <p key={i}>{serialize(node.children)}</p>
}
})
export default serialize

View File

@@ -0,0 +1,117 @@
@use './queries.scss' as *;
@use './colors.scss' as *;
@use './type.scss' as *;
@import "./theme.scss";
:root {
--base: 24px;
--font-body: system-ui;
--font-mono: 'Roboto Mono', monospace;
--gutter-h: 180px;
--block-padding: 120px;
@include large-break {
--gutter-h: 144px;
--block-padding: 96px;
}
@include mid-break {
--gutter-h: 24px;
--block-padding: 60px;
}
}
* {
box-sizing: border-box;
}
html {
@extend %body;
background: var(--theme-bg);
-webkit-font-smoothing: antialiased;
}
html,
body,
#app {
height: 100%;
}
body {
font-family: var(--font-body);
margin: 0;
color: var(--theme-text);
}
::selection {
background: var(--theme-success-500);
color: var(--color-base-800);
}
::-moz-selection {
background: var(--theme-success-500);
color: var(--color-base-800);
}
img {
max-width: 100%;
height: auto;
display: block;
}
h1 {
@extend %h1;
}
h2 {
@extend %h2;
}
h3 {
@extend %h3;
}
h4 {
@extend %h4;
}
h5 {
@extend %h5;
}
h6 {
@extend %h6;
}
p {
margin: var(--base) 0;
@include mid-break {
margin: calc(var(--base) * .75) 0;
}
}
ul,
ol {
padding-left: var(--base);
margin: 0 0 var(--base);
}
a {
color: currentColor;
&:focus {
opacity: .8;
outline: none;
}
&:active {
opacity: .7;
outline: none;
}
}
svg {
vertical-align: middle;
}

View File

@@ -0,0 +1,83 @@
:root {
--color-base-0: rgb(255, 255, 255);
--color-base-50: rgb(245, 245, 245);
--color-base-100: rgb(235, 235, 235);
--color-base-150: rgb(221, 221, 221);
--color-base-200: rgb(208, 208, 208);
--color-base-250: rgb(195, 195, 195);
--color-base-300: rgb(181, 181, 181);
--color-base-350: rgb(168, 168, 168);
--color-base-400: rgb(154, 154, 154);
--color-base-450: rgb(141, 141, 141);
--color-base-500: rgb(128, 128, 128);
--color-base-550: rgb(114, 114, 114);
--color-base-600: rgb(101, 101, 101);
--color-base-650: rgb(87, 87, 87);
--color-base-700: rgb(74, 74, 74);
--color-base-750: rgb(60, 60, 60);
--color-base-800: rgb(47, 47, 47);
--color-base-850: rgb(34, 34, 34);
--color-base-900: rgb(20, 20, 20);
--color-base-950: rgb(7, 7, 7);
--color-base-1000: rgb(0, 0, 0);
--color-success-50: rgb(247, 255, 251);
--color-success-100: rgb(240, 255, 247);
--color-success-150: rgb(232, 255, 243);
--color-success-200: rgb(224, 255, 239);
--color-success-250: rgb(217, 255, 235);
--color-success-300: rgb(209, 255, 230);
--color-success-350: rgb(201, 255, 226);
--color-success-400: rgb(193, 255, 222);
--color-success-450: rgb(186, 255, 218);
--color-success-500: rgb(178, 255, 214);
--color-success-550: rgb(160, 230, 193);
--color-success-600: rgb(142, 204, 171);
--color-success-650: rgb(125, 179, 150);
--color-success-700: rgb(107, 153, 128);
--color-success-750: rgb(89, 128, 107);
--color-success-800: rgb(71, 102, 86);
--color-success-850: rgb(53, 77, 64);
--color-success-900: rgb(36, 51, 43);
--color-success-950: rgb(18, 25, 21);
--color-warning-50: rgb(255, 255, 246);
--color-warning-100: rgb(255, 255, 237);
--color-warning-150: rgb(254, 255, 228);
--color-warning-200: rgb(254, 255, 219);
--color-warning-250: rgb(254, 255, 210);
--color-warning-300: rgb(254, 255, 200);
--color-warning-350: rgb(254, 255, 191);
--color-warning-400: rgb(253, 255, 182);
--color-warning-450: rgb(253, 255, 173);
--color-warning-500: rgb(253, 255, 164);
--color-warning-550: rgb(228, 230, 148);
--color-warning-600: rgb(202, 204, 131);
--color-warning-650: rgb(177, 179, 115);
--color-warning-700: rgb(152, 153, 98);
--color-warning-750: rgb(127, 128, 82);
--color-warning-800: rgb(101, 102, 66);
--color-warning-850: rgb(76, 77, 49);
--color-warning-900: rgb(51, 51, 33);
--color-warning-950: rgb(25, 25, 16);
--color-error-50: rgb(255, 241, 241);
--color-error-100: rgb(255, 226, 228);
--color-error-150: rgb(255, 212, 214);
--color-error-200: rgb(255, 197, 200);
--color-error-250: rgb(255, 183, 187);
--color-error-300: rgb(255, 169, 173);
--color-error-350: rgb(255, 154, 159);
--color-error-400: rgb(255, 140, 145);
--color-error-450: rgb(255, 125, 132);
--color-error-500: rgb(255, 111, 118);
--color-error-550: rgb(230, 100, 106);
--color-error-600: rgb(204, 89, 94);
--color-error-650: rgb(179, 78, 83);
--color-error-700: rgb(153, 67, 71);
--color-error-750: rgb(128, 56, 59);
--color-error-800: rgb(102, 44, 47);
--color-error-850: rgb(77, 33, 35);
--color-error-900: rgb(51, 22, 24);
--color-error-950: rgb(25, 11, 12);
}

View File

@@ -0,0 +1 @@
@forward './queries.scss';

View File

@@ -0,0 +1,28 @@
$breakpoint-xs-width: 400px;
$breakpoint-s-width: 768px;
$breakpoint-m-width: 1024px;
$breakpoint-l-width: 1440px;
@mixin extra-small-break {
@media (max-width: #{$breakpoint-xs-width}) {
@content;
}
}
@mixin small-break {
@media (max-width: #{$breakpoint-s-width}) {
@content;
}
}
@mixin mid-break {
@media (max-width: #{$breakpoint-m-width}) {
@content;
}
}
@mixin large-break {
@media (max-width: #{$breakpoint-l-width}) {
@content;
}
}

View File

@@ -0,0 +1,241 @@
@media (prefers-color-scheme: light) {
:root {
--theme-success-50: var(--color-success-50);
--theme-success-100: var(--color-success-100);
--theme-success-150: var(--color-success-150);
--theme-success-200: var(--color-success-200);
--theme-success-250: var(--color-success-250);
--theme-success-300: var(--color-success-300);
--theme-success-350: var(--color-success-350);
--theme-success-400: var(--color-success-400);
--theme-success-450: var(--color-success-450);
--theme-success-500: var(--color-success-500);
--theme-success-550: var(--color-success-550);
--theme-success-600: var(--color-success-600);
--theme-success-650: var(--color-success-650);
--theme-success-700: var(--color-success-700);
--theme-success-750: var(--color-success-750);
--theme-success-800: var(--color-success-800);
--theme-success-850: var(--color-success-850);
--theme-success-900: var(--color-success-900);
--theme-success-950: var(--color-success-950);
--theme-warning-50: var(--color-warning-50);
--theme-warning-100: var(--color-warning-100);
--theme-warning-150: var(--color-warning-150);
--theme-warning-200: var(--color-warning-200);
--theme-warning-250: var(--color-warning-250);
--theme-warning-300: var(--color-warning-300);
--theme-warning-350: var(--color-warning-350);
--theme-warning-400: var(--color-warning-400);
--theme-warning-450: var(--color-warning-450);
--theme-warning-500: var(--color-warning-500);
--theme-warning-550: var(--color-warning-550);
--theme-warning-600: var(--color-warning-600);
--theme-warning-650: var(--color-warning-650);
--theme-warning-700: var(--color-warning-700);
--theme-warning-750: var(--color-warning-750);
--theme-warning-800: var(--color-warning-800);
--theme-warning-850: var(--color-warning-850);
--theme-warning-900: var(--color-warning-900);
--theme-warning-950: var(--color-warning-950);
--theme-error-50: var(--color-error-50);
--theme-error-100: var(--color-error-100);
--theme-error-150: var(--color-error-150);
--theme-error-200: var(--color-error-200);
--theme-error-250: var(--color-error-250);
--theme-error-300: var(--color-error-300);
--theme-error-350: var(--color-error-350);
--theme-error-400: var(--color-error-400);
--theme-error-450: var(--color-error-450);
--theme-error-500: var(--color-error-500);
--theme-error-550: var(--color-error-550);
--theme-error-600: var(--color-error-600);
--theme-error-650: var(--color-error-650);
--theme-error-700: var(--color-error-700);
--theme-error-750: var(--color-error-750);
--theme-error-800: var(--color-error-800);
--theme-error-850: var(--color-error-850);
--theme-error-900: var(--color-error-900);
--theme-error-950: var(--color-error-950);
--theme-elevation-0: var(--color-base-0);
--theme-elevation-50: var(--color-base-50);
--theme-elevation-100: var(--color-base-100);
--theme-elevation-150: var(--color-base-150);
--theme-elevation-200: var(--color-base-200);
--theme-elevation-250: var(--color-base-250);
--theme-elevation-300: var(--color-base-300);
--theme-elevation-350: var(--color-base-350);
--theme-elevation-400: var(--color-base-400);
--theme-elevation-450: var(--color-base-450);
--theme-elevation-500: var(--color-base-500);
--theme-elevation-550: var(--color-base-550);
--theme-elevation-600: var(--color-base-600);
--theme-elevation-650: var(--color-base-650);
--theme-elevation-700: var(--color-base-700);
--theme-elevation-750: var(--color-base-750);
--theme-elevation-800: var(--color-base-800);
--theme-elevation-850: var(--color-base-850);
--theme-elevation-900: var(--color-base-900);
--theme-elevation-950: var(--color-base-950);
--theme-elevation-1000: var(--color-base-1000);
--theme-bg: var(--theme-elevation-0);
--theme-input-bg: var(--theme-elevation-50);
--theme-text: var(--theme-elevation-750);
--theme-border-color: var(--theme-elevation-150);
color-scheme: light;
color: var(--theme-text);
--highlight-default-bg-color: var(--theme-success-400);
--highlight-default-text-color: var(--theme-text);
--highlight-danger-bg-color: var(--theme-error-150);
--highlight-danger-text-color: var(--theme-text);
}
h1 a,
h2 a,
h3 a,
h4 a,
h5 a,
h6 a {
color: var(--theme-elevation-750);
&:hover {
color: var(--theme-elevation-800);
}
&:visited {
color: var(--theme-elevation-750);
&:hover {
color: var(--theme-elevation-800);
}
}
}
}
@media (prefers-color-scheme: dark) {
:root {
--theme-elevation-0: var(--color-base-1000);
--theme-elevation-50: var(--color-base-950);
--theme-elevation-100: var(--color-base-900);
--theme-elevation-150: var(--color-base-850);
--theme-elevation-200: var(--color-base-800);
--theme-elevation-250: var(--color-base-750);
--theme-elevation-300: var(--color-base-700);
--theme-elevation-350: var(--color-base-650);
--theme-elevation-400: var(--color-base-600);
--theme-elevation-450: var(--color-base-550);
--theme-elevation-500: var(--color-base-500);
--theme-elevation-550: var(--color-base-450);
--theme-elevation-600: var(--color-base-400);
--theme-elevation-650: var(--color-base-350);
--theme-elevation-700: var(--color-base-300);
--theme-elevation-750: var(--color-base-250);
--theme-elevation-800: var(--color-base-200);
--theme-elevation-850: var(--color-base-150);
--theme-elevation-900: var(--color-base-100);
--theme-elevation-950: var(--color-base-50);
--theme-elevation-1000: var(--color-base-0);
--theme-success-50: var(--color-success-950);
--theme-success-100: var(--color-success-900);
--theme-success-150: var(--color-success-850);
--theme-success-200: var(--color-success-800);
--theme-success-250: var(--color-success-750);
--theme-success-300: var(--color-success-700);
--theme-success-350: var(--color-success-650);
--theme-success-400: var(--color-success-600);
--theme-success-450: var(--color-success-550);
--theme-success-500: var(--color-success-500);
--theme-success-550: var(--color-success-450);
--theme-success-600: var(--color-success-400);
--theme-success-650: var(--color-success-350);
--theme-success-700: var(--color-success-300);
--theme-success-750: var(--color-success-250);
--theme-success-800: var(--color-success-200);
--theme-success-850: var(--color-success-150);
--theme-success-900: var(--color-success-100);
--theme-success-950: var(--color-success-50);
--theme-warning-50: var(--color-warning-950);
--theme-warning-100: var(--color-warning-900);
--theme-warning-150: var(--color-warning-850);
--theme-warning-200: var(--color-warning-800);
--theme-warning-250: var(--color-warning-750);
--theme-warning-300: var(--color-warning-700);
--theme-warning-350: var(--color-warning-650);
--theme-warning-400: var(--color-warning-600);
--theme-warning-450: var(--color-warning-550);
--theme-warning-500: var(--color-warning-500);
--theme-warning-550: var(--color-warning-450);
--theme-warning-600: var(--color-warning-400);
--theme-warning-650: var(--color-warning-350);
--theme-warning-700: var(--color-warning-300);
--theme-warning-750: var(--color-warning-250);
--theme-warning-800: var(--color-warning-200);
--theme-warning-850: var(--color-warning-150);
--theme-warning-900: var(--color-warning-100);
--theme-warning-950: var(--color-warning-50);
--theme-error-50: var(--color-error-950);
--theme-error-100: var(--color-error-900);
--theme-error-150: var(--color-error-850);
--theme-error-200: var(--color-error-800);
--theme-error-250: var(--color-error-750);
--theme-error-300: var(--color-error-700);
--theme-error-350: var(--color-error-650);
--theme-error-400: var(--color-error-600);
--theme-error-450: var(--color-error-550);
--theme-error-500: var(--color-error-500);
--theme-error-550: var(--color-error-450);
--theme-error-600: var(--color-error-400);
--theme-error-650: var(--color-error-350);
--theme-error-700: var(--color-error-300);
--theme-error-750: var(--color-error-250);
--theme-error-800: var(--color-error-200);
--theme-error-850: var(--color-error-150);
--theme-error-900: var(--color-error-100);
--theme-error-950: var(--color-error-50);
--theme-bg: var(--theme-elevation-100);
--theme-text: var(--theme-elevation-900);
--theme-input-bg: var(--theme-elevation-150);
--theme-border-color: var(--theme-elevation-250);
color-scheme: dark;
color: var(--theme-text);
--highlight-default-bg-color: var(--theme-success-100);
--highlight-default-text-color: var(--theme-success-600);
--highlight-danger-bg-color: var(--theme-error-100);
--highlight-danger-text-color: var(--theme-error-550);
}
h1 a,
h2 a,
h3 a,
h4 a,
h5 a,
h6 a {
color: var(--theme-success-600);
&:hover {
color: var(--theme-success-400);
}
&:visited {
color: var(--theme-success-700);
&:hover {
color: var(--theme-success-500);
}
}
}
}

View File

@@ -0,0 +1,110 @@
@use 'queries' as *;
%h1,
%h2,
%h3,
%h4,
%h5,
%h6 {
font-weight: 700;
}
%h1 {
margin: 40px 0;
font-size: 64px;
line-height: 70px;
font-weight: bold;
@include mid-break {
margin: 24px 0;
font-size: 42px;
line-height: 42px;
}
}
%h2 {
margin: 28px 0;
font-size: 48px;
line-height: 54px;
font-weight: bold;
@include mid-break {
margin: 22px 0;
font-size: 32px;
line-height: 40px;
}
}
%h3 {
margin: 24px 0;
font-size: 32px;
line-height: 40px;
font-weight: bold;
@include mid-break {
margin: 20px 0;
font-size: 26px;
line-height: 32px;
}
}
%h4 {
margin: 20px 0;
font-size: 26px;
line-height: 32px;
font-weight: bold;
@include mid-break {
font-size: 22px;
line-height: 30px;
}
}
%h5 {
margin: 20px 0;
font-size: 22px;
line-height: 30px;
font-weight: bold;
@include mid-break {
font-size: 18px;
line-height: 24px;
}
}
%h6 {
margin: 20px 0;
font-size: inherit;
line-height: inherit;
font-weight: bold;
}
%body {
font-size: 18px;
line-height: 32px;
@include mid-break {
font-size: 15px;
line-height: 24px;
}
}
%large-body {
font-size: 25px;
line-height: 32px;
@include mid-break {
font-size: 22px;
line-height: 30px;
}
}
%label {
font-size: 16px;
line-height: 24px;
text-transform: uppercase;
@include mid-break {
font-size: 13px;
}
}

View File

@@ -0,0 +1,34 @@
export const USER = `
id
email
firstName
lastName
`
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const gql = async (query: string): Promise<any> => {
try {
const res = await fetch(`${process.env.NEXT_PUBLIC_CMS_URL}/api/graphql`, {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
query,
}),
})
const { data, errors } = await res.json()
if (errors) {
throw new Error(errors[0].message)
}
if (res.ok && data) {
return data
}
} catch (e: unknown) {
throw new Error(e as string)
}
}

View File

@@ -0,0 +1,177 @@
'use client'
import React, { createContext, useCallback, useContext, useEffect, useState } from 'react'
import { User } from '../../payload-types'
import { gql, USER } from './gql'
import { rest } from './rest'
import { AuthContext, Create, ForgotPassword, Login, Logout, ResetPassword } from './types'
const Context = createContext({} as AuthContext)
export const AuthProvider: React.FC<{ children: React.ReactNode; api?: 'rest' | 'gql' }> = ({
children,
api = 'rest',
}) => {
const [user, setUser] = useState<User | null>()
const create = useCallback<Create>(
async args => {
if (api === 'rest') {
const user = await rest(`${process.env.NEXT_PUBLIC_CMS_URL}/api/users`, args)
setUser(user)
return user
}
if (api === 'gql') {
const { createUser: user } = await gql(`mutation {
createUser(data: { email: "${args.email}", password: "${args.password}", firstName: "${args.firstName}", lastName: "${args.lastName}" }) {
${USER}
}
}`)
setUser(user)
return user
}
},
[api],
)
const login = useCallback<Login>(
async args => {
if (api === 'rest') {
const user = await rest(`${process.env.NEXT_PUBLIC_CMS_URL}/api/users/login`, args)
setUser(user)
return user
}
if (api === 'gql') {
const { loginUser } = await gql(`mutation {
loginUser(email: "${args.email}", password: "${args.password}") {
user {
${USER}
}
exp
}
}`)
setUser(loginUser?.user)
return loginUser?.user
}
},
[api],
)
const logout = useCallback<Logout>(async () => {
if (api === 'rest') {
await rest(`${process.env.NEXT_PUBLIC_CMS_URL}/api/users/logout`)
setUser(null)
return
}
if (api === 'gql') {
await gql(`mutation {
logoutUser
}`)
setUser(null)
}
}, [api])
// On mount, get user and set
useEffect(() => {
const fetchMe = async () => {
if (api === 'rest') {
const user = await rest(
`${process.env.NEXT_PUBLIC_CMS_URL}/api/users/me`,
{},
{
method: 'GET',
},
)
setUser(user)
}
if (api === 'gql') {
const { meUser } = await gql(`query {
meUser {
user {
${USER}
}
exp
}
}`)
setUser(meUser.user)
}
}
fetchMe()
}, [api])
const forgotPassword = useCallback<ForgotPassword>(
async args => {
if (api === 'rest') {
const user = await rest(
`${process.env.NEXT_PUBLIC_CMS_URL}/api/users/forgot-password`,
args,
)
setUser(user)
return user
}
if (api === 'gql') {
const { forgotPasswordUser } = await gql(`mutation {
forgotPasswordUser(email: "${args.email}")
}`)
return forgotPasswordUser
}
},
[api],
)
const resetPassword = useCallback<ResetPassword>(
async args => {
if (api === 'rest') {
const user = await rest(`${process.env.NEXT_PUBLIC_CMS_URL}/api/users/reset-password`, args)
setUser(user)
return user
}
if (api === 'gql') {
const { resetPasswordUser } = await gql(`mutation {
resetPasswordUser(password: "${args.password}", token: "${args.token}") {
user {
${USER}
}
}
}`)
setUser(resetPasswordUser.user)
return resetPasswordUser.user
}
},
[api],
)
return (
<Context.Provider
value={{
user,
setUser,
login,
logout,
create,
resetPassword,
forgotPassword,
}}
>
{children}
</Context.Provider>
)
}
type UseAuth<T = User> = () => AuthContext // eslint-disable-line no-unused-vars
export const useAuth: UseAuth = () => useContext(Context)

View File

@@ -0,0 +1,34 @@
import type { User } from '../../payload-types'
export const rest = async (
url: string,
args?: any, // eslint-disable-line @typescript-eslint/no-explicit-any
options?: RequestInit,
): Promise<User | null | undefined> => {
const method = options?.method || 'POST'
try {
const res = await fetch(url, {
method,
...(method === 'POST' ? { body: JSON.stringify(args) } : {}),
credentials: 'include',
headers: {
'Content-Type': 'application/json',
...options?.headers,
},
...options,
})
const { errors, user } = await res.json()
if (errors) {
throw new Error(errors[0].message)
}
if (res.ok) {
return user
}
} catch (e: unknown) {
throw new Error(e as string)
}
}

View File

@@ -0,0 +1,41 @@
import { cookies } from 'next/headers'
import { redirect } from 'next/navigation'
import type { User } from '../payload-types'
export const getMeUser = async (args?: {
nullUserRedirect?: string
validUserRedirect?: string
}): Promise<{
user: User
token: string | undefined
}> => {
const { nullUserRedirect, validUserRedirect } = args || {}
const cookieStore = cookies()
const token = cookieStore.get('payload-token')?.value
const meUserReq = await fetch(`${process.env.NEXT_PUBLIC_CMS_URL}/api/users/me`, {
headers: {
Authorization: `JWT ${token}`,
},
})
const {
user,
}: {
user: User
} = await meUserReq.json()
if (validUserRedirect && meUserReq.ok && user) {
redirect(validUserRedirect)
}
if (nullUserRedirect && (!meUserReq.ok || !user)) {
redirect(nullUserRedirect)
}
return {
user,
token,
}
}

View File

@@ -0,0 +1,24 @@
@import "../../_css/common";
.form {
margin-bottom: var(--base);
display: flex;
flex-direction: column;
gap: calc(var(--base) / 2);
align-items: flex-start;
width: 66.66%;
@include mid-break {
width: 100%;
}
}
.changePassword {
all: unset;
cursor: pointer;
text-decoration: underline;
}
.submit {
margin-top: calc(var(--base) / 2);
}

View File

@@ -0,0 +1,152 @@
'use client'
import React, { Fragment, useCallback, useEffect, useRef, useState } from 'react'
import { useForm } from 'react-hook-form'
import { useRouter } from 'next/navigation'
import { Button } from '../../_components/Button'
import { Input } from '../../_components/Input'
import { Message } from '../../_components/Message'
import { useAuth } from '../../_providers/Auth'
import classes from './index.module.scss'
type FormData = {
email: string
name: string
password: string
passwordConfirm: string
}
export const AccountForm: React.FC = () => {
const [error, setError] = useState('')
const [success, setSuccess] = useState('')
const { user, setUser } = useAuth()
const [changePassword, setChangePassword] = useState(false)
const router = useRouter()
const {
register,
handleSubmit,
formState: { errors, isLoading },
reset,
watch,
} = useForm<FormData>()
const password = useRef({})
password.current = watch('password', '')
const onSubmit = useCallback(
async (data: FormData) => {
if (user) {
const response = await fetch(`${process.env.NEXT_PUBLIC_CMS_URL}/api/users/${user.id}`, {
// Make sure to include cookies with fetch
credentials: 'include',
method: 'PATCH',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json',
},
})
if (response.ok) {
const json = await response.json()
setUser(json.doc)
setSuccess('Successfully updated account.')
setError('')
setChangePassword(false)
reset({
email: json.doc.email,
name: json.doc.name,
password: '',
passwordConfirm: '',
})
} else {
setError('There was a problem updating your account.')
}
}
},
[user, setUser, reset],
)
useEffect(() => {
if (user === null) {
router.push(`/login?unauthorized=account`)
}
// Once user is loaded, reset form to have default values
if (user) {
reset({
email: user.email,
password: '',
passwordConfirm: '',
})
}
}, [user, router, reset, changePassword])
return (
<form onSubmit={handleSubmit(onSubmit)} className={classes.form}>
<Message error={error} success={success} className={classes.message} />
{!changePassword ? (
<Fragment>
<p>
{'To change your password, '}
<button
type="button"
className={classes.changePassword}
onClick={() => setChangePassword(!changePassword)}
>
click here
</button>
.
</p>
<Input
name="email"
label="Email Address"
required
register={register}
error={errors.email}
type="email"
/>
</Fragment>
) : (
<Fragment>
<p>
{'Change your password below, or '}
<button
type="button"
className={classes.changePassword}
onClick={() => setChangePassword(!changePassword)}
>
cancel
</button>
.
</p>
<Input
name="password"
type="password"
label="Password"
required
register={register}
error={errors.password}
/>
<Input
name="passwordConfirm"
type="password"
label="Confirm Password"
required
register={register}
validate={value => value === password.current || 'The passwords do not match'}
error={errors.passwordConfirm}
/>
</Fragment>
)}
<Button
type="submit"
className={classes.submit}
label={isLoading ? 'Processing' : changePassword ? 'Change password' : 'Update account'}
appearance="primary"
/>
</form>
)
}

View File

@@ -0,0 +1,7 @@
.account {
margin-bottom: var(--block-padding);
}
.params {
margin-top: var(--base);
}

View File

@@ -0,0 +1,34 @@
import React from 'react'
import Link from 'next/link'
import { Button } from '../_components/Button'
import { Gutter } from '../_components/Gutter'
import { RenderParams } from '../_components/RenderParams'
import { getMeUser } from '../_utilities/getMeUser'
import { AccountForm } from './AccountForm'
import classes from './index.module.scss'
export default async function Account() {
await getMeUser({
nullUserRedirect: `/login?error=${encodeURIComponent(
'You must be logged in to access your account.',
)}&redirect=${encodeURIComponent('/account')}`,
})
return (
<Gutter className={classes.account}>
<RenderParams className={classes.params} />
<h1>Account</h1>
<p>
{`This is your account dashboard. Here you can update your account information and more. To manage all users, `}
<Link href={`${process.env.NEXT_PUBLIC_CMS_URL}/admin/collections/users`}>
login to the admin dashboard
</Link>
{'.'}
</p>
<AccountForm />
<Button href="/logout" appearance="secondary" label="Log out" />
</Gutter>
)
}

View File

@@ -0,0 +1,22 @@
@import "../../_css/common";
.form {
margin-bottom: var(--base);
display: flex;
flex-direction: column;
gap: calc(var(--base) / 2);
align-items: flex-start;
width: 66.66%;
@include mid-break {
width: 100%;
}
}
.submit {
margin-top: calc(var(--base) / 2);
}
.message {
margin-bottom: var(--base);
}

View File

@@ -0,0 +1,121 @@
'use client'
import React, { useCallback, useRef, useState } from 'react'
import { useForm } from 'react-hook-form'
import Link from 'next/link'
import { useRouter, useSearchParams } from 'next/navigation'
import { Button } from '../../_components/Button'
import { Input } from '../../_components/Input'
import { Message } from '../../_components/Message'
import { useAuth } from '../../_providers/Auth'
import classes from './index.module.scss'
type FormData = {
email: string
password: string
passwordConfirm: string
}
export const CreateAccountForm: React.FC = () => {
const searchParams = useSearchParams()
const allParams = searchParams.toString() ? `?${searchParams.toString()}` : ''
const { login } = useAuth()
const router = useRouter()
const [loading, setLoading] = useState(false)
const [error, setError] = useState<string | null>(null)
const {
register,
handleSubmit,
formState: { errors },
watch,
} = useForm<FormData>()
const password = useRef({})
password.current = watch('password', '')
const onSubmit = useCallback(
async (data: FormData) => {
const response = await fetch(`${process.env.NEXT_PUBLIC_CMS_URL}/api/users`, {
method: 'POST',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json',
},
})
if (!response.ok) {
const message = response.statusText || 'There was an error creating the account.'
setError(message)
return
}
const redirect = searchParams.get('redirect')
const timer = setTimeout(() => {
setLoading(true)
}, 1000)
try {
await login(data)
clearTimeout(timer)
if (redirect) router.push(redirect as string)
else router.push(`/account?success=${encodeURIComponent('Account created successfully')}`)
} catch (_) {
clearTimeout(timer)
setError('There was an error with the credentials provided. Please try again.')
}
},
[login, router, searchParams],
)
return (
<form onSubmit={handleSubmit(onSubmit)} className={classes.form}>
<p>
{`This is where new customers can signup and create a new account. To manage all users, `}
<Link href={`${process.env.NEXT_PUBLIC_CMS_URL}/admin/collections/users`}>
login to the admin dashboard
</Link>
{'.'}
</p>
<Message error={error} className={classes.message} />
<Input
name="email"
label="Email Address"
required
register={register}
error={errors.email}
type="email"
/>
<Input
name="password"
type="password"
label="Password"
required
register={register}
error={errors.password}
/>
<Input
name="passwordConfirm"
type="password"
label="Confirm Password"
required
register={register}
validate={value => value === password.current || 'The passwords do not match'}
error={errors.passwordConfirm}
/>
<Button
type="submit"
className={classes.submit}
label={loading ? 'Processing' : 'Create Account'}
appearance="primary"
/>
<div>
{'Already have an account? '}
<Link href={`/login${allParams}`}>Login</Link>
</div>
</form>
)
}

View File

@@ -0,0 +1,5 @@
@import "../_css/common";
.createAccount {
margin-bottom: var(--block-padding);
}

View File

@@ -0,0 +1,24 @@
import React from 'react'
import { Gutter } from '../_components/Gutter'
import { RenderParams } from '../_components/RenderParams'
import { getMeUser } from '../_utilities/getMeUser'
import { CreateAccountForm } from './CreateAccountForm'
import classes from './index.module.scss'
export default async function CreateAccount() {
await getMeUser({
validUserRedirect: `/account?message=${encodeURIComponent(
'Cannot create a new account while logged in, please log out and try again.',
)}`,
})
return (
<Gutter className={classes.createAccount}>
<h1>Create Account</h1>
<RenderParams />
<CreateAccountForm />
</Gutter>
)
}

View File

@@ -0,0 +1,28 @@
import { Header } from './_components/Header'
import { AuthProvider } from './_providers/Auth'
import './_css/app.scss'
export const metadata = {
title: 'Payload Auth + Next.js App Router Example',
description: 'An example of how to authenticate with Payload from a Next.js app.',
}
export default async function RootLayout(props: { children: React.ReactNode }) {
const { children } = props
return (
<html lang="en">
<body>
<AuthProvider
// To toggle between the REST and GraphQL APIs,
// change the `api` prop to either `rest` or `gql`
api="rest" // change this to `gql` to use the GraphQL API
>
<Header />
<main>{children}</main>
</AuthProvider>
</body>
</html>
)
}

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