Refactor: Publish mode to publish 'workflow'

This commit is contained in:
Cássio Zen 2016-09-05 18:56:03 -03:00
parent e18c7191d7
commit b0e62d1ca9
5 changed files with 13 additions and 13 deletions

View File

@ -70,9 +70,9 @@ function parseConfig(data) {
} }
} }
if (!('publish_mode' in config.backend)) { if (!('publish_workflow' in config)) {
// Make sure there is a publish mode // Make sure there is a publish workflow mode set
config.backend['publish_mode'] = 'simple'; config['publish_workflow'] = 'simple';
} }
if (!('public_folder' in config)) { if (!('public_folder' in config)) {

View File

@ -3,7 +3,7 @@ import GitHubBackend from './github/implementation';
import NetlifyGitBackend from './netlify-git/implementation'; import NetlifyGitBackend from './netlify-git/implementation';
import { resolveFormat } from '../formats/formats'; import { resolveFormat } from '../formats/formats';
import { createEntry } from '../valueObjects/Entry'; import { createEntry } from '../valueObjects/Entry';
import { SIMPLE, BRANCH } from './constants'; import { SIMPLE, EDITORIAL } from './constants';
class LocalStorageAuthStore { class LocalStorageAuthStore {
storageKey = 'nf-cms-user'; storageKey = 'nf-cms-user';
@ -94,9 +94,9 @@ class Backend {
} }
getPublishMode(config) { getPublishMode(config) {
const publish_modes = [SIMPLE, BRANCH]; const publish_workflows = [SIMPLE, EDITORIAL];
const mode = config.getIn(['backend', 'publish_mode']); const mode = config.get('publish_workflow');
if (publish_modes.indexOf(mode) !== -1) { if (publish_workflows.indexOf(mode) !== -1) {
return mode; return mode;
} else { } else {
return SIMPLE; return SIMPLE;

View File

@ -1,3 +1,3 @@
// Create/edit modes // Create/edit workflows
export const SIMPLE = 'simple'; export const SIMPLE = 'simple';
export const BRANCH = 'branch'; export const EDITORIAL = 'editorial';

View File

@ -1,7 +1,7 @@
import LocalForage from 'localforage'; import LocalForage from 'localforage';
import MediaProxy from '../../valueObjects/MediaProxy'; import MediaProxy from '../../valueObjects/MediaProxy';
import { Base64 } from 'js-base64'; import { Base64 } from 'js-base64';
import { BRANCH } from '../constants'; import { EDITORIAL } from '../constants';
const API_ROOT = 'https://api.github.com'; const API_ROOT = 'https://api.github.com';
@ -169,7 +169,7 @@ export default class API {
.then(branchData => this.updateTree(branchData.commit.sha, '/', fileTree)) .then(branchData => this.updateTree(branchData.commit.sha, '/', fileTree))
.then(changeTree => this.commit(options.commitMessage, changeTree)) .then(changeTree => this.commit(options.commitMessage, changeTree))
.then((response) => { .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 contentKey = options.collectionName ? `${options.collectionName}-${entry.slug}` : entry.slug;
const branchName = `cms/${contentKey}`; const branchName = `cms/${contentKey}`;
return this.createBranch(branchName, response.sha) return this.createBranch(branchName, response.sha)

View File

@ -1,7 +1,7 @@
import LocalForage from 'localforage'; import LocalForage from 'localforage';
import MediaProxy from '../../valueObjects/MediaProxy'; import MediaProxy from '../../valueObjects/MediaProxy';
import { Base64 } from 'js-base64'; import { Base64 } from 'js-base64';
import { BRANCH } from '../constants'; import { EDITORIAL } from '../constants';
export default class API { export default class API {
constructor(token, url, branch) { constructor(token, url, branch) {
@ -161,7 +161,7 @@ export default class API {
.then(branchData => this.updateTree(branchData.commit.sha, '/', fileTree)) .then(branchData => this.updateTree(branchData.commit.sha, '/', fileTree))
.then(changeTree => this.commit(options.commitMessage, changeTree)) .then(changeTree => this.commit(options.commitMessage, changeTree))
.then((response) => { .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 contentKey = options.collectionName ? `${options.collectionName}-${entry.slug}` : entry.slug;
return this.createBranch(`cms/${contentKey}`, response.sha) return this.createBranch(`cms/${contentKey}`, response.sha)
.then(this.storeMetadata(contentKey, { status: 'draft' })) .then(this.storeMetadata(contentKey, { status: 'draft' }))