Compare commits

..

79 Commits

Author SHA1 Message Date
Elliot DeNolf
a06c06415c ci: increase stale operations-per-run 2024-05-23 09:09:50 -04:00
Elliot DeNolf
2dd7e82fdc ci: add stale workflow in debug mode 2024-05-22 16:43:17 -04:00
Donovan Glover
63e04e2ae0 fix(editorconfig): use off for max_line_length (#4713)
Fixes "invalid value for option max_line_length: null"

See:
https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#max_line_length
2024-05-22 15:28:14 -04:00
Elliot DeNolf
e71888a625 chore: add label-author.yml 2024-05-21 23:03:14 -04:00
Patrik
c5514f1441 chore(bundler-webpack): updates webpack-dev-middleware dependency (#6446)
## Description

`pnpm audit` of `bundler-webpack` showed a high severity security issue
with the `webpack-dev-middleware` package

Updated package to latest to resolve.

- [x] I have read and understand the
[CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md)
document in this repository.

## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)

## Checklist:

- [x] Existing test suite passes locally with my changes
2024-05-21 16:08:00 -04:00
Elliot DeNolf
23e2fe643e chore: v3 bug template ids update 2024-05-21 11:56:17 -04:00
Elliot DeNolf
bdef2f1bc7 chore: add v3 bug template 2024-05-21 11:54:26 -04:00
Jessica Chowdhury
8f03cd7c78 fix(ui): blocks browser save dialog from opening when hotkey used with no changes (#6365)
## Description

Related issue
[#214](https://github.com/payloadcms/payload-3.0-demo/issues/214) (3.0).

Using the `cmd+s` hotkey in the Edit Document view was opening the
_browser_ save dialogue when no changes had been made.

This change triggers a toast info banner with `No changes to save` and
adds translated string for other languages.

PR for 3.0 is [here](https://github.com/payloadcms/payload/pull/6366).

- [X] I have read and understand the
[CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md)
document in this repository.

## Type of change

- [X] Chore (non-breaking change which does not add functionality)

## Checklist:

- [X] Existing test suite passes locally with my changes
2024-05-21 14:07:47 +01:00
Anders Semb Hermansen
c0092191a6 fix: separate sort and search fields when looking up relationship. (#5964)
## Description

Default sort is used as searching field which is causing unexpected
behaviour described in #4815 and #5222 This bugfix separates which field
is used for sorting and which is used for searching.

Fixes: #4815 #5222

- [X] I have read and understand the
[CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md)
document in this repository.

## Type of change

- [X] Bug fix (non-breaking change which fixes an issue)

## Checklist:

- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] Existing test suite passes locally with my changes
- [ ] I have made corresponding changes to the documentation
2024-05-20 15:59:54 -04:00
Elliot DeNolf
b9854ed60a chore(release): db-postgres/0.8.4 [skip ci] 2024-05-17 14:36:02 -04:00
Elliot DeNolf
576ee14976 chore(release): payload/2.18.3 [skip ci] 2024-05-17 14:33:14 -04:00
Dan Ribbens
bf77cec7e9 fix(db-postgres): query with like on id columns (#6416)
copy of https://github.com/payloadcms/payload/pull/6414 to main
2024-05-17 14:07:57 -04:00
Patrik
ab8b2f3fb8 fix: nested disableListColumn in rows (#6412)
## Description

Fixes #6407 

- [x] I have read and understand the
[CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md)
document in this repository.

## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)

## Checklist:

- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] Existing test suite passes locally with my changes
2024-05-17 14:01:08 -04:00
Patrik
db5f3f3ccd fix(db-postgres): uuid custom db name (#6409)
## Description

Fixes an issue with creating versions when using custom DB names,
`uuid`, and drafts.

v3 PR [here](https://github.com/payloadcms/payload/pull/6408)

- [x] I have read and understand the
[CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md)
document in this repository.

## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)

## Checklist:

- [x] Existing test suite passes locally with my changes
2024-05-17 13:58:08 -04:00
Francis Turmel
cece39957f chore(i18n): French translation improvements (#6035)
## Description

see #6406 for the changes against `beta`

* The apostrophe character `’` should be used instead of the single
quote `'`
* Gender corrections: "L’adresse e-mail fourni**e**", "Vérification
échoué**e**"
* Lowercase: "Supprimer le **té**léversement"
* Dark and light theme: I think it makes more sense to use "Sombre" and
"Clair" here to identify the theme. Day/Night modes imply a hue/warmth
correction and are different features altogether. Reference:
https://fr.wikipedia.org/wiki/Mode_sombre#Mode_sombre_et_mode_nuit_ou_chaud
* Fix accent: "Mis à jour avec succ**è**s"
* "Bienvenue" I think would be the correct standalone greeting form.
Reference:
https://www.projet-voltaire.fr/question-orthographe/orthographe-bienvenu-bienvenue-chez-moi/
* "Recadrer" is the correct word for "crop". "Récolte" means "crop" in
the sense of "harvest", so this was probably a bad literal Google
Translate that slipped through.
* Correct all "Es-tu sûr ?" to the proper formal "Êtes-vous sûr ?" for
consistency
* Use _article défini_ since we will enumerate the values: "Ce champ
contient **les** sélections invalides suivantes :"
* Space before question marks

---

<!-- Please include a summary of the pull request and any related issues
it fixes. Please also include relevant motivation and context. -->

- [x] I have read and understand the
[CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md)
document in this repository.

## Type of change

<!-- Please delete options that are not relevant. -->

- [x] 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](https://github.com/payloadcms/payload/tree/main/templates)
directory (does not affect core functionality)
- [ ] Change to the
[examples](https://github.com/payloadcms/payload/tree/main/examples)
directory (does not affect core functionality)
- [ ] This change requires a documentation update

## Checklist:

- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] Existing test suite passes locally with my changes
- [ ] I have made corresponding changes to the documentation
2024-05-17 13:51:47 -03:00
Elliot DeNolf
157fff0417 chore(release): payload/2.18.2 [skip ci] 2024-05-17 10:09:35 -04:00
Elliot DeNolf
88e113a545 fix: allow focal point when no sizes defined (#6397)
Allow focal points to be saved even when no imageSizes are defined.
Expands upon #6364 .
2024-05-17 09:06:42 -04:00
Elliot DeNolf
d33afe48fe chore(release): payload/2.18.1 [skip ci] 2024-05-16 15:46:23 -04:00
Elliot DeNolf
e76df32f09 fix: add back explicit crop x and y values (#6391)
Cropping x and y values pulling from the UI were unintentionally removed
in #6364
2024-05-16 15:32:36 -04:00
Elliot DeNolf
b068f30f51 chore(release): richtext-lexical/0.11.1 [skip ci] 2024-05-16 14:05:28 -04:00
Elliot DeNolf
82bd5c656f chore(release): db-postgres/0.8.3 [skip ci] 2024-05-16 14:05:16 -04:00
Elliot DeNolf
afe8992ca6 chore(release): payload/2.18.0 [skip ci] 2024-05-16 14:04:05 -04:00
Alessio Gravili
48a410e294 fix(richtext-lexical): upload, relationship and block node insertion fails sometimes (#6390)
Backport of https://github.com/payloadcms/payload/pull/6389
2024-05-16 13:34:43 -04:00
Elliot DeNolf
82b88a315f feat: store focal point on uploads (#6364)
Store focal point data on uploads as `focalX` and `focalY`

Addresses https://github.com/payloadcms/payload/discussions/4082
2024-05-16 11:58:49 -04:00
Patrik
cc94078607 fix: filter with ID not_in AND queries - postgres (#6358)
## Description

Fixes #5151 

`Issue`: With `Postgres`, when filtering by two queries with `AND`, if
the first query involved `ID` and the `not_in` operator, the second
query in the filter would never be evaluated.

- [x] I have read and understand the
[CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md)
document in this repository.

## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)

## Checklist:

- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] Existing test suite passes locally with my changes
2024-05-15 15:09:53 -04:00
Elliot DeNolf
1c30ad73b6 chore(release): richtext-lexical/0.11.0 [skip ci] 2024-05-15 11:35:05 -04:00
Elliot DeNolf
d9442dcce3 chore(release): payload/2.17.0 [skip ci] 2024-05-15 11:33:53 -04:00
Patrik
de92c50847 fix: safely access cookie header for uploads (#6367)
## Description

Issue with editing and changing the crop or focal point of an image

`Error`:

```
ERROR (payload): FileRetrievalError: There was a problem while uploading the file. Cannot read properties of undefined (reading 'cookie')
    at generateFileData (/node_modules/payload/src/uploads/generateFileData.ts:86:15)
```
(`payload v2.16.1` and `plugin-cloud v3.0.1`)

Fix: add optional chaing to safely access `cookie` header when fetching
image

- [x] I have read and understand the
[CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md)
document in this repository.

## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)

## Checklist:

- [x] Existing test suite passes locally with my changes
2024-05-15 10:50:14 -04:00
Jacob Fletcher
b7f5f932f6 fix(examples/live-preview): regenerates yarn lockfiles (#6356) 2024-05-14 15:27:51 -04:00
Jessica Chowdhury
bc9e591e37 chore: removes letter spacing in loading overlay for script languages (#4769) 2024-05-14 16:51:34 +01:00
Jessica Chowdhury
ad38011348 chore: fix api preview indentation (#6152) 2024-05-14 16:09:17 +01:00
Patrik
d02b1fb084 fix: step-nav breadcrumbs ellipsis (#6345) 2024-05-14 11:08:59 -04:00
Jessica Chowdhury
51efe4f39b fix: collection labels with locales not working when creating new doc (#5995) 2024-05-14 10:45:39 -04:00
Jessica Chowdhury
30e535b5b9 feat: adds misc translations to API view and react select (#6138) 2024-05-13 08:52:12 -04:00
Jessica Chowdhury
4bd3bb9400 chore: adds translations for checkbox field in collection view (#6167) 2024-05-13 12:31:36 +01:00
Patrik
69c93d3c62 fix: appends editDepth value to radio & checkbox IDs when inside drawer (#6181) 2024-05-10 11:24:21 -04:00
Elliot DeNolf
78aa957043 fix(plugin-object-ids): add webpack to dev deps 2024-05-10 11:02:29 -04:00
Patrik
cd06c022c0 feat(plugin-relationship-object-ids): adds plugin-relationship-object-ids package (#6044) 2024-05-10 10:39:47 -04:00
Jacob Fletcher
8299e9fc33 docs(examples): adds examples docs (#6312) 2024-05-10 10:22:22 -04:00
Alessio Gravili
9df5ab8a10 feat(richtext-lexical)!: remove LexicalBlock, RichTextFieldRequiredEditor and FieldWithRichTextRequiredEditor types (#6279)
BREAKING:

`LexicalBlock`, `RichTextFieldRequiredEditor` and `FieldWithRichTextRequiredEditor` types have been removed. Instead of `LexicalBlock`, use `Block`. Instead of `RichTextFieldRequiredEditor`, use `RichTextField`. And instead of `FieldWithRichTextRequiredEditor`, use `Field`.
2024-05-09 09:46:03 -04:00
Elliot DeNolf
6979f5a1b1 ci: register release-canary workflow 2024-05-09 09:22:18 -04:00
Elliot DeNolf
723791b94f chore(release): richtext-lexical/0.10.0 [skip ci] 2024-05-07 15:53:11 -04:00
Elliot DeNolf
aa3833ec83 chore(release): payload/2.16.1 [skip ci] 2024-05-07 15:52:06 -04:00
Dan Ribbens
2972af2af1 chore: add index to version status field (#6256) 2024-05-07 15:47:55 -04:00
Alessio Gravili
857b9a4ac3 feat(richtext-lexical): add maxDepth property to various lexical features (#6250)
Backports #6242
2024-05-07 09:39:48 -04:00
Alessio Gravili
f829b084ba fix(richtext-lexical): export missing HorizontalRuleFeature (#6236) 2024-05-06 13:54:49 -04:00
Elliot DeNolf
6ae682698d chore(release): payload/2.16.0 [skip ci] 2024-05-06 12:47:28 -04:00
Francisco Lourenço
622cdb0440 fix: hide drag handles when admin.isSortable: false (#6225)
Co-authored-by: Kendell Joseph <kendelljoseph@gmail.com>
2024-05-06 12:21:35 -04:00
Jarrod Flesch
cac52da638 fix: graphql upload relations returning null (#6233) 2024-05-06 11:58:48 -04:00
DracoBlue
3cb3c1aceb docs(plugin-cloud): Fix link to local-dev.md (#6222) 2024-05-05 22:27:26 -04:00
Patrik
db4aacebb8 feat: adds disableListColumn, disableListFilter to fields admin props (#6188) 2024-05-03 16:49:06 -04:00
Paul
b735d6aa16 fix(plugin-form-builder): hook overrides not working as intended (#6203) 2024-05-03 17:36:03 -03:00
Elliot DeNolf
fbec3a33e0 chore(release): richtext-slate/1.5.2 [skip ci] 2024-05-03 11:23:16 -04:00
Elliot DeNolf
034be89bdb chore(release): richtext-lexical/0.9.3 [skip ci] 2024-05-03 11:23:00 -04:00
Elliot DeNolf
1f2af0963b chore(release): plugin-cloud/3.0.1 [skip ci] 2024-05-03 11:22:42 -04:00
Elliot DeNolf
20f1ece2d7 chore(release): payload/2.15.0 [skip ci] 2024-05-03 11:21:26 -04:00
Jessica Chowdhury
2be5ad0eba fix: hide unusable fields from collection filter select (#6135) 2024-05-03 11:01:47 -04:00
Kendell Joseph
5c58bd322d feat: add isSortable to arrays and blocks (#5962) 2024-05-03 10:38:02 -04:00
Dan Ribbens
23f3eb1cf0 feat: use filterOptions in list relationship filter (#6156) 2024-05-03 10:26:49 -04:00
Patrik
af67749e49 fix: incorrect localesNotSaved translation (#5996) 2024-05-03 10:22:06 -04:00
Patrik
43dab5c705 fix: sanitizes fields in default edit view for drawer content (#6175) 2024-05-03 10:16:24 -04:00
Patrik
9b7e62dc20 fix: properly adds readonly styles to disabled radio fields (#6176) 2024-05-03 10:07:52 -04:00
Patrik
6e38cc2bcf fix: resets filter state when param state change within route (#6169) 2024-05-02 13:21:51 -04:00
Tylan Davis
83551bfcaa docs: adjust line breaks in code blocks - v2 (#6002) 2024-05-01 15:58:15 -04:00
Francisco Lourenço
7b44d9d28a docs: fix outdated #aliasing-server-only-modules urls (#5014) 2024-05-01 15:52:18 -04:00
ovalice
182d5db6de docs: Fix RowLabel code snippet that causes compilation error (#4947)
Co-authored-by: smarten <user@example.com>
2024-05-01 15:42:43 -04:00
Mina Sameh
93109ec84a docs: edit code of generate email subject in verify auth section (#4607) 2024-05-01 15:31:24 -04:00
Take Weiland
4d9e0f35f0 docs: clarify docs around direction transaction access (#3648) 2024-05-01 15:22:48 -04:00
Carlo Taleon
19327c8d6d docs: slate linebreak serialization in 'Generating HTML' example (#3804) 2024-05-01 15:21:03 -04:00
Elliot DeNolf
831f1ff5be fix(plugin-cloud): purge cache for all sizes (#5301) 2024-05-01 15:15:16 -04:00
Jarrod Flesch
a8ac8b4633 fix: cascade draft arg in nested GraphQL relationship queries (#6141) 2024-04-30 14:19:20 -04:00
Alessio Gravili
36b1f5a763 fix(richtext-lexical): floating toolbar caret positioned incorrectly for some line heights (#6151) 2024-04-30 12:06:02 -04:00
Alessio Gravili
24f697219b fix(richtext-lexical): drag and add block handles disappear too quickly for smaller screen sizes. (#6145) 2024-04-30 10:52:37 -04:00
Jarrod Flesch
3fccd34abe fix: GraphQL nested relationships not respecting req locale (#6117) 2024-04-29 16:32:33 -04:00
Friggo
a38f8e93a6 chore: Czech translation improvement (#6079) 2024-04-28 07:57:47 -04:00
Dan Ribbens
84570e6e3b fix: bulk publish from collection list (#6063) 2024-04-28 07:30:37 -04:00
Friggo
5ad8e0edcb chore: Czech translation improvements (#6077) 2024-04-28 07:27:26 -04:00
Jarrod Flesch
91bac9c0aa fix: version restoration (#6039) 2024-04-26 16:15:14 -04:00
Elliot DeNolf
33f6edc9d5 chore(release): richtext-slate/1.5.1 [skip ci] 2024-04-26 16:05:01 -04:00
222 changed files with 10087 additions and 7878 deletions

View File

@@ -0,0 +1,57 @@
name: Bug Report v3
description: Create a bug report for Payload v3 (beta)
labels: ['status:needs-triage', 'v3']
body:
- type: input
id: reproduction-link
attributes:
label: Link to reproduction
description: Want us to look into your issue faster? Follow the [reproduction-guide](https://github.com/payloadcms/payload/blob/main/.github/reproduction-guide.md) for more information.
validations:
required: false
- type: input
id: version
attributes:
label: Payload Version
description: What version of Payload are you running?
validations:
required: true
- type: input
id: node-version
attributes:
label: Node Version
description: What version of Node are you running?
validations:
required: true
- type: input
id: nextjs-version
attributes:
label: Next.js Version
description: What version of Next.js are you running?
validations:
required: true
- type: textarea
attributes:
label: Describe the Bug
validations:
required: true
- type: textarea
attributes:
label: Reproduction Steps
description: Steps to reproduce the behavior, please provide a clear description of how to reproduce the issue, based on the linked minimal reproduction. Screenshots can be provided in the issue body below. If using code blocks, make sure that [syntax highlighting is correct](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks#syntax-highlighting) and double check that the rendered preview is not broken.
validations:
required: true
- type: input
id: adapters-plugins
attributes:
label: Adapters and Plugins
description: What adapters and plugins are you using if relevant? ie. db-mongodb, db-postgres, storage-vercel-blob, etc.
- type: markdown
attributes:
value: Before submitting the issue, go through the steps you've written down to make sure the steps provided are detailed and clear.
- type: markdown
attributes:
value: Contributors should be able to follow the steps provided in order to reproduce the bug.
- type: markdown
attributes:
value: These steps are used to add integration tests to ensure the same issue does not happen again. Thanks in advance!

50
.github/workflows/label-author.yml vendored Normal file
View File

@@ -0,0 +1,50 @@
name: label-author
on:
pull_request:
types: [opened]
issues:
types: [opened]
permissions:
contents: read
pull-requests: write
issues: write
jobs:
debug-context:
runs-on: ubuntu-latest
steps:
- name: View context attributes
uses: actions/github-script@v7
with:
script: console.log(context)
label-created-by:
name: Label pr/issue on opening
runs-on: ubuntu-latest
steps:
- name: Tag with 'created-by'
uses: actions/github-script@v7
if: github.event.action == 'opened'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const type = context.payload.pull_request ? 'pull_request' : 'issue';
const association = context.payload[type].author_association;
let label = ''
if (association === 'MEMBER' || association === 'OWNER') {
label = 'created-by: Payload team';
} else if (association === 'CONTRIBUTOR') {
label = 'created-by: Contributor';
}
if (!label) return;
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: [label],
});
console.log('Added created-by: Payload team label');

View File

@@ -1,4 +1,4 @@
name: pr-title
name: release-canary
on:
workflow_dispatch:
@@ -8,4 +8,4 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Echo
run: echo "Register pr-title workflow"
run: echo "Register release-canary workflow"

42
.github/workflows/stale.yml vendored Normal file
View File

@@ -0,0 +1,42 @@
name: stale
on:
workflow_dispatch:
jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v9
id: stale
with:
debug-only: true
days-before-stale: 90
days-before-close: 7
ascending: true
operations-per-run: 300
# Ignore all assigned
exempt-all-assignees: true
# Issues
stale-issue-label: 'stale'
exempt-issue-labels: 'blocked,must,should,keep,created-by: Payload team'
stale-issue-message: >
This issue has been marked as stale due to lack of activity. To keep the ticket open, please indicate that it is still relevant in a comment below.
close-issue-message: >
This issue was automatically closed due to lack of activity.
# Pull Requests
stale-pr-label: 'stale'
exempt-pr-labels: 'blocked,must,should,keep,created-by: Payload team'
stale-pr-message: >
This PR is stale due to lack of activity. To keep the PR open, please indicate that it is still relevant in a comment below.
close-pr-message: >
This pull request was automatically closed due to lack of activity.
- name: Print outputs
run: echo ${{ format('{0},{1}', toJSON(steps.stale.outputs.staled-issues-prs), toJSON(steps.stale.outputs.closed-issues-prs)) }}

7
.vscode/launch.json vendored
View File

@@ -19,6 +19,13 @@
"PAYLOAD_PUBLIC_CLOUD_STORAGE_ADAPTER": "s3"
}
},
{
"command": "pnpm run dev collections-graphql",
"cwd": "${workspaceFolder}",
"name": "Run Dev GraphQL",
"request": "launch",
"type": "node-terminal"
},
{
"command": "pnpm run dev fields",
"cwd": "${workspaceFolder}",

View File

@@ -1,3 +1,109 @@
## [2.18.3](https://github.com/payloadcms/payload/compare/v2.18.2...v2.18.3) (2024-05-17)
### Bug Fixes
* **db-postgres:** query with like on id columns ([#6416](https://github.com/payloadcms/payload/issues/6416)) ([bf77cec](https://github.com/payloadcms/payload/commit/bf77cec7e9e7db4988e481d464178636203fca32))
* **db-postgres:** uuid custom db name ([#6409](https://github.com/payloadcms/payload/issues/6409)) ([db5f3f3](https://github.com/payloadcms/payload/commit/db5f3f3ccdaedd9e8036c3e39fc20650a309a151))
* nested `disableListColumn` in rows ([#6412](https://github.com/payloadcms/payload/issues/6412)) ([ab8b2f3](https://github.com/payloadcms/payload/commit/ab8b2f3fb87864484582b7d819ca307888a9449b)), closes [#6407](https://github.com/payloadcms/payload/issues/6407)
## [2.18.2](https://github.com/payloadcms/payload/compare/v2.18.1...v2.18.2) (2024-05-17)
### Bug Fixes
* allow focal point when no sizes defined ([#6397](https://github.com/payloadcms/payload/issues/6397)) ([88e113a](https://github.com/payloadcms/payload/commit/88e113a5452300434f690186d10ea02ab159ffc3))
## [2.18.1](https://github.com/payloadcms/payload/compare/v2.18.0...v2.18.1) (2024-05-16)
### Bug Fixes
* add back explicit crop x and y values ([#6391](https://github.com/payloadcms/payload/issues/6391)) ([e76df32](https://github.com/payloadcms/payload/commit/e76df32f0987cc92dc8d9c693950e650c52576bf))
## [2.18.0](https://github.com/payloadcms/payload/compare/v2.17.0...v2.18.0) (2024-05-16)
### Features
* store focal point on uploads ([#6364](https://github.com/payloadcms/payload/issues/6364)) ([82b88a3](https://github.com/payloadcms/payload/commit/82b88a315ff1d52f0b19a70224d5c600a3a97eb5))
### Bug Fixes
* **db-postgres:** filter with ID not_in AND queries - postgres ([#6358](https://github.com/payloadcms/payload/issues/6358)) ([cc94078](https://github.com/payloadcms/payload/commit/cc940786072c0065f10fdd2893050bddc4595a21)), closes [#5151](https://github.com/payloadcms/payload/issues/5151)
* **richtext-lexical:** upload, relationship and block node insertion fails sometimes ([#6390](https://github.com/payloadcms/payload/issues/6390)) ([48a410e](https://github.com/payloadcms/payload/commit/48a410e294598af9c73577a04f86466248f93da0))
## [2.17.0](https://github.com/payloadcms/payload/compare/v2.16.1...v2.17.0) (2024-05-15)
### Features
* adds misc translations to API view and react select ([#6138](https://github.com/payloadcms/payload/issues/6138)) ([30e535b](https://github.com/payloadcms/payload/commit/30e535b5b929dddead007d8a9adca62808595e2c))
* **richtext-lexical:** remove LexicalBlock, RichTextFieldRequiredEditor and FieldWithRichTextRequiredEditor types ([#6279](https://github.com/payloadcms/payload/issues/6279)) ([9df5ab8](https://github.com/payloadcms/payload/commit/9df5ab8a10a35ad34615d7e4da024f59ff037e0e))
### Bug Fixes
* appends `editDepth` value to `radio` & `checkbox` IDs when inside drawer ([#6181](https://github.com/payloadcms/payload/issues/6181)) ([69c93d3](https://github.com/payloadcms/payload/commit/69c93d3c62394a5cf995a2eaec9a3ab30e0f77af))
* collection labels with locales not working when creating new doc ([#5995](https://github.com/payloadcms/payload/issues/5995)) ([51efe4f](https://github.com/payloadcms/payload/commit/51efe4f39bcaadccb109a2a02a690ca65041ee57))
* safely access cookie header for uploads ([#6367](https://github.com/payloadcms/payload/issues/6367)) ([de92c50](https://github.com/payloadcms/payload/commit/de92c50847640661f915455f8db0029873ddc7ab))
* step-nav breadcrumbs ellipsis ([#6345](https://github.com/payloadcms/payload/issues/6345)) ([d02b1fb](https://github.com/payloadcms/payload/commit/d02b1fb084e636e49122ad55b25b9c49eb761f1c))
*
### ⚠ BREAKING CHANGES
* **richtext-lexical:** remove LexicalBlock, RichTextFieldRequiredEditor and FieldWithRichTextRequiredEditor types (#6279)
## [2.16.1](https://github.com/payloadcms/payload/compare/v2.16.0...v2.16.1) (2024-05-07)
### Features
* **richtext-lexical:** add maxDepth property to various lexical features ([#6250](https://github.com/payloadcms/payload/issues/6250)) ([857b9a4](https://github.com/payloadcms/payload/commit/857b9a4ac3236c740458750f156a3a4274eda210)), closes [#6242](https://github.com/payloadcms/payload/issues/6242)
### Bug Fixes
* **richtext-lexical:** export missing HorizontalRuleFeature ([#6236](https://github.com/payloadcms/payload/issues/6236)) ([f829b08](https://github.com/payloadcms/payload/commit/f829b084ba9649ef596cce4a7bf6ae8c7ccf57e3))
## [2.16.0](https://github.com/payloadcms/payload/compare/v2.15.0...v2.16.0) (2024-05-06)
### Features
* adds disableListColumn, disableListFilter to fields admin props ([#6188](https://github.com/payloadcms/payload/issues/6188)) ([db4aace](https://github.com/payloadcms/payload/commit/db4aacebb801f1cc11ef8732f9f3b78475256641))
### Bug Fixes
* graphql upload relations returning null ([#6233](https://github.com/payloadcms/payload/issues/6233)) ([cac52da](https://github.com/payloadcms/payload/commit/cac52da638a0df4356120a2f61c6aaf25641a5ad))
* hide drag handles when `admin.isSortable: false` ([#6225](https://github.com/payloadcms/payload/issues/6225)) ([622cdb0](https://github.com/payloadcms/payload/commit/622cdb044002b2c3182c3b0432b51befbfb9b979))
* **plugin-form-builder:** hook overrides not working as intended ([#6203](https://github.com/payloadcms/payload/issues/6203)) ([b735d6a](https://github.com/payloadcms/payload/commit/b735d6aa169acca8cb638859d2c8ba43e315f02c))
## [2.15.0](https://github.com/payloadcms/payload/compare/v2.14.2...v2.15.0) (2024-05-03)
### Features
* add isSortable to arrays and blocks ([#5962](https://github.com/payloadcms/payload/issues/5962)) ([5c58bd3](https://github.com/payloadcms/payload/commit/5c58bd322da966fe610959df13dfd49add35a2ef))
* use filterOptions in list relationship filter ([#6156](https://github.com/payloadcms/payload/issues/6156)) ([23f3eb1](https://github.com/payloadcms/payload/commit/23f3eb1cf0b75a4044319d7cd3e5000d5b4e42c4))
### Bug Fixes
* bulk publish from collection list ([#6063](https://github.com/payloadcms/payload/issues/6063)) ([84570e6](https://github.com/payloadcms/payload/commit/84570e6e3bbb81fcae80da92b01bc56d09906072))
* cascade draft arg in nested GraphQL relationship queries ([#6141](https://github.com/payloadcms/payload/issues/6141)) ([a8ac8b4](https://github.com/payloadcms/payload/commit/a8ac8b463349664f3188ae77217f037da72f796b))
* GraphQL nested relationships not respecting req locale ([#6117](https://github.com/payloadcms/payload/issues/6117)) ([3fccd34](https://github.com/payloadcms/payload/commit/3fccd34abe5a332f88f5e950b755cd1d21441fb6))
* hide unusable fields from collection filter select ([#6135](https://github.com/payloadcms/payload/issues/6135)) ([2be5ad0](https://github.com/payloadcms/payload/commit/2be5ad0ebafd1d3c1c0567e2085ccfd593f18271))
* incorrect `localesNotSaved` translation ([#5996](https://github.com/payloadcms/payload/issues/5996)) ([af67749](https://github.com/payloadcms/payload/commit/af67749e49db92e675b63b52190e562468894706))
* **plugin-cloud:** purge cache for all sizes ([#5301](https://github.com/payloadcms/payload/issues/5301)) ([831f1ff](https://github.com/payloadcms/payload/commit/831f1ff5bed7e083cc076e9eb5ff9a2b2f1ed710))
* properly adds `readonly` styles to disabled `radio` fields ([#6176](https://github.com/payloadcms/payload/issues/6176)) ([9b7e62d](https://github.com/payloadcms/payload/commit/9b7e62dc20dca7402c6c68dfb8a5995c211993af))
* resets filter state when param state change within route ([#6169](https://github.com/payloadcms/payload/issues/6169)) ([6e38cc2](https://github.com/payloadcms/payload/commit/6e38cc2bcfb08b608abcb6aac4b4c1f6eea63428))
* **richtext-lexical:** drag and add block handles disappear too quickly for smaller screen sizes. ([#6145](https://github.com/payloadcms/payload/issues/6145)) ([24f6972](https://github.com/payloadcms/payload/commit/24f697219b5071d91a5c37aafb50e2d823b68d4c))
* **richtext-lexical:** floating toolbar caret positioned incorrectly for some line heights ([#6151](https://github.com/payloadcms/payload/issues/6151)) ([36b1f5a](https://github.com/payloadcms/payload/commit/36b1f5a763f782c140e62aa062b4077d6efd0738))
* sanitizes fields in default edit view for drawer content ([#6175](https://github.com/payloadcms/payload/issues/6175)) ([43dab5c](https://github.com/payloadcms/payload/commit/43dab5c7053831a0c71f3a6860113f653cab674f))
* version restoration ([#6039](https://github.com/payloadcms/payload/issues/6039)) ([91bac9c](https://github.com/payloadcms/payload/commit/91bac9c0aa1ff3da052b9c2ad83fa5ac23a16d1d))
## [2.14.2](https://github.com/payloadcms/payload/compare/v2.14.1...v2.14.2) (2024-04-26)

View File

@@ -216,7 +216,7 @@ Example:
{
slug: 'customers',
auth: {
forgotPassword: {
verify: {
// highlight-start
generateEmailSubject: ({ req, user }) => {
return `Hey ${user.email}, reset your password!`;

View File

@@ -49,7 +49,8 @@ export default buildConfig({
{
label: 'Arabic',
code: 'ar',
// opt-in to setting default text-alignment on Input fields to rtl (right-to-left) when current locale is rtl
// opt-in to setting default text-alignment on Input fields to rtl (right-to-left)
// when current locale is rtl
rtl: true,
},
],
@@ -134,13 +135,9 @@ to support localization, you need to specify each field that you would like to l
```js
{
name: 'title',
type
:
'text',
// highlight-start
localized
:
true,
type: 'text',
// highlight-start
localized: true,
// highlight-end
}
```

View File

@@ -20,7 +20,8 @@ The initial request made to Payload will begin a new transaction and attach it t
```ts
const afterChange: CollectionAfterChangeHook = async ({ req }) => {
// because req.transactionID is assigned from Payload and passed through, my-slug will only persist if the entire request is successful
// because req.transactionID is assigned from Payload and passed through,
// my-slug will only persist if the entire request is successful
await req.payload.create({
req,
collection: 'my-slug',
@@ -60,10 +61,44 @@ const afterChange: CollectionAfterChangeHook = async ({ req }) => {
### Direct Transaction Access
When writing your own scripts or custom endpoints, you may wish to have direct control over transactions. This is useful for interacting with your database outside of Payload's local API.
When writing your own scripts or custom endpoints, you may wish to have direct control over transactions. This is useful for interacting with your database in something like a background job, outside the normal request-response flow.
The following functions can be used for managing transactions:
`payload.db.beginTransaction` - Starts a new session and returns a transaction ID for use in other Payload Local API calls.
`payload.db.commitTransaction` - Takes the identifier for the transaction, finalizes any changes.
`payload.db.rollbackTransaction` - Takes the identifier for the transaction, discards any changes.
`payload.db.beginTransaction` - Starts a new session and returns a transaction ID for use in other Payload Local API calls. Note that if your database does not support transactions, this will return `null`.\
`payload.db.commitTransaction` - Takes the identifier for the transaction, finalizes any changes.\
`payload.db.rollbackTransaction` - Takes the identifier for the transaction, discards any changes.
You can then use the transaction ID with Payload's local API by passing it inside the `PayloadRequest` object.
Here is an example for a "background job" function, which utilizes the direct transaction API to make sure it either succeeds completely or gets rolled back in case of an error.
```ts
async function allOrNothingJob() {
const req = {} as PayloadRequest;
req.transactionID = await payload.db.beginTransaction();
try {
await payload.create({
req, // use our manual transaction
collection: 'my-slug',
data: {
some: 'data'
}
});
await payload.create({
req, // use our manual transaction
collection: 'something-else',
data: {
some: 'data'
}
});
console.log('Everything done.');
if (req.transactionID) await payload.db.commitTransaction(req.transactionID);
} catch (e) {
console.error('Oh no, something went wrong!');
if (req.transactionID) await payload.db.rollbackTransaction(req.transactionID);
}
}
```

View File

@@ -0,0 +1,39 @@
---
title: Examples
label: Overview
order: 10
desc:
keywords: example, examples, starter, boilerplate, template, templates
---
Payload provides a vast array of examples to help you get started with your project no matter what you are working on. These examples are designed to be easy to get up and running, and to be easy to understand. They showcase nothing more than the specific features being demonstrated, so you can easily decipher what is going on.
Examples are changing every day, so be sure to check back often to see what new examples have been added. If you have a specific example you would like to see, please feel free to start a new [Discussion](https://github.com/payloadcms/payload/discussions) or open a new [PR](https://github.com/payloadcms/payload/pulls) to add it yourself.
- [Auth](https://github.com/payloadcms/payload/tree/main/examples/auth)
- [Custom Server](https://github.com/payloadcms/payload/tree/main/examples/custom-server)
- [Draft Preview](https://github.com/payloadcms/payload/tree/main/examples/draft-preview)
- [Email](https://github.com/payloadcms/payload/tree/main/examples/email)
- [Form Builder](https://github.com/payloadcms/payload/tree/main/examples/form-builder)
- [Hierarchy](https://github.com/payloadcms/payload/tree/main/examples/hierarchy)
- [Live Preview](https://github.com/payloadcms/payload/tree/main/examples/live-preview)
- [Multi-tenant](https://github.com/payloadcms/payload/tree/main/examples/multi-tenant)
- [Nested Docs](https://github.com/payloadcms/payload/tree/main/examples/nested-docs)
- [Redirects](https://github.com/payloadcms/payload/tree/main/examples/redirects)
- [Tests](https://github.com/payloadcms/payload/tree/main/examples/testing)
- [Virtual Fields](https://github.com/payloadcms/payload/tree/main/examples/virtual-fields)
- [White-label Admin UI](https://github.com/payloadcms/payload/tree/main/examples/whitelabel)
Where necessary, some examples include a front-end. Examples that require a front-end share this folder structure:
```plaintext
example/
├── payload/
├── next-app/
├── next-pages/
├── react-router/
├── vue/
├── svelte/
```
Where `payload` is your Payload project, and the other directories are dedicated to their respective front-end framework. We are adding new examples every day, so if your framework of choice is not yet supported in any particular example, please feel free to start a new [Discussion](https://github.com/payloadcms/payload/discussions) or open a new [PR](https://github.com/payloadcms/payload/pulls) to add it yourself.

View File

@@ -59,6 +59,7 @@ properties:
| Option | Description |
|---------------------------|----------------------------------------------------------------------------------------------------------------------|
| **`initCollapsed`** | Set the initial collapsed state |
| **`isSortable`** | Disable array order sorting by setting this value to `false` |
| **`components.RowLabel`** | Function or React component to be rendered as the label on the array row. Receives `({ data, index, path })` as args |
### Example
@@ -67,6 +68,7 @@ properties:
```ts
import { CollectionConfig } from 'payload/types'
import { RowLabelArgs } from 'payload/dist/admin/components/forms/RowLabel/types'
export const ExampleCollection: CollectionConfig = {
slug: 'example-collection',
@@ -101,7 +103,7 @@ export const ExampleCollection: CollectionConfig = {
],
admin: {
components: {
RowLabel: ({ data, index }) => {
RowLabel: ({ data, index }: RowLabelArgs) => {
return data?.title || `Slide ${String(index).padStart(2, '0')}`
},
},

View File

@@ -58,6 +58,7 @@ properties:
| Option | Description |
|---------------------|---------------------------------|
| **`initCollapsed`** | Set the initial collapsed state |
| **`isSortable`** | Disable block order sorting by setting this value to `false` |
### Block configs

View File

@@ -163,19 +163,21 @@ Example:
In addition to each field's base configuration, you can define specific traits and properties for fields that only have effect on how they are rendered in the Admin panel. The following properties are available for all fields within the `admin` property:
| Option | Description |
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `condition` | You can programmatically show / hide fields based on what other fields are doing. [Click here](#conditional-logic) for more info. |
| `components` | All field components can be completely and easily swapped out for custom components that you define. [Click here](#custom-components) for more info. |
| `description` | Helper text to display with the field to provide more information for the editor user. [Click here](#description) for more info. |
| `position` | Specify if the field should be rendered in the sidebar by defining `position: 'sidebar'`. |
| `width` | Restrict the width of a field. you can pass any string-based value here, be it pixels, percentages, etc. This property is especially useful when fields are nested within a `Row` type where they can be organized horizontally. |
| `style` | Attach raw CSS style properties to the root DOM element of a field. |
| `className` | Attach a CSS class name to the root DOM element of a field. |
| `readOnly` | Setting a field to `readOnly` has no effect on the API whatsoever but disables the admin component's editability to prevent editors from modifying the field's value. |
| `disabled` | If a field is `disabled`, it is completely omitted from the Admin panel. |
| `disableBulkEdit` | Set `disableBulkEdit` to `true` to prevent fields from appearing in the select options when making edits for multiple documents. |
| `hidden` | Setting a field's `hidden` property on its `admin` config will transform it into a `hidden` input type. Its value will still submit with the Admin panel's requests, but the field itself will not be visible to editors. |
| Option | Description |
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `condition` | You can programmatically show / hide fields based on what other fields are doing. [Click here](#conditional-logic) for more info. |
| `components` | All field components can be completely and easily swapped out for custom components that you define. [Click here](#custom-components) for more info. |
| `description` | Helper text to display with the field to provide more information for the editor user. [Click here](#description) for more info. |
| `position` | Specify if the field should be rendered in the sidebar by defining `position: 'sidebar'`. |
| `width` | Restrict the width of a field. you can pass any string-based value here, be it pixels, percentages, etc. This property is especially useful when fields are nested within a `Row` type where they can be organized horizontally. |
| `style` | Attach raw CSS style properties to the root DOM element of a field. |
| `className` | Attach a CSS class name to the root DOM element of a field. |
| `readOnly` | Setting a field to `readOnly` has no effect on the API whatsoever but disables the admin component's editability to prevent editors from modifying the field's value. |
| `disabled` | If a field is `disabled`, it is completely omitted from the Admin panel. |
| `disableBulkEdit` | Set `disableBulkEdit` to `true` to prevent fields from appearing in the select options when making edits for multiple documents. |
| `disableListColumn` | Set `disableListColumn` to `true` to prevent fields from appearing in the list view column selector. |
| `disableListFilter` | Set `disableListFilter` to `true` to prevent fields from appearing in the list view filter options. |
| `hidden` | Setting a field's `hidden` property on its `admin` config will transform it into a `hidden` input type. Its value will still submit with the Admin panel's requests, but the field itself will not be visible to editors. |
### Custom components

View File

@@ -36,7 +36,7 @@ If your Hook simply performs a side-effect, such as updating a CRM, it might be
#### Server-only execution
Payload Hooks are only triggered on the server. You can safely [remove your hooks](/docs/admin/webpack#aliasing-server-only-modules) from your Admin panel's client-side code by customizing the Webpack config, which not only keeps your Admin bundles' filesize small but also ensures that any server-side only code does not cause problems within browser environments.
Payload Hooks are only triggered on the server. You can safely [remove your hooks](/docs/admin/excluding-server-code#aliasing-server-only-modules) from your Admin panel's client-side code by customizing the Webpack config, which not only keeps your Admin bundles' filesize small but also ensures that any server-side only code does not cause problems within browser environments.
## Hook Types

View File

@@ -247,7 +247,7 @@ In the template, we have stubbed out a basic `onInitExtension` file that you can
### Webpack
If any of your files use server only packages such as fs, stripe, nodemailer, etc, they will need to be removed from the browser bundle. To do that, you can [alias the file imports with webpack](https://payloadcms.com/docs/admin/webpack#aliasing-server-only-modules).
If any of your files use server only packages such as fs, stripe, nodemailer, etc, they will need to be removed from the browser bundle. To do that, you can [alias the file imports with webpack](https://payloadcms.com/docs/admin/excluding-server-code#aliasing-server-only-modules).
When files are bundled for the browser, the import paths are essentially crawled to determine what files to include in the bundle. To prevent the server only files from making it into the bundle, we can alias their import paths to a file that can be included in the browser. This will short-circuit the import path crawling and ensure browser only code is bundled.

View File

@@ -203,7 +203,8 @@ const Pages: CollectionConfig = {
editor: lexicalEditor({
features: ({ defaultFeatures }) => [
...defaultFeatures,
// The HTMLConverter Feature is the feature which manages the HTML serializers. If you do not pass any arguments to it, it will use the default serializers.
// The HTMLConverter Feature is the feature which manages the HTML serializers.
// If you do not pass any arguments to it, it will use the default serializers.
HTMLConverterFeature({}),
],
}),

View File

@@ -270,6 +270,10 @@ const serialize = (children) =>
text = <em key={i}>{text}</em>;
}
if (node.text === '') {
text = <br />;
}
// Handle other leaf types here...
return <Fragment key={i}>{text}</Fragment>;

View File

@@ -7,4 +7,4 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf
max_line_length = null
max_line_length = off

View File

@@ -7,4 +7,4 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf
max_line_length = null
max_line_length = off

File diff suppressed because it is too large Load Diff

View File

@@ -7,4 +7,4 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf
max_line_length = null
max_line_length = off

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -7,4 +7,4 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf
max_line_length = null
max_line_length = off

View File

@@ -7,4 +7,4 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf
max_line_length = null
max_line_length = off

View File

@@ -47,7 +47,7 @@
"webpack": "^5.78.0",
"webpack-bundle-analyzer": "^4.8.0",
"webpack-cli": "^4.10.0",
"webpack-dev-middleware": "6.0.1",
"webpack-dev-middleware": "6.1.2",
"webpack-hot-middleware": "^2.25.3"
},
"devDependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "@payloadcms/db-postgres",
"version": "0.8.2",
"version": "0.8.4",
"description": "The officially supported Postgres database adapter for Payload",
"repository": {
"type": "git",

View File

@@ -45,8 +45,7 @@ export async function createVersion<T extends TypeWithID>(
const table = this.tables[tableName]
const relationshipsTable =
this.tables[`_${defaultTableName}${this.versionsSuffix}${this.relationshipsSuffix}`]
const relationshipsTable = this.tables[`${tableName}${this.relationshipsSuffix}`]
if (collection.versions.drafts) {
await db.execute(sql`

View File

@@ -10,8 +10,8 @@ import type { GenericColumn, PostgresAdapter } from '../types'
import type { BuildQueryJoinAliases, BuildQueryJoins } from './buildQuery'
import { buildAndOrConditions } from './buildAndOrConditions'
import { convertPathToJSONTraversal } from './createJSONQuery/convertPathToJSONTraversal'
import { createJSONQuery } from './createJSONQuery'
import { convertPathToJSONTraversal } from './createJSONQuery/convertPathToJSONTraversal'
import { getTableColumnFromPath } from './getTableColumnFromPath'
import { operatorMap } from './operatorMap'
import { sanitizeQueryValue } from './sanitizeQueryValue'
@@ -71,7 +71,7 @@ export async function parseParams({
// So we need to loop on keys again here to handle each operator independently
const pathOperators = where[relationOrPath]
if (typeof pathOperators === 'object') {
for (const operator of Object.keys(pathOperators)) {
for (let operator of Object.keys(pathOperators)) {
if (validOperators.includes(operator as Operator)) {
const val = where[relationOrPath][operator]
const {
@@ -157,6 +157,13 @@ export async function parseParams({
break
}
if (
operator === 'like' &&
(field.type === 'number' || table[columnName].columnType === 'PgUUID')
) {
operator = 'equals'
}
if (operator === 'like') {
constraints.push(
and(...val.split(' ').map((word) => ilike(table[columnName], `%${word}%`))),
@@ -195,10 +202,10 @@ export async function parseParams({
operator === 'not_in'
) {
constraints.push(
sql`${notInArray(table[columnName], queryValue)} OR
sql`(${notInArray(table[columnName], queryValue)} OR
${table[columnName]}
IS
NULL`,
NULL)`,
)
break

View File

@@ -1,6 +1,6 @@
{
"name": "payload",
"version": "2.14.2",
"version": "2.18.3",
"description": "Node, React and MongoDB Headless CMS and Application Framework",
"license": "MIT",
"main": "./dist/index.js",

View File

@@ -19,6 +19,7 @@ import { ConfigProvider } from './components/utilities/Config'
import { CustomProvider } from './components/utilities/CustomProvider'
import { DocumentEventsProvider } from './components/utilities/DocumentEvents'
import { I18n } from './components/utilities/I18n'
import { LanguageWrap } from './components/utilities/LanguageWrap'
import { LoadingOverlayProvider } from './components/utilities/LoadingOverlay'
import { LocaleProvider } from './components/utilities/Locale'
import { PreferencesProvider } from './components/utilities/Preferences'
@@ -46,21 +47,23 @@ const Root = ({ config: incomingConfig }: { config?: SanitizedConfig }) => {
<AuthProvider>
<PreferencesProvider>
<ThemeProvider>
<SearchParamsProvider>
<LocaleProvider>
<StepNavProvider>
<LoadingOverlayProvider>
<DocumentEventsProvider>
<NavProvider>
<CustomProvider>
<Routes />
</CustomProvider>
</NavProvider>
</DocumentEventsProvider>
</LoadingOverlayProvider>
</StepNavProvider>
</LocaleProvider>
</SearchParamsProvider>
<LanguageWrap>
<SearchParamsProvider>
<LocaleProvider>
<StepNavProvider>
<LoadingOverlayProvider>
<DocumentEventsProvider>
<NavProvider>
<CustomProvider>
<Routes />
</CustomProvider>
</NavProvider>
</DocumentEventsProvider>
</LoadingOverlayProvider>
</StepNavProvider>
</LocaleProvider>
</SearchParamsProvider>
</LanguageWrap>
</ThemeProvider>
<ModalContainer />
</PreferencesProvider>

View File

@@ -19,6 +19,7 @@ export const ArrayAction: React.FC<Props> = ({
duplicateRow,
hasMaxRows,
index,
isSortable,
moveRow,
removeRow,
rowCount,
@@ -33,7 +34,7 @@ export const ArrayAction: React.FC<Props> = ({
render={({ close }) => {
return (
<PopupList.ButtonGroup buttonSize="small">
{index !== 0 && (
{isSortable && index !== 0 && (
<PopupList.Button
className={`${baseClass}__action ${baseClass}__move-up`}
onClick={() => {
@@ -47,7 +48,7 @@ export const ArrayAction: React.FC<Props> = ({
{t('moveUp')}
</PopupList.Button>
)}
{index < rowCount - 1 && (
{isSortable && index < rowCount - 1 && (
<PopupList.Button
className={`${baseClass}__action`}
onClick={() => {

View File

@@ -3,6 +3,7 @@ export type Props = {
duplicateRow: (current: number) => void
hasMaxRows: boolean
index: number
isSortable: boolean
moveRow: (from: number, to: number) => void
removeRow: (index: number) => void
rowCount: number

View File

@@ -15,7 +15,7 @@ import './index.scss'
const baseClass = 'column-selector'
const ColumnSelector: React.FC<Props> = (props) => {
const { collection } = props
const { slug } = props
const { columns, moveColumn, toggleColumn } = useTableColumns()
@@ -53,7 +53,7 @@ const ColumnSelector: React.FC<Props> = (props) => {
draggable
icon={active ? <X /> : <Plus />}
id={accessor}
key={`${collection.slug}-${col.name || i}${editDepth ? `-${editDepth}-` : ''}${uuid}`}
key={`${slug}-${col.name || i}${editDepth ? `-${editDepth}-` : ''}${uuid}`}
onClick={() => {
toggleColumn(accessor)
}}

View File

@@ -1,5 +1,5 @@
import type { SanitizedCollectionConfig } from '../../../../collections/config/types'
export type Props = {
collection: SanitizedCollectionConfig
slug: SanitizedCollectionConfig['slug']
}

View File

@@ -5,6 +5,7 @@ import type { CollectionPermission, GlobalPermission } from '../../../../auth'
import type { SanitizedCollectionConfig } from '../../../../collections/config/types'
import type { SanitizedGlobalConfig } from '../../../../globals/config/types'
import { getTranslation } from '../../../../utilities/getTranslation'
import { formatDate } from '../../../utilities/formatDate'
import { useConfig } from '../../utilities/Config'
import { useDocumentInfo } from '../../utilities/DocumentInfo'
@@ -63,6 +64,12 @@ export const DocumentControls: React.FC<{
collection && id && !disableActions && (hasCreatePermission || hasDeletePermission),
)
const collectionLabel = () => {
const label = collection?.labels?.singular
if (!label) return t('document')
return typeof label === 'string' ? label : getTranslation(label, i18n)
}
return (
<Gutter className={baseClass}>
<div className={`${baseClass}__wrapper`}>
@@ -71,12 +78,7 @@ export const DocumentControls: React.FC<{
{collection && !isEditing && !isAccountView && (
<li className={`${baseClass}__list-item`}>
<p className={`${baseClass}__value`}>
{t('creatingNewLabel', {
label:
typeof collection?.labels?.singular === 'string'
? collection.labels.singular
: t('document'),
})}
{t('creatingNewLabel', { label: collectionLabel() })}
</p>
</li>
)}

View File

@@ -139,7 +139,7 @@ const Duplicate: React.FC<Props> = ({ id, slug, collection }) => {
if (localeErrors.length > 0) {
toast.error(
`
${t('error:localesNotSaved', { count: localeErrors.length })}
${t('error:localesNotSaved_other', { count: localeErrors.length })}
${localeErrors.join(', ')}
`,
{ autoClose: 5000 },

View File

@@ -32,7 +32,7 @@ export const EditUpload: React.FC<{
imageCacheTag?: string
showCrop?: boolean
showFocalPoint?: boolean
}> = ({ fileName, fileSrc, imageCacheTag, showCrop, showFocalPoint }) => {
}> = ({ doc, fileName, fileSrc, imageCacheTag, showCrop, showFocalPoint }) => {
const { closeModal } = useModal()
const { t } = useTranslation(['general', 'upload'])
const { formQueryParams, setFormQueryParams } = useFormQueryParams()
@@ -45,10 +45,11 @@ export const EditUpload: React.FC<{
y: uploadEdits?.crop?.y || 0,
})
const [pointPosition, setPointPosition] = useState<{ x: number; y: number }>({
x: uploadEdits?.focalPoint?.x || 50,
y: uploadEdits?.focalPoint?.y || 50,
const [focalPosition, setFocalPosition] = useState<{ x: number; y: number }>({
x: uploadEdits?.focalPoint?.x || doc.focalX || 50,
y: uploadEdits?.focalPoint?.y || doc.focalY || 50,
})
const [checkBounds, setCheckBounds] = useState<boolean>(false)
const [originalHeight, setOriginalHeight] = useState<number>(0)
const [originalWidth, setOriginalWidth] = useState<number>(0)
@@ -72,10 +73,16 @@ export const EditUpload: React.FC<{
})
}
const fineTuneFocalPoint = ({ coordinate, value }: { coordinate: 'x' | 'y'; value: string }) => {
const fineTuneFocalPosition = ({
coordinate,
value,
}: {
coordinate: 'x' | 'y'
value: string
}) => {
const intValue = parseInt(value)
if (intValue >= 0 && intValue <= 100) {
setPointPosition((prevPosition) => ({ ...prevPosition, [coordinate]: intValue }))
setFocalPosition((prevPosition) => ({ ...prevPosition, [coordinate]: intValue }))
}
}
@@ -84,14 +91,14 @@ export const EditUpload: React.FC<{
...formQueryParams,
uploadEdits: {
crop: crop || undefined,
focalPoint: pointPosition ? pointPosition : undefined,
focalPoint: focalPosition ? focalPosition : undefined,
},
})
closeModal(editDrawerSlug)
}
const onDragEnd = React.useCallback(({ x, y }) => {
setPointPosition({ x, y })
setFocalPosition({ x, y })
setCheckBounds(false)
}, [])
@@ -104,7 +111,7 @@ export const EditUpload: React.FC<{
((boundsRect.left - containerRect.left + boundsRect.width / 2) / containerRect.width) * 100
const yCenter =
((boundsRect.top - containerRect.top + boundsRect.height / 2) / containerRect.height) * 100
setPointPosition({ x: xCenter, y: yCenter })
setFocalPosition({ x: xCenter, y: yCenter })
}
const fileSrcToUse = imageCacheTag ? `${fileSrc}?${imageCacheTag}` : fileSrc
@@ -180,7 +187,7 @@ export const EditUpload: React.FC<{
checkBounds={showCrop ? checkBounds : false}
className={`${baseClass}__focalPoint`}
containerRef={focalWrapRef}
initialPosition={pointPosition}
initialPosition={focalPosition}
onDragEnd={onDragEnd}
setCheckBounds={showCrop ? setCheckBounds : false}
>
@@ -251,13 +258,13 @@ export const EditUpload: React.FC<{
<div className={`${baseClass}__inputsWrap`}>
<Input
name="X %"
onChange={(value) => fineTuneFocalPoint({ coordinate: 'x', value })}
value={pointPosition.x.toFixed(0)}
onChange={(value) => fineTuneFocalPosition({ coordinate: 'x', value })}
value={focalPosition.x.toFixed(0)}
/>
<Input
name="Y %"
onChange={(value) => fineTuneFocalPoint({ coordinate: 'y', value })}
value={pointPosition.y.toFixed(0)}
onChange={(value) => fineTuneFocalPosition({ coordinate: 'y', value })}
value={focalPosition.y.toFixed(0)}
/>
</div>
</div>

View File

@@ -9,7 +9,6 @@ import { fieldAffectsData } from '../../../../fields/config/types'
import { getTranslation } from '../../../../utilities/getTranslation'
import Chevron from '../../icons/Chevron'
import { useSearchParams } from '../../utilities/SearchParams'
import Button from '../Button'
import ColumnSelector from '../ColumnSelector'
import DeleteMany from '../DeleteMany'
import EditMany from '../EditMany'
@@ -50,6 +49,8 @@ export const ListControls: React.FC<Props> = (props) => {
const params = useSearchParams()
const shouldInitializeWhereOpened = validateWhereQuery(params?.where)
const hasWhereParam = React.useRef(Boolean(params?.where))
const [textFieldsToBeSearched, setFieldsToBeSearched] = useState(
getTextFieldsToBeSearched(listSearchableFields, fields),
)
@@ -65,6 +66,15 @@ export const ListControls: React.FC<Props> = (props) => {
setFieldsToBeSearched(getTextFieldsToBeSearched(listSearchableFields, fields))
}, [listSearchableFields, fields])
React.useEffect(() => {
if (hasWhereParam.current && !params?.where) {
setVisibleDrawer(undefined)
hasWhereParam.current = false
} else if (params?.where) {
hasWhereParam.current = true
}
}, [setVisibleDrawer, params?.where])
return (
<div className={baseClass}>
<div className={`${baseClass}__wrap`}>
@@ -136,7 +146,7 @@ export const ListControls: React.FC<Props> = (props) => {
height={visibleDrawer === 'columns' ? 'auto' : 0}
id={`${baseClass}-columns`}
>
<ColumnSelector collection={collection} />
<ColumnSelector slug={collection.slug} />
</AnimateHeight>
)}
<AnimateHeight
@@ -147,6 +157,7 @@ export const ListControls: React.FC<Props> = (props) => {
<WhereBuilder
collection={collection}
handleChange={handleWhereChange}
key={String(hasWhereParam.current && !params?.where)}
modifySearchQuery={modifySearchQuery}
/>
</AnimateHeight>

View File

@@ -24,7 +24,6 @@ export const LoadingOverlay: React.FC<Props> = ({
show = true,
}) => {
const { t } = useTranslation('general')
return (
<div
className={[
@@ -59,25 +58,25 @@ type UseLoadingOverlayToggleT = {
}
export const LoadingOverlayToggle: React.FC<UseLoadingOverlayToggleT> = ({
name: key,
type = 'fullscreen',
loadingText,
show,
type = 'fullscreen',
}) => {
const { toggleLoadingOverlay } = useLoadingOverlay()
React.useEffect(() => {
toggleLoadingOverlay({
type,
isLoading: show,
key,
loadingText: loadingText || undefined,
type,
})
return () => {
toggleLoadingOverlay({
type,
isLoading: false,
key,
type,
})
}
}, [show, toggleLoadingOverlay, key, type, loadingText])
@@ -94,10 +93,10 @@ type FormLoadingOverlayToggleT = {
}
export const FormLoadingOverlayToggle: React.FC<FormLoadingOverlayToggleT> = ({
name,
type = 'fullscreen',
action,
formIsLoading = false,
loadingSuffix,
type = 'fullscreen',
}) => {
const isProcessing = useFormProcessing()
const { i18n, t } = useTranslation('general')

View File

@@ -18,7 +18,7 @@ import './index.scss'
const baseClass = 'publish-many'
const PublishMany: React.FC<Props> = (props) => {
const { collection: { labels: { plural }, slug, versions } = {}, resetParams } = props
const { collection: { slug, labels: { plural }, versions } = {}, resetParams } = props
const {
routes: { api },
@@ -27,7 +27,7 @@ const PublishMany: React.FC<Props> = (props) => {
const { permissions } = useAuth()
const { toggleModal } = useModal()
const { i18n, t } = useTranslation('version')
const { count, getQueryParams, selectAll } = useSelection()
const { getQueryParams, selectAll } = useSelection()
const [submitted, setSubmitted] = useState(false)
const collectionPermissions = permissions?.collections?.[slug]
@@ -41,9 +41,11 @@ const PublishMany: React.FC<Props> = (props) => {
const handlePublish = useCallback(() => {
setSubmitted(true)
requests
void requests
.patch(
`${serverURL}${api}/${slug}${getQueryParams({ _status: { not_equals: 'published' } })}`,
`${serverURL}${api}/${slug}${getQueryParams({
_status: { not_equals: 'published' },
})}&draft=true`,
{
body: JSON.stringify({
_status: 'published',

View File

@@ -40,7 +40,7 @@ const SelectAdapter: React.FC<ReactSelectAdapterProps> = (props) => {
isCreatable,
isLoading,
isSearchable = true,
noOptionsMessage,
noOptionsMessage = () => t('general:noOptions'),
numberOnly = false,
onChange,
onMenuOpen,
@@ -50,6 +50,8 @@ const SelectAdapter: React.FC<ReactSelectAdapterProps> = (props) => {
value,
} = props
const loadingMessage = () => t('general:loading') + '...'
const classes = [className, 'react-select', showError && 'react-select--error']
.filter(Boolean)
.join(' ')
@@ -79,6 +81,7 @@ const SelectAdapter: React.FC<ReactSelectAdapterProps> = (props) => {
isClearable={isClearable}
isDisabled={disabled}
isSearchable={isSearchable}
loadingMessage={loadingMessage}
menuPlacement="auto"
noOptionsMessage={noOptionsMessage}
onChange={onChange}
@@ -148,6 +151,7 @@ const SelectAdapter: React.FC<ReactSelectAdapterProps> = (props) => {
isClearable={isClearable}
isDisabled={disabled}
isSearchable={isSearchable}
loadingMessage={loadingMessage}
menuPlacement="auto"
noOptionsMessage={noOptionsMessage}
onChange={onChange}

View File

@@ -2,9 +2,10 @@ import React, { useRef } from 'react'
import { useTranslation } from 'react-i18next'
import useHotkey from '../../../hooks/useHotkey'
import { useForm } from '../../forms/Form/context'
import { useForm, useFormModified } from '../../forms/Form/context'
import FormSubmit from '../../forms/Submit'
import { useEditDepth } from '../../utilities/EditDepth'
import { useOperation } from '../../utilities/OperationProvider'
import RenderCustomComponent from '../../utilities/RenderCustomComponent'
export type CustomSaveButtonProps = React.ComponentType<
@@ -20,17 +21,26 @@ type DefaultSaveButtonProps = {
const DefaultSaveButton: React.FC<DefaultSaveButtonProps> = ({ label, save }) => {
const ref = useRef<HTMLButtonElement>(null)
const editDepth = useEditDepth()
const operation = useOperation()
const modified = useFormModified()
const forceDisable = operation === 'update' && !modified
useHotkey({ cmdCtrlKey: true, editDepth, keyCodes: ['s'] }, (e) => {
e.preventDefault()
e.stopPropagation()
if (forceDisable) {
return
}
if (ref?.current) {
ref.current.click()
}
})
return (
<FormSubmit buttonId="action-save" onClick={save} ref={ref} type="button" size="small">
<FormSubmit buttonId="action-save" onClick={save} ref={ref} size="small" type="button">
{label}
</FormSubmit>
)

View File

@@ -8,6 +8,7 @@ import { useConfig } from '../../utilities/Config'
import { useDocumentInfo } from '../../utilities/DocumentInfo'
import { useEditDepth } from '../../utilities/EditDepth'
import { useLocale } from '../../utilities/Locale'
import { useOperation } from '../../utilities/OperationProvider'
import RenderCustomComponent from '../../utilities/RenderCustomComponent'
const baseClass = 'save-draft'
@@ -31,12 +32,13 @@ const DefaultSaveDraftButton: React.FC<DefaultSaveDraftButtonProps> = ({
const editDepth = useEditDepth()
useHotkey({ cmdCtrlKey: true, editDepth, keyCodes: ['s'] }, (e) => {
e.preventDefault()
e.stopPropagation()
if (disabled) {
return
}
e.preventDefault()
e.stopPropagation()
if (ref?.current) {
ref.current.click()
}
@@ -68,11 +70,13 @@ export const SaveDraft: React.FC<Props> = ({ CustomComponent }) => {
} = useConfig()
const { submit } = useForm()
const { id, collection, global } = useDocumentInfo()
const operation = useOperation()
const modified = useFormModified()
const { code: locale } = useLocale()
const { t } = useTranslation('version')
const canSaveDraft = modified
const canSaveDraft = operation === 'update' && modified
const saveDraft = useCallback(async () => {
const search = `?locale=${locale}&depth=0&fallback-locale=null&draft=true`

View File

@@ -2,6 +2,7 @@
.step-nav {
display: flex;
align-items: center;
gap: calc(var(--base) / 2);
&::after {
@@ -56,8 +57,6 @@
}
span {
display: flex;
align-items: center;
max-width: base(8);
text-overflow: ellipsis;
overflow: hidden;

View File

@@ -9,12 +9,12 @@ import React, {
} from 'react'
import type { SanitizedCollectionConfig } from '../../../../collections/config/types'
import type { Field } from '../../../../fields/config/types'
import type { Props as CellProps } from '../../views/collections/List/Cell/types'
import type { ListPreferences } from '../../views/collections/List/types'
import type { Column } from '../Table/types'
import type { Action } from './columnReducer'
import { type Field, fieldHasSubFields } from '../../../../fields/config/types'
import { usePreferences } from '../../utilities/Preferences'
import formatFields from '../../views/collections/List/formatFields'
import buildColumns from './buildColumns'
@@ -33,6 +33,19 @@ export const TableColumnContext = createContext<ITableColumns>({} as ITableColum
export const useTableColumns = (): ITableColumns => useContext(TableColumnContext)
const filterTableFields = (fields: Field[]): Field[] => {
return fields.reduce((acc, field) => {
if (fieldHasSubFields(field)) {
field = {
...field,
fields: filterTableFields(field.fields),
}
}
if (!field.admin?.disableListColumn) acc.push(field)
return acc
}, [])
}
export const TableColumnsProvider: React.FC<{
cellProps?: Partial<CellProps>[]
children: React.ReactNode
@@ -50,9 +63,10 @@ export const TableColumnsProvider: React.FC<{
const hasInitialized = useRef(false)
const { getPreference, setPreference } = usePreferences()
const [formattedFields] = useState<Field[]>(() => formatFields(collection))
const filteredFields = filterTableFields(formattedFields)
const [tableColumns, dispatchTableColumns] = useReducer(columnReducer, {}, () => {
const initialColumns = getInitialColumnState(formattedFields, useAsTitle, defaultColumns)
const initialColumns = getInitialColumnState(filteredFields, useAsTitle, defaultColumns)
return buildColumns({
cellProps,
@@ -77,13 +91,14 @@ export const TableColumnsProvider: React.FC<{
const currentPreferences = await getPreference<ListPreferences>(preferenceKey)
prevCollection.current = collection.slug
const initialColumns = getInitialColumnState(formattedFields, useAsTitle, defaultColumns)
const initialColumns = getInitialColumnState(filteredFields, useAsTitle, defaultColumns)
const newCols = currentPreferences?.columns || initialColumns
dispatchTableColumns({
type: 'set',
payload: {
cellProps,
collection: { ...collection, fields: formatFields(collection) },
collection: { ...collection, fields: filteredFields },
columns: newCols.map((column) => {
// 'string' is for backwards compatibility
// the preference used to be stored as an array of strings
@@ -96,14 +111,13 @@ export const TableColumnsProvider: React.FC<{
return column
}),
},
type: 'set',
})
hasInitialized.current = true
}
}
sync()
void sync()
}, [
preferenceKey,
setPreference,
@@ -113,7 +127,7 @@ export const TableColumnsProvider: React.FC<{
defaultColumns,
collection,
cellProps,
formattedFields,
filteredFields,
])
// /////////////////////////////////////
@@ -133,6 +147,7 @@ export const TableColumnsProvider: React.FC<{
const setActiveColumns = useCallback(
(columns: string[]) => {
dispatchTableColumns({
type: 'set',
payload: {
// onSelect,
cellProps,
@@ -142,7 +157,6 @@ export const TableColumnsProvider: React.FC<{
active: true,
})),
},
type: 'set',
})
},
[collection, cellProps],
@@ -153,13 +167,13 @@ export const TableColumnsProvider: React.FC<{
const { fromIndex, toIndex } = args
dispatchTableColumns({
type: 'move',
payload: {
cellProps,
collection: { ...collection, fields: formatFields(collection) },
fromIndex,
toIndex,
},
type: 'move',
})
},
[collection, cellProps],
@@ -168,12 +182,12 @@ export const TableColumnsProvider: React.FC<{
const toggleColumn = useCallback(
(column: string) => {
dispatchTableColumns({
type: 'toggle',
payload: {
cellProps,
collection: { ...collection, fields: formatFields(collection) },
column,
},
type: 'toggle',
})
},
[collection, cellProps],

View File

@@ -1,3 +1,6 @@
import type { Where } from 'payload/types'
import qs from 'qs'
import React, { useCallback, useEffect, useReducer, useState } from 'react'
import { useTranslation } from 'react-i18next'
@@ -6,6 +9,7 @@ import type { Option } from '../../../ReactSelect/types'
import type { GetResults, Props, ValueWithRelation } from './types'
import useDebounce from '../../../../../hooks/useDebounce'
import { useAuth } from '../../../../utilities/Auth'
import { useConfig } from '../../../../utilities/Config'
import ReactSelect from '../../../ReactSelect'
import './index.scss'
@@ -16,7 +20,15 @@ const baseClass = 'condition-value-relationship'
const maxResultsPerRequest = 10
const RelationshipField: React.FC<Props> = (props) => {
const { admin: { isSortable } = {}, disabled, hasMany, onChange, relationTo, value } = props
const {
admin: { isSortable } = {},
disabled,
filterOptions,
hasMany,
onChange,
relationTo,
value,
} = props
const {
collections,
@@ -33,11 +45,12 @@ const RelationshipField: React.FC<Props> = (props) => {
const [hasLoadedFirstOptions, setHasLoadedFirstOptions] = useState(false)
const debouncedSearch = useDebounce(search, 300)
const { i18n, t } = useTranslation('general')
const { user } = useAuth()
const addOptions = useCallback(
(data, relation) => {
const collection = collections.find((coll) => coll.slug === relation)
dispatchOptions({ collection, data, hasMultipleRelations, i18n, relation, type: 'ADD' })
dispatchOptions({ type: 'ADD', collection, data, hasMultipleRelations, i18n, relation })
},
[collections, hasMultipleRelations, i18n],
)
@@ -61,23 +74,66 @@ const RelationshipField: React.FC<Props> = (props) => {
let resultsFetched = 0
if (!errorLoading) {
relationsToFetch.reduce(async (priorRelation, relation) => {
void relationsToFetch.reduce(async (priorRelation, relation) => {
await priorRelation
if (resultsFetched < 10) {
const search: Record<string, unknown> & { where: Where } = {
depth: 0,
limit: maxResultsPerRequest,
page: lastLoadedPageToUse,
where: { and: [] },
}
const collection = collections.find((coll) => coll.slug === relation)
const fieldToSearch = collection?.admin?.useAsTitle || 'id'
const searchParam = searchArg ? `&where[${fieldToSearch}][like]=${searchArg}` : ''
const response = await fetch(
`${serverURL}${api}/${relation}?limit=${maxResultsPerRequest}&page=${lastLoadedPageToUse}&depth=0${searchParam}`,
{
credentials: 'include',
headers: {
'Accept-Language': i18n.language,
// add search arg to where object
if (searchArg) {
search.where.and.push({
[fieldToSearch]: {
like: searchArg,
},
})
}
// call the filterOptions function if it exists passing in the collection
if (filterOptions) {
const optionFilter =
typeof filterOptions === 'function'
? await filterOptions({
// data and siblingData are empty since we cannot fetch with the values covering the
// entire list this limitation means that filterOptions functions using a document's
// data are unsupported in the whereBuilder
id: undefined,
data: {},
relationTo: collection.slug,
siblingData: {},
user,
})
: filterOptions
if (typeof optionFilter === 'object') {
search.where.and.push(optionFilter)
}
if (optionFilter === false) {
// no options will be returned
setLastFullyLoadedRelation(relations.indexOf(relation))
// If there are more relations to search, need to reset lastLoadedPage to 1
// both locally within function and state
if (relations.indexOf(relation) + 1 < relations.length) {
lastLoadedPageToUse = 1
}
return
}
}
if (search.where.and.length === 0) {
delete search.where
}
const response = await fetch(`${serverURL}${api}/${relation}?${qs.stringify(search)}`, {
credentials: 'include',
headers: {
'Accept-Language': i18n.language,
},
)
})
if (response.ok) {
const data: PaginatedDocs = await response.json()
@@ -103,7 +159,18 @@ const RelationshipField: React.FC<Props> = (props) => {
}, Promise.resolve())
}
},
[i18n, relationTo, errorLoading, collections, serverURL, api, addOptions, t],
[
relationTo,
errorLoading,
collections,
filterOptions,
serverURL,
api,
i18n.language,
user,
addOptions,
t,
],
)
const findOptionsByValue = useCallback((): Option | Option[] => {

View File

@@ -52,9 +52,9 @@ const Condition: React.FC<Props> = (props) => {
useEffect(() => {
dispatch({
type: 'update',
andIndex,
orIndex,
type: 'update',
value: debouncedValue || '',
})
}, [debouncedValue, dispatch, orIndex, andIndex])
@@ -80,10 +80,10 @@ const Condition: React.FC<Props> = (props) => {
isClearable={false}
onChange={(field) => {
dispatch({
andIndex: andIndex,
field: field?.value,
orIndex: orIndex,
type: 'update',
andIndex,
field: field?.value,
orIndex,
})
}}
options={fields}
@@ -96,10 +96,10 @@ const Condition: React.FC<Props> = (props) => {
isClearable={false}
onChange={(operator) => {
dispatch({
type: 'update',
andIndex,
operator: operator.value,
orIndex,
type: 'update',
})
setInternalOperatorField(operator.value)
}}
@@ -134,9 +134,9 @@ const Condition: React.FC<Props> = (props) => {
iconStyle="with-border"
onClick={() =>
dispatch({
type: 'remove',
andIndex,
orIndex,
type: 'remove',
})
}
round
@@ -148,11 +148,11 @@ const Condition: React.FC<Props> = (props) => {
iconStyle="with-border"
onClick={() =>
dispatch({
type: 'add',
andIndex: andIndex + 1,
field: fields[0].value,
orIndex,
relation: 'and',
type: 'add',
})
}
round

View File

@@ -32,34 +32,38 @@ const reduceFields = (fields, i18n) =>
} else {
operators = fieldTypes[field.type].operators
}
}
const operatorKeys = new Set()
const filteredOperators = operators.reduce((acc, operator) => {
if (!operatorKeys.has(operator.value)) {
operatorKeys.add(operator.value)
return [
...acc,
{
...operator,
label: i18n.t(`operators:${operator.label}`),
},
]
const operatorKeys = new Set()
const filteredOperators = operators.reduce((acc, operator) => {
if (!operatorKeys.has(operator.value)) {
operatorKeys.add(operator.value)
return [
...acc,
{
...operator,
label: i18n.t(`operators:${operator.label}`),
},
]
}
return acc
}, [])
const formattedField = {
label: getTranslation(field.label || field.name, i18n),
value: field.name,
...fieldTypes[field.type],
operators: filteredOperators,
props: {
...field,
},
}
return acc
}, [])
const formattedField = {
label: getTranslation(field.label || field.name, i18n),
value: field.name,
...fieldTypes[field.type],
operators: filteredOperators,
props: {
...field,
},
if (field.admin?.disableListFilter) return reduced
return [...reduced, formattedField]
}
return [...reduced, formattedField]
return reduced
}, [])
/**

View File

@@ -26,6 +26,7 @@ type ArrayRowProps = UseDraggableSortableReturn &
duplicateRow: (rowIndex: number) => void
forceRender?: boolean
hasMaxRows?: boolean
isSortable: boolean
moveRow: (fromIndex: number, toIndex: number) => void
readOnly?: boolean
removeRow: (rowIndex: number) => void
@@ -44,6 +45,7 @@ export const ArrayRow: React.FC<ArrayRowProps> = ({
forceRender = false,
hasMaxRows,
indexPath,
isSortable,
labels,
listeners,
moveRow,
@@ -94,6 +96,7 @@ export const ArrayRow: React.FC<ArrayRowProps> = ({
duplicateRow={duplicateRow}
hasMaxRows={hasMaxRows}
index={rowIndex}
isSortable={isSortable}
moveRow={moveRow}
removeRow={removeRow}
rowCount={rowCount}
@@ -103,11 +106,15 @@ export const ArrayRow: React.FC<ArrayRowProps> = ({
className={classNames}
collapsed={row.collapsed}
collapsibleStyle={fieldHasErrors ? 'error' : 'default'}
dragHandleProps={{
id: row.id,
attributes,
listeners,
}}
dragHandleProps={
isSortable
? {
id: row.id,
attributes,
listeners,
}
: undefined
}
header={
<div className={`${baseClass}__row-header`}>
<RowLabel

View File

@@ -29,7 +29,7 @@ const baseClass = 'array-field'
const ArrayFieldType: React.FC<Props> = (props) => {
const {
name,
admin: { className, components, condition, description, readOnly },
admin: { className, components, condition, description, isSortable = true, readOnly },
fieldTypes,
fields,
forceRender = false,
@@ -113,7 +113,7 @@ const ArrayFieldType: React.FC<Props> = (props) => {
const duplicateRow = useCallback(
(rowIndex: number) => {
dispatchFields({ path, rowIndex, type: 'DUPLICATE_ROW' })
dispatchFields({ type: 'DUPLICATE_ROW', path, rowIndex })
setModified(true)
setTimeout(() => {
@@ -133,7 +133,7 @@ const ArrayFieldType: React.FC<Props> = (props) => {
const moveRow = useCallback(
(moveFromIndex: number, moveToIndex: number) => {
dispatchFields({ moveFromIndex, moveToIndex, path, type: 'MOVE_ROW' })
dispatchFields({ type: 'MOVE_ROW', moveFromIndex, moveToIndex, path })
setModified(true)
},
[dispatchFields, path, setModified],
@@ -141,14 +141,14 @@ const ArrayFieldType: React.FC<Props> = (props) => {
const toggleCollapseAll = useCallback(
(collapsed: boolean) => {
dispatchFields({ collapsed, path, setDocFieldPreferences, type: 'SET_ALL_ROWS_COLLAPSED' })
dispatchFields({ type: 'SET_ALL_ROWS_COLLAPSED', collapsed, path, setDocFieldPreferences })
},
[dispatchFields, path, setDocFieldPreferences],
)
const setCollapse = useCallback(
(rowID: string, collapsed: boolean) => {
dispatchFields({ collapsed, path, rowID, setDocFieldPreferences, type: 'SET_ROW_COLLAPSED' })
dispatchFields({ type: 'SET_ROW_COLLAPSED', collapsed, path, rowID, setDocFieldPreferences })
},
[dispatchFields, path, setDocFieldPreferences],
)
@@ -227,7 +227,7 @@ const ArrayFieldType: React.FC<Props> = (props) => {
onDragEnd={({ moveFromIndex, moveToIndex }) => moveRow(moveFromIndex, moveToIndex)}
>
{rows.map((row, i) => (
<DraggableSortableItem disabled={readOnly} id={row.id} key={row.id}>
<DraggableSortableItem disabled={readOnly || !isSortable} id={row.id} key={row.id}>
{(draggableSortableItemProps) => (
<ArrayRow
{...draggableSortableItemProps}
@@ -239,6 +239,7 @@ const ArrayFieldType: React.FC<Props> = (props) => {
forceRender={forceRender}
hasMaxRows={hasMaxRows}
indexPath={indexPath}
isSortable={isSortable}
labels={labels}
moveRow={moveRow}
path={path}

View File

@@ -26,6 +26,7 @@ type BlockFieldProps = UseDraggableSortableReturn &
duplicateRow: (rowIndex: number) => void
forceRender?: boolean
hasMaxRows?: boolean
isSortable?: boolean
moveRow: (fromIndex: number, toIndex: number) => void
readOnly: boolean
removeRow: (rowIndex: number) => void
@@ -44,6 +45,7 @@ export const BlockRow: React.FC<BlockFieldProps> = ({
forceRender,
hasMaxRows,
indexPath,
isSortable,
labels,
listeners,
moveRow,
@@ -90,6 +92,7 @@ export const BlockRow: React.FC<BlockFieldProps> = ({
blocks={blocks}
duplicateRow={duplicateRow}
hasMaxRows={hasMaxRows}
isSortable={isSortable}
labels={labels}
moveRow={moveRow}
removeRow={removeRow}
@@ -101,11 +104,15 @@ export const BlockRow: React.FC<BlockFieldProps> = ({
className={classNames}
collapsed={row.collapsed}
collapsibleStyle={fieldHasErrors ? 'error' : 'default'}
dragHandleProps={{
id: row.id,
attributes,
listeners,
}}
dragHandleProps={
isSortable
? {
id: row.id,
attributes,
listeners,
}
: undefined
}
header={
<div className={`${baseClass}__block-header`}>
<span className={`${baseClass}__block-number`}>

View File

@@ -13,6 +13,7 @@ export const RowActions: React.FC<{
blocks: Block[]
duplicateRow: (rowIndex: number, blockType: string) => void
hasMaxRows?: boolean
isSortable?: boolean
labels: Labels
moveRow: (fromIndex: number, toIndex: number) => void
removeRow: (rowIndex: number) => void
@@ -25,6 +26,7 @@ export const RowActions: React.FC<{
blocks,
duplicateRow,
hasMaxRows,
isSortable,
labels,
moveRow,
removeRow,
@@ -59,6 +61,7 @@ export const RowActions: React.FC<{
duplicateRow={() => duplicateRow(rowIndex, blockType)}
hasMaxRows={hasMaxRows}
index={rowIndex}
isSortable={isSortable}
moveRow={moveRow}
removeRow={removeRow}
rowCount={rowCount}

View File

@@ -34,7 +34,7 @@ const BlocksField: React.FC<Props> = (props) => {
const {
name,
admin: { className, condition, description, readOnly },
admin: { className, condition, description, isSortable = true, readOnly },
blocks,
fieldTypes,
forceRender = false,
@@ -230,7 +230,7 @@ const BlocksField: React.FC<Props> = (props) => {
if (blockToRender) {
return (
<DraggableSortableItem disabled={readOnly} id={row.id} key={row.id}>
<DraggableSortableItem disabled={readOnly || !isSortable} id={row.id} key={row.id}>
{(draggableSortableItemProps) => (
<BlockRow
{...draggableSortableItemProps}
@@ -242,6 +242,7 @@ const BlocksField: React.FC<Props> = (props) => {
forceRender={forceRender}
hasMaxRows={hasMaxRows}
indexPath={indexPath}
isSortable={isSortable}
labels={labels}
moveRow={moveRow}
path={path}

View File

@@ -5,6 +5,7 @@ import type { Props } from './types'
import { checkbox } from '../../../../../fields/validations'
import { getTranslation } from '../../../../../utilities/getTranslation'
import { useEditDepth } from '../../../utilities/EditDepth'
import DefaultError from '../../Error'
import FieldDescription from '../../FieldDescription'
import useField from '../../useField'
@@ -41,6 +42,8 @@ const Checkbox: React.FC<Props> = (props) => {
const path = pathFromProps || name
const editDepth = useEditDepth()
const memoizedValidate = useCallback(
(value, options) => {
return validate(value, { ...options, required })
@@ -62,7 +65,7 @@ const Checkbox: React.FC<Props> = (props) => {
}
}, [onChange, readOnly, setValue, value])
const fieldID = `field-${path.replace(/\./g, '__')}`
const fieldID = `field-${path.replace(/\./g, '__')}${editDepth > 1 ? `-${editDepth}` : ''}`
return (
<div

View File

@@ -98,6 +98,7 @@ const RadioGroupInput: React.FC<RadioGroupInputProps> = (props) => {
onChange={readOnly ? undefined : onChange}
option={optionIsObject(option) ? option : { label: option, value: option }}
path={path}
readOnly={readOnly}
/>
</li>
)

View File

@@ -70,31 +70,3 @@
}
}
}
.radio-group--read-only {
.radio-input {
cursor: default;
&__label {
color: var(--theme-elevation-800);
}
&--is-selected {
.radio-input__styled-radio {
&:before {
background-color: var(--theme-elevation-800);
}
}
}
&:not(.radio-input--is-selected) {
&:hover {
.radio-input__styled-radio {
&:before {
opacity: 0;
}
}
}
}
}
}

View File

@@ -4,23 +4,27 @@ import { useTranslation } from 'react-i18next'
import type { Props } from './types'
import { getTranslation } from '../../../../../../utilities/getTranslation'
import { useEditDepth } from '../../../../utilities/EditDepth'
import './index.scss'
const baseClass = 'radio-input'
const RadioInput: React.FC<Props> = (props) => {
const { isSelected, onChange, option, path } = props
const { isSelected, onChange, option, path, readOnly } = props
const { i18n } = useTranslation()
const editDepth = useEditDepth()
const classes = [baseClass, isSelected && `${baseClass}--is-selected`].filter(Boolean).join(' ')
const id = `field-${path}-${option.value}`
const id = `field-${path}-${option.value}${editDepth > 1 ? `-${editDepth}` : ''}`
return (
<label htmlFor={id}>
<div className={classes}>
<input
checked={isSelected}
disabled={readOnly}
id={id}
onChange={() => (typeof onChange === 'function' ? onChange(option.value) : null)}
type="radio"

View File

@@ -8,4 +8,5 @@ export type Props = {
value: string
}
path: string
readOnly?: boolean
}

View File

@@ -29,6 +29,34 @@
}
}
.radio-group--read-only {
.radio-input {
cursor: default;
&__label {
color: var(--theme-elevation-400);
}
&--is-selected {
.radio-input__styled-radio {
&:before {
background-color: var(--theme-elevation-100);
}
}
}
&:not(.radio-input--is-selected) {
&:hover {
.radio-input__styled-radio {
&:before {
opacity: 0;
}
}
}
}
}
}
html[data-theme='light'] {
.radio-group {
&.error {

View File

@@ -55,6 +55,7 @@ const RadioGroup: React.FC<Props> = (props) => {
onChange={readOnly ? undefined : setValue}
options={options}
path={path}
readOnly={readOnly}
required={required}
showError={showError}
style={style}

View File

@@ -146,13 +146,12 @@ const Relationship: React.FC<Props> = (props) => {
if (resultsFetched < 10) {
const collection = collections.find((coll) => coll.slug === relation)
let fieldToSearch = collection?.defaultSort || collection?.admin?.useAsTitle || 'id'
if (!searchArg) {
if (typeof sortOptions === 'string') {
fieldToSearch = sortOptions
} else if (sortOptions?.[relation]) {
fieldToSearch = sortOptions[relation]
}
const fieldToSearch = collection?.admin?.useAsTitle || 'id'
let fieldToSort = collection?.defaultSort || 'id'
if (typeof sortOptions === 'string') {
fieldToSort = sortOptions
} else if (sortOptions?.[relation]) {
fieldToSort = sortOptions[relation]
}
const query: {
@@ -164,7 +163,7 @@ const Relationship: React.FC<Props> = (props) => {
limit: maxResultsPerRequest,
locale,
page: lastLoadedPageToUse,
sort: fieldToSearch,
sort: fieldToSort,
where: {
and: [
{

View File

@@ -51,6 +51,7 @@ type RichTextAdapterBase<
context: RequestContext
currentDepth?: number
depth: number
draft: boolean
field: RichTextField<Value, AdapterProps, ExtraFieldProperties>
findMany: boolean
flattenLocales: boolean

View File

@@ -0,0 +1,14 @@
import React from 'react'
import { useTranslation } from 'react-i18next'
import '../../../scss/app.scss'
const scriptLanguages = ['ar', 'fa']
export const LanguageWrap: React.FC<{ children?: React.ReactNode }> = ({ children }) => {
const { i18n } = useTranslation()
const currentLanguage = i18n?.language
const isScriptLanguage = currentLanguage && scriptLanguages.includes(currentLanguage)
return <div className={isScriptLanguage ? `script-language` : ''}>{children}</div>
}

View File

@@ -27,9 +27,9 @@ const chars = {
const baseClass = 'query-inspector'
const Bracket = ({
type,
comma = false,
position,
type,
}: {
comma?: boolean
position: 'end' | 'start'
@@ -64,9 +64,9 @@ const RecursivelyRenderObjectData = ({
const objectKeys = Object.keys(object)
const objectLength = objectKeys.length
const [isOpen, setIsOpen] = React.useState<boolean>(true)
const isNestedAndEmpty = isEmpty && (parentType === 'object' || parentType === 'array')
return (
<li>
<li className={isNestedAndEmpty ? `${baseClass}__row-line--nested` : ''}>
<button
aria-label="toggle"
className={`${baseClass}__list-toggle ${isEmpty ? `${baseClass}__list-toggle--empty` : ''}`}
@@ -173,7 +173,7 @@ function createURL(url: string) {
export const API: React.FC<EditViewProps> = (props) => {
const { apiURL } = props
const { i18n } = useTranslation()
const { i18n, t } = useTranslation()
const {
localization,
routes: { api },
@@ -262,14 +262,14 @@ export const API: React.FC<EditViewProps> = (props) => {
<CheckboxInput
checked={draft}
id="draft-checkbox"
label="Draft"
label={t('version:draft')}
onToggle={() => setDraft(!draft)}
/>
)}
<CheckboxInput
checked={authenticated}
id="auth-checkbox"
label="Authenticated"
label={t('authentication:authenticated')}
onToggle={() => setAuthenticated(!authenticated)}
/>
</div>
@@ -280,7 +280,7 @@ export const API: React.FC<EditViewProps> = (props) => {
label: locale,
value: locale,
}}
label="Locale"
label={t('general:locale')}
name="locale"
onChange={(e) => setLocale(e.value as string)}
options={localeOptions}
@@ -292,7 +292,7 @@ export const API: React.FC<EditViewProps> = (props) => {
label: depth,
value: depth,
}}
label="Depth"
label={t('general:depth')}
name="depth"
onChange={(e) => setDepth(e.value as string)}
options={[

View File

@@ -66,7 +66,9 @@ const Restore: React.FC<Props> = ({
if (res.status === 200) {
const json = await res.json()
toast.success(json.message)
history.push(redirectURL)
history.push(redirectURL, {
refetchDocumentData: true,
})
} else {
toast.error(t('problemRestoringVersion'))
}

View File

@@ -1,4 +1,4 @@
import React, { Fragment } from 'react'
import React, { Fragment, useState } from 'react'
import { useTranslation } from 'react-i18next'
import type { FieldTypes } from '../../../../forms/field-types'
@@ -12,6 +12,7 @@ import Meta from '../../../../utilities/Meta'
import Auth from '../Auth'
import { SetStepNav } from '../SetStepNav'
import { Upload } from '../Upload'
import formatFields from '../formatFields'
import './index.scss'
const baseClass = 'collection-default-edit'
@@ -37,7 +38,9 @@ export const DefaultCollectionEdit: React.FC<
permissions,
} = props
const { auth, fields, upload } = collection
const { auth, upload } = collection
const [fields] = useState(() => formatFields(collection, isEditing))
const operation = isEditing ? 'update' : 'create'

View File

@@ -116,10 +116,12 @@ export const Upload: React.FC<Props> = (props) => {
const hasImageSizes = collection?.upload?.imageSizes?.length > 0
const hasResizeOptions = Boolean(collection?.upload?.resizeOptions)
// Explicitly check if set to true, default is undefined
const focalPointEnabled = collection?.upload?.focalPoint === true
const { collection: { upload: { crop: showCrop = true, focalPoint = true } } = {} } = props
const showFocalPoint = focalPoint && (hasImageSizes || hasResizeOptions)
const showFocalPoint = focalPoint && (hasImageSizes || hasResizeOptions || focalPointEnabled)
const lastSubmittedTime = submitted ? new Date().toISOString() : null

View File

@@ -50,7 +50,8 @@ const EditView: React.FC<IndexProps> = (props) => {
} = config
const { params: { id } = {} } = useRouteMatch<Record<string, string>>()
const history = useHistory()
const history = useHistory<{ refetchDocumentData?: boolean }>()
const [internalState, setInternalState] = useState<Fields>()
const [updatedAt, setUpdatedAt] = useState<string>()
const { permissions, user } = useAuth()
@@ -58,7 +59,7 @@ const EditView: React.FC<IndexProps> = (props) => {
const { docPermissions, getDocPermissions, getDocPreferences, getVersions } = useDocumentInfo()
const { t } = useTranslation('general')
const [{ data, isError, isLoading: isLoadingData }] = usePayloadAPI(
const [{ data, isError, isLoading: isLoadingData }, { refetchData }] = usePayloadAPI(
isEditing ? `${serverURL}${api}/${collectionSlug}/${id}` : '',
{ initialData: null, initialParams: { depth: 0, draft: 'true', 'fallback-locale': 'null' } },
)
@@ -128,10 +129,16 @@ const EditView: React.FC<IndexProps> = (props) => {
useEffect(() => {
setFormQueryParams((params) => ({
...params,
locale: locale,
locale,
}))
}, [locale])
useEffect(() => {
if (history.location.state?.refetchDocumentData) {
void refetchData()
}
}, [history.location.state?.refetchDocumentData, refetchData])
if (isError) {
return <NotFound marginTop="large" />
}

View File

@@ -1,4 +1,5 @@
import React from 'react'
import { useTranslation } from 'react-i18next'
import type { CheckboxField } from '../../../../../../../../exports/types'
import type { CellComponentProps } from '../../types'
@@ -6,9 +7,13 @@ import type { CellComponentProps } from '../../types'
import './index.scss'
// Handles boolean values
const Checkbox: React.FC<CellComponentProps<CheckboxField>> = ({ data }) => (
<code className="bool-cell">
<span>{JSON.stringify(data)}</span>
</code>
)
const Checkbox: React.FC<CellComponentProps<CheckboxField>> = ({ data }) => {
const { t } = useTranslation('general')
if (typeof data !== 'boolean') return null
return (
<code className="bool-cell">
<span>{t(`${data}`).toLowerCase()}</span>
</code>
)
}
export default Checkbox

View File

@@ -9,11 +9,11 @@ const formatFields = (config: SanitizedCollectionConfig): Field[] => {
const defaultIDField: Field = {
name: 'id',
type: 'text',
admin: {
disableBulkEdit: true,
},
label: 'ID',
type: 'text',
}
const shouldSkipField = (field: Field): boolean =>

View File

@@ -47,13 +47,13 @@ const ListView: React.FC<ListIndexProps> = (props) => {
const {
collection,
collection: {
slug,
admin: {
components: { views: { List: CustomList } = {} } = {},
listSearchableFields,
pagination: { defaultLimit },
},
labels: { plural },
slug,
},
} = props

View File

@@ -1,5 +1,5 @@
import queryString from 'qs'
import { useEffect, useState } from 'react'
import { useCallback, useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { requests } from '../api'
@@ -12,6 +12,7 @@ type Result = [
isLoading: boolean
},
{
refetchData: (abortController?: AbortController) => Promise<void>
setParams: React.Dispatch<unknown>
},
]
@@ -43,49 +44,53 @@ const usePayloadAPI: UsePayloadAPI = (url, options = {}) => {
},
)
const fetchData = useCallback(
async (abortController?: AbortController) => {
if (url) {
setIsError(false)
setIsLoading(true)
try {
const response = await requests.get(`${url}${search}`, {
headers: {
'Accept-Language': i18n.language,
},
signal: abortController ? abortController.signal : undefined,
})
if (response.status > 201) {
setIsError(true)
}
const json = await response.json()
setData(json)
setIsLoading(false)
} catch (error) {
if (!abortController || !abortController.signal.aborted) {
setIsError(true)
setIsLoading(false)
}
}
} else {
setIsError(false)
setIsLoading(false)
}
},
[url, search, i18n.language],
)
useEffect(() => {
const abortController = new AbortController()
const fetchData = async () => {
setIsError(false)
setIsLoading(true)
try {
const response = await requests.get(`${url}${search}`, {
headers: {
'Accept-Language': i18n.language,
},
signal: abortController.signal,
})
if (response.status > 201) {
setIsError(true)
}
const json = await response.json()
setData(json)
setIsLoading(false)
} catch (error) {
if (!abortController.signal.aborted) {
setIsError(true)
setIsLoading(false)
}
}
}
if (url) {
fetchData()
} else {
setIsError(false)
setIsLoading(false)
}
void fetchData(abortController)
return () => {
abortController.abort()
}
}, [url, locale, search, i18n.language])
}, [url, search, fetchData])
return [{ data, isError, isLoading }, { setParams }]
return [
{ data, isError, isLoading },
{ refetchData: fetchData, setParams },
]
}
export default usePayloadAPI

View File

@@ -200,4 +200,11 @@ dialog {
z-index: var(--z-modal);
}
.script-language {
& > *,
& > * > * {
letter-spacing: 0 !important;
}
}
@import '~payload-user-css';

View File

@@ -205,6 +205,7 @@ async function login<TSlug extends keyof GeneratedTypes['collections']>(
context: req.context,
depth,
doc: user,
draft: undefined,
fallbackLocale,
global: null,
locale,

View File

@@ -54,6 +54,7 @@ const batchAndLoadDocs =
fallbackLocale,
overrideAccess,
showHiddenFields,
draft,
] = JSON.parse(key)
const batchKeyArray = [
@@ -65,6 +66,7 @@ const batchAndLoadDocs =
fallbackLocale,
overrideAccess,
showHiddenFields,
draft,
]
const batchKey = JSON.stringify(batchKeyArray)
@@ -100,6 +102,7 @@ const batchAndLoadDocs =
fallbackLocale,
overrideAccess,
showHiddenFields,
draft,
] = JSON.parse(batchKey)
req.transactionID = transactionID
@@ -109,6 +112,7 @@ const batchAndLoadDocs =
currentDepth,
depth,
disableErrors: true,
draft,
fallbackLocale,
locale,
overrideAccess: Boolean(overrideAccess),
@@ -136,6 +140,7 @@ const batchAndLoadDocs =
fallbackLocale,
overrideAccess,
showHiddenFields,
draft,
])
const docsIndex = keys.findIndex((key) => key === docKey)

View File

@@ -54,6 +54,8 @@ function initCollectionsGraphQL(payload: Payload): void {
if (!graphQL) return
const draftsEnabled = collection.config.versions?.drafts
let singularName
let pluralName
const fromSlug = formatNames(collection.config.slug)
@@ -150,7 +152,11 @@ function initCollectionsGraphQL(payload: Payload): void {
type: collection.graphQL.type,
args: {
id: { type: new GraphQLNonNull(idType) },
draft: { type: GraphQLBoolean },
...(draftsEnabled
? {
draft: { type: GraphQLBoolean },
}
: {}),
...(payload.config.localization
? {
fallbackLocale: { type: payload.types.fallbackLocaleInputType },
@@ -164,7 +170,11 @@ function initCollectionsGraphQL(payload: Payload): void {
payload.Query.fields[pluralName] = {
type: buildPaginatedListType(pluralName, collection.graphQL.type),
args: {
draft: { type: GraphQLBoolean },
...(draftsEnabled
? {
draft: { type: GraphQLBoolean },
}
: {}),
where: { type: collection.graphQL.whereInputType },
...(payload.config.localization
? {
@@ -187,7 +197,11 @@ function initCollectionsGraphQL(payload: Payload): void {
},
}),
args: {
draft: { type: GraphQLBoolean },
...(draftsEnabled
? {
draft: { type: GraphQLBoolean },
}
: {}),
where: { type: collection.graphQL.whereInputType },
...(payload.config.localization
? {
@@ -217,7 +231,11 @@ function initCollectionsGraphQL(payload: Payload): void {
...(createMutationInputType
? { data: { type: collection.graphQL.mutationInputType } }
: {}),
draft: { type: GraphQLBoolean },
...(draftsEnabled
? {
draft: { type: GraphQLBoolean },
}
: {}),
...(payload.config.localization
? {
locale: { type: payload.types.localeInputType },
@@ -235,7 +253,11 @@ function initCollectionsGraphQL(payload: Payload): void {
...(updateMutationInputType
? { data: { type: collection.graphQL.updateMutationInputType } }
: {}),
draft: { type: GraphQLBoolean },
...(draftsEnabled
? {
draft: { type: GraphQLBoolean },
}
: {}),
...(payload.config.localization
? {
locale: { type: payload.types.localeInputType },

View File

@@ -28,6 +28,8 @@ export default function findResolver(collection: Collection): Resolver {
req.locale = args.locale || locale
req.fallbackLocale = fallbackLocale
context.req = req
const options = {
collection,
req: isolateObjectProperty<PayloadRequest>(req, 'transactionID'),

View File

@@ -33,6 +33,17 @@ export default function createResolver<TSlug extends keyof GeneratedTypes['colle
const locale = req.locale
req = isolateObjectProperty(req, 'locale')
req.locale = args.locale || locale
if (!req.query) req.query = {}
const draft: boolean =
args.draft ?? req.query?.draft === 'false'
? false
: req.query?.draft === 'true'
? true
: undefined
if (typeof draft === 'boolean') req.query.draft = String(draft)
context.req = req
const options = {
collection,

View File

@@ -31,6 +31,17 @@ export default function getDeleteResolver<TSlug extends keyof GeneratedTypes['co
req = isolateObjectProperty(req, 'fallbackLocale')
req.locale = args.locale || locale
req.fallbackLocale = args.fallbackLocale || fallbackLocale
if (!req.query) req.query = {}
const draft: boolean =
args.draft ?? req.query?.draft === 'false'
? false
: req.query?.draft === 'true'
? true
: undefined
if (typeof draft === 'boolean') req.query.draft = String(draft)
context.req = req
const options = {
id: args.id,

View File

@@ -35,6 +35,17 @@ export default function findResolver(collection: Collection): Resolver {
req = isolateObjectProperty(req, 'fallbackLocale')
req.locale = args.locale || locale
req.fallbackLocale = args.fallbackLocale || fallbackLocale
if (!req.query) req.query = {}
const draft: boolean =
args.draft ?? req.query?.draft === 'false'
? false
: req.query?.draft === 'true'
? true
: undefined
if (typeof draft === 'boolean') req.query.draft = String(draft)
context.req = req
const options = {
collection,

View File

@@ -30,6 +30,17 @@ export default function findByIDResolver<T extends keyof GeneratedTypes['collect
req = isolateObjectProperty(req, 'fallbackLocale')
req.locale = args.locale || locale
req.fallbackLocale = args.fallbackLocale || fallbackLocale
if (!req.query) req.query = {}
const draft: boolean =
args.draft ?? req.query?.draft === 'false'
? false
: req.query?.draft === 'true'
? true
: undefined
if (typeof draft === 'boolean') req.query.draft = String(draft)
context.req = req
const options = {
id: args.id,

View File

@@ -11,7 +11,6 @@ import findVersionByID from '../../operations/findVersionByID'
export type Resolver<T extends TypeWithID = any> = (
_: unknown,
args: {
draft: boolean
fallbackLocale?: string
id: number | string
locale?: string
@@ -32,11 +31,12 @@ export default function findVersionByIDResolver(collection: Collection): Resolve
req.locale = args.locale || locale
req.fallbackLocale = args.fallbackLocale || fallbackLocale
context.req = req
const options = {
id: args.id,
collection,
depth: 0,
draft: args.draft,
req: isolateObjectProperty<PayloadRequest>(req, 'transactionID'),
}

View File

@@ -35,6 +35,17 @@ export default function findVersionsResolver(collection: Collection): Resolver {
req = isolateObjectProperty(req, 'fallbackLocale')
req.locale = args.locale || locale
req.fallbackLocale = args.fallbackLocale || fallbackLocale
if (!req.query) req.query = {}
const draft: boolean =
args.draft ?? req.query?.draft === 'false'
? false
: req.query?.draft === 'true'
? true
: undefined
if (typeof draft === 'boolean') req.query.draft = String(draft)
context.req = req
const options = {
collection,

View File

@@ -34,6 +34,17 @@ export default function updateResolver<TSlug extends keyof GeneratedTypes['colle
req = isolateObjectProperty(req, 'fallbackLocale')
req.locale = args.locale || locale
req.fallbackLocale = args.fallbackLocale || fallbackLocale
if (!req.query) req.query = {}
const draft: boolean =
args.draft ?? req.query?.draft === 'false'
? false
: req.query?.draft === 'true'
? true
: undefined
if (typeof draft === 'boolean') req.query.draft = String(draft)
context.req = req
const options = {
id: args.id,

View File

@@ -130,6 +130,7 @@ async function create<TSlug extends keyof GeneratedTypes['collections']>(
collection,
config,
data,
operation: 'create',
overwriteExistingFiles,
req,
throwOnMissingFile:
@@ -290,6 +291,7 @@ async function create<TSlug extends keyof GeneratedTypes['collections']>(
context: req.context,
depth,
doc: result,
draft,
fallbackLocale,
global: null,
locale,

View File

@@ -179,6 +179,7 @@ async function deleteOperation<TSlug extends keyof GeneratedTypes['collections']
context: req.context,
depth,
doc: result || doc,
draft: undefined,
fallbackLocale,
global: null,
locale,

View File

@@ -158,6 +158,7 @@ async function deleteByID<TSlug extends keyof GeneratedTypes['collections']>(
context: req.context,
depth,
doc: result,
draft: undefined,
fallbackLocale,
global: null,
locale,

View File

@@ -196,6 +196,7 @@ async function find<T extends TypeWithID & Record<string, unknown>>(
currentDepth,
depth,
doc,
draft: draftsEnabled,
fallbackLocale,
findMany: true,
global: null,

View File

@@ -139,6 +139,7 @@ async function findByID<T extends TypeWithID>(incomingArgs: Arguments): Promise<
currentDepth,
depth,
doc: result,
draft: draftEnabled,
fallbackLocale,
global: null,
locale,

View File

@@ -112,6 +112,7 @@ async function findVersionByID<T extends TypeWithID = any>(
currentDepth,
depth,
doc: result.version,
draft: undefined,
fallbackLocale,
global: null,
locale,

View File

@@ -125,6 +125,7 @@ async function findVersions<T extends TypeWithVersion<T>>(
context: req.context,
depth,
doc: data.version,
draft: undefined,
fallbackLocale,
findMany: true,
global: null,

View File

@@ -140,6 +140,7 @@ async function restoreVersion<T extends TypeWithID = any>(args: Arguments): Prom
context: req.context,
depth,
doc: result,
draft: undefined,
fallbackLocale,
global: null,
locale,

View File

@@ -157,6 +157,7 @@ async function update<TSlug extends keyof GeneratedTypes['collections']>(
collection,
config,
data: bulkUpdateData,
operation: 'update',
overwriteExistingFiles,
req,
throwOnMissingFile: false,
@@ -177,6 +178,7 @@ async function update<TSlug extends keyof GeneratedTypes['collections']>(
context: req.context,
depth: 0,
doc,
draft: draftArg,
fallbackLocale,
global: null,
locale,
@@ -312,6 +314,7 @@ async function update<TSlug extends keyof GeneratedTypes['collections']>(
context: req.context,
depth,
doc: result,
draft: draftArg,
fallbackLocale: null,
global: null,
locale,

View File

@@ -131,6 +131,7 @@ async function updateByID<TSlug extends keyof GeneratedTypes['collections']>(
context: req.context,
depth: 0,
doc: docWithLocales,
draft: draftArg,
fallbackLocale: null,
global: null,
locale,
@@ -147,6 +148,8 @@ async function updateByID<TSlug extends keyof GeneratedTypes['collections']>(
collection,
config,
data,
operation: 'update',
originalDoc,
overwriteExistingFiles,
req,
throwOnMissingFile: false,
@@ -300,6 +303,7 @@ async function updateByID<TSlug extends keyof GeneratedTypes['collections']>(
context: req.context,
depth,
doc: result,
draft: draftArg,
fallbackLocale,
global: null,
locale,

View File

@@ -68,7 +68,6 @@ export type {
FieldWithMany,
FieldWithMaxDepth,
FieldWithPath,
FieldWithRichTextRequiredEditor,
FieldWithSubFields,
FilterOptions,
FilterOptionsProps,
@@ -87,7 +86,6 @@ export type {
RelationshipField,
RelationshipValue,
RichTextField,
RichTextFieldRequiredEditor,
RowAdmin,
RowField,
SelectField,

View File

@@ -19,6 +19,8 @@ export const baseAdminFields = joi.object().keys({
.alternatives()
.try(joi.string(), joi.object().pattern(joi.string(), [joi.string()]), componentSchema),
disableBulkEdit: joi.boolean().default(false),
disableListColumn: joi.boolean().default(false),
disableListFilter: joi.boolean().default(false),
disabled: joi.boolean().default(false),
hidden: joi.boolean().default(false),
initCollapsed: joi.boolean().default(false),
@@ -311,6 +313,7 @@ export const array = baseField.keys({
RowLabel: componentSchema,
})
.default({}),
isSortable: joi.boolean(),
})
.default({}),
dbName: joi.alternatives().try(joi.string(), joi.func()),
@@ -408,6 +411,11 @@ export const relationship = baseField.keys({
export const blocks = baseField.keys({
name: joi.string().required(),
type: joi.string().valid('blocks').required(),
admin: baseAdminFields
.keys({
isSortable: joi.boolean(),
})
.default({}),
blocks: joi
.array()
.items(
@@ -469,6 +477,7 @@ export const richText = baseField.keys({
validate: joi.func().required(),
})
.unknown(),
maxDepth: joi.number(),
})
export const date = baseField.keys({

View File

@@ -113,6 +113,8 @@ type Admin = {
condition?: Condition
description?: Description
disableBulkEdit?: boolean
disableListColumn?: boolean
disableListFilter?: boolean
disabled?: boolean
hidden?: boolean
position?: 'sidebar'
@@ -387,6 +389,8 @@ export type UIField = {
}
condition?: Condition
disableBulkEdit?: boolean
disableListColumn?: boolean
disableListFilter?: boolean
position?: string
width?: string
}
@@ -547,23 +551,23 @@ export type RichTextField<
}
}
editor?: RichTextAdapter<Value, AdapterProps, AdapterProps>
/**
* Sets a maximum population depth for this field, regardless of the remaining depth when this field is reached.
*/
maxDepth?: number
type: 'richText'
} & ExtraProperties
export type RichTextFieldRequiredEditor<
Value extends object = any,
AdapterProps = any,
ExtraProperties = object,
> = Omit<RichTextField<Value, AdapterProps, ExtraProperties>, 'editor'> & {
editor: RichTextAdapter<Value, AdapterProps, ExtraProperties>
}
export type ArrayField = FieldBase & {
admin?: Admin & {
components?: {
RowLabel?: RowLabel
} & Admin['components']
initCollapsed?: boolean | false
/**
* Disable drag and drop sorting
*/
isSortable?: boolean
}
/**
* Customize the SQL table name
@@ -631,6 +635,10 @@ export type Block = {
export type BlockField = FieldBase & {
admin?: Admin & {
initCollapsed?: boolean | false
/**
* Disable drag and drop sorting
*/
isSortable?: boolean
}
blocks: Block[]
defaultValue?: unknown
@@ -667,10 +675,6 @@ export type Field =
| UIField
| UploadField
export type FieldWithRichTextRequiredEditor =
| Exclude<Field, RichTextField>
| RichTextFieldRequiredEditor
export type FieldAffectingData =
| ArrayField
| BlockField

View File

@@ -11,6 +11,7 @@ type Args = {
currentDepth?: number
depth: number
doc: Record<string, unknown>
draft: boolean
fallbackLocale: null | string
findMany?: boolean
flattenLocales?: boolean
@@ -28,6 +29,7 @@ export async function afterRead<T = any>(args: Args): Promise<T> {
currentDepth: incomingCurrentDepth,
depth: incomingDepth,
doc: incomingDoc,
draft,
fallbackLocale,
findMany,
flattenLocales = true,
@@ -56,6 +58,7 @@ export async function afterRead<T = any>(args: Args): Promise<T> {
currentDepth,
depth,
doc,
draft,
fallbackLocale,
fieldPromises,
fields: collection?.fields || global?.fields,

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