Merge branch 'fix-demo-ui' of github.com:netlify/netlify-cms into fix-demo-ui
This commit is contained in:
commit
378be79a76
@ -20,8 +20,9 @@ class LocalStorageAuthStore {
|
|||||||
|
|
||||||
const slugFormatter = (template, entryData) => {
|
const slugFormatter = (template, entryData) => {
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
return template.replace(/\{\{([^\}]+)\}\}/g, (_, name) => {
|
const identifier = entryData.get('title', entryData.get('path'));
|
||||||
switch (name) {
|
return template.replace(/\{\{([^\}]+)\}\}/g, (_, field) => {
|
||||||
|
switch (field) {
|
||||||
case 'year':
|
case 'year':
|
||||||
return date.getFullYear();
|
return date.getFullYear();
|
||||||
case 'month':
|
case 'month':
|
||||||
@ -29,10 +30,9 @@ const slugFormatter = (template, entryData) => {
|
|||||||
case 'day':
|
case 'day':
|
||||||
return (`0${ date.getDate() }`).slice(-2);
|
return (`0${ date.getDate() }`).slice(-2);
|
||||||
case 'slug':
|
case 'slug':
|
||||||
const identifier = entryData.get('title', entryData.get('path'));
|
return identifier.trim().toLowerCase().replace(/[^a-z0-9\.\-_]+/gi, '-');
|
||||||
return identifier.trim().toLowerCase().replace(/[^a-z0-9\.\-\_]+/gi, '-');
|
|
||||||
default:
|
default:
|
||||||
return entryData.get(name);
|
return entryData.get(field);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -53,6 +53,7 @@ class Backend {
|
|||||||
this.implementation.setUser(stored);
|
this.implementation.setUser(stored);
|
||||||
return stored;
|
return stored;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
authComponent() {
|
authComponent() {
|
||||||
@ -112,30 +113,28 @@ class Backend {
|
|||||||
|
|
||||||
unpublishedEntries(page, perPage) {
|
unpublishedEntries(page, perPage) {
|
||||||
return this.implementation.unpublishedEntries(page, perPage)
|
return this.implementation.unpublishedEntries(page, perPage)
|
||||||
.then(loadedEntries => (
|
.then(loadedEntries => loadedEntries.filter(entry => entry !== null))
|
||||||
loadedEntries.map((loadedEntry) => {
|
.then(entries => (
|
||||||
const entry = createEntry('draft', loadedEntry.slug, loadedEntry.file.path, { raw: loadedEntry.data })
|
entries.map((loadedEntry) => {
|
||||||
|
const entry = createEntry('draft', loadedEntry.slug, loadedEntry.file.path, { raw: loadedEntry.data });
|
||||||
entry.metaData = loadedEntry.metaData;
|
entry.metaData = loadedEntry.metaData;
|
||||||
return entry;
|
return entry;
|
||||||
})
|
})
|
||||||
))
|
))
|
||||||
.then((entries) => {
|
.then(entries => ({
|
||||||
const filteredEntries = entries.filter(entry => entry !== null);
|
pagination: 0,
|
||||||
return {
|
entries: entries.map(this.entryWithFormat('editorialWorkflow')),
|
||||||
pagination: 0,
|
}));
|
||||||
entries: filteredEntries.map(this.entryWithFormat('editorialWorkflow')),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unpublishedEntry(collection, slug) {
|
unpublishedEntry(collection, slug) {
|
||||||
return this.implementation.unpublishedEntry(collection, slug)
|
return this.implementation.unpublishedEntry(collection, slug)
|
||||||
.then(loadedEntry => this.entryWithFormat(collection, slug)(createEntry(
|
.then((loadedEntry) => {
|
||||||
collection.get('name'),
|
const entry = createEntry('draft', loadedEntry.slug, loadedEntry.file.path, { raw: loadedEntry.data });
|
||||||
slug,
|
entry.metaData = loadedEntry.metaData;
|
||||||
loadedEntry.file.path,
|
return entry;
|
||||||
{ raw: loadedEntry.data }
|
})
|
||||||
)));
|
.then(this.entryWithFormat(collection, slug));
|
||||||
}
|
}
|
||||||
|
|
||||||
persistEntry(config, collection, entryDraft, MediaFiles, options) {
|
persistEntry(config, collection, entryDraft, MediaFiles, options) {
|
||||||
@ -144,7 +143,7 @@ class Backend {
|
|||||||
|
|
||||||
const parsedData = {
|
const parsedData = {
|
||||||
title: entryDraft.getIn(['entry', 'data', 'title'], 'No Title'),
|
title: entryDraft.getIn(['entry', 'data', 'title'], 'No Title'),
|
||||||
description: entryDraft.getIn(['entry', 'data', 'description'], 'No Description'),
|
description: entryDraft.getIn(['entry', 'data', 'description'], 'No Description!'),
|
||||||
};
|
};
|
||||||
|
|
||||||
const entryData = entryDraft.getIn(['entry', 'data']).toJS();
|
const entryData = entryDraft.getIn(['entry', 'data']).toJS();
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import semaphore from 'semaphore';
|
import semaphore from 'semaphore';
|
||||||
import { createEntry } from '../../valueObjects/Entry';
|
|
||||||
import AuthenticationPage from './AuthenticationPage';
|
import AuthenticationPage from './AuthenticationPage';
|
||||||
import API from './API';
|
import API from './API';
|
||||||
|
|
||||||
@ -9,7 +8,7 @@ export default class GitHub {
|
|||||||
constructor(config) {
|
constructor(config) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
if (config.getIn(['backend', 'repo']) == null) {
|
if (config.getIn(['backend', 'repo']) == null) {
|
||||||
throw 'The GitHub backend needs a "repo" in the backend configuration.';
|
throw new Error('The GitHub backend needs a "repo" in the backend configuration.');
|
||||||
}
|
}
|
||||||
this.repo = config.getIn(['backend', 'repo']);
|
this.repo = config.getIn(['backend', 'repo']);
|
||||||
this.branch = config.getIn(['backend', 'branch']) || 'master';
|
this.branch = config.getIn(['backend', 'branch']) || 'master';
|
||||||
@ -101,15 +100,17 @@ export default class GitHub {
|
|||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
return Promise.all(promises);
|
return Promise.all(promises);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
unpublishedEntry(collection, slug) {
|
unpublishedEntry(collection, slug) {
|
||||||
return this.unpublishedEntries().then(response => (
|
return this.api.readUnpublishedBranchFile(slug)
|
||||||
response.filter((entry) => {
|
.then(data => ({
|
||||||
return entry.metaData && entry.slug === slug;
|
slug,
|
||||||
})[0]
|
file: { path: data.metaData.objects.entry },
|
||||||
));
|
data: data.fileData,
|
||||||
|
metaData: data.metaData,
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
updateUnpublishedEntryStatus(collection, slug, newStatus) {
|
updateUnpublishedEntryStatus(collection, slug, newStatus) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user