2016-09-08 19:04:54 -03:00
|
|
|
import React from 'react';
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
2016-09-12 15:35:56 +02:00
|
|
|
import moment from 'moment';
|
2016-09-08 19:04:54 -03:00
|
|
|
import { Card } from './UI';
|
2016-09-13 03:59:48 -03:00
|
|
|
import { Link } from 'react-router'
|
2016-09-08 19:04:54 -03:00
|
|
|
import { statusDescriptions } from '../constants/publishModes';
|
2016-09-09 17:15:58 -03:00
|
|
|
import styles from './UnpublishedListing.css';
|
2016-09-08 19:04:54 -03:00
|
|
|
|
|
|
|
export default class UnpublishedListing extends React.Component {
|
2016-09-09 17:15:58 -03:00
|
|
|
renderColumns(entries, column) {
|
2016-09-08 19:04:54 -03:00
|
|
|
if (!entries) return;
|
2016-09-09 17:15:58 -03:00
|
|
|
|
|
|
|
if (!column) {
|
|
|
|
return entries.entrySeq().map(([currColumn, currEntries]) => (
|
|
|
|
<div key={currColumn} className={styles.column}>
|
|
|
|
<h3>{statusDescriptions.get(currColumn)}</h3>
|
|
|
|
{this.renderColumns(currEntries, currColumn)}
|
|
|
|
</div>
|
|
|
|
));
|
|
|
|
} else {
|
|
|
|
return <div>
|
2016-09-08 19:04:54 -03:00
|
|
|
{entries.map(entry => {
|
2016-09-09 17:15:58 -03:00
|
|
|
// Look for an "author" field. Fallback to username on backend implementation;
|
|
|
|
const author = entry.getIn(['data', 'author'], entry.getIn(['metaData', 'user']));
|
2016-09-12 15:35:56 +02:00
|
|
|
const timeStamp = moment(entry.getIn(['metaData', 'timeStamp'])).formate('llll');
|
2016-09-13 03:59:48 -03:00
|
|
|
const link = `/editorialworkflow/${entry.getIn(['metaData', 'collection'])}/${entry.getIn(['metaData', 'status'])}/${entry.get('slug')}`;
|
2016-09-09 17:15:58 -03:00
|
|
|
return (
|
|
|
|
<Card key={entry.get('slug')} className={styles.card}>
|
2016-09-13 03:59:48 -03:00
|
|
|
<h1><Link to={link}>{entry.getIn(['data', 'title'])}</Link> <small>by {author}</small></h1>
|
2016-09-09 17:15:58 -03:00
|
|
|
<p>Last updated: {timeStamp} by {entry.getIn(['metaData', 'user'])}</p>
|
|
|
|
</Card>
|
|
|
|
);
|
2016-09-08 19:04:54 -03:00
|
|
|
}
|
|
|
|
)}
|
2016-09-09 17:15:58 -03:00
|
|
|
</div>;
|
|
|
|
}
|
2016-09-08 19:04:54 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2016-09-09 17:15:58 -03:00
|
|
|
const columns = this.renderColumns(this.props.entries);
|
2016-09-08 19:04:54 -03:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
{columns}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UnpublishedListing.propTypes = {
|
2016-09-09 17:15:58 -03:00
|
|
|
entries: ImmutablePropTypes.orderedMap,
|
2016-09-08 19:04:54 -03:00
|
|
|
};
|