diff --git a/docs/3.0.0-beta.x/guides/custom-admin.md b/docs/3.0.0-beta.x/guides/custom-admin.md index 838670facb..28195a7ab0 100644 --- a/docs/3.0.0-beta.x/guides/custom-admin.md +++ b/docs/3.0.0-beta.x/guides/custom-admin.md @@ -74,15 +74,15 @@ To be able to see the update, you will need to have a Content Type that have a ` Then you will have to investigate into the [`strapi-plugin-content-manager`](https://github.com/strapi/strapi/tree/master/packages/strapi-plugin-content-manager) package to find the file that is used to format the date for the list view. -Here is the [Row component](https://github.com/strapi/strapi/blob/master/packages/strapi-plugin-content-manager/admin/src/components/CustomTable/Row.js) you will have to update. +Here is the [Row component](https://github.com/strapi/strapi/blob/master/packages/strapi-plugin-content-manager/admin/src/components/CustomTable/Row.js) which requires a [dedicated file](https://github.com/strapi/strapi/blob/master/packages/strapi-plugin-content-manager/admin/src/utils/dateFormats.js) to modify the date display. ### Eject the file Let's eject the file to be able to customize it. -**Path —** `./extensions/content-manager/admin/src/components/CustomTable/Row.js` +**Path —** `./extensions/content-manager/admin/src/utils/dateFormats.js` -In this new file, paste the current [Row component](https://github.com/strapi/strapi/blob/master/packages/strapi-plugin-content-manager/admin/src/components/CustomTable/Row.js) code. +In this new file, paste the current [dateFormats](https://github.com/strapi/strapi/blob/master/packages/strapi-plugin-content-manager/admin/src/utils/dateFormats.js) code. To run your application, you will have to run the `yarn develop --watch-admin` command. @@ -95,13 +95,17 @@ In our example, we want to change the format of the date. We have to find in thi Here is the code you have to find: ```js -return moment - .parseZone(date) - .utc() - .format('dddd, MMMM Do YYYY'); +const dateFormats = { + ...defaultDateFormats, + // Customise the format by uncommenting the one you wan to override it corresponds to the type of your field + // date: 'dddd, MMMM Do YYYY', + // datetime: 'dddd, MMMM Do YYYY HH:mm', + // time: 'HH:mm A', + // timestamp: 'dddd, MMMM Do YYYY HH:mm', +}; ``` -Now let's replace `.format('dddd, MMMM Do YYYY');` by `.format('YYYY/MM/DD');` +Now let's replace `data: 'dddd, MMMM Do YYYY'` by `date: 'YYYY/MM/DD';` And tada, the date will now display with the new format. diff --git a/packages/strapi-admin/admin/src/config.js b/packages/strapi-admin/admin/src/config.js index 711a4534d8..9efd2e7292 100644 --- a/packages/strapi-admin/admin/src/config.js +++ b/packages/strapi-admin/admin/src/config.js @@ -5,6 +5,8 @@ // Here's the file: strapi/docs/3.0.0-beta.x/admin-panel/customization.md#tutorial-videos // IF THE DOC IS NOT UPDATED THE PULL REQUEST WILL NOT BE MERGED +// IMPORTANT: It also needs to be added to the migration guide. + export const LOGIN_LOGO = null; export const SHOW_TUTORIALS = true; export const SETTINGS_BASE_URL = '/settings'; diff --git a/packages/strapi-plugin-content-manager/admin/src/utils/dateFormats.js b/packages/strapi-plugin-content-manager/admin/src/utils/dateFormats.js index bb9c39635e..d2cb3f58ba 100644 --- a/packages/strapi-plugin-content-manager/admin/src/utils/dateFormats.js +++ b/packages/strapi-plugin-content-manager/admin/src/utils/dateFormats.js @@ -1,3 +1,9 @@ +// NOTE TO PLUGINS DEVELOPERS: +// If you modify this file you need to update the documentation accordingly +// Here's the file: strapi/docs/3.0.0-beta.x/guides/custom-admin.md#update-the-content-manager +// Also the strapi-generate-plugins/files/admin/src/index.js needs to be updated +// IF THE DOC IS NOT UPDATED THE PULL REQUEST WILL NOT BE MERGED + import { dateFormats as defaultDateFormats } from 'strapi-helper-plugin'; const dateFormats = {