diff --git a/dev-test/backends/default-workflow-status/config.yml b/dev-test/backends/default-workflow-status/config.yml index 18d686453409..5b44c1177ead 100644 --- a/dev-test/backends/default-workflow-status/config.yml +++ b/dev-test/backends/default-workflow-status/config.yml @@ -1,6 +1,5 @@ backend: - name: git-gateway - branch: master + name: test-repo publish_mode: editorial_workflow default_workflow_status: pending_publish diff --git a/packages/netlify-cms-core/src/actions/__tests__/config.spec.js b/packages/netlify-cms-core/src/actions/__tests__/config.spec.js index 107a4188c0c5..a766d71aa3e0 100644 --- a/packages/netlify-cms-core/src/actions/__tests__/config.spec.js +++ b/packages/netlify-cms-core/src/actions/__tests__/config.spec.js @@ -131,6 +131,14 @@ describe('config', () => { expect(applyDefaults(config).default_workflow_status).toEqual(Statues.DRAFT); }); + it('should set default_workflow_status to "draft" if the given one is unknown', () => { + const config = { + publish_mode: 'editorial_workflow', + default_workflow_status: 'unknown', + }; + expect(applyDefaults(config).default_workflow_status).toEqual(Statues.DRAFT); + }); + it('should set default_workflow_status from config', () => { const config = { publish_mode: 'editorial_workflow', diff --git a/packages/netlify-cms-core/src/actions/config.ts b/packages/netlify-cms-core/src/actions/config.ts index f45ef865fccf..0515553ba307 100644 --- a/packages/netlify-cms-core/src/actions/config.ts +++ b/packages/netlify-cms-core/src/actions/config.ts @@ -215,7 +215,11 @@ export function applyDefaults(originalConfig: CmsConfig) { config.collections = config.collections || []; if (config.publish_mode === EDITORIAL_WORKFLOW) { - config.default_workflow_status = config.default_workflow_status || Statues.DRAFT; + config.default_workflow_status = + config.default_workflow_status && + Object.values(Statues).includes(config.default_workflow_status) + ? config.default_workflow_status + : Statues.DRAFT; } // Use `site_url` as default `display_url`. diff --git a/packages/netlify-cms-core/src/constants/publishModes.ts b/packages/netlify-cms-core/src/constants/publishModes.ts index 49c1faf1a481..56fba78ffb3d 100644 --- a/packages/netlify-cms-core/src/constants/publishModes.ts +++ b/packages/netlify-cms-core/src/constants/publishModes.ts @@ -20,4 +20,3 @@ export const statusDescriptions = Map({ }); export type Status = keyof typeof Statues; -export type StatusValues = typeof Statues[Status]; diff --git a/packages/netlify-cms-core/src/types/redux.ts b/packages/netlify-cms-core/src/types/redux.ts index b587cd797cce..e58d64bfd947 100644 --- a/packages/netlify-cms-core/src/types/redux.ts +++ b/packages/netlify-cms-core/src/types/redux.ts @@ -2,7 +2,6 @@ import type { Action } from 'redux'; import type { StaticallyTypedRecord } from './immutable'; import type { Map, List, OrderedMap, Set } from 'immutable'; import type { FILES, FOLDER } from '../constants/collectionTypes'; -import type { StatusValues as PublishStatusValues } from '../constants/publishModes'; import type { MediaFile as BackendMediaFile } from '../backend'; import type { Auth } from '../reducers/auth'; import type { Status } from '../reducers/status'; @@ -401,7 +400,7 @@ export interface CmsConfig { media_folder_relative?: boolean; media_library?: CmsMediaLibrary; publish_mode?: CmsPublishMode; - default_workflow_status?: PublishStatusValues; + default_workflow_status?: string; load_config_file?: boolean; integrations?: { hooks: string[];