2016-05-30 16:55:32 -07:00
|
|
|
import React from 'react';
|
|
|
|
import Widgets from './Widgets';
|
|
|
|
|
|
|
|
export default class PreviewPane extends React.Component {
|
|
|
|
previewFor(field) {
|
2016-06-10 00:16:01 -03:00
|
|
|
const { entry, getMedia } = this.props;
|
2016-05-30 16:55:32 -07:00
|
|
|
const widget = Widgets[field.get('widget')] || Widgets._unknown;
|
|
|
|
return React.createElement(widget.Preview, {
|
|
|
|
key: field.get('name'),
|
|
|
|
field: field,
|
2016-06-10 00:16:01 -03:00
|
|
|
value: entry.getIn(['data', field.get('name')]),
|
|
|
|
getMedia: getMedia,
|
2016-05-30 16:55:32 -07:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { collection } = this.props;
|
|
|
|
if (!collection) { return null; }
|
|
|
|
|
|
|
|
return <div>
|
|
|
|
{collection.get('fields').map((field) => <div>{this.previewFor(field)}</div>)}
|
|
|
|
</div>;
|
|
|
|
}
|
|
|
|
}
|