-
Notifications
You must be signed in to change notification settings - Fork 3k
feat: adds new experimental.allLocaleStatus flag #13509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 26 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
9ef5c9a
fix: adds enableStatusLocalization option to reflects current locale …
jessrynkar 6ac13f4
fix: add enableStatusLocalization support for postgres
jessrynkar 9c3316e
chore: make localeStatus an optional property
jessrynkar 32bfb7b
chore: make localeStatus an optional property again
jessrynkar b5185bb
chore: feedback changes
jessrynkar 403bf5b
chore: merge conflicts
jessrynkar 035ff38
fix: update status component
jessrynkar d885f07
Merge branch 'main' into fix/localized-status-UI
jessrynkar 35471fc
fix: apply locale specific status to draft if available
jessrynkar 75f9d99
chore: revert error thrown when adding locale status fields
jessrynkar 1b71d69
chore: remove log and fix tests
jessrynkar 8a9caef
Merge branch 'main' into fix/localized-status-UI
jessrynkar b2becb8
chore: update localization.enableStatusLocalization to experimental.l…
jessrynkar 51f1c99
Merge branch 'main' into fix/localized-status-UI
jessrynkar b5ea211
chore: update localizeStatus option verbiage in docs
jessrynkar 8996a31
Merge branch 'main' into fix/localized-status-UI
jessrynkar 7425b04
feat: adds experimental.allLocaleStatus flag to add new group status …
jessrynkar 54f444f
chore: updates docs to add experimental.allLocaleStatus
jessrynkar 961355e
Merge branch 'main' into fix/localized-status-UI
jessrynkar cef081c
chore: separates experimental from localization in createClientConfig
jessrynkar 903d235
chore: update createClientConfig to remove unnecessary if statement
jessrynkar d8eabd1
Merge branch 'fix/localized-status-UI' into feat/all-locale-status
jessrynkar eb8a925
chore: fix typo in createClientConfig
jessrynkar 5ef49cf
add default experimental object
JarrodMFlesch 29f4b8e
Merge branch 'fix/localized-status-UI' into feat/all-locale-status
jessrynkar ee8933f
chore: merge conflicts
jessrynkar 04d5d43
Merge branch 'main' into feat/all-locale-status
jessrynkar fcfcd56
chore: improve localeStatus query performance and rename field
jessrynkar 1e8df7a
chore: feedback updates
jessrynkar 7595b05
chore: merge conflicts
jessrynkar 33f6ebb
fix: only add the allLocaleStatus field to versioned collections
JarrodMFlesch 818d26f
clean up saveVersion looping
JarrodMFlesch 8ee892a
rm duplicative type
JarrodMFlesch cf9a15e
assign to shared localStatus
JarrodMFlesch 9872d24
simplify react code
JarrodMFlesch 1405877
fix var naming
JarrodMFlesch 0348d5b
removes unnecessary optional chaining
JarrodMFlesch 1a942e5
moves version read logic to server component, out of hooks
JarrodMFlesch 3353a8c
localize label
JarrodMFlesch efd75cb
Merge branch 'main' into feat/all-locale-status
JarrodMFlesch 374d3b5
update translations
JarrodMFlesch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
packages/payload/src/fields/baseFields/baseAllLocaleStatusField.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import type { Field } from '../config/types.js' | ||
|
||
export const baseAllLocaleStatusField: Field[] = [ | ||
{ | ||
name: '_allLocaleStatus', | ||
jacobsfletch marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
type: 'json', | ||
admin: { | ||
components: { | ||
Cell: '@payloadcms/ui/rsc#AllLocaleStatusCell', | ||
}, | ||
hidden: true, | ||
}, | ||
hooks: { | ||
afterRead: [ | ||
jacobsfletch marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
async (args) => { | ||
const { collection, data, req } = args | ||
const id = data?.id | ||
if (id && collection && collection.versions) { | ||
const version = await req.payload.findVersions({ | ||
jessrynkar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
collection: collection.slug, | ||
limit: 1, | ||
jacobsfletch marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
where: { | ||
jacobsfletch marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
parent: { | ||
equals: id, | ||
}, | ||
}, | ||
}) | ||
|
||
if (version.docs && version.docs[0]?.localeStatus) { | ||
return version.docs[0].localeStatus | ||
} | ||
} | ||
}, | ||
], | ||
}, | ||
label: 'Status - All Locales', | ||
}, | ||
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
packages/ui/src/elements/Status/AllLocaleStatusCell/index.client.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use client' | ||
|
||
import type { Data } from 'payload' | ||
|
||
import React from 'react' | ||
|
||
import { Pill } from '../../Pill/index.js' | ||
import './index.scss' | ||
|
||
type Props = { | ||
readonly availableLocales: string[] | ||
readonly data: Data | ||
} | ||
|
||
const baseClass = 'locale-status-cell' | ||
|
||
export const AllLocaleStatusCellClient = ({ availableLocales, data }: Props) => { | ||
const localesToRender = Object.fromEntries( | ||
Object.entries(data).filter(([key]) => availableLocales.includes(key)) | ||
) | ||
|
||
if (Object.keys(localesToRender).length === 0) { | ||
return null | ||
} | ||
|
||
return ( | ||
<div className={baseClass}> | ||
{Object.entries(localesToRender).map(([locale, status]) => ( | ||
<Pill key={locale} pillStyle={status === 'published' ? 'success' : 'light-gray'} size="small"> | ||
{locale} | ||
</Pill> | ||
))} | ||
</div> | ||
) | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/ui/src/elements/Status/AllLocaleStatusCell/index.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@import '../../../scss/styles.scss'; | ||
|
||
@layer payload-default { | ||
.locale-status-cell { | ||
display: flex; | ||
align-items: center; | ||
gap: calc(var(--base) / 2); | ||
flex-wrap: wrap; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
packages/ui/src/elements/Status/AllLocaleStatusCell/index.server.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { createLocalReq, type DefaultServerCellComponentProps } from 'payload' | ||
import React from 'react' | ||
|
||
import { AllLocaleStatusCellClient } from './index.client.js' | ||
|
||
export const AllLocaleStatusCell = async ({ cellData, payload }: DefaultServerCellComponentProps) => { | ||
const { localization } = payload.config | ||
const req = await createLocalReq({}, payload) | ||
|
||
let availableLocales: string[] = [] | ||
|
||
|
||
if (localization) { | ||
const filtered = | ||
(await localization.filterAvailableLocales?.({ | ||
locales: localization.locales, | ||
req, | ||
})) ?? localization.locales | ||
|
||
availableLocales = filtered.map((locale) => locale.code) | ||
} | ||
|
||
return ( | ||
<AllLocaleStatusCellClient | ||
availableLocales={availableLocales} | ||
data={cellData} | ||
/> | ||
) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.