chore: set up content history files (#19298)

* setup history server files

* add admin files

* chore: remove dedicated lifecycle files
This commit is contained in:
Rémi de Juvigny 2024-01-23 18:15:34 +01:00 committed by GitHub
parent af2ee25513
commit 18b28ce2ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 100 additions and 3 deletions

View File

@ -1 +1,5 @@
module.exports = ({ env }) => ({});
module.exports = ({ env }) => ({
future: {
history: true,
},
});

View File

@ -472,7 +472,7 @@ class StrapiApp {
);
invariant(component, 'A Component must be provided');
// @ts-expect-error we've alredy checked above that the block exists.
// @ts-expect-error we've already checked above that the block exists.
this.admin.injectionZones.contentManager[containerName][blockName].push(component);
};

View File

@ -0,0 +1 @@
If you or the company you represent has entered into a written agreement referencing the Enterprise Edition of the Strapi source code available at https://github.com/strapi/strapi, then such agreement applies to your use of the Enterprise Edition of the Strapi Software. If you or the company you represent is using the Enterprise Edition of the Strapi Software in connection with a subscription to our cloud offering, then the agreement you have agreed to with respect to our cloud offering and the licenses included in such agreement apply to your use of the Enterprise Edition of the Strapi Software. Otherwise, the Strapi Enterprise Software License Agreement (found here https://strapi.io/enterprise-terms) applies to your use of the Enterprise Edition of the Strapi Software. BY ACCESSING OR USING THE ENTERPRISE EDITION OF THE STRAPI SOFTWARE, YOU ARE AGREEING TO BE BOUND BY THE RELEVANT REFERENCED AGREEMENT. IF YOU ARE NOT AUTHORIZED TO ACCEPT THESE TERMS ON BEHALF OF THE COMPANY YOU REPRESENT OR IF YOU DO NOT AGREE TO ALL OF THE RELEVANT TERMS AND CONDITIONS REFERENCED AND YOU HAVE NOT OTHERWISE EXECUTED A WRITTEN AGREEMENT WITH STRAPI, YOU ARE NOT AUTHORIZED TO ACCESS OR USE OR ALLOW ANY USER TO ACCESS OR USE ANY PART OF THE ENTERPRISE EDITION OF THE STRAPI SOFTWARE. YOUR ACCESS RIGHTS ARE CONDITIONAL ON YOUR CONSENT TO THE RELEVANT REFERENCED TERMS TO THE EXCLUSION OF ALL OTHER TERMS; IF THE RELEVANT REFERENCED TERMS ARE CONSIDERED AN OFFER BY YOU, ACCEPTANCE IS EXPRESSLY LIMITED TO THE RELEVANT REFERENCED TERMS.

View File

@ -0,0 +1,9 @@
/* eslint-disable check-file/filename-naming-convention */
import { type RouteObject } from 'react-router-dom';
/**
* These routes will be merged with the rest of the Content Manager routes
*/
const routes: RouteObject[] = [];
export { routes };

View File

@ -2,6 +2,8 @@
import { UID } from '@strapi/types';
import { Navigate, RouteObject, useLoaderData } from 'react-router-dom';
import { routes as historyRoutes } from './history/routes';
const Redirect = () => {
const pathname = useLoaderData() as string;
@ -132,6 +134,7 @@ const routes: RouteObject[] = [
};
},
},
...historyRoutes,
],
},
];

View File

