Replies: 14 comments 6 replies
-
Design IntentWe'll be updating the button component to allow for a dropdown of actions. Clicking on the main part of the button will publish the full document's changes, while clicking on 'Publish [Locale] only' will only publish changes from that locale's data, and keep other locale's changes in their draft state. |
Beta Was this translation helpful? Give feedback.
-
Is there an updated timeline for this feature? |
Beta Was this translation helpful? Give feedback.
-
Any update here? |
Beta Was this translation helpful? Give feedback.
-
also interested in this feature 👋 |
Beta Was this translation helpful? Give feedback.
-
Hey everyone, we're all deep into getting 3.0 beta out, and should be ready to release in the next week or so. Once that's complete we will be back to working on roadmap features, and this one is definitely one of the top priorities for us. |
Beta Was this translation helpful? Give feedback.
-
@tylandavis would it be possible for me to implement a temporary workaround using the |
Beta Was this translation helpful? Give feedback.
-
+1 for this feature, it's really important for a project I have at the moment. Looking for alternative implantation for now, but hitting road blocks. |
Beta Was this translation helpful? Give feedback.
-
I had a look at the ongoing implementation. I tried it for a bit and want to second what @PP-Tom mentioned on the design. If I'm working on a specific locale, the only two use cases I see are publishing the current locale and publishing all locales, but not any other locale than the current one. So my expectation is that the default action is publishing the current locale, and in the dropdown menu there would be an option to publish all locales. |
Beta Was this translation helpful? Give feedback.
-
Released in 3.0 Relevant PR |
Beta Was this translation helpful? Give feedback.
-
Hello! Nice to see V3 :)
|
Beta Was this translation helpful? Give feedback.
-
The locale dropdown is not fully visible here. Probably a z-index issue. Is there an API to get the list of published locales of a document? I checked the source code and Payload creates snapshots in the revision collection. Still migrating our code to Payload 3.x and this is soon next on our migration list. |
Beta Was this translation helpful? Give feedback.
-
I reviewed this new Payload 3 feature and in my opinion the handling is confusing and I doubt my customers would understand the currently implemented behavior and easily wrong content gets published. The current behavior is:
We would like to have:
Some of those features could be implemented on top of Payload in custom fields but in my opinion those are core features which should be available to all users. |
Beta Was this translation helpful? Give feedback.
-
Wrote an initial version of a locales plugin. It basically works but if more than one locale is published, it's currently impossible to know which ones got published therefore the status value is wrong. The beforeChangeHook fires only once. import type { CollectionConfig, Config, Field, GlobalConfig, GroupField, CollectionBeforeChangeHook, PayloadRequest } from 'payload';
//flags
const DEBUG = false;
/**
* Locale plugin configuration.
*/
export interface LocalePluginConfig {
//no params
}
/**
* Locale data of the document.
*/
type DocumentLocales = Record<string, DocumentLocale>;
/**
* Locale info.
*/
interface DocumentLocale {
/**
* Locale status.
*/
status: 'draft' | 'published'
/**
* Creation date of the locale.
*/
createdAt: Date
/**
* Update date of locale.
*/
updatedAt: Date
/**
* Published date of the locale.
*/
publishedAt?: Date
}
/**
* Stores locale data in a locales group field.
*
* @param _pluginConfig
* @returns
*/
export default function localePlugin(_pluginConfig: LocalePluginConfig) {
//modify configuration
return (config: Config) => {
//modify collections
const collections = (config.collections || []).map(collection => {
//create new collection data
return <CollectionConfig>{
...collection,
hooks: {
...(collection.hooks || {}),
beforeChange: [
...(collection.hooks?.beforeChange || []),
//collect locale data
({ data, operation, req }) => handleBeforeChange(collection.slug, data, operation, req)
]
},
fields: [
...(collection.fields || []),
createLocalesGroup(config)
]
};
});
//modify globals
const globals = (config.globals || []).map(global => {
//create new collection data
return <GlobalConfig>{
...global,
hooks: {
...(global.hooks || {}),
beforeChange: [
...(global.hooks?.beforeChange || []),
//collect locale data
({ data, req }) => handleBeforeChange(global.slug, data, 'update', req)
]
}
};
});
return <Config>{
...config,
collections,
globals
};
};
}
/**
* Handle before change.
*
* @param slug
* @param data
* @param operation
* @param req
* @returns
*/
function handleBeforeChange(slug: string, data: Partial<any>, operation: Parameters<CollectionBeforeChangeHook>[0]['operation'], req: PayloadRequest) {
//check locale is set
const locale = req.locale;
if (!locale) {
//log
req.payload.logger.error('Locale missing!');
return data;
}
//update fields
const localesData: DocumentLocales = data.locales || {};
const localeData: DocumentLocale = localesData[locale] ?? {};
const now = new Date();
localesData[locale] = localeData;
// 1) status (keep global value)
//cbxx FIXME fails if two languages are published -> only first one set as published!!!
//cbxx 1) create new document 2) edit two languages, 3) publish both at once -> single call with the currently active language
localeData.status = data._status;
// 2) creation date (store once using current date)
if (!localeData.createdAt) {
localeData.createdAt = now;
}
// 3) update date (now)
localeData.updatedAt = now;
// 4) publishedAt (first publish)
if (operation === 'create' || operation === 'update') {
if (data._status === 'published' && !localeData.publishedAt) {
localeData.publishedAt = now;
}
}
if (DEBUG) {
console.log(`Locales ${slug} ${data.id ?? ''}:`);
console.dir(localesData);
}
data.locales = localesData;
return data;
}
/**
* Create the locales group field.
*
* @param config
* @returns
*/
function createLocalesGroup(config: Config): GroupField {
return {
//locales
name: 'locales',
type: 'group',
admin: {
components: {
//no edit
Field: false
}
},
fields: createLocaleFields(config)
};
}
/**
* Get locale group and its fields.
*
* @param config
* @returns
*/
function createLocaleFields(config: Config): Field[] {
if (!config.localization) {
return [];
}
return config.localization.locales.map(locale => {
const name = typeof locale === 'string' ? locale:locale.code;
return <GroupField>{
//locale group
name,
type: 'group',
fields: [{
//status
name: 'status',
type: 'select',
options: [{
label: 'Draft',
value: 'draft'
}, {
label: 'Published',
value: 'published'
}]
}, {
//createdAt
name: 'createdAt',
type: 'date'
}, {
//updatedAt
name: 'updatedAt',
type: 'date'
}, {
//publishedAt
name: 'publishedAt',
type: 'date',
admin: {
date: {
pickerAppearance: 'dayAndTime'
},
position: 'sidebar'
}
}]
};
});
}
//cbxx TODO scheduled published (date range) |
Beta Was this translation helpful? Give feedback.
-
Provide the ability for users to publish one locale at a time e.g. promote only Spanish, German, etc. to prod.
Feature breakdown:
This is applicable to collections and globals.
Estimated Date of Completion: 8th Dec
Beta Was this translation helpful? Give feedback.
All reactions