From d69edb356d3204209e098f4a42a9c7e79233f8ea Mon Sep 17 00:00:00 2001 From: Phillip Kruger Date: Fri, 10 Sep 2021 10:52:10 +0200 Subject: [PATCH] Small Dev UI change to allow going back to Dev UI when in Swagger and GraphQL UI Signed-off-by:Phillip Kruger --- bom/application/pom.xml | 4 ++-- .../branding/smallrye-graphql-ui-graphiql.css | 10 +++++++--- .../META-INF/branding/smallrye-open-api-ui.css | 11 ++++++++--- .../graphql/deployment/SmallRyeGraphQLProcessor.java | 9 +++++++++ .../swaggerui/deployment/SwaggerUiProcessor.java | 12 +++++++++--- 5 files changed, 35 insertions(+), 11 deletions(-) diff --git a/bom/application/pom.xml b/bom/application/pom.xml index 7061ce41ff0ee..55967c45ba2e3 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -45,8 +45,8 @@ 2.4.4 3.1.1 3.0.1 - 2.1.13 - 1.3.2 + 2.1.14 + 1.3.3 2.0.1 5.2.1 3.2.1 diff --git a/core/deployment/src/main/resources/META-INF/branding/smallrye-graphql-ui-graphiql.css b/core/deployment/src/main/resources/META-INF/branding/smallrye-graphql-ui-graphiql.css index 7f2d9aa345b01..25247ea1a11c9 100644 --- a/core/deployment/src/main/resources/META-INF/branding/smallrye-graphql-ui-graphiql.css +++ b/core/deployment/src/main/resources/META-INF/branding/smallrye-graphql-ui-graphiql.css @@ -51,11 +51,11 @@ body { padding-top: 12px !important; } -#graphiql .title a::after { +#graphQLUiTitleLink::after { content: "GraphQL UI"; } -#graphiql .title a { +#graphQLUiTitleLink { display: flex; align-items:center; color: white; @@ -64,9 +64,13 @@ body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; } -#graphiql .title img { +#graphQLUiLogoLink img { border-right: 1px solid darkgrey; padding-right: 10px; margin-right: 10px; height: 30px; +} + +.graphiql-container .title { + display: flex; } \ No newline at end of file diff --git a/core/deployment/src/main/resources/META-INF/branding/smallrye-open-api-ui.css b/core/deployment/src/main/resources/META-INF/branding/smallrye-open-api-ui.css index a10a15a508f31..0b6dec6d4eab9 100644 --- a/core/deployment/src/main/resources/META-INF/branding/smallrye-open-api-ui.css +++ b/core/deployment/src/main/resources/META-INF/branding/smallrye-open-api-ui.css @@ -10,11 +10,16 @@ html{ padding-bottom: 5px !important; } -#swagger-ui .swagger-ui .topbar a { - max-width: 180px; +#swaggerUiLogoLink { + max-width: 50px; + min-width: 50px; } -#swagger-ui .topbar-wrapper .link a::after { +#swaggerUiTitleLink { + max-width: 120px; +} + +#swaggerUiTitleLink::after { content: "Swagger UI"; font-size: 1.25rem; font-weight: normal; diff --git a/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java b/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java index 22de82bc20aad..8665c4a4f9018 100644 --- a/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java +++ b/extensions/smallrye-graphql/deployment/src/main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLProcessor.java @@ -100,6 +100,8 @@ public class SmallRyeGraphQLProcessor { private static final String LINE_FORMAT = LINE_TO_UPDATE + "%s';"; private static final String UI_LINE_TO_UPDATE = "const ui = '"; private static final String UI_LINE_FORMAT = UI_LINE_TO_UPDATE + "%s';"; + private static final String LOGO_LINE_TO_UPDATE = "const logo = '"; + private static final String LOGO_LINE_FORMAT = LOGO_LINE_TO_UPDATE + "%s';"; // Branding files to monitor for changes private static final String BRANDING_DIR = "META-INF/branding/"; @@ -519,6 +521,8 @@ void getGraphqlUiFinalDestination( WebJarUtil.updateUrl(tempPath.resolve(FILE_TO_UPDATE), graphQLPath, LINE_TO_UPDATE, LINE_FORMAT); WebJarUtil.updateUrl(tempPath.resolve(FILE_TO_UPDATE), graphQLUiPath, UI_LINE_TO_UPDATE, UI_LINE_FORMAT); + WebJarUtil.updateUrl(tempPath.resolve(FILE_TO_UPDATE), nonApplicationRootPathBuildItem.resolvePath("dev"), + LOGO_LINE_TO_UPDATE, LOGO_LINE_FORMAT); smallRyeGraphQLBuildProducer .produce(new SmallRyeGraphQLBuildItem(tempPath.toAbsolutePath().toString(), graphQLUiPath)); @@ -546,6 +550,11 @@ void getGraphqlUiFinalDestination( UI_LINE_TO_UPDATE, UI_LINE_FORMAT) .getBytes(StandardCharsets.UTF_8); + content = WebJarUtil + .updateUrl(new String(content, StandardCharsets.UTF_8), graphQLUiPath, + LOGO_LINE_TO_UPDATE, + LOGO_LINE_FORMAT) + .getBytes(StandardCharsets.UTF_8); } fileName = GRAPHQL_UI_FINAL_DESTINATION + "/" + fileName; diff --git a/extensions/swagger-ui/deployment/src/main/java/io/quarkus/swaggerui/deployment/SwaggerUiProcessor.java b/extensions/swagger-ui/deployment/src/main/java/io/quarkus/swaggerui/deployment/SwaggerUiProcessor.java index 85188b2fff31b..797293ba16f0a 100644 --- a/extensions/swagger-ui/deployment/src/main/java/io/quarkus/swaggerui/deployment/SwaggerUiProcessor.java +++ b/extensions/swagger-ui/deployment/src/main/java/io/quarkus/swaggerui/deployment/SwaggerUiProcessor.java @@ -132,7 +132,7 @@ public void getSwaggerUiFinalDestination( SWAGGER_UI_WEBJAR_PREFIX); // Update index.html WebJarUtil.updateFile(tempPath.resolve("index.html"), - generateIndexHtml(openApiPath, swaggerUiPath, swaggerUiConfig)); + generateIndexHtml(openApiPath, swaggerUiPath, swaggerUiConfig, nonApplicationRootPathBuildItem)); swaggerUiBuildProducer.produce(new SwaggerUiBuildItem(tempPath.toAbsolutePath().toString(), swaggerUiPath)); @@ -151,7 +151,7 @@ public void getSwaggerUiFinalDestination( if (fileName.equals(theme.toString()) || !fileName.startsWith("theme-")) { byte[] content; if (fileName.endsWith("index.html")) { - content = generateIndexHtml(openApiPath, swaggerUiPath, swaggerUiConfig); + content = generateIndexHtml(openApiPath, swaggerUiPath, swaggerUiConfig, null); } else { content = file.getValue(); } @@ -194,12 +194,18 @@ public void registerSwaggerUiHandler(SwaggerUiRecorder recorder, } } - private byte[] generateIndexHtml(String openApiPath, String swaggerUiPath, SwaggerUiConfig swaggerUiConfig) + private byte[] generateIndexHtml(String openApiPath, String swaggerUiPath, SwaggerUiConfig swaggerUiConfig, + NonApplicationRootPathBuildItem nonApplicationRootPath) throws IOException { Map options = new HashMap<>(); Map urlsMap = null; options.put(Option.selfHref, swaggerUiPath); + if (nonApplicationRootPath != null) { + options.put(Option.backHref, nonApplicationRootPath.resolvePath("dev")); + } else { + options.put(Option.backHref, swaggerUiPath); + } // Only add the url if the user did not specified urls if (swaggerUiConfig.urls != null && !swaggerUiConfig.urls.isEmpty()) {