Skip to content

Commit 00d81a1

Browse files
committed
Merge branch 'master' into c125-info-box-wysiwyg
2 parents 7150c25 + 3e70306 commit 00d81a1

524 files changed

Lines changed: 13602 additions & 4325 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
web/client/dist/
22
web/client/libs/Cesium
33
web/client/libs/cesium-navigation
4+
web/client/test-resources/
45
web/docs/
56
web/client/mapstore/docs/

.eslintrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"parser": "babel-eslint", // https://github.com/babel/babel-eslint
33
"plugins": [
44
"no-only-tests", // https://github.com/levibuzolic/eslint-plugin-no-only-tests
5-
"react" // https://github.com/yannickcr/eslint-plugin-react
5+
"react", // https://github.com/yannickcr/eslint-plugin-react
6+
"import" // https://github.com/benmosher/eslint-plugin-import
67
],
78
"env": { // http://eslint.org/docs/user-guide/configuring.html#specifying-environments
89
"browser": true, // browser global variables
@@ -86,6 +87,7 @@
8687
"eqeqeq": 2, // http://eslint.org/docs/rules/eqeqeq
8788
"guard-for-in": 2, // http://eslint.org/docs/rules/guard-for-in
8889
"no-caller": 2, // http://eslint.org/docs/rules/no-caller
90+
"import/named": 2, // https://github.com/benmosher/eslint-plugin-import/blob/HEAD/docs/rules/named.md
8991
"no-else-return": 2, // http://eslint.org/docs/rules/no-else-return
9092
"no-eq-null": 2, // http://eslint.org/docs/rules/no-eq-null
9193
"no-eval": 2, // http://eslint.org/docs/rules/no-eval

backend/src/main/java/it/geosolutions/mapstore/UploadPluginController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ private void addPluginConfiguration(JsonNode json) throws IOException {
267267
int remove = -1;
268268
for (int count = 0; count < plugins.size(); count++) {
269269
JsonNode node = plugins.get(count);
270-
if (json.get("name").asText().equals(node.get("value").get("name").asText())) {
270+
if (json.get("name").asText().equals(node.get("name").asText())) {
271271
remove = count;
272272
}
273273
}

backend/src/test/java/it/geosolutions/mapstore/UploadPluginControllerTest.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,33 @@ public String answer(InvocationOnMock invocation) throws Throwable {
5858
tempExtensions.delete();
5959
}
6060

61+
@Test
62+
public void testUploadValidBundleReplace() throws IOException {
63+
ServletContext context = Mockito.mock(ServletContext.class);
64+
controller.setContext(context);
65+
File tempConfig = TestUtils.copyToTemp(ConfigControllerTest.class.getResourceAsStream("/pluginsConfigWithPlugin.json"));
66+
Mockito.when(context.getRealPath(Mockito.endsWith("pluginsConfig.json"))).thenReturn(tempConfig.getAbsolutePath());
67+
File tempExtensions = TestUtils.copyToTemp(ConfigControllerTest.class.getResourceAsStream("/extensionsWithPlugin.json"));
68+
File tempDist = TestUtils.getDataDir();
69+
Mockito.when(context.getRealPath(Mockito.contains("extensions.json"))).thenReturn(tempExtensions.getAbsolutePath());
70+
Mockito.when(context.getRealPath(Mockito.contains("dist/extensions/"))).thenAnswer(new Answer<String>() {
71+
72+
@Override
73+
public String answer(InvocationOnMock invocation) throws Throwable {
74+
String path = (String)invocation.getArguments()[0];
75+
return tempDist.getAbsolutePath() + File.separator + path.substring("dist/extensions/".length());
76+
}
77+
78+
});
79+
InputStream zipStream = UploadPluginControllerTest.class.getResourceAsStream("/plugin.zip");
80+
String result = controller.uploadPlugin(zipStream);
81+
assertEquals("{\"name\":\"My\",\"dependencies\":[\"Toolbar\"],\"extension\":true}", result);
82+
String extensions = TestUtils.getContent(tempExtensions);
83+
assertEquals("{\"MyPlugin\":{\"bundle\":\"dist/extensions/My/myplugin.js\",\"translations\":\"dist/extensions/My/translations\"}}", extensions);
84+
tempConfig.delete();
85+
tempExtensions.delete();
86+
}
87+
6188
@Test
6289
public void testUploadValidBundleUsingPatch() throws IOException {
6390
controller.setPluginsConfigAsPatch(true);

build/docma-config.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
"web/client/components/notifications/NotificationContainer.jsx",
112112
"web/client/components/buttons/ToggleButton.jsx",
113113
"web/client/components/data/featuregrid/FeatureGrid.jsx",
114+
"web/client/components/data/featuregrid/editors/index.jsdoc",
114115
"web/client/components/data/featuregrid/editors/customEditors.jsx",
115116
"web/client/components/data/featuregrid/editors/DropDownEditor.jsx",
116117
"web/client/components/data/featuregrid/editors/FormatEditor.jsx",
@@ -260,6 +261,7 @@
260261
"web/client/plugins/TOC.jsx",
261262
"web/client/plugins/TOCItemsSettings.jsx",
262263
"web/client/plugins/Tutorial.jsx",
264+
"web/client/plugins/UserSession.jsx",
263265
"web/client/plugins/Version.jsx",
264266
"web/client/plugins/WFSDownload.jsx",
265267
"web/client/plugins/Widgets.jsx",

build/extensions/app.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import plugins from "./plugins";
1212
import rootTranslations from "../../web/client/translations/data.en-US.json";
1313
import bundleTranslations from "./bundle/translations/data.en-US.json";
1414

15-
const pluginsConfig = ["Map", "Toolbar", "ZoomIn", "ZoomOut", "Extension"];
15+
const pluginsConfig = ["Map", "Toolbar", "ZoomIn", "ZoomOut", "SampleExtension"];
1616
const LOCALE = "en-US";
1717

1818
const startApp = (messages) => {

build/extensions/bundle/index.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"plugins": [
33
{
4-
"name": "Extension",
4+
"name": "SampleExtension",
55
"dependencies": [
66
"Toolbar"
77
]
88
}
99
]
10-
}
10+
}

build/extensions/components/Extension.jsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
11
import React from "react";
22
import Message from "../../../web/client/components/I18N/Message";
33

4+
const style = {
5+
backgroundColor: "rgba(255,255,255,.9)",
6+
borderRadius: 10,
7+
maxWidth: 550,
8+
padding: 10,
9+
margin: 10,
10+
position: "absolute",
11+
top: 50, zIndex: 1000
12+
};
413
const Extension = ({ value = 0, onIncrease, changeZoomLevel }) => {
5-
return (<div style={{ top: "600px", zIndex: 1000 }}><span><Message msgId="extension.message"/>{value}</span>
6-
<button onClick={onIncrease}>+</button>
7-
<button onClick={() => {changeZoomLevel(1);}}>z</button>
14+
return (<div id="SAMPLE_EXTENSION" style={style}>
15+
<h2>Extension Sample</h2>
16+
<div>This is a sample extension plugin. The following tools demonstrate the correct binding inside MapStore</div>
17+
<h3>State and epics</h3>
18+
<div>A button like this should be visualized also in the toolbar: <br /><button onClick={onIncrease} className="btn-primary square-button btn">INC</button><br /> </div>
19+
<div>Clicking on that button (or on the button above) should increase this counter value: <b>{value}</b>. <br />The counter value updates should be logged in console by an epic</div>
20+
<i>note: the button in the toolbar can be hidden, in this case click on the "..." button</i>
21+
<h3>Localization</h3>
22+
The following text should be localized: <b><Message msgId="extension.message" /></b><br /> (you should see something like "Message!" if your language is set to en-US)
23+
<h3>Core action</h3>
24+
This button should change the zoom level to "1"
25+
<button onClick={() => { changeZoomLevel(1); }}>zoom to level 1</button>
826
</div>);
927
};
1028

build/extensions/extensions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import { createPlugin } from "../../web/client/utils/PluginsUtils";
1010

1111
export default {
12-
Extension: createPlugin('Extension', {
12+
SampleExtension: createPlugin('SampleExtension', {
1313
lazy: true,
14-
loader: () => import(/* webpackChunkName: "extensions/extension" */`./plugins/Extension`)
14+
loader: () => import(/* webpackChunkName: "extensions/sampleExtension" */`./plugins/SampleExtension`)
1515
})
1616
};

build/extensions/plugins/Extension.jsx renamed to build/extensions/plugins/SampleExtension.jsx

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,43 @@ import Rx from "rxjs";
55
import { changeZoomLevel } from "../../../web/client/actions/map";
66

77
export default {
8-
name: "Extension",
8+
name: "SampleExtension",
99
component: connect(state => ({
10-
value: state.extension && state.extension.value
11-
}), {onIncrease: () => {
12-
return {
13-
type: 'INCREASE_COUNTER'
14-
};
15-
}, changeZoomLevel})(Extension),
10+
value: state.sampleExtension && state.sampleExtension.value
11+
}), {
12+
onIncrease: () => {
13+
return {
14+
type: 'INCREASE_COUNTER'
15+
};
16+
}, changeZoomLevel
17+
})(Extension),
1618
reducers: {
17-
extension: (state = {value: 1}, action) => {
19+
sampleExtension: (state = { value: 1 }, action) => {
1820
if (action.type === 'INCREASE_COUNTER') {
19-
return {value: state.value + 1};
21+
return { value: state.value + 1 };
2022
}
2123
return state;
2224
}
2325
},
2426
epics: {
2527
logCounterValue: (action$, store) => action$.ofType('INCREASE_COUNTER').switchMap(() => {
2628
/* eslint-disable */
27-
console.log('CURRENT VALUE: ' + store.getState().extension.value);
29+
console.log('CURRENT VALUE: ' + store.getState().sampleExtension.value);
2830
/* eslint-enable */
2931
return Rx.Observable.empty();
3032
})
3133
},
3234
containers: {
3335
Toolbar: {
34-
name: "extension",
36+
name: "sampleExtension",
3537
position: 10,
36-
tooltip: "",
37-
help: "",
38-
tool: true,
38+
text: "INC",
39+
doNotHide: true,
40+
action: () => {
41+
return {
42+
type: 'INCREASE_COUNTER'
43+
};
44+
},
3945
priority: 1
4046
}
4147
}

0 commit comments

Comments
 (0)