diff --git a/packages/netlify-cms-core/index.d.ts b/packages/netlify-cms-core/index.d.ts index be4a3835d081..45c34b4a2fd0 100644 --- a/packages/netlify-cms-core/index.d.ts +++ b/packages/netlify-cms-core/index.d.ts @@ -50,6 +50,8 @@ declare module 'netlify-cms-core' { export type CmsPublishMode = 'simple' | 'editorial_workflow'; + export type CmsPublishWorkflowStatus = 'draft' | 'pending_review' | 'pending_publish'; + export type CmsSlugEncoding = 'unicode' | 'ascii'; export interface CmsI18nConfig { @@ -394,6 +396,7 @@ declare module 'netlify-cms-core' { media_folder_relative?: boolean; media_library?: CmsMediaLibrary; publish_mode?: CmsPublishMode; + default_workflow_status?: CmsPublishWorkflowStatus; load_config_file?: boolean; integrations?: { hooks: string[]; diff --git a/packages/netlify-cms-core/src/backend.ts b/packages/netlify-cms-core/src/backend.ts index b328dac88133..9c452c20d9a5 100644 --- a/packages/netlify-cms-core/src/backend.ts +++ b/packages/netlify-cms-core/src/backend.ts @@ -14,7 +14,7 @@ import { basename, join, extname, dirname } from 'path'; import { stringTemplate } from 'netlify-cms-lib-widgets'; import { resolveFormat } from './formats/formats'; -import { selectUseWorkflow } from './reducers/config'; +import { selectUseWorkflow, selectDefaultWorkflowStatus } from './reducers/config'; import { selectMediaFilePath, selectEntry } from './reducers/entries'; import { selectIntegration } from './reducers/integrations'; import { @@ -33,7 +33,6 @@ import { createEntry } from './valueObjects/Entry'; import { sanitizeChar } from './lib/urlHelper'; import { getBackend, invokeEvent } from './lib/registry'; import { commitMessageFormatter, slugFormatter, previewUrlFormatter } from './lib/formatters'; -import { status } from './constants/publishModes'; import { FOLDER, FILES } from './constants/collectionTypes'; import { selectCustomPath } from './reducers/entryDraft'; import { @@ -322,7 +321,7 @@ export class Backend { this.implementation = implementation.init(this.config, { useWorkflow: selectUseWorkflow(this.config), updateUserCredentials: this.updateUserCredentials, - initialWorkflowStatus: status.first(), + initialWorkflowStatus: selectDefaultWorkflowStatus(this.config), }); this.backendName = backendName; this.authStore = authStore; diff --git a/packages/netlify-cms-core/src/constants/configSchema.js b/packages/netlify-cms-core/src/constants/configSchema.js index 31e3711f8745..6f0dd0b3b820 100644 --- a/packages/netlify-cms-core/src/constants/configSchema.js +++ b/packages/netlify-cms-core/src/constants/configSchema.js @@ -8,6 +8,7 @@ import { import ajvErrors from 'ajv-errors'; import uuid from 'uuid/v4'; +import { Statues } from './publishModes'; import { formatExtensions, frontmatterFormats, extensionFormatters } from '../formats/formats'; import { getWidgets } from '../lib/registry'; import { I18N_STRUCTURE, I18N_FIELD } from '../lib/i18n'; @@ -178,6 +179,11 @@ function getConfigSchema() { enum: ['simple', 'editorial_workflow'], examples: ['editorial_workflow'], }, + default_workflow_status: { + type: 'string', + enum: Object.values(Statues), + examples: [Statues.PENDING_PUBLISH], + }, slug: { type: 'object', properties: { diff --git a/packages/netlify-cms-core/src/reducers/config.ts b/packages/netlify-cms-core/src/reducers/config.ts index d98546a48c1a..3553dbba6cca 100644 --- a/packages/netlify-cms-core/src/reducers/config.ts +++ b/packages/netlify-cms-core/src/reducers/config.ts @@ -1,7 +1,7 @@ import { produce } from 'immer'; import { CONFIG_REQUEST, CONFIG_SUCCESS, CONFIG_FAILURE } from '../actions/config'; -import { EDITORIAL_WORKFLOW } from '../constants/publishModes'; +import { EDITORIAL_WORKFLOW, status } from '../constants/publishModes'; import type { ConfigAction } from '../actions/config'; import type { CmsConfig } from '../types/redux'; @@ -35,4 +35,8 @@ export function selectUseWorkflow(state: CmsConfig) { return state.publish_mode === EDITORIAL_WORKFLOW; } +export function selectDefaultWorkflowStatus(state: CmsConfig) { + return state.default_workflow_status || status.first(); +} + export default config; diff --git a/packages/netlify-cms-core/src/types/redux.ts b/packages/netlify-cms-core/src/types/redux.ts index e00ad57246a8..f9947c4137e8 100644 --- a/packages/netlify-cms-core/src/types/redux.ts +++ b/packages/netlify-cms-core/src/types/redux.ts @@ -2,6 +2,7 @@ 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 { Status as PublishStatus } from '../constants/publishModes'; import type { MediaFile as BackendMediaFile } from '../backend'; import type { Auth } from '../reducers/auth'; import type { Status } from '../reducers/status'; @@ -400,6 +401,7 @@ export interface CmsConfig { media_folder_relative?: boolean; media_library?: CmsMediaLibrary; publish_mode?: CmsPublishMode; + default_workflow_status?: PublishStatus; load_config_file?: boolean; integrations?: { hooks: string[];