Compare commits

..

9 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
16 changed files with 193 additions and 28 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');

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)) }}

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

@@ -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

@@ -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

@@ -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

@@ -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: [
{

17
pnpm-lock.yaml generated
View File

@@ -340,8 +340,8 @@ importers:
specifier: ^4.10.0
version: 4.10.0(webpack-bundle-analyzer@4.10.2)(webpack@5.91.0)
webpack-dev-middleware:
specifier: 6.0.1
version: 6.0.1(webpack@5.91.0)
specifier: 6.1.2
version: 6.1.2(webpack@5.91.0)
webpack-hot-middleware:
specifier: ^2.25.3
version: 2.26.1
@@ -10461,8 +10461,8 @@ packages:
universalify: 2.0.1
dev: false
/fs-monkey@1.0.5:
resolution: {integrity: sha512-8uMbBjrhzW76TYgEV27Y5E//W2f/lTFmx78P2w19FZSxarhI/798APGQyuGCwmkNxgwGRhrLfvWyLBvNtuOmew==}
/fs-monkey@1.0.6:
resolution: {integrity: sha512-b1FMfwetIKymC0eioW7mTywihSQE4oLzQn1dB6rZB5fx/3NpNEdAWeCSMB+60/AeT0TCXsxzAlcYVEFCTAksWg==}
dev: false
/fs.realpath@1.0.0:
@@ -13182,7 +13182,7 @@ packages:
resolution: {integrity: sha512-UERzLsxzllchadvbPs5aolHh65ISpKpM+ccLbOJ8/vvpBKmAWf+la7dXFy7Mr0ySHbdHrFv5kGFCUHHe6GFEmw==}
engines: {node: '>= 4.0.0'}
dependencies:
fs-monkey: 1.0.5
fs-monkey: 1.0.6
dev: false
/memoize-one@6.0.0:
@@ -18057,11 +18057,14 @@ packages:
webpack-bundle-analyzer: 4.10.2
webpack-merge: 5.10.0
/webpack-dev-middleware@6.0.1(webpack@5.91.0):
resolution: {integrity: sha512-PZPZ6jFinmqVPJZbisfggDiC+2EeGZ1ZByyMP5sOFJcPPWSexalISz+cvm+j+oYPT7FIJyxT76esjnw9DhE5sw==}
/webpack-dev-middleware@6.1.2(webpack@5.91.0):
resolution: {integrity: sha512-Wu+EHmX326YPYUpQLKmKbTyZZJIB8/n6R09pTmB03kJmnMsVPTo9COzHZFr01txwaCAuZvfBJE4ZCHRcKs5JaQ==}
engines: {node: '>= 14.15.0'}
peerDependencies:
webpack: ^5.0.0
peerDependenciesMeta:
webpack:
optional: true
dependencies:
colorette: 2.0.20
memfs: 3.5.3

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