chore: set up preview feature boilerplate (#21443)

* chore: set up preview feature boilerplate

* fix: admin build
This commit is contained in:
Rémi de Juvigny 2024-09-25 05:54:59 -04:00 committed by GitHub
parent 927824c76d
commit e7af8a5ec7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 84 additions and 2 deletions

View File

@ -1,5 +1,5 @@
module.exports = ({ env }) => ({
future: {
contentReleasesScheduling: env.bool('STRAPI_FUTURE_CONTENT_RELEASES_SCHEDULING', false),
preview: env.bool('STRAPI_FUTURE_PREVIEW', false),
},
});

View File

@ -4,6 +4,7 @@ import { PLUGIN_ID } from './constants/plugin';
import { ContentManagerPlugin } from './content-manager';
import { historyAdmin } from './history';
import { reducer } from './modules/reducers';
import { previewAdmin } from './preview';
import { routes } from './router';
import { prefixPluginTranslations } from './utils/translations';
@ -45,6 +46,9 @@ export default {
if (typeof historyAdmin.bootstrap === 'function') {
historyAdmin.bootstrap(app);
}
if (typeof previewAdmin.bootstrap === 'function') {
previewAdmin.bootstrap(app);
}
},
async registerTrads({ locales }: { locales: string[] }) {
const importedTrads = await Promise.all(

View File

@ -0,0 +1,17 @@
Copyright (c) 2015-present Strapi Solutions SAS
* All software that resides within this directory and its subdirectories, is licensed under the license defined below.
Enterprise License
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 @@
export const FEATURE_ID = 'preview';

View File

@ -0,0 +1,18 @@
/* eslint-disable check-file/no-index */
import { FEATURE_ID } from './constants';
import type { PluginDefinition } from '@strapi/admin/strapi-admin';
const previewAdmin = {
bootstrap(app) {
// TODO: Add license registry check when it's available
if (!window.strapi.future.isEnabled(FEATURE_ID)) {
return {};
}
// eslint-disable-next-line no-console -- TODO remove when we have real functionality
console.log('Bootstrapping preview admin');
},
} satisfies Partial<PluginDefinition>;
export { previewAdmin };

View File

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

View File

@ -0,0 +1,17 @@
Copyright (c) 2015-present Strapi Solutions SAS
* All software that resides within this directory and its subdirectories, is licensed under the license defined below.
Enterprise License
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 @@
export const FEATURE_ID = 'preview';

View File

@ -0,0 +1,22 @@
import type { Plugin } from '@strapi/types';
import { FEATURE_ID } from './constants';
/**
* Check once if the feature is enabled before loading it,
* so that we can assume it is enabled in the other files.
*/
const getFeature = (): Partial<Plugin.LoadedPlugin> => {
// TODO: Add license registry check when it's available
if (!strapi.features.future.isEnabled(FEATURE_ID)) {
return {};
}
return {
bootstrap() {
// eslint-disable-next-line no-console -- TODO remove when we have real functionality
console.log('Bootstrapping preview server');
},
};
};
export default getFeature();

View File

@ -1,6 +1,6 @@
export interface FeaturesConfig {
future?: {
contentReleases?: boolean;
preview?: boolean;
};
}