Skip to content

Commit

Permalink
Don't render "Zoomed image" link in Book mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
jkeck committed Jun 4, 2019
1 parent 9180ca6 commit 40efaca
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
7 changes: 7 additions & 0 deletions __tests__/CanvasDownloadLinks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function createWrapper(props) {
<CanvasDownloadLinks
canvasId="abc123"
canvasLabel="My Canvas Label"
viewType="single"
windowId="wid123"
{...props}
/>,
Expand Down Expand Up @@ -77,6 +78,12 @@ describe('CanvasDownloadLinks', () => {
'WithStyles(Link)[href="http://example.com/iiif/abc123/0,0,2000,500/full/0/default.jpg"]',
).props().children).toEqual('Zoomed image (2000 x 500px)');
});

it('is not present when the window is in book view', () => {
wrapper = createWrapper({ canvas, viewType: 'book', windowId: 'zoomedInWindow' });

expect(wrapper.find('WithStyles(Link)').length).toBe(2);
});
});

describe('when the image is > 1000px wide', () => {
Expand Down
1 change: 1 addition & 0 deletions __tests__/miradorDownloadPlugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ function createWrapper(props) {
<miradorDownloadPlugin.component
canvasLabel={label => (label || 'My Canvas Title')}
canvases={[]}
viewType="single"
windowId="wid123"
{...props}
/>,
Expand Down
4 changes: 4 additions & 0 deletions src/CanvasDownloadLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ export default class CanvasDownloadLinks extends Component {
}

displayCurrentZoomLink() {
const { viewType } = this.props;

if (viewType === 'book') return false;
return this.osdViewport().getZoom() > this.osdViewport().getHomeZoom();
}

Expand Down Expand Up @@ -118,5 +121,6 @@ CanvasDownloadLinks.propTypes = {
getWidth: PropTypes.func.isRequired,
}).isRequired,
canvasLabel: PropTypes.string.isRequired, // canvasLabel is passed because we need access to redux
viewType: PropTypes.string.isRequired,
windowId: PropTypes.string.isRequired,
};
8 changes: 7 additions & 1 deletion src/miradorDownloadPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import MenuItem from '@material-ui/core/MenuItem';
import Typography from '@material-ui/core/Typography';
import DownloadIcon from '@material-ui/icons/VerticalAlignBottomSharp';
import { getCanvasLabel, getSelectedCanvases } from 'mirador/dist/es/src/state/selectors/canvases';
import { getWindowViewType } from 'mirador/dist/es/src/state/selectors/windows';
import CanvasDownloadLinks from './CanvasDownloadLinks';

const mapStateToProps = (state, { windowId }) => ({
canvases: getSelectedCanvases(state, { windowId }),
canvasLabel: canvasIndex => (getCanvasLabel(state, { canvasIndex, windowId })),
viewType: getWindowViewType(state, { windowId }),
});

class MiradorDownload extends Component {
Expand All @@ -39,7 +41,9 @@ class MiradorDownload extends Component {
}

render() {
const { canvases, canvasLabel, windowId } = this.props;
const {
canvases, canvasLabel, viewType, windowId
} = this.props;
const { modalDisplayed } = this.state;
return (
<div>
Expand All @@ -64,6 +68,7 @@ class MiradorDownload extends Component {
canvas={canvas}
canvasLabel={canvasLabel(canvas.index)}
key={canvas.id}
viewType={viewType}
windowId={windowId}
/>
))}
Expand All @@ -84,6 +89,7 @@ MiradorDownload.propTypes = {
canvases: PropTypes.arrayOf(
PropTypes.shape({ id: PropTypes.string, index: PropTypes.number }),
).isRequired,
viewType: PropTypes.string.isRequired,
windowId: PropTypes.string.isRequired,
};

Expand Down

0 comments on commit 40efaca

Please sign in to comment.