show dimmed image preview for updates -- not working for videos yet
This commit is contained in:
parent
4deeaed4e6
commit
7f3e97d339
3 changed files with 38 additions and 15 deletions
|
@ -10,7 +10,12 @@ class PublishPreview extends React.Component {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
this.setPreviewImageSource(this.props.file);
|
const { isUpdate, sourceUrl, file } = this.props;
|
||||||
|
if (isUpdate && sourceUrl) {
|
||||||
|
this.setState({ imgSource: sourceUrl });
|
||||||
|
} else {
|
||||||
|
this.setPreviewImageSource(file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
componentWillReceiveProps (newProps) {
|
componentWillReceiveProps (newProps) {
|
||||||
if (newProps.file !== this.props.file) {
|
if (newProps.file !== this.props.file) {
|
||||||
|
@ -54,8 +59,10 @@ class PublishPreview extends React.Component {
|
||||||
|
|
||||||
PublishPreview.propTypes = {
|
PublishPreview.propTypes = {
|
||||||
dimPreview: PropTypes.bool.isRequired,
|
dimPreview: PropTypes.bool.isRequired,
|
||||||
file : PropTypes.object.isRequired,
|
file : PropTypes.object,
|
||||||
thumbnail : PropTypes.object,
|
thumbnail : PropTypes.object,
|
||||||
|
isUpdate : PropTypes.bool,
|
||||||
|
sourceUrl : PropTypes.string,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default PublishPreview;
|
export default PublishPreview;
|
||||||
|
|
|
@ -1,12 +1,18 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { selectFile, updateError, clearFile } from '../../actions/publish';
|
import { selectFile, updateError, clearFile } from '../../actions/publish';
|
||||||
|
import { selectAsset } from '../../selectors/show';
|
||||||
import View from './view';
|
import View from './view';
|
||||||
|
|
||||||
const mapStateToProps = ({ publish }) => {
|
const mapStateToProps = ({ publish, show }) => {
|
||||||
|
const asset = selectAsset(show);
|
||||||
|
const { name, claimData: { claimId, fileExt, outpoint } } = asset;
|
||||||
|
const sourceUrl = `/${claimId}/${name}.${fileExt}?${outpoint}`;
|
||||||
return {
|
return {
|
||||||
file : publish.file,
|
file : publish.file,
|
||||||
thumbnail: publish.thumbnail,
|
thumbnail: publish.thumbnail,
|
||||||
fileError: publish.error.file,
|
fileError: publish.error.file,
|
||||||
|
isUpdate : publish.isUpdate,
|
||||||
|
sourceUrl,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,8 @@ class Dropzone extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
render () {
|
render () {
|
||||||
|
const { dragOver, mouseOver, dimPreview } = this.state;
|
||||||
|
const { file, thumbnail, fileError, isUpdate, sourceUrl } = this.props;
|
||||||
return (
|
return (
|
||||||
<div className='dropzone-wrapper'>
|
<div className='dropzone-wrapper'>
|
||||||
<form>
|
<form>
|
||||||
|
@ -95,7 +97,7 @@ class Dropzone extends React.Component {
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
<div
|
<div
|
||||||
className={'dropzone' + (this.state.dragOver ? ' dropzone--drag-over' : '')}
|
className={'dropzone' + (dragOver ? ' dropzone--drag-over' : '')}
|
||||||
onDrop={this.handleDrop}
|
onDrop={this.handleDrop}
|
||||||
onDragOver={this.handleDragOver}
|
onDragOver={this.handleDragOver}
|
||||||
onDragEnd={this.handleDragEnd}
|
onDragEnd={this.handleDragEnd}
|
||||||
|
@ -104,26 +106,34 @@ class Dropzone extends React.Component {
|
||||||
onMouseEnter={this.handleMouseEnter}
|
onMouseEnter={this.handleMouseEnter}
|
||||||
onMouseLeave={this.handleMouseLeave}
|
onMouseLeave={this.handleMouseLeave}
|
||||||
onClick={this.handleClick}>
|
onClick={this.handleClick}>
|
||||||
{this.props.file ? (
|
{file || isUpdate ? (
|
||||||
<div className={'dropzone-preview-wrapper'}>
|
<div className={'dropzone-preview-wrapper'}>
|
||||||
|
{file ? (
|
||||||
<DropzonePreviewImage
|
<DropzonePreviewImage
|
||||||
dimPreview={this.state.dimPreview}
|
dimPreview={dimPreview}
|
||||||
file={this.props.file}
|
file={file}
|
||||||
thumbnail={this.props.thumbnail}
|
thumbnail={thumbnail}
|
||||||
/>
|
/>
|
||||||
|
) : (
|
||||||
|
<DropzonePreviewImage
|
||||||
|
dimPreview
|
||||||
|
isUpdate
|
||||||
|
sourceUrl={sourceUrl}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<div className={'dropzone-preview-overlay'}>
|
<div className={'dropzone-preview-overlay'}>
|
||||||
{ this.state.dragOver ? <DropzoneDropItDisplay /> : null }
|
{ dragOver ? <DropzoneDropItDisplay /> : null }
|
||||||
{ this.state.mouseOver ? (
|
{ mouseOver ? (
|
||||||
<DropzoneInstructionsDisplay
|
<DropzoneInstructionsDisplay
|
||||||
fileError={this.props.fileError}
|
fileError={fileError}
|
||||||
/>
|
/>
|
||||||
) : null }
|
) : null }
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
this.state.dragOver ? <DropzoneDropItDisplay /> : (
|
dragOver ? <DropzoneDropItDisplay /> : (
|
||||||
<DropzoneInstructionsDisplay
|
<DropzoneInstructionsDisplay
|
||||||
fileError={this.props.fileError}
|
fileError={fileError}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
|
|
Loading…
Add table
Reference in a new issue