Skip to content

Commit bdd58b9

Browse files
authored
Merge pull request #3016 from offtherailz/porting_2018.02_to_master
Porting 2018.02.00 to master
2 parents 02ae240 + 5c3201f commit bdd58b9

6 files changed

Lines changed: 92 additions & 5 deletions

File tree

web/client/components/data/query/NumberField.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class NumberField extends React.Component {
141141
this.props.onUpdateExceptionField(this.props.fieldRowId, null);
142142
}
143143
}
144-
this.props.onUpdateField(this.props.fieldRowId, this.props.fieldName, value, this.props.attType);
144+
this.props.onUpdateField(this.props.fieldRowId, this.props.fieldName, isNaN(value) ? null : value, this.props.attType);
145145
};
146146
}
147147

web/client/components/data/query/__tests__/NumberField-test.jsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,19 @@ describe('NumberField', () => {
7474
cmp.changeNumber(10);
7575

7676
});
77+
78+
it('create number field with null if value is NaN', () => {
79+
const actions = {
80+
onUpdateField: () => {}
81+
};
82+
83+
const spyOnUpdateField = expect.spyOn(actions, 'onUpdateField');
84+
const cmp = ReactDOM.render(
85+
<NumberField
86+
onUpdateField={actions.onUpdateField}
87+
/>, document.getElementById("container"));
88+
expect(cmp).toExist();
89+
cmp.changeNumber('a');
90+
expect(spyOnUpdateField).toHaveBeenCalledWith(null, null, null, 'number');
91+
});
7792
});

web/client/epics/__tests__/login-test.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88

99
const expect = require('expect');
1010
const {INIT_CATALOG} = require('../../actions/catalog');
11-
const {loginSuccess, logout, logoutWithReload} = require('../../actions/security');
12-
const {initCatalogOnLoginOutEpic, reloadMapConfig} = require('../login');
11+
const {SET_CONTROL_PROPERTY} = require('../../actions/controls');
12+
const { loginSuccess, logout, logoutWithReload} = require('../../actions/security');
13+
const { initCatalogOnLoginOutEpic, promtLoginOnMapError, reloadMapConfig} = require('../login');
14+
const {configureError} = require('../../actions/config');
15+
1316

1417
const {testEpic} = require('./epicTestUtils');
1518

@@ -47,4 +50,17 @@ describe('login Epics', () => {
4750
};
4851
testEpic(initCatalogOnLoginOutEpic, 1, logout(), epicResult, {});
4952
});
53+
54+
it('it prompts login on accessing non-public map', (done) => {
55+
const e = {
56+
status: 403
57+
};
58+
const epicResult = actions => {
59+
expect(actions.length).toBe(1);
60+
const action = actions[0];
61+
expect(action.type).toBe(SET_CONTROL_PROPERTY);
62+
done();
63+
};
64+
testEpic(promtLoginOnMapError, 1, configureError(e, 123), epicResult, {});
65+
});
5066
});

web/client/epics/login.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88
const {refreshAccessToken, sessionValid, logout, LOGIN_SUCCESS, LOGOUT} = require('../actions/security');
9-
const {loadMapConfig, configureError} = require('../actions/config');
9+
const {loadMapConfig, configureError, MAP_CONFIG_LOAD_ERROR} = require('../actions/config');
1010
const {mapIdSelector} = require('../selectors/map');
1111
const {hasMapAccessLoadingError} = require('../selectors/mapInitialConfig');
1212
const {initCatalog} = require('../actions/catalog');
13+
const {setControlProperty} = require('../actions/controls');
1314
const {pathnameSelector} = require('../selectors/routing');
15+
const {isLoggedIn} = require('../selectors/security');
1416
const ConfigUtils = require('../utils/ConfigUtils');
1517
const AuthenticationAPI = require('../api/GeoStoreDAO');
1618
const Rx = require('rxjs');
@@ -54,6 +56,13 @@ const reloadMapConfig = (action$, store) =>
5456
return Rx.Observable.of(configureError(e));
5557
});
5658

59+
const promtLoginOnMapError = (actions$, store) =>
60+
actions$.ofType(MAP_CONFIG_LOAD_ERROR)
61+
.filter( (action) => action.error && action.error.status === 403 && !isLoggedIn(store.getState()))
62+
.switchMap(() => {
63+
return Rx.Observable.of(setControlProperty('LoginForm', 'enabled', true, true));
64+
});
65+
5766
const initCatalogOnLoginOutEpic = (action$) =>
5867
action$.ofType(LOGIN_SUCCESS, LOGOUT)
5968
.switchMap(() => {
@@ -68,5 +77,6 @@ const initCatalogOnLoginOutEpic = (action$) =>
6877
module.exports = {
6978
refreshTokenEpic,
7079
reloadMapConfig,
80+
promtLoginOnMapError,
7181
initCatalogOnLoginOutEpic
7282
};

web/client/utils/FilterUtils.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ const FilterUtils = {
282282

283283
filters.push(spatialFilter);
284284
}
285-
if (objFilter.crossLayerFilter) {
285+
if (objFilter.crossLayerFilter && objFilter.crossLayerFilter.operation) {
286286
let crossLayerFilter = {
287287
...objFilter.crossLayerFilter,
288288
attribute: objFilter.crossLayerFilter.attribute // || (objFilter.spatialField && objFilter.spatialField.attribute)

web/client/utils/__tests__/FilterUtils-test.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,52 @@ describe('FilterUtils', () => {
173173
expect(filter.indexOf('maxFeatures="20"') !== -1).toBe(true);
174174
expect(filter.indexOf('startIndex="1"') !== -1).toBe(true);
175175
});
176+
177+
it('Check for no oparation', () => {
178+
const versionOGC = "1.1.0";
179+
const nsplaceholder = "ogc";
180+
const objFilter = {
181+
featureTypeName: "topp:states",
182+
groupFields: [{
183+
id: 1,
184+
logic: "OR",
185+
index: 0
186+
}],
187+
filterFields: [],
188+
spatialField: {
189+
method: null,
190+
operation: "INTERSECTS",
191+
geometry: null,
192+
attribute: "the_geom"
193+
},
194+
pagination: {
195+
startIndex: 0,
196+
maxFeatures: 20
197+
},
198+
filterType: "OGC",
199+
ogcVersion: "1.1.0",
200+
sortOptions: null,
201+
crossLayerFilter: {
202+
attribute: "the_geom",
203+
collectGeometries: {
204+
queryCollection: {
205+
typeName: "topp:states",
206+
filterFields: [],
207+
geometryName: "the_geom",
208+
groupFields: [{
209+
id: 1,
210+
index: 0,
211+
logic: "OR"
212+
}]
213+
}
214+
}
215+
},
216+
hits: false
217+
};
218+
219+
let filterParts = FilterUtils.toOGCFilterParts(objFilter, versionOGC, nsplaceholder);
220+
expect(filterParts).toEqual([]);
221+
});
176222
it('Check for pagination wfs 2.0', () => {
177223
let filterObj = {
178224
pagination: {

0 commit comments

Comments
 (0)