mirror of
https://github.com/strapi/strapi.git
synced 2025-12-26 14:44:31 +00:00
feat: disable dp by default (#19743)
This commit is contained in:
parent
364e8c4870
commit
fc1ac2acd5
@ -22,6 +22,7 @@ describe.skip('Admin Permissions - Conditions', () => {
|
||||
singularName: 'article',
|
||||
pluralName: 'articles',
|
||||
displayName: 'Article',
|
||||
draftAndPublish: true,
|
||||
attributes: {
|
||||
title: {
|
||||
type: 'string',
|
||||
@ -40,6 +41,7 @@ describe.skip('Admin Permissions - Conditions', () => {
|
||||
singularName: 'category',
|
||||
pluralName: 'categories',
|
||||
displayName: 'Category',
|
||||
draftAndPublish: true,
|
||||
attributes: {
|
||||
name: {
|
||||
type: 'string',
|
||||
|
||||
@ -20,6 +20,7 @@ const baseWorkflow = {
|
||||
const productUID = 'api::product.product';
|
||||
const productModel = {
|
||||
pluginOptions: {},
|
||||
draftAndPublish: true,
|
||||
singularName: 'product',
|
||||
pluralName: 'products',
|
||||
displayName: 'Product',
|
||||
@ -34,6 +35,7 @@ const productModel = {
|
||||
const articleUID = 'api::article.article';
|
||||
const articleModel = {
|
||||
pluginOptions: {},
|
||||
draftAndPublish: true,
|
||||
singularName: 'article',
|
||||
pluralName: 'articles',
|
||||
displayName: 'Article',
|
||||
|
||||
@ -12,6 +12,7 @@ const model = {
|
||||
pluralName: 'products',
|
||||
displayName: 'Product',
|
||||
kind: 'collectionType',
|
||||
draftAndPublish: true,
|
||||
attributes: {
|
||||
name: {
|
||||
type: 'string',
|
||||
|
||||
@ -20,6 +20,7 @@ const edition = process.env.STRAPI_DISABLE_EE === 'true' ? 'CE' : 'EE';
|
||||
const productUID = 'api::product.product';
|
||||
const model = {
|
||||
pluginOptions: {},
|
||||
draftAndPublish: false,
|
||||
singularName: 'product',
|
||||
pluralName: 'products',
|
||||
displayName: 'Product',
|
||||
@ -57,11 +58,6 @@ describe.skip('Review workflows', () => {
|
||||
body: data,
|
||||
});
|
||||
|
||||
await requests.admin({
|
||||
method: 'POST',
|
||||
url: `/content-manager/collection-types/${uid}/${body.id}/actions/publish`,
|
||||
});
|
||||
|
||||
return body;
|
||||
};
|
||||
|
||||
|
||||
@ -43,6 +43,7 @@ const productWithCompoAndDP = {
|
||||
repeatable: true,
|
||||
},
|
||||
},
|
||||
draftAndPublish: true,
|
||||
displayName: 'product with compo and DP',
|
||||
singularName: 'product-with-compo-and-dp',
|
||||
pluralName: 'product-with-compo-and-dps',
|
||||
|
||||
@ -42,6 +42,7 @@ const productWithCompoAndDP = {
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
draftAndPublish: true,
|
||||
displayName: 'product with compo and DP',
|
||||
singularName: 'product-with-compo-and-dp',
|
||||
pluralName: 'product-with-compo-and-dps',
|
||||
|
||||
@ -42,6 +42,7 @@ const productWithCompoAndDP = {
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
draftAndPublish: true,
|
||||
displayName: 'product with dz and DP',
|
||||
singularName: 'product-with-dz-and-dp',
|
||||
pluralName: 'product-with-dz-and-dps',
|
||||
|
||||
@ -25,6 +25,7 @@ const productWithDP = {
|
||||
maxLength: 30,
|
||||
},
|
||||
},
|
||||
draftAndPublish: true,
|
||||
displayName: 'product with DP',
|
||||
singularName: 'product-with-dp',
|
||||
pluralName: 'product-with-dps',
|
||||
|
||||
@ -40,6 +40,7 @@ const productWithDz = {
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
draftAndPublish: true,
|
||||
displayName: 'Product with dz',
|
||||
singularName: 'product-with-dz',
|
||||
pluralName: 'product-with-dzs',
|
||||
|
||||
@ -35,6 +35,7 @@ const product = {
|
||||
},
|
||||
},
|
||||
},
|
||||
draftAndPublish: true,
|
||||
displayName: 'Product',
|
||||
singularName: 'product',
|
||||
pluralName: 'products',
|
||||
|
||||
@ -24,6 +24,7 @@ const product = {
|
||||
localized: true,
|
||||
},
|
||||
},
|
||||
draftAndPublish: true,
|
||||
displayName: 'Product',
|
||||
singularName: 'product',
|
||||
pluralName: 'products',
|
||||
|
||||
@ -18,6 +18,7 @@ const productModel = {
|
||||
pluralName: 'products',
|
||||
description: '',
|
||||
collectionName: '',
|
||||
draftAndPublish: true,
|
||||
pluginOptions: {
|
||||
i18n: {
|
||||
localized: true,
|
||||
|
||||
@ -62,6 +62,7 @@ const productModel = () => ({
|
||||
pluralName: 'products',
|
||||
description: '',
|
||||
collectionName: '',
|
||||
draftAndPublish: true,
|
||||
pluginOptions: {
|
||||
i18n: {
|
||||
localized: true,
|
||||
@ -80,6 +81,7 @@ const employeeModal = () => ({
|
||||
pluralName: 'employees',
|
||||
description: '',
|
||||
collectionName: '',
|
||||
draftAndPublish: true,
|
||||
attributes: {
|
||||
name: {
|
||||
type: 'string',
|
||||
@ -91,6 +93,7 @@ const shopModel = () => ({
|
||||
displayName: 'Shop',
|
||||
singularName: 'shop',
|
||||
pluralName: 'shops',
|
||||
draftAndPublish: true,
|
||||
pluginOptions: {
|
||||
i18n: {
|
||||
localized: true,
|
||||
|
||||
@ -20,6 +20,7 @@ const bedModel = {
|
||||
singularName: 'bed',
|
||||
pluralName: 'beds',
|
||||
kind: 'collectionType',
|
||||
draftAndPublish: true,
|
||||
options: {
|
||||
noStageAttribute: true,
|
||||
},
|
||||
|
||||
@ -15,6 +15,7 @@ const ct = {
|
||||
displayName: 'single-type-model',
|
||||
singularName: 'single-type-model',
|
||||
pluralName: 'single-type-models',
|
||||
draftAndPublish: true,
|
||||
attributes: {
|
||||
title: {
|
||||
type: 'string',
|
||||
@ -60,7 +61,6 @@ const unpublish = async (discardDraft = false) => {
|
||||
});
|
||||
};
|
||||
|
||||
// TODO: Migrate single types to use document service
|
||||
describe('Content Manager single types', () => {
|
||||
beforeAll(async () => {
|
||||
await builder.addContentType(ct).build();
|
||||
|
||||
@ -18,7 +18,7 @@ exports[`Content Type Builder - Content types Single Types Get single type retur
|
||||
"collectionName": "test_single_types",
|
||||
"description": "",
|
||||
"displayName": "Test Single Type",
|
||||
"draftAndPublish": true,
|
||||
"draftAndPublish": false,
|
||||
"kind": "singleType",
|
||||
"pluginOptions": {
|
||||
"i18n": {
|
||||
|
||||
@ -77,6 +77,7 @@ describe('Content Type Builder - Content types', () => {
|
||||
displayName: 'Test Collection Type',
|
||||
singularName: 'test-collection-type',
|
||||
pluralName: 'test-collection-types',
|
||||
draftAndPublish: true,
|
||||
pluginOptions: {
|
||||
i18n: {
|
||||
localized: true,
|
||||
@ -123,6 +124,7 @@ describe('Content Type Builder - Content types', () => {
|
||||
displayName: 'CT with DP',
|
||||
singularName: 'ct-with-dp',
|
||||
pluralName: 'ct-with-dps',
|
||||
draftAndPublish: true,
|
||||
attributes: {
|
||||
title: {
|
||||
type: 'string',
|
||||
@ -240,6 +242,7 @@ describe('Content Type Builder - Content types', () => {
|
||||
url: '/content-type-builder/content-types',
|
||||
body: {
|
||||
contentType: {
|
||||
draftAndPublish: true,
|
||||
attributes: {
|
||||
title: {
|
||||
type: 'string',
|
||||
@ -292,6 +295,7 @@ describe('Content Type Builder - Content types', () => {
|
||||
displayName: 'new displayName',
|
||||
singularName: 'ct-with-dp-new',
|
||||
pluralName: 'ct-with-dps-new',
|
||||
draftAndPublish: true,
|
||||
attributes: {
|
||||
title: {
|
||||
type: 'string',
|
||||
@ -317,6 +321,7 @@ describe('Content Type Builder - Content types', () => {
|
||||
displayName: 'new displayName',
|
||||
singularName: 'ct-with-dp', // no change
|
||||
pluralName: 'ct-with-dps',
|
||||
draftAndPublish: true,
|
||||
attributes: {
|
||||
title: {
|
||||
type: 'string',
|
||||
|
||||
@ -302,12 +302,12 @@ describe('Core API - Basic + compo', () => {
|
||||
error: {
|
||||
status: 400,
|
||||
name: 'ValidationError',
|
||||
message: 'compo[0].name must be a `string` type, but the final value was: `null`.',
|
||||
message: 'compo[0].name must be defined.',
|
||||
details: {
|
||||
errors: [
|
||||
{
|
||||
path: ['compo', '0', 'name'],
|
||||
message: 'compo[0].name must be a `string` type, but the final value was: `null`.',
|
||||
message: 'compo[0].name must be defined.',
|
||||
name: 'ValidationError',
|
||||
},
|
||||
],
|
||||
|
||||
@ -41,6 +41,7 @@ const productWithCompoAndDP = {
|
||||
repeatable: true,
|
||||
},
|
||||
},
|
||||
draftAndPublish: true,
|
||||
displayName: 'product-with-compo-and-dp',
|
||||
singularName: 'product-with-compo-and-dp',
|
||||
pluralName: 'product-with-compo-and-dps',
|
||||
|
||||
@ -40,6 +40,7 @@ const productWithCompoAndDP = {
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
draftAndPublish: true,
|
||||
displayName: 'product-with-compo-and-dp',
|
||||
singularName: 'product-with-compo-and-dp',
|
||||
pluralName: 'product-with-compo-and-dps',
|
||||
|
||||
@ -40,6 +40,7 @@ const productWithDP = {
|
||||
maxLength: 30,
|
||||
},
|
||||
},
|
||||
draftAndPublish: true,
|
||||
displayName: 'product-with-dp',
|
||||
singularName: 'product-with-dp',
|
||||
pluralName: 'product-with-dps',
|
||||
|
||||
@ -303,12 +303,12 @@ describe('Core API - Basic + dz', () => {
|
||||
error: {
|
||||
status: 400,
|
||||
name: 'ValidationError',
|
||||
message: 'dz[0].name must be a `string` type, but the final value was: `null`.',
|
||||
message: 'dz[0].name must be defined.',
|
||||
details: {
|
||||
errors: [
|
||||
{
|
||||
path: ['dz', '0', 'name'],
|
||||
message: 'dz[0].name must be a `string` type, but the final value was: `null`.',
|
||||
message: 'dz[0].name must be defined.',
|
||||
name: 'ValidationError',
|
||||
},
|
||||
],
|
||||
|
||||
@ -36,6 +36,7 @@ const productModel = {
|
||||
localized: true,
|
||||
},
|
||||
},
|
||||
draftAndPublish: true,
|
||||
displayName: 'Product',
|
||||
singularName: 'product',
|
||||
pluralName: 'products',
|
||||
@ -49,7 +50,7 @@ const tagModel = {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
|
||||
draftAndPublish: true,
|
||||
displayName: 'Tag',
|
||||
singularName: 'tag',
|
||||
pluralName: 'tags',
|
||||
@ -97,6 +98,7 @@ const shopModel = {
|
||||
target: PRODUCT_UID,
|
||||
},
|
||||
},
|
||||
draftAndPublish: true,
|
||||
displayName: 'Shop',
|
||||
singularName: 'shop',
|
||||
pluralName: 'shops',
|
||||
|
||||
@ -35,6 +35,7 @@ const productModel = {
|
||||
localized: true,
|
||||
},
|
||||
},
|
||||
draftAndPublish: true,
|
||||
displayName: 'Product',
|
||||
singularName: 'product',
|
||||
pluralName: 'products',
|
||||
@ -46,7 +47,7 @@ const tagModel = {
|
||||
attributes: {
|
||||
name: { type: 'string' },
|
||||
},
|
||||
|
||||
draftAndPublish: true,
|
||||
displayName: 'Tag',
|
||||
singularName: 'tag',
|
||||
pluralName: 'tags',
|
||||
|
||||
@ -19,6 +19,7 @@ const dogModel = {
|
||||
required: false,
|
||||
},
|
||||
},
|
||||
draftAndPublish: true,
|
||||
connection: 'default',
|
||||
singularName: 'dog',
|
||||
pluralName: 'dogs',
|
||||
|
||||
@ -60,6 +60,7 @@ const contentTypes = {
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
draftAndPublish: true,
|
||||
displayName: 'Product',
|
||||
singularName: 'product',
|
||||
pluralName: 'products',
|
||||
@ -72,6 +73,7 @@ const contentTypes = {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
draftAndPublish: true,
|
||||
displayName: 'Country',
|
||||
singularName: 'country',
|
||||
pluralName: 'countries',
|
||||
@ -84,6 +86,7 @@ const contentTypes = {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
draftAndPublish: true,
|
||||
displayName: 'Category',
|
||||
singularName: 'category',
|
||||
pluralName: 'categories',
|
||||
|
||||
@ -20,6 +20,7 @@ const articleModel = {
|
||||
type: 'richtext',
|
||||
},
|
||||
},
|
||||
draftAndPublish: true,
|
||||
singularName: 'article',
|
||||
pluralName: 'articles',
|
||||
displayName: 'Article',
|
||||
@ -39,6 +40,7 @@ const labelModel = {
|
||||
targetAttribute: 'labels',
|
||||
},
|
||||
},
|
||||
draftAndPublish: true,
|
||||
singularName: 'label',
|
||||
pluralName: 'labels',
|
||||
displayName: 'Label',
|
||||
|
||||
@ -7,7 +7,9 @@
|
||||
"displayName": "Article",
|
||||
"description": ""
|
||||
},
|
||||
"options": {},
|
||||
"options": {
|
||||
"draftAndPublish": true
|
||||
},
|
||||
"pluginOptions": {
|
||||
"i18n": {
|
||||
"localized": true
|
||||
|
||||
@ -6,7 +6,9 @@
|
||||
"pluralName": "authors",
|
||||
"displayName": "Author"
|
||||
},
|
||||
"options": {},
|
||||
"options": {
|
||||
"draftAndPublish": true
|
||||
},
|
||||
"pluginOptions": {},
|
||||
"attributes": {
|
||||
"name": {
|
||||
|
||||
@ -7,7 +7,9 @@
|
||||
"displayName": "Homepage",
|
||||
"description": ""
|
||||
},
|
||||
"options": {},
|
||||
"options": {
|
||||
"draftAndPublish": true
|
||||
},
|
||||
"pluginOptions": {
|
||||
"i18n": {
|
||||
"localized": true
|
||||
|
||||
@ -7,7 +7,9 @@
|
||||
"displayName": "Products",
|
||||
"description": ""
|
||||
},
|
||||
"options": {},
|
||||
"options": {
|
||||
"draftAndPublish": true
|
||||
},
|
||||
"pluginOptions": {
|
||||
"i18n": {
|
||||
"localized": true
|
||||
|
||||
@ -7,7 +7,9 @@
|
||||
"displayName": "Shop",
|
||||
"description": ""
|
||||
},
|
||||
"options": {},
|
||||
"options": {
|
||||
"draftAndPublish": true
|
||||
},
|
||||
"pluginOptions": {
|
||||
"i18n": {
|
||||
"localized": true
|
||||
|
||||
@ -6,7 +6,9 @@
|
||||
"pluralName": "upcoming-matches",
|
||||
"displayName": "Upcoming Matches"
|
||||
},
|
||||
"options": {},
|
||||
"options": {
|
||||
"draftAndPublish": true
|
||||
},
|
||||
"pluginOptions": {},
|
||||
"attributes": {
|
||||
"title": {
|
||||
|
||||
@ -9,7 +9,8 @@
|
||||
"name": "Category"
|
||||
},
|
||||
"options": {
|
||||
"reviewWorkflows": true
|
||||
"reviewWorkflows": true,
|
||||
"draftAndPublish": true
|
||||
},
|
||||
"pluginOptions": {
|
||||
"i18n": {
|
||||
|
||||
@ -9,7 +9,8 @@
|
||||
"name": "Country"
|
||||
},
|
||||
"options": {
|
||||
"comment": ""
|
||||
"comment": "",
|
||||
"draftAndPublish": false
|
||||
},
|
||||
"pluginOptions": {
|
||||
"i18n": {
|
||||
|
||||
@ -6,7 +6,9 @@
|
||||
"singularName": "homepage",
|
||||
"pluralName": "homepages"
|
||||
},
|
||||
"options": {},
|
||||
"options": {
|
||||
"draftAndPublish": true
|
||||
},
|
||||
"pluginOptions": {
|
||||
"i18n": {
|
||||
"localized": true
|
||||
|
||||
@ -8,7 +8,9 @@
|
||||
"description": "",
|
||||
"name": "Kitchen Sink"
|
||||
},
|
||||
"options": {},
|
||||
"options": {
|
||||
"draftAndPublish": true
|
||||
},
|
||||
"pluginOptions": {},
|
||||
"attributes": {
|
||||
"short_text": {
|
||||
|
||||
@ -8,7 +8,8 @@
|
||||
"description": ""
|
||||
},
|
||||
"options": {
|
||||
"comment": ""
|
||||
"comment": "",
|
||||
"draftAndPublish": false
|
||||
},
|
||||
"attributes": {
|
||||
"author": {
|
||||
|
||||
@ -8,7 +8,8 @@
|
||||
"pluralName": "menus"
|
||||
},
|
||||
"options": {
|
||||
"comment": ""
|
||||
"comment": "",
|
||||
"draftAndPublish": false
|
||||
},
|
||||
"attributes": {
|
||||
"description": {
|
||||
|
||||
@ -8,7 +8,8 @@
|
||||
"description": ""
|
||||
},
|
||||
"options": {
|
||||
"comment": ""
|
||||
"comment": "",
|
||||
"draftAndPublish": false
|
||||
},
|
||||
"attributes": {
|
||||
"name": {
|
||||
|
||||
@ -7,7 +7,9 @@
|
||||
"displayName": "Relations",
|
||||
"description": ""
|
||||
},
|
||||
"options": {},
|
||||
"options": {
|
||||
"draftAndPublish": true
|
||||
},
|
||||
"pluginOptions": {
|
||||
"i18n": {
|
||||
"localized": true
|
||||
|
||||
@ -10,7 +10,8 @@
|
||||
},
|
||||
"options": {
|
||||
"populateCreatorFields": true,
|
||||
"comment": ""
|
||||
"comment": "",
|
||||
"draftAndPublish": true
|
||||
},
|
||||
"pluginOptions": {
|
||||
"i18n": {
|
||||
|
||||
@ -8,7 +8,8 @@
|
||||
"description": ""
|
||||
},
|
||||
"options": {
|
||||
"comment": ""
|
||||
"comment": "",
|
||||
"draftAndPublish": false
|
||||
},
|
||||
"attributes": {
|
||||
"comment": {
|
||||
|
||||
@ -7,7 +7,9 @@
|
||||
"pluralName": "tags",
|
||||
"description": ""
|
||||
},
|
||||
"options": {},
|
||||
"options": {
|
||||
"draftAndPublish": true
|
||||
},
|
||||
"pluginOptions": {},
|
||||
"attributes": {
|
||||
"name": {
|
||||
|
||||
@ -8,7 +8,9 @@
|
||||
"name": "temp",
|
||||
"description": ""
|
||||
},
|
||||
"options": {},
|
||||
"options": {
|
||||
"draftAndPublish": false
|
||||
},
|
||||
"pluginOptions": {},
|
||||
"attributes": {
|
||||
"name": {
|
||||
|
||||
@ -6,7 +6,9 @@
|
||||
"pluralName": "testings",
|
||||
"displayName": "testing"
|
||||
},
|
||||
"options": {},
|
||||
"options": {
|
||||
"draftAndPublish": true
|
||||
},
|
||||
"attributes": {
|
||||
"title": {
|
||||
"type": "string"
|
||||
|
||||
@ -736,6 +736,8 @@ components:
|
||||
maxItems: 2
|
||||
items:
|
||||
type: string
|
||||
draftAndPublish:
|
||||
type: boolean
|
||||
attributes:
|
||||
type: object
|
||||
additionalProperties:
|
||||
|
||||
@ -67,9 +67,8 @@ const addTimestamps = (schema: Schema.ContentType) => {
|
||||
};
|
||||
|
||||
const addDraftAndPublish = (schema: Schema.ContentType) => {
|
||||
// Enable draft and publish by default
|
||||
if (!_.has(schema, 'options.draftAndPublish')) {
|
||||
_.set(schema, 'options.draftAndPublish', true);
|
||||
_.set(schema, 'options.draftAndPublish', false); // Disabled by default
|
||||
}
|
||||
|
||||
schema.attributes[PUBLISHED_AT_ATTRIBUTE] = {
|
||||
|
||||
@ -231,7 +231,7 @@ export const createContentTypeRepository: RepositoryFactoryMethod = (uid) => {
|
||||
model,
|
||||
data,
|
||||
{
|
||||
isDraft: !params?.data?.publishedAt, // Always update the draft version
|
||||
isDraft: !queryParams?.data?.publishedAt, // Always update the draft version
|
||||
locale: queryParams?.locale,
|
||||
},
|
||||
entryToUpdate
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user