@ -1,5 +1,6 @@
import { getService } from './utils';
import { ALLOWED_WEBHOOK_EVENTS } from './constants';
import history from './history';
export default async () => {
Object.entries(ALLOWED_WEBHOOK_EVENTS).forEach(([key, value]) => {
@ -10,4 +11,6 @@ export default async () => {
await getService('components').syncConfigurations();
await getService('content-types').syncConfigurations();
await getService('permission').registerPermissions();
await history.bootstrap?.({ strapi });
};

View File

@ -5,6 +5,7 @@ import init from './init';
import relations from './relations';
import singleTypes from './single-types';
import uid from './uid';
import history from '../history';
export default {
'collection-types': collectionTypes,
@ -14,4 +15,5 @@ export default {
relations,
'single-types': singleTypes,
uid,
...(history.controllers ? history.controllers : {}),
};

View File

@ -0,0 +1,8 @@
import type { Plugin } from '@strapi/types';
import history from './history';
const destroy: Plugin.LoadedPlugin['destroy'] = async ({ strapi }) => {
await history.destroy?.({ strapi });
};
export default destroy;

View File

@ -0,0 +1 @@
If you or the company you represent has entered into a written agreement referencing the Enterprise Edition of the Strapi source code available at https://github.com/strapi/strapi, then such agreement applies to your use of the Enterprise Edition of the Strapi Software. If you or the company you represent is using the Enterprise Edition of the Strapi Software in connection with a subscription to our cloud offering, then the agreement you have agreed to with respect to our cloud offering and the licenses included in such agreement apply to your use of the Enterprise Edition of the Strapi Software. Otherwise, the Strapi Enterprise Software License Agreement (found here https://strapi.io/enterprise-terms) applies to your use of the Enterprise Edition of the Strapi Software. BY ACCESSING OR USING THE ENTERPRISE EDITION OF THE STRAPI SOFTWARE, YOU ARE AGREEING TO BE BOUND BY THE RELEVANT REFERENCED AGREEMENT. IF YOU ARE NOT AUTHORIZED TO ACCEPT THESE TERMS ON BEHALF OF THE COMPANY YOU REPRESENT OR IF YOU DO NOT AGREE TO ALL OF THE RELEVANT TERMS AND CONDITIONS REFERENCED AND YOU HAVE NOT OTHERWISE EXECUTED A WRITTEN AGREEMENT WITH STRAPI, YOU ARE NOT AUTHORIZED TO ACCESS OR USE OR ALLOW ANY USER TO ACCESS OR USE ANY PART OF THE ENTERPRISE EDITION OF THE STRAPI SOFTWARE. YOUR ACCESS RIGHTS ARE CONDITIONAL ON YOUR CONSENT TO THE RELEVANT REFERENCED TERMS TO THE EXCLUSION OF ALL OTHER TERMS; IF THE RELEVANT REFERENCED TERMS ARE CONSIDERED AN OFFER BY YOU, ACCEPTANCE IS EXPRESSLY LIMITED TO THE RELEVANT REFERENCED TERMS.

View File

@ -0,0 +1,7 @@
import type { Plugin } from '@strapi/types';
/**
* The controllers will me merged with the other Content Manager controllers,
* so we need to avoid conficts in the controller names.
*/
export const controllers: Plugin.LoadedPlugin['controllers'] = {};

View File

@ -0,0 +1,31 @@
import type { Plugin } from '@strapi/types';
import { controllers } from './controllers';
import { services } from './services';
/**
* Check once if the feature is enabled (both license info & feature flag) before loading it,
* so that we can assume it is enabled in the other files.
*/
const getFeature = (): Partial<Plugin.LoadedPlugin> => {
// TODO: add license check here when it's ready on the license registry
if (strapi.features.future.isEnabled('history')) {
const register: Plugin.LoadedPlugin['register'] = async () => {
// TODO: remove log once there are actual features
console.log('registering history feature');
};
const bootstrap: Plugin.LoadedPlugin['bootstrap'] = async () => {};
const destroy: Plugin.LoadedPlugin['destroy'] = async () => {};
return {
register,
bootstrap,
controllers,
services,
destroy,
};
}
return {};
};
export default getFeature();

View File

@ -0,0 +1,7 @@
import type { Plugin } from '@strapi/types';
/**
* The routes will me merged with the other Content Manager routers,
* so we need to avoid conficts in the router name, and to prefix the path for each route.
*/
export const routes: Plugin.LoadedPlugin['routes'] = {};

View File

@ -0,0 +1,3 @@
import type { Plugin } from '@strapi/types';
export const services: Plugin.LoadedPlugin['services'] = {};

View File

@ -1,4 +1,6 @@
import register from './register';
import bootstrap from './bootstrap';
import destroy from './destroy';
import routes from './routes';
import policies from './policies';
import controllers from './controllers';
@ -6,7 +8,9 @@ import services from './services';
export default () => {
return {
register,
bootstrap,
destroy,
controllers,
routes,
policies,

View File

@ -0,0 +1,8 @@
import type { Plugin } from '@strapi/types';
import history from './history';
const register: Plugin.LoadedPlugin['register'] = async ({ strapi }) => {
await history.register?.({ strapi });
};
export default register;

View File

@ -1,3 +1,7 @@
import admin from './admin';
import history from '../history';
export default { admin };
export default {
admin,
...(history.routes ? history.routes : {}),
};

View File

@ -8,6 +8,7 @@ import permissionChecker from './permission-checker';
import permission from './permission';
import populateBuilder from './populate-builder';
import uid from './uid';
import history from '../history';
export default {
components,
@ -20,4 +21,5 @@ export default {
permission,
'populate-builder': populateBuilder,
uid,
...(history.services ? history.services : {}),
};