Open freitasfa-bahag opened 1 year ago
I saw there is an similar issue
Interesting, I was not aware of this injection zone. I will have a look, if its allows for opting in from the configure the view I do not see why not.
Cool! Just to let you know, I've tried to add this hook on ./admin/src/index.js
but it didn't work out. I'm aware that the key that brings the value from the plugin is name
, so I'm not sure if should be publisher
in that case or something else.
This code
import React from 'react';
import { prefixPluginTranslations } from '@strapi/helper-plugin';
import pluginPkg from 'strapi-plugin-publisher/package.json';
import { pluginId } from 'strapi-plugin-publisher/admin/src/pluginId';
import Initializer from 'strapi-plugin-publisher/admin/src/components/Initializer';
import { ActionLayout } from 'strapi-plugin-publisher/admin/src/components/ActionLayout';
const name = pluginPkg.strapi.name;
export default {
register(app) {
app.registerPlugin({
id: pluginId,
initializer: Initializer,
isReady: false,
name,
});
},
bootstrap(app) {
app.injectContentManagerComponent('editView', 'informations', {
name: name,
Component: ActionLayout,
});
app.registerHook(
'Admin/CM/pages/ListView/inject-column-in-table',
({ displayedHeaders, layout }) => {
return {
layout,
displayedHeaders: [
...displayedHeaders,
{
key: '__publisher_key__',
fieldSchema: { type: 'string' },
metadatas: {
label: 'Publisher',
searchable: false,
sortable: false,
},
name: 'publisher',
cellFormatter: props => <p>{props}</p>
},
],
};
}
);
},
async registerTrads({ locales }) {
const importedTrads = [];
for (const locale of locales) {
try {
const data = await import(`./translations/${locale}.json`);
importedTrads.push({
data: prefixPluginTranslations(data, pluginId),
locale,
});
} catch (error) {
importedTrads.push({ data: {}, locale });
}
}
return importedTrads;
},
};
Results:
If I can help somehow, please let me know :) For now, I just don't know what else to do haha
Awesome! It still might not be possible as i18n injects the data into the content type itself as opposed to the way I am doing it which is a seperate content type.
I will try and have a look over the weekend to see if it's possible.
Hey! Any updates on this? :)
Unfortunately as the info is not actually on the schema aside from fetching it for each row in the table (which is not efficient) I do not see a way to do this.
So at this time it is not possible to do this. At some point I will probably migrate to using the injected fields like the i18n plugin does which will suport this behaviour but no ETA on that at this point.
I would like to add the date times for publish/unpublish to the List View as columns. How could that be possible? I saw Strapi offers a hook for that, but I didn't manage to find a way to set it.
Just to make it clear, the idea is to have a interface like this: