Skip to content

Commit

Permalink
feat(history): add history-version content type (#19316)
Browse files Browse the repository at this point in the history
* feat: add history version content type

* chore: disable i18n and review workflows

* fix: i18n

* chore: use Schema.CollectionType
  • Loading branch information
remidej committed Jan 25, 2024
1 parent ea0fc28 commit be6cc4a
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 1 deletion.
@@ -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',
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,
};
};

0 comments on commit be6cc4a

Please sign in to comment.