Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(history): add history-version content type #19316

Merged
merged 4 commits into from Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,63 @@
import type { Schema } from '@strapi/types';

const historyVersion: { schema: Schema.CollectionType } = {
schema: {
uid: 'plugin::content-manager.history-version',
modelName: 'history-version',
globalId: 'ContentManagerHistoryVersion',
remidej marked this conversation as resolved.
Show resolved Hide resolved
kind: 'collectionType',
modelType: 'contentType',
collectionName: 'strapi_history_versions',
info: {
singularName: 'history-version',
pluralName: 'history-versions',
displayName: 'History Version',
},
pluginOptions: {
'content-manager': {
visible: false,
},
'content-type-builder': {
visible: false,
},
i18n: {
localized: false,
},
},
attributes: {
contentType: {
type: 'string',
required: true,
},
// documentId is a reserved attribute name
relatedDocumentId: {
type: 'string',
required: true,
},
locale: {
type: 'string',
required: false,
},
status: {
type: 'enumeration',
enum: ['draft', 'published', 'modified'],
},
data: {
type: 'json',
},
schema: {
type: 'json',
},
createdAt: {
type: 'date',
},
createdBy: {
type: 'relation',
relation: 'oneToOne',
target: 'admin::user',
},
},
},
};

export { historyVersion };
@@ -0,0 +1,5 @@
import { historyVersion } from './history-version';

export const contentTypes = {
'history-version': historyVersion,
};
8 changes: 7 additions & 1 deletion packages/core/content-manager/server/src/history/index.ts
@@ -1,6 +1,7 @@
import type { Plugin } from '@strapi/types';
import { controllers } from './controllers';
import { services } from './services';
import { contentTypes } from './content-types';

/**
* Check once if the feature is enabled (both license info & feature flag) before loading it,
Expand All @@ -22,10 +23,15 @@ const getFeature = (): Partial<Plugin.LoadedPlugin> => {
controllers,
services,
destroy,
contentTypes,
};
}

return {};
/**
* Keep returning contentTypes to avoid losing the data if the feature is disabled,
* or if the license expires.
*/
return { contentTypes };
};

export default getFeature();
2 changes: 2 additions & 0 deletions packages/core/content-manager/server/src/index.ts
Expand Up @@ -5,6 +5,7 @@ import routes from './routes';
import policies from './policies';
import controllers from './controllers';
import services from './services';
import history from './history';

export default () => {
return {
Expand All @@ -15,5 +16,6 @@ export default () => {
routes,
policies,
services,
contentTypes: history.contentTypes,
};
};