diff --git a/src/backends/backend.js b/src/backends/backend.js index 0d4b3204..0001eaba 100644 --- a/src/backends/backend.js +++ b/src/backends/backend.js @@ -124,7 +124,15 @@ class Backend { .then(loadedEntries => loadedEntries.filter(entry => entry !== null)) .then(entries => ( entries.map((loadedEntry) => { - const entry = createEntry(loadedEntry.metaData.collection, loadedEntry.slug, loadedEntry.file.path, { raw: loadedEntry.data }); + const entry = createEntry( + loadedEntry.metaData.collection, + loadedEntry.slug, + loadedEntry.file.path, + { + raw: loadedEntry.data, + isModification: loadedEntry.isModification, + } + ); entry.metaData = loadedEntry.metaData; return entry; }) @@ -138,7 +146,14 @@ class Backend { unpublishedEntry(collection, slug) { return this.implementation.unpublishedEntry(collection, slug) .then((loadedEntry) => { - const entry = createEntry("draft", loadedEntry.slug, loadedEntry.file.path, { raw: loadedEntry.data }); + const entry = createEntry( + "draft", + loadedEntry.slug, + loadedEntry.file.path, + { + raw: loadedEntry.data, + isModification: loadedEntry.isModification, + }); entry.metaData = loadedEntry.metaData; return entry; }) diff --git a/src/backends/github/API.js b/src/backends/github/API.js index e5c37842..5bf5a0d9 100644 --- a/src/backends/github/API.js +++ b/src/backends/github/API.js @@ -159,7 +159,7 @@ export default class API { } readUnpublishedBranchFile(contentKey) { - let metaData; + let metaData, fileData; const unpublishedPromise = this.retrieveMetadata(contentKey) .then((data) => { metaData = data; @@ -168,13 +168,28 @@ export default class API { } return Promise.reject(null); }) - .then(fileData => ({ metaData, fileData })) + .then((file) => { + fileData = file; + return this.isUnpublishedEntryModification(metaData.objects.entry.path); + }) + .then(isModification => ({ metaData, fileData, isModification })) .catch(() => { throw new EditorialWorkflowError('content is not under editorial workflow', true); }); return unpublishedPromise; } + isUnpublishedEntryModification(path, branch) { + return this.readFile(path, null, branch) + .then(data => true) + .catch((err) => { + if (err.message && err.message === "Not Found") { + return false; + } + throw err; + }); + } + listUnpublishedBranches() { console.log("%c Checking for Unpublished entries", "line-height: 30px;text-align: center;font-weight: bold"); // eslint-disable-line return this.request(`${ this.repoURL }/git/refs/heads/cms`) diff --git a/src/backends/github/implementation.js b/src/backends/github/implementation.js index 87818864..0c1d982f 100644 --- a/src/backends/github/implementation.js +++ b/src/backends/github/implementation.js @@ -99,6 +99,7 @@ export default class GitHub { file: { path }, data: data.fileData, metaData: data.metaData, + isModification: data.isModification, }); sem.leave(); } @@ -127,6 +128,7 @@ export default class GitHub { file: { path: data.metaData.objects.entry.path }, data: data.fileData, metaData: data.metaData, + isModification: data.isModification, }; }); } diff --git a/src/components/UI/theme.css b/src/components/UI/theme.css index 272713af..ee29dabb 100644 --- a/src/components/UI/theme.css +++ b/src/components/UI/theme.css @@ -2,12 +2,14 @@ --defaultColor: #333; --defaultColorLight: #eee; --backgroundColor: #fff; + --backgroundColorShaded: #eee; --shadowColor: rgba(0, 0, 0, .25); --infoColor: #69c; --successColor: #1c7; --warningColor: #fa0; --errorColor: #f52; --borderRadius: 2px; + --borderRadiusLarge: 10px; --topmostZindex: 99999; --foregroundAltColor: #fff; --backgroundAltColor: #272e30; diff --git a/src/components/UnpublishedListing/UnpublishedListing.js b/src/components/UnpublishedListing/UnpublishedListing.js index 66266b8b..7b064c5a 100644 --- a/src/components/UnpublishedListing/UnpublishedListing.js +++ b/src/components/UnpublishedListing/UnpublishedListing.js @@ -3,8 +3,11 @@ import { DragSource, DropTarget, HTML5DragDrop } from 'react-simple-dnd'; import ImmutablePropTypes from 'react-immutable-proptypes'; import { Link } from 'react-router'; import moment from 'moment'; +import pluralize from 'pluralize'; +import { capitalize } from 'lodash' import { Card, CardTitle, CardText, CardActions } from 'react-toolbox/lib/card'; import Button from 'react-toolbox/lib/button'; +import UnpublishedListingCardMeta from './UnpublishedListingCardMeta.js'; import { status, statusDescriptions } from '../../constants/publishModes'; import styles from './UnpublishedListing.css'; @@ -68,6 +71,7 @@ class UnpublishedListing extends React.Component { const slug = entry.get('slug'); const ownStatus = entry.getIn(['metaData', 'status']); const collection = entry.getIn(['metaData', 'collection']); + const isModification = entry.get('isModification'); return (
+ +
+ {meta} + {(label && label.length > 0) + ? {label} + : ""} +
; + +UnpublishedListingCardMeta.propTypes = { + meta: PropTypes.string.isRequired, + label: PropTypes.string, +}; + +export default UnpublishedListingCardMeta; diff --git a/src/valueObjects/Entry.js b/src/valueObjects/Entry.js index 0798960c..56960b1e 100644 --- a/src/valueObjects/Entry.js +++ b/src/valueObjects/Entry.js @@ -1,3 +1,5 @@ +import { isBoolean } from "lodash"; + export function createEntry(collection, slug = '', path = '', options = {}) { const returnObj = {}; returnObj.collection = collection; @@ -8,5 +10,8 @@ export function createEntry(collection, slug = '', path = '', options = {}) { returnObj.data = options.data || {}; returnObj.label = options.label || null; returnObj.metaData = options.metaData || null; + returnObj.isModification = isBoolean(options.isModification) + ? options.isModification + : null; return returnObj; }