2021-01-29 10:08:58 +01:00
|
|
|
import React from 'react';
|
2021-01-26 16:18:26 +01:00
|
|
|
import * as yup from 'yup';
|
2021-01-22 17:57:15 +01:00
|
|
|
import pluginPkg from '../../package.json';
|
2021-01-26 10:31:50 +01:00
|
|
|
import middlewares from './middlewares';
|
2021-01-22 17:57:15 +01:00
|
|
|
import pluginId from './pluginId';
|
|
|
|
import pluginLogo from './assets/images/logo.svg';
|
|
|
|
import trads from './translations';
|
2021-01-28 11:33:37 +01:00
|
|
|
import { getTrad } from './utils';
|
|
|
|
import SettingsPage from './containers/SettingsPage';
|
2021-02-08 13:47:43 +01:00
|
|
|
import pluginPermissions from './permissions';
|
2021-01-22 17:57:15 +01:00
|
|
|
|
|
|
|
export default strapi => {
|
|
|
|
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
|
|
|
|
2021-01-26 10:31:50 +01:00
|
|
|
middlewares.forEach(middleware => {
|
|
|
|
strapi.middlewares.add(middleware);
|
|
|
|
});
|
|
|
|
|
2021-01-22 17:57:15 +01:00
|
|
|
const plugin = {
|
|
|
|
blockerComponent: null,
|
|
|
|
blockerComponentProps: {},
|
|
|
|
description: pluginDescription,
|
|
|
|
icon: pluginPkg.strapi.icon,
|
|
|
|
id: pluginId,
|
|
|
|
isReady: true,
|
|
|
|
initializer: () => null,
|
|
|
|
injectedComponents: [],
|
|
|
|
isRequired: pluginPkg.strapi.required || false,
|
|
|
|
layout: null,
|
|
|
|
lifecycles: () => {},
|
|
|
|
mainComponent: null,
|
|
|
|
name: pluginPkg.strapi.name,
|
|
|
|
pluginLogo,
|
|
|
|
preventComponentRendering: false,
|
2021-01-28 11:33:37 +01:00
|
|
|
settings: {
|
|
|
|
global: {
|
|
|
|
links: [
|
|
|
|
{
|
|
|
|
title: {
|
|
|
|
id: getTrad('plugin.name'),
|
2021-01-29 10:08:58 +01:00
|
|
|
defaultMessage: 'Internationalization',
|
2021-01-28 11:33:37 +01:00
|
|
|
},
|
2021-01-29 10:08:58 +01:00
|
|
|
name: 'internationalization',
|
|
|
|
to: `${strapi.settingsBaseURL}/internationalization`,
|
2021-01-28 11:33:37 +01:00
|
|
|
Component: () => <SettingsPage />,
|
2021-02-08 13:47:43 +01:00
|
|
|
permissions: pluginPermissions.accessMain,
|
2021-01-28 11:33:37 +01:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
2021-01-22 17:57:15 +01:00
|
|
|
trads,
|
2021-01-26 16:18:26 +01:00
|
|
|
boot(app) {
|
|
|
|
const ctbPlugin = app.getPlugin('content-type-builder');
|
|
|
|
|
|
|
|
if (ctbPlugin) {
|
|
|
|
ctbPlugin.internals.forms.extendFields(['text', 'string'], {
|
|
|
|
validator: {
|
|
|
|
i18n: yup.string().required(),
|
|
|
|
},
|
|
|
|
form: {
|
|
|
|
advanced(args) {
|
|
|
|
console.log('advanced', args);
|
|
|
|
|
|
|
|
return [[{ name: 'i18n', type: 'text', label: { id: 'i18nTest' } }]];
|
|
|
|
},
|
|
|
|
base(args) {
|
|
|
|
console.log('base', args);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2021-01-22 17:57:15 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
return strapi.registerPlugin(plugin);
|
|
|
|
};
|