Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix other than markdown editorial workflow entries on dashboard. #794

Merged
merged 1 commit into from
Nov 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/actions/editorialWorkflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ export function loadUnpublishedEntry(collection, slug) {
};
}

export function loadUnpublishedEntries() {
export function loadUnpublishedEntries(collections) {
return (dispatch, getState) => {
const state = getState();
if (state.config.get('publish_mode') !== EDITORIAL_WORKFLOW) return;
const backend = currentBackend(state.config);
dispatch(unpublishedEntriesLoading());
backend.unpublishedEntries().then(
backend.unpublishedEntries(collections).then(
response => dispatch(unpublishedEntriesLoaded(response.entries, response.pagination)),
error => dispatch(unpublishedEntriesFailed(error))
);
Expand Down
9 changes: 6 additions & 3 deletions src/backends/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ class Backend {
};
}

unpublishedEntries(page, perPage) {
return this.implementation.unpublishedEntries(page, perPage)
unpublishedEntries(collections) {
return this.implementation.unpublishedEntries()
.then(loadedEntries => loadedEntries.filter(entry => entry !== null))
.then(entries => (
entries.map((loadedEntry) => {
Expand All @@ -184,7 +184,10 @@ class Backend {
))
.then(entries => ({
pagination: 0,
entries: entries.map(this.entryWithFormat("editorialWorkflow")),
entries: entries.map(entry => {
const collection = collections.get(entry.collection);
return this.entryWithFormat(collection)(entry);
}),
}));
}

Expand Down
8 changes: 5 additions & 3 deletions src/containers/editorialWorkflow/UnpublishedEntriesPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { Loader } from '../../components/UI';

class unpublishedEntriesPanel extends Component {
static propTypes = {
collections: ImmutablePropTypes.orderedMap,
isEditorialWorkflow: PropTypes.bool.isRequired,
isFetching: PropTypes.bool,
unpublishedEntries: ImmutablePropTypes.map,
Expand All @@ -26,9 +27,9 @@ class unpublishedEntriesPanel extends Component {
};

componentDidMount() {
const { loadUnpublishedEntries, isEditorialWorkflow } = this.props;
const { loadUnpublishedEntries, isEditorialWorkflow, collections } = this.props;
if (isEditorialWorkflow) {
loadUnpublishedEntries();
loadUnpublishedEntries(collections);
}
}

Expand All @@ -49,8 +50,9 @@ class unpublishedEntriesPanel extends Component {
}

function mapStateToProps(state) {
const { collections } = state;
const isEditorialWorkflow = (state.config.get('publish_mode') === EDITORIAL_WORKFLOW);
const returnObj = { isEditorialWorkflow };
const returnObj = { collections, isEditorialWorkflow };

if (isEditorialWorkflow) {
returnObj.isFetching = state.editorialWorkflow.getIn(['pages', 'isFetching'], false);
Expand Down
9 changes: 0 additions & 9 deletions src/formats/formats.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ export const formatToExtension = format => ({
html: 'html',
}[format]);

function formatByType(type) {
// Right now the only type is "editorialWorkflow" and
// we always returns the same format
return FrontmatterFormatter;
}

export function formatByExtension(extension) {
return {
yml: yamlFormatter,
Expand All @@ -39,9 +33,6 @@ function formatByName(name) {
}

export function resolveFormat(collectionOrEntity, entry) {
if (typeof collectionOrEntity === 'string') {
return formatByType(collectionOrEntity);
}
const path = entry && entry.path;
if (path) {
return formatByExtension(path.split('.').pop());
Expand Down