Skip to content

Commit 1c6a737

Browse files
committed
task: add React to dependencies and make it available in views.
Addressed to #1060 No functional changes.
1 parent 054acbc commit 1c6a737

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

pom.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,20 @@
278278
<scope>runtime</scope>
279279
</dependency>
280280

281+
<dependency>
282+
<groupId>org.webjars.npm</groupId>
283+
<artifactId>react</artifactId>
284+
<version>${react.version}</version>
285+
<scope>runtime</scope>
286+
</dependency>
287+
288+
<dependency>
289+
<groupId>org.webjars.npm</groupId>
290+
<artifactId>react-dom</artifactId>
291+
<version>${react.version}</version>
292+
<scope>runtime</scope>
293+
</dependency>
294+
281295
<!-- For mocking of non-interface types -->
282296
<dependency>
283297
<groupId>cglib</groupId>
@@ -549,6 +563,9 @@
549563
<!-- Redefine default value from spring-boot-dependencies (https://github.com/spring-projects/spring-boot/blob/v1.5.21.RELEASE/spring-boot-dependencies/pom.xml) -->
550564
<postgresql.version>9.4.1212.jre7</postgresql.version>
551565

566+
<!-- Don't forget to update version in the ResourceUrl class -->
567+
<react.version>16.8.6</react.version>
568+
552569
<resources.plugin.version>3.1.0</resources.plugin.version>
553570
<robotframework-httprequest.version>0.0.15</robotframework-httprequest.version>
554571
<robotframework-plugin.version>1.4.7</robotframework-plugin.version>

src/main/java/ru/mystamps/web/config/MvcConfig.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {
131131
.addResourceLocations("classpath:/META-INF/resources/webjars/bootstrap/");
132132
registry.addResourceHandler("/public/jquery/**")
133133
.addResourceLocations("classpath:/META-INF/resources/webjars/jquery/");
134+
registry.addResourceHandler("/public/react/**")
135+
.addResourceLocations("classpath:/META-INF/resources/webjars/react/");
136+
registry.addResourceHandler("/public/react-dom/**")
137+
.addResourceLocations("classpath:/META-INF/resources/webjars/react-dom/");
134138
registry.addResourceHandler("/public/selectize/**")
135139
.addResourceLocations("classpath:/META-INF/resources/webjars/selectize.js/");
136140
}

src/main/java/ru/mystamps/web/feature/site/ResourceUrl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ public final class ResourceUrl {
4949
private static final String BOOTSTRAP_CSS = "/bootstrap/3.4.1/css/bootstrap.min.css";
5050
private static final String BOOTSTRAP_JS = "/bootstrap/3.4.1/js/bootstrap.min.js";
5151
private static final String JQUERY_JS = "/jquery/1.9.1/jquery.min.js";
52+
private static final String REACT_JS = "16.8.6/umd/react.production.min.js";
53+
private static final String REACT_DOM_JS = "16.8.6/umd/react-dom.production.min.js";
5254
private static final String SELECTIZE_JS = "/0.12.5/js/standalone/selectize.min.js";
5355

5456
// CheckStyle: ignore LineLength for next 3 lines
@@ -80,6 +82,8 @@ public static void exposeWebjarResourcesToView(Map<String, String> resources, bo
8082
put(resources, "https://maxcdn.bootstrapcdn.com", "BOOTSTRAP_CSS", BOOTSTRAP_CSS);
8183
put(resources, "https://maxcdn.bootstrapcdn.com", "BOOTSTRAP_JS", BOOTSTRAP_JS);
8284
put(resources, "https://yandex.st", "JQUERY_JS", JQUERY_JS);
85+
put(resources, "https://unpkg.com/react@", "REACT_JS", REACT_JS);
86+
put(resources, "https://unpkg.com/react-dom@", "REACT_DOM_JS", REACT_DOM_JS);
8387
// CheckStyle: ignore LineLength for next 1 line
8488
put(resources, "https://cdnjs.cloudflare.com/ajax/libs/selectize.js", "SELECTIZE_JS", SELECTIZE_JS);
8589
put(resources, null, "SELECTIZE_CSS", SELECTIZE_CSS_CDN);
@@ -89,6 +93,8 @@ public static void exposeWebjarResourcesToView(Map<String, String> resources, bo
8993
put(resources, "/public", "BOOTSTRAP_CSS", BOOTSTRAP_CSS);
9094
put(resources, "/public", "BOOTSTRAP_JS", BOOTSTRAP_JS);
9195
put(resources, "/public", "JQUERY_JS", JQUERY_JS);
96+
put(resources, "/public/react/", "REACT_JS", REACT_JS);
97+
put(resources, "/public/react-dom/", "REACT_DOM_JS", REACT_DOM_JS);
9298
put(resources, "/public/selectize", "SELECTIZE_JS", SELECTIZE_JS);
9399
put(resources, null, "SELECTIZE_CSS", SELECTIZE_CSS);
94100
}

0 commit comments

Comments
 (0)