2020-03-06 13:33:07 +01: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';
|
2019-04-16 18:23:26 +02:00
|
|
|
import pluginPkg from '../../package.json';
|
2020-02-11 17:15:53 +01:00
|
|
|
import pluginLogo from './assets/images/logo.svg';
|
2020-06-10 14:52:09 +02:00
|
|
|
import pluginPermissions from './permissions';
|
2020-03-03 16:40:02 +01:00
|
|
|
import InputMedia from './components/InputMedia';
|
2021-05-26 07:28:22 +02:00
|
|
|
import InputModalStepper from './components/InputModalStepper';
|
2019-04-18 01:10:38 +02:00
|
|
|
import pluginId from './pluginId';
|
2020-03-16 13:37:10 +01:00
|
|
|
import { getTrad } from './utils';
|
2019-04-16 18:23:26 +02:00
|
|
|
|
2021-05-11 09:59:14 +02:00
|
|
|
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
|
|
|
const icon = pluginPkg.strapi.icon;
|
|
|
|
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-05-12 09:10:29 +02:00
|
|
|
// TODO update doc and guides
|
2021-05-12 15:33:02 +02:00
|
|
|
app.addComponents({ name: 'media-library', Component: InputModalStepper });
|
2021-06-16 13:05:21 +02:00
|
|
|
|
2021-09-10 14:03:18 +02:00
|
|
|
app.addMenuLink({
|
|
|
|
to: `/plugins/${pluginId}`,
|
|
|
|
icon,
|
|
|
|
intlLabel: {
|
|
|
|
id: `${pluginId}.plugin.name`,
|
|
|
|
defaultMessage: 'Media Library',
|
|
|
|
},
|
|
|
|
permissions: pluginPermissions.main,
|
|
|
|
Component: async () => {
|
2021-09-09 10:56:57 +02:00
|
|
|
const component = await import(/* webpackChunkName: "upload" */ './pages/App');
|
2021-06-16 13:05:21 +02:00
|
|
|
|
2021-09-10 14:03:18 +02:00
|
|
|
return component;
|
|
|
|
},
|
|
|
|
});
|
2021-06-16 13:05:21 +02:00
|
|
|
|
2021-05-12 15:33:02 +02:00
|
|
|
app.addFields({ type: 'media', Component: InputMedia });
|
2021-05-12 09:10:29 +02:00
|
|
|
|
2021-05-11 09:59:14 +02:00
|
|
|
app.registerPlugin({
|
|
|
|
description: pluginDescription,
|
|
|
|
icon,
|
|
|
|
id: pluginId,
|
2021-10-15 17:28:52 +02:00
|
|
|
isReady: true,
|
2021-05-11 09:59:14 +02:00
|
|
|
isRequired: pluginPkg.strapi.required || false,
|
|
|
|
name,
|
|
|
|
pluginLogo,
|
|
|
|
});
|
|
|
|
},
|
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',
|
2021-07-28 08:16:15 +02:00
|
|
|
Component: async () => {
|
|
|
|
const component = await import(
|
|
|
|
/* webpackChunkName: "upload-settings" */ './pages/SettingsPage'
|
|
|
|
);
|
|
|
|
|
|
|
|
return component;
|
|
|
|
},
|
2021-06-08 09:02:20 +02:00
|
|
|
permissions: pluginPermissions.settings,
|
|
|
|
});
|
|
|
|
},
|
2021-06-09 11:22:23 +02:00
|
|
|
async registerTrads({ locales }) {
|
|
|
|
const importedTrads = await Promise.all(
|
|
|
|
locales.map(locale => {
|
|
|
|
return import(
|
|
|
|
/* webpackChunkName: "upload-translation-[request]" */ `./translations/${locale}.json`
|
|
|
|
)
|
|
|
|
.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
|
|
|
};
|