diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2022-10-27 17:15:55 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-27 17:15:55 +0200 |
| commit | c4cfb6f6e0507f335fd88935857f20e88c34abd0 (patch) | |
| tree | 8dad74b6a213bb294dbcea33ebab34a3be193e77 /opendc-web/opendc-web-ui-quarkus-deployment/src/main/java | |
| parent | fa7fdbb0126ea465130961dc37c4ef2d6feb36e9 (diff) | |
| parent | 5a3d5148a9d52487f102e52bd079006c916075c9 (diff) | |
merge: Update to Next.js 13 and React 18
This pull request updates the web interface to make use of Next.js 13 and React 18.
## Implementation Notes :hammer_and_pick:
* Drop dependency on FontAwesome
* Update to Next 13 and React 18
* Drop dependency on Roboto font
* Make root redirect non-permanent
* Do not optimize images for export
* Update to Node 18 for the build process
* Ensure consistency of build tasks
* Update README.md of web UI
* Default to anonymous auth domain
* Disable configuration of basePath
## External Dependencies :four_leaf_clover:
* Next.js 13
* React 18
* PatternFly 4
* Node 18
## Breaking API Changes :warning:
* The base path of the web UI cannot be configured anymore via the Quarkus extension.
The previous implementation relied on Next.js internals and this functionality cannot be
provided without resorting to hacks. Since this functionality was not actually used, we have
removed it for now.
Diffstat (limited to 'opendc-web/opendc-web-ui-quarkus-deployment/src/main/java')
2 files changed, 8 insertions, 28 deletions
diff --git a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiConfig.java b/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiConfig.java index d630dbac..091e60ab 100644 --- a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiConfig.java +++ b/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiConfig.java @@ -38,12 +38,6 @@ public class OpenDCUiConfig { boolean include; /** - * The path where the OpenDC UI is available. - */ - @ConfigItem(defaultValue = "/") - String path; - - /** * The base URL of the OpenDC API. */ @ConfigItem(defaultValue = "/api") diff --git a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiProcessor.java b/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiProcessor.java index 093a9bfa..5733e0db 100644 --- a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiProcessor.java +++ b/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiProcessor.java @@ -75,13 +75,13 @@ public class OpenDCUiProcessor { * Build the WebJar that is used to serve the Next.js resources. */ @BuildStep(onlyIf = IsIncluded.class) - public WebJarBuildItem buildWebJar(OpenDCUiConfig config, HttpRootPathBuildItem httpRootPathBuildItem) { + public WebJarBuildItem buildWebJar(OpenDCUiConfig config) { return WebJarBuildItem.builder() .artifactKey(OPENDC_UI_WEBJAR_ARTIFACT_KEY) .root(OPENDC_UI_WEBJAR_STATIC_RESOURCES_PATH) .onlyCopyNonArtifactFiles(false) .useDefaultQuarkusBranding(false) - .filter(new InsertVariablesResourcesFilter(config, httpRootPathBuildItem)) + .filter(new InsertVariablesResourcesFilter(config)) .build(); } @@ -128,8 +128,8 @@ public class OpenDCUiProcessor { } int statusCode = redirect.get("statusCode").asInt(); - String path = redirect.get("source").asText().replaceAll("/%%NEXT_BASE_PATH%%", ""); - String destination = redirect.get("destination").asText().replaceAll("/%%NEXT_BASE_PATH%%", ""); + String path = redirect.get("source").asText(); + String destination = redirect.get("destination").asText(); if (path.isEmpty()) { path = "/"; @@ -154,7 +154,6 @@ public class OpenDCUiProcessor { WebJarResultsBuildItem webJarResultsBuildItem, OpenDCUiRoutingBuildItem openDCUiBuildItem, OpenDCUiRuntimeConfig runtimeConfig, - OpenDCUiConfig buildConfig, ShutdownContextBuildItem shutdownContext) { WebJarResultsBuildItem.WebJarResult result = @@ -163,7 +162,7 @@ public class OpenDCUiProcessor { return; } - String basePath = httpRootPathBuildItem.resolvePath(buildConfig.path); + String basePath = httpRootPathBuildItem.getRootPath(); String finalDestination = result.getFinalDestination(); /* Construct dynamic routes */ @@ -192,15 +191,7 @@ public class OpenDCUiProcessor { routes.produce(httpRootPathBuildItem .routeBuilder() - .route(buildConfig.path) - .displayOnNotFoundPage("OpenDC UI") - .routeConfigKey("quarkus.opendc-ui.path") - .handler(staticHandler) - .build()); - - routes.produce(httpRootPathBuildItem - .routeBuilder() - .route(buildConfig.path + "*") + .route("*") .handler(staticHandler) .build()); } @@ -215,11 +206,9 @@ public class OpenDCUiProcessor { private static final String JS = ".js"; private final OpenDCUiConfig config; - private final HttpRootPathBuildItem httpRootPathBuildItem; - public InsertVariablesResourcesFilter(OpenDCUiConfig config, HttpRootPathBuildItem httpRootPathBuildItem) { + public InsertVariablesResourcesFilter(OpenDCUiConfig config) { this.config = config; - this.httpRootPathBuildItem = httpRootPathBuildItem; } @Override @@ -247,9 +236,6 @@ public class OpenDCUiProcessor { private String substitute(String var) { switch (var) { - case "NEXT_BASE_PATH": - String basePath = httpRootPathBuildItem.resolvePath(config.path); - return basePath.equals("/") ? "" : basePath; // Base path must not end with trailing slash case "NEXT_PUBLIC_API_BASE_URL": return config.apiBaseUrl; case "NEXT_PUBLIC_SENTRY_DSN": @@ -271,7 +257,7 @@ public class OpenDCUiProcessor { * Be aware that to properly handle Next.js base path, we need to also match a possible forward slash in front * of the variable. */ - private static final Pattern PATTERN = Pattern.compile("/?%%(\\w+)%%"); + private static final Pattern PATTERN = Pattern.compile("%%(\\w+)%%"); /** * Helper method to substitute variables in the OpenDC web UI. |
