Skip to content

Commit

Permalink
fix scrubber isolated ref image (#1262)
Browse files Browse the repository at this point in the history
  • Loading branch information
ledenis committed Dec 5, 2020
1 parent cf42513 commit 7d84de7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
6 changes: 3 additions & 3 deletions compare/output/index_bundle.js

Large diffs are not rendered by default.

23 changes: 13 additions & 10 deletions compare/src/components/atoms/ImageScrubber.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,17 @@ export default class ImageScrubber extends React.Component {
constructor (props) {
super(props);
this.state = {
dontUseScrubberView: false,
isRefImageMissing: false,
isLoading: false
};

this.handleLoadingError = this.handleLoadingError.bind(this);
this.handleRefImageLoadingError = this.handleRefImageLoadingError.bind(this);
this.loadingDiverge = this.loadingDiverge.bind(this);
}

handleLoadingError () {
handleRefImageLoadingError () {
this.setState({
dontUseScrubberView: true
isRefImageMissing: true
});
}

Expand All @@ -114,7 +114,6 @@ export default class ImageScrubber extends React.Component {
testImage,
diffImage,
divergedImage,
showButtons,
showScrubberTestImage,
showScrubberRefImage,
showScrubberDiffImage,
Expand All @@ -123,6 +122,7 @@ export default class ImageScrubber extends React.Component {
} = this.props;

const scrubberTestImageSlug = this.props[testImageType];
const hasDiff = diffImage && diffImage.length > 0;

// only show the diverged option if the report comes from web server
function showDivergedOption () {
Expand Down Expand Up @@ -189,11 +189,13 @@ export default class ImageScrubber extends React.Component {
});
}

const dontUseScrubberView = this.state.dontUseScrubberView || !showButtons;
const dontUseScrubberView = this.state.isRefImageMissing || !hasDiff;
const showIsolatedRefImage = !hasDiff && scrubberModalMode === 'SHOW_SCRUBBER_REF_IMAGE';
const showIsolatedTestImage = !hasDiff && scrubberModalMode === 'SHOW_SCRUBBER_TEST_IMAGE';
return (
<div>
<WrapTitle>
{showButtons && (
{hasDiff && (
<div>
<ScrubberViewBtn
selected={scrubberModalMode === 'SHOW_SCRUBBER_REF_IMAGE'}
Expand Down Expand Up @@ -241,7 +243,8 @@ export default class ImageScrubber extends React.Component {
id="isolatedRefImage"
src={refImage}
style={{
display: 'none'
margin: 'auto',
display: showIsolatedRefImage ? 'block' : 'none'
}}
/>
<img
Expand All @@ -250,7 +253,7 @@ export default class ImageScrubber extends React.Component {
src={testImage}
style={{
margin: 'auto',
display: dontUseScrubberView ? 'block' : 'none'
display: showIsolatedTestImage ? 'block' : 'none'
}}
/>
<img
Expand All @@ -277,7 +280,7 @@ export default class ImageScrubber extends React.Component {
id="scrubberRefImage"
className="refImage"
src={refImage}
onError={this.handleLoadingError}
onError={this.handleRefImageLoadingError}
/>
<img
id="scrubberTestImage"
Expand Down
1 change: 0 additions & 1 deletion compare/src/components/ecosystems/ScrubberModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ class ScrubberModal extends React.Component {
diffImage={diffImage}
divergedImage={divergedImage}
position={position}
showButtons={diffImage && diffImage.length > 0}
showScrubberTestImage={showScrubberTestImage}
showScrubberRefImage={showScrubberRefImage}
showScrubberDiffImage={showScrubberDiffImage}
Expand Down
3 changes: 2 additions & 1 deletion compare/src/reducers/scrubber.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ const scrubber = (state = {}, action) => {
case 'SHOW_SCRUBBER':
return Object.assign({}, state, {
position: getPosFromImgId(),
scrubberModalMode: 'SCRUB'
scrubberModalMode: 'SCRUB',
testImageType: 'testImage'
});

default:
Expand Down

0 comments on commit 7d84de7

Please sign in to comment.