Editorial Workflow skeleton
This commit is contained in:
@ -3,7 +3,6 @@ import GitHubBackend from './github/implementation';
|
||||
import NetlifyGitBackend from './netlify-git/implementation';
|
||||
import { resolveFormat } from '../formats/formats';
|
||||
import { createEntry } from '../valueObjects/Entry';
|
||||
import { SIMPLE, EDITORIAL } from './constants';
|
||||
|
||||
class LocalStorageAuthStore {
|
||||
storageKey = 'nf-cms-user';
|
||||
@ -65,9 +64,9 @@ class Backend {
|
||||
return this.entryWithFormat(collection)(newEntry);
|
||||
}
|
||||
|
||||
entryWithFormat(collection) {
|
||||
entryWithFormat(collectionOrEntity) {
|
||||
return (entry) => {
|
||||
const format = resolveFormat(collection, entry);
|
||||
const format = resolveFormat(collectionOrEntity, entry);
|
||||
if (entry && entry.raw) {
|
||||
entry.data = format && format.fromFile(entry.raw);
|
||||
}
|
||||
@ -75,6 +74,15 @@ class Backend {
|
||||
};
|
||||
}
|
||||
|
||||
unpublishedEntries(page, perPage) {
|
||||
return this.implementation.unpublishedEntries(page, perPage).then((response) => {
|
||||
return {
|
||||
pagination: response.pagination,
|
||||
entries: response.entries.map(this.entryWithFormat('editorialWorkflow'))
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
slugFormatter(template, entry) {
|
||||
var date = new Date();
|
||||
return template.replace(/\{\{([^\}]+)\}\}/g, function(_, name) {
|
||||
@ -93,16 +101,6 @@ class Backend {
|
||||
});
|
||||
}
|
||||
|
||||
getPublishMode(config) {
|
||||
const publish_workflows = [SIMPLE, EDITORIAL];
|
||||
const mode = config.get('publish_workflow');
|
||||
if (publish_workflows.indexOf(mode) !== -1) {
|
||||
return mode;
|
||||
} else {
|
||||
return SIMPLE;
|
||||
}
|
||||
}
|
||||
|
||||
persistEntry(config, collection, entryDraft, MediaFiles) {
|
||||
const newEntry = entryDraft.getIn(['entry', 'newRecord']) || false;
|
||||
|
||||
@ -132,7 +130,7 @@ class Backend {
|
||||
collection.get('label') + ' “' +
|
||||
entryDraft.getIn(['entry', 'data', 'title']) + '”';
|
||||
|
||||
const mode = this.getPublishMode(config);
|
||||
const mode = config.get('publish_mode');
|
||||
|
||||
const collectionName = collection.get('name');
|
||||
|
||||
|
Reference in New Issue
Block a user