From ac67514cefb275eb93146fc3f6f8ee13b1268abb Mon Sep 17 00:00:00 2001 From: Romain Oliva Date: Mon, 6 Jun 2022 09:08:11 +0200 Subject: [PATCH] fixup! fixup! feat: add initial workflow status in config --- dev-test/backends/default-workflow-status/config.yml | 3 +-- packages/netlify-cms-core/src/actions/config.ts | 6 +++++- packages/netlify-cms-core/src/constants/publishModes.ts | 1 - packages/netlify-cms-core/src/types/redux.ts | 3 +-- 4 files changed, 7 insertions(+), 6 deletions(-) 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/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[];