2016-04-18 06:48:07 +02:00
|
|
|
import React from 'react';
|
2016-04-21 11:59:44 +02:00
|
|
|
import SilverStripeComponent from 'lib/SilverStripeComponent';
|
2016-04-18 06:48:07 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the right-hand collapsable change preview panel
|
|
|
|
*/
|
2016-04-21 11:59:44 +02:00
|
|
|
class Preview extends SilverStripeComponent {
|
2016-04-18 06:48:07 +02:00
|
|
|
|
|
|
|
render() {
|
2016-04-27 04:26:39 +02:00
|
|
|
// @todo - Multiple preview views with toggle slider
|
|
|
|
let body = null;
|
2016-04-28 01:41:40 +02:00
|
|
|
if (!this.props.previewUrl) {
|
2016-04-27 04:26:39 +02:00
|
|
|
body = (
|
2016-04-18 06:48:07 +02:00
|
|
|
<div className="preview__overlay">
|
|
|
|
<h3 className="preview__overlay-text">There is no preview available for this item.</h3>
|
|
|
|
</div>
|
2016-04-27 04:26:39 +02:00
|
|
|
);
|
2016-04-28 01:41:40 +02:00
|
|
|
} else if (this.props.previewType.indexOf('image/') === 0) {
|
|
|
|
body = (
|
|
|
|
<div className="preview__file-container panel-scrollable">
|
|
|
|
<img alt={this.props.previewUrl} className="preview__file--fits-space" src={this.props.previewUrl} />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
body = <iframe className="preview__iframe" src={this.props.previewUrl}></iframe>;
|
2016-04-27 04:26:39 +02:00
|
|
|
}
|
|
|
|
return (
|
|
|
|
<div className="cms-content__right preview">
|
|
|
|
{body}
|
|
|
|
<a href="" className="cms-content__back-btn font-icon-left-open-big" />
|
2016-04-19 06:37:25 +02:00
|
|
|
<div className="toolbar--south">
|
2016-04-18 06:48:07 +02:00
|
|
|
<div className="btn-toolbar">
|
2016-04-26 09:36:38 +02:00
|
|
|
<button className="btn btn-secondary btn-secondary font-icon-edit" type="button">
|
2016-04-27 04:26:39 +02:00
|
|
|
</button>
|
2016-04-18 06:48:07 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-28 01:41:40 +02:00
|
|
|
Preview.propTypes = {
|
|
|
|
previewUrl: React.PropTypes.string.isRequired,
|
|
|
|
previewType: React.PropTypes.string, // Mime type
|
|
|
|
};
|
|
|
|
|
2016-04-21 11:59:44 +02:00
|
|
|
export default Preview;
|