Skip to content

Commit

Permalink
Fix #1235. Hide zoom to when loading error occours (#1236)
Browse files Browse the repository at this point in the history
  • Loading branch information
offtherailz authored Nov 2, 2016
1 parent 0a037e8 commit 8e628c8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 5 deletions.
4 changes: 3 additions & 1 deletion web/client/components/TOC/DefaultLayer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,17 @@ var DefaultLayer = React.createClass({
if (this.props.activateLegendTool) {
tools.push(
<LayersTool key="toollegend"
className="toc-legendTool"
ref="target"
style={{"float": "right", cursor: "pointer"}}
glyph="list"
onClick={(node) => this.props.onToggle(node.id, node.expanded)}/>
);
}
if (this.props.activateZoomTool && this.props.node.bbox) {
if (this.props.activateZoomTool && this.props.node.bbox && !this.props.node.loadingError) {
tools.push(
<LayersTool key="toolzoom"
className="toc-zoomTool"
ref="target"
style={{"float": "right", cursor: "pointer"}}
glyph="1-full-screen"
Expand Down
34 changes: 32 additions & 2 deletions web/client/components/TOC/__tests__/DefaultLayer-test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe('test DefaultLayer module component', () => {
expect(comp).toExist();
const domNode = ReactDOM.findDOMNode(comp);
expect(domNode).toExist();
const tool = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithClass(comp, "glyphicon")[1]);
const tool = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithClass(comp, "toc-legendTool")[0]);
expect(tool).toExist();
tool.click();
expect(spy.calls.length).toBe(1);
Expand Down Expand Up @@ -162,12 +162,42 @@ describe('test DefaultLayer module component', () => {
expect(comp).toExist();
const domNode = ReactDOM.findDOMNode(comp);
expect(domNode).toExist();
const tool = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithClass(comp, "glyphicon")[1]);
const tool = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithClass(comp, "toc-zoomTool")[0]);
expect(tool).toExist();
tool.click();
expect(spy.calls.length).toBe(1);
});

it('hide zoom tool when error occours', () => {
const l = {
name: 'layer00',
title: 'Layer',
visibility: true,
storeIndex: 9,
type: 'wms',
loadingError: true,
bbox: {
crs: "EPSG:4326",
bounds: {
minx: 11.0,
maxx: 13.0,
miny: 43.0,
maxy: 44.0
}
}
};
const actions = {
onZoom: () => {}
};
const comp = ReactDOM.render(<Layer visibilityCheckType="checkbox" node={l} activateZoomTool={true} onZoom={actions.onZoom}/>,
document.getElementById("container"));
expect(comp).toExist();
const domNode = ReactDOM.findDOMNode(comp);
expect(domNode).toExist();
const tool = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithClass(comp, "toc-zoomTool")[0]);
expect(tool).toNotExist();
});

it('tests removelayer tool', () => {
const l = {
name: 'layer000',
Expand Down
6 changes: 4 additions & 2 deletions web/client/components/TOC/fragments/LayersTool.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const LayersTool = React.createClass({
onClick: React.PropTypes.func,
style: React.PropTypes.object,
glyph: React.PropTypes.string,
tooltip: React.PropTypes.string
tooltip: React.PropTypes.string,
className: React.PropTypes.string
},
getDefaultProps() {
return {
Expand All @@ -28,7 +29,8 @@ const LayersTool = React.createClass({
};
},
render() {
const tool = (<Glyphicon className="toc-layer-tool" style={this.props.style}
const cn = this.props.className ? " " + this.props.className : "";
const tool = (<Glyphicon className={"toc-layer-tool" + cn} style={this.props.style}
glyph={this.props.glyph}
onClick={(options) => this.props.onClick(this.props.node, options || {})}/>);
return this.props.tooltip ? (
Expand Down

0 comments on commit 8e628c8

Please sign in to comment.