Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit 96f2eeb

Browse files
authored
Merge pull request #154 from GeoNode/fix-save
Fix add layer and save not showing up
2 parents 87d22f3 + aec1193 commit 96f2eeb

File tree

2 files changed

+53
-9
lines changed

2 files changed

+53
-9
lines changed

src/components/geonode.jsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,21 @@ class GeoNodeViewer extends React.Component {
106106
errorOpen: false
107107
});
108108
}
109+
_createLayerList() {
110+
let layerList;
111+
if(this._local) {
112+
layerList = {
113+
sources: [{title: this._local.title, url: this._local.url, type: 'WMS'}],
114+
allowUserInput: true
115+
};
116+
} else {
117+
layerList = {
118+
sources: [{title: 'Local Geoserver', url: this.props.server+'/geoserver/wms', type: 'WMS'}],
119+
allowUserInput: true
120+
};
121+
}
122+
return layerList;
123+
}
109124
render() {
110125
var error;
111126
if (this.state.errors.length > 0) {
@@ -121,11 +136,8 @@ class GeoNodeViewer extends React.Component {
121136
/>);
122137
}
123138
let layerList, save, mapUrl;
124-
if(this.edit && this._local) {
125-
layerList = {
126-
sources: [{title: this._local.title, url: this._local.url, type: 'WMS'}],
127-
allowUserInput: true
128-
};
139+
if(this.edit) {
140+
layerList = this._createLayerList();
129141
if(this.props.server) {
130142
save = (<div id='save-button' className='geonode-save'><Save map={map} /></div>);
131143
mapUrl = (<MapUrlLink />);

tests/components/geonodeviewer.test.js

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import {assert} from 'chai';
55
import ol from 'openlayers';
66

77
import ReactTestUtils from 'react-addons-test-utils';
8+
import {shallowWithIntl} from '../testhelper';
9+
10+
import LayerList from 'boundless-sdk/components/LayerList';
811

912
import GeoNodeViewer from '../../src/components/geonode';
1013
import rendererWithIntl from '../../helper/renderWithIntl.js';
@@ -90,15 +93,44 @@ describe('GeoNodeViewer', () => {
9093
});
9194
describe('composer', () => {
9295
it('can remove layers', () => {
93-
const geonodeviewer = ReactTestUtils.renderIntoDocument(<IntlProvider locale="en"><GeoNodeViewer mode='composer' addLayerSources={layerSources} config={config}/></IntlProvider>);
94-
var contents = ReactTestUtils.scryRenderedDOMComponentsWithClass(geonodeviewer, 'layer-list-item-remove');
95-
assert.equal(contents.length, 1);
96+
const wrapper = shallowWithIntl(<GeoNodeViewer mode='composer' config={config}/>, {});
97+
assert.equal(wrapper.find(LayerList).prop('allowRemove'),true);
9698
});
9799
it('can add layers', () => {
98-
const geonodeviewer = ReactTestUtils.renderIntoDocument(<IntlProvider locale="en"><GeoNodeViewer mode='composer' addLayerSources={layerSources} config={config}/></IntlProvider>);
100+
const geonodeviewer = ReactTestUtils.renderIntoDocument(<IntlProvider locale="en"><GeoNodeViewer mode='composer' config={config}/></IntlProvider>);
99101
var contents = ReactTestUtils.scryRenderedDOMComponentsWithClass(geonodeviewer, 'layer-list-add');
100102
assert.equal(contents.length, 1);
101103
});
104+
it('does allow styling of layers', () => {
105+
const wrapper = shallowWithIntl(<GeoNodeViewer mode='composer' config={config}/>, {});
106+
assert.equal(wrapper.find(LayerList).prop('allowStyling'),true);
107+
});
108+
it('has addLayer list and uses server correctly', () => {
109+
const layerList = {
110+
sources: [{title: 'Local Geoserver', url: 'http://geonode.org/geoserver/wms', type: 'WMS'}],
111+
allowUserInput: true
112+
};
113+
const wrapper = shallowWithIntl(<GeoNodeViewer mode='composer' server='http://geonode.org' config={config}/>, {});
114+
assert.deepEqual(wrapper.find(LayerList).prop('addLayer'),layerList);
115+
});
116+
it('as addLayer list', () => {
117+
const layerList = {
118+
sources: [{title: 'Local Geoserver', url: 'undefined/geoserver/wms', type: 'WMS'}],
119+
allowUserInput: true
120+
};
121+
const wrapper = shallowWithIntl(<GeoNodeViewer mode='composer' config={config}/>, {});
122+
assert.deepEqual(wrapper.find(LayerList).prop('addLayer'),layerList);
123+
});
124+
it('as addLayer list', () => {
125+
const sources = {'0': { ptype: 'gxp_wmscsource', url: 'http://geonode.org?access_token=1', title: 'test'}}
126+
const baseUrl = 'http://geonode.org'
127+
const layerList = {
128+
sources: [{title: 'test', url: 'http://geonode.org?access_token=1', type: 'WMS'}],
129+
allowUserInput: true
130+
};
131+
const wrapper = shallowWithIntl(<GeoNodeViewer mode='composer' sources={sources} baseUrl={baseUrl} config={config}/>, {});
132+
assert.deepEqual(wrapper.find(LayerList).prop('addLayer'),layerList);
133+
});
102134
});
103135
});
104136
});

0 commit comments

Comments
 (0)