Refactor: Publish mode to publish 'workflow'
This commit is contained in:
parent
e18c7191d7
commit
b0e62d1ca9
@ -70,9 +70,9 @@ function parseConfig(data) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!('publish_mode' in config.backend)) {
|
||||
// Make sure there is a publish mode
|
||||
config.backend['publish_mode'] = 'simple';
|
||||
if (!('publish_workflow' in config)) {
|
||||
// Make sure there is a publish workflow mode set
|
||||
config['publish_workflow'] = 'simple';
|
||||
}
|
||||
|
||||
if (!('public_folder' in config)) {
|
||||
|
@ -3,7 +3,7 @@ import GitHubBackend from './github/implementation';
|
||||
import NetlifyGitBackend from './netlify-git/implementation';
|
||||
import { resolveFormat } from '../formats/formats';
|
||||
import { createEntry } from '../valueObjects/Entry';
|
||||
import { SIMPLE, BRANCH } from './constants';
|
||||
import { SIMPLE, EDITORIAL } from './constants';
|
||||
|
||||
class LocalStorageAuthStore {
|
||||
storageKey = 'nf-cms-user';
|
||||
@ -94,9 +94,9 @@ class Backend {
|
||||
}
|
||||
|
||||
getPublishMode(config) {
|
||||
const publish_modes = [SIMPLE, BRANCH];
|
||||
const mode = config.getIn(['backend', 'publish_mode']);
|
||||
if (publish_modes.indexOf(mode) !== -1) {
|
||||
const publish_workflows = [SIMPLE, EDITORIAL];
|
||||
const mode = config.get('publish_workflow');
|
||||
if (publish_workflows.indexOf(mode) !== -1) {
|
||||
return mode;
|
||||
} else {
|
||||
return SIMPLE;
|
||||
|
@ -1,3 +1,3 @@
|
||||
// Create/edit modes
|
||||
// Create/edit workflows
|
||||
export const SIMPLE = 'simple';
|
||||
export const BRANCH = 'branch';
|
||||
export const EDITORIAL = 'editorial';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import LocalForage from 'localforage';
|
||||
import MediaProxy from '../../valueObjects/MediaProxy';
|
||||
import { Base64 } from 'js-base64';
|
||||
import { BRANCH } from '../constants';
|
||||
import { EDITORIAL } from '../constants';
|
||||
|
||||
const API_ROOT = 'https://api.github.com';
|
||||
|
||||
@ -169,7 +169,7 @@ export default class API {
|
||||
.then(branchData => this.updateTree(branchData.commit.sha, '/', fileTree))
|
||||
.then(changeTree => this.commit(options.commitMessage, changeTree))
|
||||
.then((response) => {
|
||||
if (options.mode && options.mode === BRANCH) {
|
||||
if (options.mode && options.mode === EDITORIAL) {
|
||||
const contentKey = options.collectionName ? `${options.collectionName}-${entry.slug}` : entry.slug;
|
||||
const branchName = `cms/${contentKey}`;
|
||||
return this.createBranch(branchName, response.sha)
|
||||
|
@ -1,7 +1,7 @@
|
||||
import LocalForage from 'localforage';
|
||||
import MediaProxy from '../../valueObjects/MediaProxy';
|
||||
import { Base64 } from 'js-base64';
|
||||
import { BRANCH } from '../constants';
|
||||
import { EDITORIAL } from '../constants';
|
||||
|
||||
export default class API {
|
||||
constructor(token, url, branch) {
|
||||
@ -161,7 +161,7 @@ export default class API {
|
||||
.then(branchData => this.updateTree(branchData.commit.sha, '/', fileTree))
|
||||
.then(changeTree => this.commit(options.commitMessage, changeTree))
|
||||
.then((response) => {
|
||||
if (options.mode && options.mode === BRANCH) {
|
||||
if (options.mode && options.mode === EDITORIAL) {
|
||||
const contentKey = options.collectionName ? `${options.collectionName}-${entry.slug}` : entry.slug;
|
||||
return this.createBranch(`cms/${contentKey}`, response.sha)
|
||||
.then(this.storeMetadata(contentKey, { status: 'draft' }))
|
||||
|
Loading…
x
Reference in New Issue
Block a user