2023-08-29 09:24:29 +02:00
|
|
|
// NOTE TO PLUGINS DEVELOPERS:
|
|
|
|
// If you modify this file by adding new options to the plugin entry point
|
|
|
|
// Here's the file: strapi/docs/3.0.0-beta.x/plugin-development/frontend-field-api.md
|
|
|
|
// Here's the file: strapi/docs/3.0.0-beta.x/guides/registering-a-field-in-admin.md
|
|
|
|
// 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
|
2021-07-28 08:16:15 +02:00
|
|
|
import { prefixPluginTranslations } from '@strapi/helper-plugin';
|
2023-06-12 16:22:11 +02:00
|
|
|
|
2019-04-16 18:23:26 +02:00
|
|
|
import pluginPkg from '../../package.json';
|
2023-06-12 16:22:11 +02:00
|
|
|
|
|
|
|
import { MediaLibraryDialog } from './components/MediaLibraryDialog';
|
|
|
|
import { MediaLibraryInput } from './components/MediaLibraryInput';
|
2021-10-22 14:42:34 +02:00
|
|
|
import PluginIcon from './components/PluginIcon';
|
2023-06-20 13:15:59 +02:00
|
|
|
import { PERMISSIONS } from './constants';
|
2019-04-18 01:10:38 +02:00
|
|
|
import pluginId from './pluginId';
|
2021-11-02 08:52:06 +01:00
|
|
|
import getTrad from './utils/getTrad';
|
2019-04-16 18:23:26 +02:00
|
|
|
|
2021-05-11 09:59:14 +02:00
|
|
|
const name = pluginPkg.strapi.name;
|
2020-06-09 15:01:35 +02:00
|
|
|
|
2021-05-11 09:59:14 +02:00
|
|
|
export default {
|
|
|
|
register(app) {
|
2021-09-10 14:03:18 +02:00
|
|
|
app.addMenuLink({
|
|
|
|
to: `/plugins/${pluginId}`,
|
2021-10-22 14:42:34 +02:00
|
|
|
icon: PluginIcon,
|
2021-09-10 14:03:18 +02:00
|
|
|
intlLabel: {
|
|
|
|
id: `${pluginId}.plugin.name`,
|
|
|
|
defaultMessage: 'Media Library',
|
|
|
|
},
|
2023-06-20 13:15:59 +02:00
|
|
|
permissions: PERMISSIONS.main,
|
2023-08-29 09:24:29 +02:00
|
|
|
async Component() {
|
2023-10-30 11:36:16 +00:00
|
|
|
const component = await import('./pages/App');
|
2023-08-29 09:24:29 +02:00
|
|
|
|
|
|
|
return component;
|
|
|
|
},
|
2021-09-10 14:03:18 +02:00
|
|
|
});
|
2021-06-16 13:05:21 +02:00
|
|
|
|
2021-11-05 15:52:41 +01:00
|
|
|
app.addFields({ type: 'media', Component: MediaLibraryInput });
|
2021-11-15 09:11:08 +01:00
|
|
|
app.addComponents([{ name: 'media-library', Component: MediaLibraryDialog }]);
|
2021-05-12 09:10:29 +02:00
|
|
|
|
2021-05-11 09:59:14 +02:00
|
|
|
app.registerPlugin({
|
|
|
|
id: pluginId,
|
|
|
|
name,
|
|
|
|
});
|
|
|
|
},
|
2021-07-21 09:05:20 +02:00
|
|
|
bootstrap(app) {
|
2021-06-08 09:02:20 +02:00
|
|
|
app.addSettingsLink('global', {
|
2021-06-08 09:37:14 +02:00
|
|
|
id: 'media-library-settings',
|
2021-06-08 09:02:20 +02:00
|
|
|
intlLabel: {
|
|
|
|
id: getTrad('plugin.name'),
|
|
|
|
defaultMessage: 'Media Library',
|
|
|
|
},
|
|
|
|
to: '/settings/media-library',
|
2023-08-29 09:24:29 +02:00
|
|
|
async Component() {
|
2023-10-30 11:36:16 +00:00
|
|
|
const component = await import('./pages/SettingsPage');
|
2023-08-29 09:24:29 +02:00
|
|
|
|
|
|
|
return component;
|
|
|
|
},
|
2023-06-20 13:15:59 +02:00
|
|
|
permissions: PERMISSIONS.settings,
|
2021-06-08 09:02:20 +02:00
|
|
|
});
|
|
|
|
},
|
2021-06-09 11:22:23 +02:00
|
|
|
async registerTrads({ locales }) {
|
|
|
|
const importedTrads = await Promise.all(
|
2022-08-08 23:33:39 +02:00
|
|
|
locales.map((locale) => {
|
2023-10-30 11:36:16 +00:00
|
|
|
return import(`./translations/${locale}.json`)
|
2021-06-09 11:22:23 +02:00
|
|
|
.then(({ default: data }) => {
|
|
|
|
return {
|
2021-06-09 12:11:51 +02:00
|
|
|
data: prefixPluginTranslations(data, pluginId),
|
2021-06-09 11:22:23 +02:00
|
|
|
locale,
|
|
|
|
};
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
return {
|
|
|
|
data: {},
|
|
|
|
locale,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
return Promise.resolve(importedTrads);
|
|
|
|
},
|
2021-05-11 09:59:14 +02:00
|
|
|
};
|