mirror of
https://github.com/strapi/strapi.git
synced 2025-11-03 11:25:17 +00:00
Init load upload
Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
parent
1989f6dfac
commit
c4560c95b3
@ -4,6 +4,8 @@ class Plugin {
|
||||
// TODO
|
||||
this.description = pluginConf.description;
|
||||
// TODO
|
||||
this.fileModel = pluginConf.fileModel || null;
|
||||
// TODO
|
||||
this.icon = pluginConf.icon;
|
||||
this.initializer = pluginConf.initializer || null;
|
||||
|
||||
|
||||
@ -6,12 +6,14 @@ import usersPermissionsPlugin from '../../../../plugins/users-permissions/admin/
|
||||
import cmPlugin from '../../../content-manager/admin/src';
|
||||
import ctbPlugin from '../../../content-type-builder/admin/src';
|
||||
import emailPlugin from '../../../email/admin/src';
|
||||
import uploadPlugin from '../../../upload/admin/src';
|
||||
|
||||
const plugins = {
|
||||
'@strapi/plugin-content-manager': cmPlugin,
|
||||
'@strapi/plugin-content-type-builder': ctbPlugin,
|
||||
'@strapi/plugin-documentation': documentationPlugin,
|
||||
'@strapi/plugin-email': emailPlugin,
|
||||
'@strapi/plugin-upload': uploadPlugin,
|
||||
'@strapi/plugin-graphql': graphqlPlugin,
|
||||
'@strapi/plugin-sentry': sentryPlugin,
|
||||
'@strapi/plugin-users-permissions': usersPermissionsPlugin,
|
||||
|
||||
@ -9,9 +9,9 @@ import PropTypes from 'prop-types';
|
||||
import { request } from '@strapi/helper-plugin';
|
||||
import pluginId from '../../pluginId';
|
||||
|
||||
const Initializer = ({ updatePlugin }) => {
|
||||
const Initializer = ({ setPlugin }) => {
|
||||
const ref = useRef();
|
||||
ref.current = updatePlugin;
|
||||
ref.current = setPlugin;
|
||||
|
||||
useEffect(() => {
|
||||
const getData = async () => {
|
||||
@ -38,7 +38,7 @@ const Initializer = ({ updatePlugin }) => {
|
||||
};
|
||||
|
||||
Initializer.propTypes = {
|
||||
updatePlugin: PropTypes.func.isRequired,
|
||||
setPlugin: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
export default Initializer;
|
||||
|
||||
@ -19,67 +19,128 @@ import trads from './translations';
|
||||
import pluginId from './pluginId';
|
||||
import { getTrad } from './utils';
|
||||
|
||||
export default strapi => {
|
||||
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
||||
const icon = pluginPkg.strapi.icon;
|
||||
const name = pluginPkg.strapi.name;
|
||||
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
||||
const icon = pluginPkg.strapi.icon;
|
||||
const name = pluginPkg.strapi.name;
|
||||
|
||||
const plugin = {
|
||||
blockerComponent: null,
|
||||
blockerComponentProps: {},
|
||||
description: pluginDescription,
|
||||
fileModel: null,
|
||||
icon,
|
||||
id: pluginId,
|
||||
initializer: Initializer,
|
||||
injectedComponents: [],
|
||||
isReady: false,
|
||||
isRequired: pluginPkg.strapi.required || false,
|
||||
layout: null,
|
||||
lifecycles: null,
|
||||
mainComponent: App,
|
||||
name,
|
||||
pluginLogo,
|
||||
preventComponentRendering: false,
|
||||
settings: {
|
||||
global: {
|
||||
links: [
|
||||
export default {
|
||||
register(app) {
|
||||
app.componentApi.registerComponent({ name: 'media-library', Component: InputModalStepper });
|
||||
app.fieldApi.registerField({ type: 'media', Component: InputMedia });
|
||||
|
||||
app.registerPlugin({
|
||||
description: pluginDescription,
|
||||
// FIXME
|
||||
fileModel: null,
|
||||
icon,
|
||||
id: pluginId,
|
||||
initializer: Initializer,
|
||||
|
||||
isReady: false,
|
||||
isRequired: pluginPkg.strapi.required || false,
|
||||
|
||||
mainComponent: App,
|
||||
name,
|
||||
pluginLogo,
|
||||
preventComponentRendering: false,
|
||||
settings: {
|
||||
global: {
|
||||
links: [
|
||||
{
|
||||
title: {
|
||||
id: getTrad('plugin.name'),
|
||||
defaultMessage: 'Media Library',
|
||||
},
|
||||
name: 'media-library',
|
||||
to: '/settings/media-library',
|
||||
Component: () => (
|
||||
<CheckPagePermissions permissions={pluginPermissions.settings}>
|
||||
<SettingsPage />
|
||||
</CheckPagePermissions>
|
||||
),
|
||||
permissions: pluginPermissions.settings,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
trads,
|
||||
menu: {
|
||||
pluginsSectionLinks: [
|
||||
{
|
||||
title: {
|
||||
id: getTrad('plugin.name'),
|
||||
destination: `/plugins/${pluginId}`,
|
||||
icon,
|
||||
label: {
|
||||
id: `${pluginId}.plugin.name`,
|
||||
defaultMessage: 'Media Library',
|
||||
},
|
||||
name: 'media-library',
|
||||
to: '/settings/media-library',
|
||||
Component: () => (
|
||||
<CheckPagePermissions permissions={pluginPermissions.settings}>
|
||||
<SettingsPage />
|
||||
</CheckPagePermissions>
|
||||
),
|
||||
permissions: pluginPermissions.settings,
|
||||
name,
|
||||
permissions: pluginPermissions.main,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
trads,
|
||||
menu: {
|
||||
pluginsSectionLinks: [
|
||||
{
|
||||
destination: `/plugins/${pluginId}`,
|
||||
icon,
|
||||
label: {
|
||||
id: `${pluginId}.plugin.name`,
|
||||
defaultMessage: 'Media Library',
|
||||
},
|
||||
name,
|
||||
permissions: pluginPermissions.main,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
strapi.registerComponent({ name: 'media-library', Component: InputModalStepper });
|
||||
strapi.registerField({ type: 'media', Component: InputMedia });
|
||||
|
||||
return strapi.registerPlugin(plugin);
|
||||
});
|
||||
},
|
||||
boot() {},
|
||||
};
|
||||
|
||||
// export default strapi => {
|
||||
|
||||
// const plugin = {
|
||||
// blockerComponent: null,
|
||||
// blockerComponentProps: {},
|
||||
// description: pluginDescription,
|
||||
// fileModel: null,
|
||||
// icon,
|
||||
// id: pluginId,
|
||||
// initializer: Initializer,
|
||||
// injectedComponents: [],
|
||||
// isReady: false,
|
||||
// isRequired: pluginPkg.strapi.required || false,
|
||||
// layout: null,
|
||||
// lifecycles: null,
|
||||
// mainComponent: App,
|
||||
// name,
|
||||
// pluginLogo,
|
||||
// preventComponentRendering: false,
|
||||
// settings: {
|
||||
// global: {
|
||||
// links: [
|
||||
// {
|
||||
// title: {
|
||||
// id: getTrad('plugin.name'),
|
||||
// defaultMessage: 'Media Library',
|
||||
// },
|
||||
// name: 'media-library',
|
||||
// to: '/settings/media-library',
|
||||
// Component: () => (
|
||||
// <CheckPagePermissions permissions={pluginPermissions.settings}>
|
||||
// <SettingsPage />
|
||||
// </CheckPagePermissions>
|
||||
// ),
|
||||
// permissions: pluginPermissions.settings,
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// },
|
||||
// trads,
|
||||
// menu: {
|
||||
// pluginsSectionLinks: [
|
||||
// {
|
||||
// destination: `/plugins/${pluginId}`,
|
||||
// icon,
|
||||
// label: {
|
||||
// id: `${pluginId}.plugin.name`,
|
||||
// defaultMessage: 'Media Library',
|
||||
// },
|
||||
// name,
|
||||
// permissions: pluginPermissions.main,
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// };
|
||||
|
||||
// strapi.registerComponent({ name: 'media-library', Component: InputModalStepper });
|
||||
// strapi.registerField({ type: 'media', Component: InputMedia });
|
||||
|
||||
// return strapi.registerPlugin(plugin);
|
||||
// };
|
||||
|
||||
@ -1,8 +1,13 @@
|
||||
import { get } from 'lodash';
|
||||
import pluginId from '../pluginId';
|
||||
|
||||
// FIXME
|
||||
const getFileModelTimestamps = plugins => {
|
||||
const timestamps = get(plugins, [pluginId, 'fileModel', 'options', 'timestamps']);
|
||||
const timestamps = get(
|
||||
plugins,
|
||||
[pluginId, 'fileModel', 'options', 'timestamps'],
|
||||
['created_at', 'updated_at']
|
||||
);
|
||||
|
||||
// All connectors must initialise the "timestamps" option as a tuple
|
||||
if (!Array.isArray(timestamps) || timestamps.length !== 2) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user