mirror of
https://github.com/strapi/strapi.git
synced 2025-06-27 00:41:25 +00:00
chore: set up preview feature boilerplate (#21443)
* chore: set up preview feature boilerplate * fix: admin build
This commit is contained in:
parent
927824c76d
commit
e7af8a5ec7
@ -1,5 +1,5 @@
|
||||
module.exports = ({ env }) => ({
|
||||
future: {
|
||||
contentReleasesScheduling: env.bool('STRAPI_FUTURE_CONTENT_RELEASES_SCHEDULING', false),
|
||||
preview: env.bool('STRAPI_FUTURE_PREVIEW', false),
|
||||
},
|
||||
});
|
||||
|
@ -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(
|
||||
|
17
packages/core/content-manager/admin/src/preview/LICENSE
Normal file
17
packages/core/content-manager/admin/src/preview/LICENSE
Normal 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.
|
@ -0,0 +1 @@
|
||||
export const FEATURE_ID = 'preview';
|
18
packages/core/content-manager/admin/src/preview/index.ts
Normal file
18
packages/core/content-manager/admin/src/preview/index.ts
Normal 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 };
|
@ -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 });
|
||||
};
|
||||
|
17
packages/core/content-manager/server/src/preview/LICENSE
Normal file
17
packages/core/content-manager/server/src/preview/LICENSE
Normal 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.
|
@ -0,0 +1 @@
|
||||
export const FEATURE_ID = 'preview';
|
22
packages/core/content-manager/server/src/preview/index.ts
Normal file
22
packages/core/content-manager/server/src/preview/index.ts
Normal 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();
|
@ -1,6 +1,6 @@
|
||||
export interface FeaturesConfig {
|
||||
future?: {
|
||||
contentReleases?: boolean;
|
||||
preview?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user