Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/beta' into feat/jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
AlessioGr committed Oct 8, 2024
2 parents ede3889 + ca77944 commit 291e44c
Show file tree
Hide file tree
Showing 386 changed files with 12,573 additions and 11,744 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,6 @@ test/app/(payload)/admin/importMap.js
/test/app/(payload)/admin/importMap.js
test/pnpm-lock.yaml
test/databaseAdapter.js
/filename-compound-index
/media-with-relation-preview
/media-without-relation-preview
13 changes: 13 additions & 0 deletions docs/admin/customizing-css.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ Here is an example of how you might target the Dashboard View and change the bac
If you are building [Custom Components](./overview), it is best to import your own stylesheets directly into your components, rather than using the global stylesheet. You can continue to use the [CSS library](#css-library) as needed.
</Banner>

### Specificity rules

All Payload CSS is encapsulated inside CSS layers under `@layer payload-default`. Any custom css will now have the highest possible specificity.

We have also provided a layer `@layer payload` if you want to use layers and ensure that your styles are applied after payload.

To override existing styles in a way that the previous rules of specificity would be respected you can use the default layer like so
```css
@layer payload-default {
// my styles within the payload specificity
}
```

## Re-using Payload SCSS variables and utilities

You can re-use Payload's SCSS variables and utilities in your own stylesheets by importing it from the UI package.
Expand Down
5 changes: 3 additions & 2 deletions docs/configuration/localization.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ import { buildConfig } from 'payload'
export default buildConfig({
// ...
localization: {
locales: ['en', 'es', 'de'] // highlight-line
locales: ['en', 'es', 'de'] // required
defaultLocale: 'en', // required
},
})
```
Expand Down Expand Up @@ -63,7 +64,7 @@ export default buildConfig({
rtl: true,
},
],
defaultLocale: 'en',
defaultLocale: 'en', // required
fallback: true,
},
})
Expand Down
33 changes: 24 additions & 9 deletions docs/fields/array.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ _\* An asterisk denotes that a property is required._

## Admin Options

The customize the appearance and behavior of the Array Field in the [Admin Panel](../admin/overview), you can use the `admin` option:
To customize the appearance and behavior of the Array Field in the [Admin Panel](../admin/overview), you can use the `admin` option:

```ts
import type { Field } from 'payload/types'
Expand All @@ -81,11 +81,11 @@ export const MyArrayField: Field = {

The Array Field inherits all of the default options from the base [Field Admin Config](../admin/fields#admin-options), plus the following additional options:

| Option | Description |
| ------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| **`initCollapsed`** | Set the initial collapsed state |
| **`components.RowLabel`** | Function or React component to be rendered as the label on the array row. Receives `({ data, index, path })` as args |
| **`isSortable`** | Disable order sorting by setting this value to `false` |
| Option | Description |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| **`initCollapsed`** | Set the initial collapsed state |
| **`components.RowLabel`** | React component to be rendered as the label on the array row. [Example](#example-of-a-custom-rowlabel-component) |
| **`isSortable`** | Disable order sorting by setting this value to `false` |

## Example

Expand Down Expand Up @@ -127,12 +127,27 @@ export const ExampleCollection: CollectionConfig = {
],
admin: {
components: {
RowLabel: ({ data, index }) => {
return data?.title || `Slide ${String(index).padStart(2, '0')}`
},
RowLabel: '/path/to/ArrayRowLabel#ArrayRowLabel',
},
},
},
],
}
```

### Example of a custom RowLabel component


```tsx
'use client'

import { useRowLabel } from '@payloadcms/ui'

export const ArrayRowLabel = () => {
const { data, rowNumber } = useRowLabel<{ title?: string }>()

const customLabel = `${data.title || 'Slide'} ${String(rowNumber).padStart(2, '0')} `

return <div>Custom Label: {customLabel}</div>
}
```
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const rootEslintConfig = [
'payload/no-relative-monorepo-imports': 'error',
'payload/no-imports-from-exports-dir': 'error',
'payload/no-imports-from-self': 'error',
'payload/proper-payload-logger-usage': 'error',
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "payload-monorepo",
"version": "3.0.0-beta.110",
"version": "3.0.0-beta.111",
"private": true,
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/create-payload-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-payload-app",
"version": "3.0.0-beta.110",
"version": "3.0.0-beta.111",
"homepage": "https://payloadcms.com",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/db-mongodb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@payloadcms/db-mongodb",
"version": "3.0.0-beta.110",
"version": "3.0.0-beta.111",
"description": "The officially supported MongoDB database adapter for Payload",
"homepage": "https://payloadcms.com",
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions packages/db-postgres/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@payloadcms/db-postgres",
"version": "3.0.0-beta.110",
"version": "3.0.0-beta.111",
"description": "The officially supported Postgres database adapter for Payload",
"homepage": "https://payloadcms.com",
"repository": {
Expand Down Expand Up @@ -48,6 +48,7 @@
},
"dependencies": {
"@payloadcms/drizzle": "workspace:*",
"@types/pg": "8.10.2",
"console-table-printer": "2.11.2",
"drizzle-kit": "0.23.2-df9e596",
"drizzle-orm": "0.32.1",
Expand All @@ -59,7 +60,6 @@
"devDependencies": {
"@hyrious/esbuild-plugin-commonjs": "^0.2.4",
"@payloadcms/eslint-config": "workspace:*",
"@types/pg": "8.10.2",
"@types/to-snake-case": "1.0.0",
"esbuild": "0.23.1",
"payload": "workspace:*"
Expand Down
2 changes: 1 addition & 1 deletion packages/db-sqlite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@payloadcms/db-sqlite",
"version": "3.0.0-beta.110",
"version": "3.0.0-beta.111",
"description": "The officially supported SQLite database adapter for Payload",
"homepage": "https://payloadcms.com",
"repository": {
Expand Down
7 changes: 6 additions & 1 deletion packages/db-sqlite/src/schema/traverseFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,12 @@ export const traverseFields = ({
}),
)
} else {
targetTable[fieldName] = withDefault(text(fieldName, { enum: options }), field)
targetTable[fieldName] = withDefault(
text(columnName, {
enum: options,
}),
field,
)
}
break
}
Expand Down
6 changes: 3 additions & 3 deletions packages/db-vercel-postgres/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@payloadcms/db-vercel-postgres",
"version": "3.0.0-beta.110",
"version": "3.0.0-beta.111",
"description": "Vercel Postgres adapter for Payload",
"homepage": "https://payloadcms.com",
"repository": {
Expand Down Expand Up @@ -52,6 +52,7 @@
"console-table-printer": "2.11.2",
"drizzle-kit": "0.23.2-df9e596",
"drizzle-orm": "0.32.1",
"pg": "8.11.3",
"prompts": "2.4.2",
"to-snake-case": "1.0.0",
"uuid": "10.0.0"
Expand All @@ -62,8 +63,7 @@
"@types/pg": "8.10.2",
"@types/to-snake-case": "1.0.0",
"esbuild": "0.23.1",
"payload": "workspace:*",
"pg": "8.11.3"
"payload": "workspace:*"
},
"peerDependencies": {
"payload": "workspace:*"
Expand Down
2 changes: 1 addition & 1 deletion packages/drizzle/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@payloadcms/drizzle",
"version": "3.0.0-beta.110",
"version": "3.0.0-beta.111",
"description": "A library of shared functions used by different payload database adapters",
"homepage": "https://payloadcms.com",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/drizzle/src/postgres/schema/traverseFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ export const traverseFields = ({
}),
)
} else {
targetTable[fieldName] = withDefault(adapter.enums[enumName](fieldName), field)
targetTable[fieldName] = withDefault(adapter.enums[enumName](columnName), field)
}
break
}
Expand Down
2 changes: 1 addition & 1 deletion packages/email-nodemailer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@payloadcms/email-nodemailer",
"version": "3.0.0-beta.110",
"version": "3.0.0-beta.111",
"description": "Payload Nodemailer Email Adapter",
"homepage": "https://payloadcms.com",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/email-resend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@payloadcms/email-resend",
"version": "3.0.0-beta.110",
"version": "3.0.0-beta.111",
"description": "Payload Resend Email Adapter",
"homepage": "https://payloadcms.com",
"repository": {
Expand Down
89 changes: 89 additions & 0 deletions packages/eslint-plugin/customRules/proper-payload-logger-usage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
export const rule = {
meta: {
type: 'problem',
docs: {
description: 'Disallow improper usage of payload.logger.error',
recommended: 'error',
},
messages: {
improperUsage: 'Improper logger usage. Pass { msg, err } so full error stack is logged.',
wrongErrorField: 'Improper usage. Use { err } instead of { error }.',
wrongMessageField: 'Improper usage. Use { msg } instead of { message }.',
},
schema: [],
},
create(context) {
return {
CallExpression(node) {
const callee = node.callee

// Function to check if the expression ends with `payload.logger.error`
function isPayloadLoggerError(expression) {
return (
expression.type === 'MemberExpression' &&
expression.property.name === 'error' && // must be `.error`
expression.object.type === 'MemberExpression' &&
expression.object.property.name === 'logger' && // must be `.logger`
(expression.object.object.name === 'payload' || // handles just `payload`
(expression.object.object.type === 'MemberExpression' &&
expression.object.object.property.name === 'payload')) // handles `*.payload`
)
}

// Check if the function being called is `payload.logger.error` or `*.payload.logger.error`
if (isPayloadLoggerError(callee)) {
const args = node.arguments

// Case 1: Single string is passed as the argument
if (
args.length === 1 &&
args[0].type === 'Literal' &&
typeof args[0].value === 'string'
) {
return // Valid: single string argument
}

// Case 2: Object is passed as the first argument
if (args.length > 0 && args[0].type === 'ObjectExpression') {
const properties = args[0].properties

// Ensure no { error } key, only { err } is allowed
properties.forEach((prop) => {
if (prop.key.type === 'Identifier' && prop.key.name === 'error') {
context.report({
node: prop,
messageId: 'wrongErrorField',
})
}

// Ensure no { message } key, only { msg } is allowed
if (prop.key.type === 'Identifier' && prop.key.name === 'message') {
context.report({
node: prop,
messageId: 'wrongMessageField',
})
}
})
return // Valid object, checked for 'err'/'error' keys
}

// Case 3: Improper usage (string + error or additional err/error)
if (
args.length > 1 &&
args[0].type === 'Literal' &&
typeof args[0].value === 'string' &&
args[1].type === 'Identifier' &&
(args[1].name === 'err' || args[1].name === 'error')
) {
context.report({
node,
messageId: 'improperUsage',
})
}
}
},
}
},
}

export default rule
6 changes: 5 additions & 1 deletion packages/eslint-plugin/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@ import noRelativeMonorepoImports from './customRules/no-relative-monorepo-import
import noImportsFromExportsDir from './customRules/no-imports-from-exports-dir.js'
import noFlakyAssertions from './customRules/no-flaky-assertions.js'
import noImportsFromSelf from './customRules/no-imports-from-self.js'
import properPinoLoggerErrorUsage from './customRules/proper-payload-logger-usage.js'

/**
* @type {import('eslint').ESLint.Plugin}
*/
const index = {
rules: {
'no-jsx-import-statements': noJsxImportStatements,
'no-non-retryable-assertions': noNonRetryableAssertions,
'no-relative-monorepo-imports': noRelativeMonorepoImports,
'no-imports-from-exports-dir': noImportsFromExportsDir,
'no-imports-from-self': noImportsFromSelf,
'proper-payload-logger-usage': properPinoLoggerErrorUsage,

// Testing-related
'no-non-retryable-assertions': noNonRetryableAssertions,
'no-flaky-assertions': noFlakyAssertions,
'no-wait-function': {
create: function (context) {
Expand Down
Loading

0 comments on commit 291e44c

Please sign in to comment.