From 87e0351002b3c2e32c3f56a60d22bcbded078295 Mon Sep 17 00:00:00 2001 From: JordenReuter <149687553+JordenReuter@users.noreply.github.com> Date: Thu, 21 Nov 2024 08:54:34 +0100 Subject: [PATCH] fix: removed favicon and logo path generation (#72) Co-authored-by: Andrej Petras --- .../rs/controllers/WorkspaceConfigRestController.java | 7 +------ .../shell/bff/rs/mappers/WorkspaceConfigMapper.java | 10 ++-------- .../bff/rs/WorkspaceConfigRestControllerTest.java | 3 ++- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/tkit/onecx/shell/bff/rs/controllers/WorkspaceConfigRestController.java b/src/main/java/org/tkit/onecx/shell/bff/rs/controllers/WorkspaceConfigRestController.java index 0edf1fe..3a33b03 100644 --- a/src/main/java/org/tkit/onecx/shell/bff/rs/controllers/WorkspaceConfigRestController.java +++ b/src/main/java/org/tkit/onecx/shell/bff/rs/controllers/WorkspaceConfigRestController.java @@ -4,10 +4,8 @@ import jakarta.inject.Inject; import jakarta.transaction.Transactional; import jakarta.validation.ConstraintViolationException; -import jakarta.ws.rs.core.Context; import jakarta.ws.rs.core.HttpHeaders; import jakarta.ws.rs.core.Response; -import jakarta.ws.rs.core.UriInfo; import org.eclipse.microprofile.rest.client.inject.RestClient; import org.jboss.resteasy.reactive.ClientWebApplicationException; @@ -49,9 +47,6 @@ public class WorkspaceConfigRestController implements WorkspaceConfigApiService @Inject ExceptionMapper exceptionMapper; - @Context - UriInfo uriInfo; - @Override public Response loadWorkspaceConfig(LoadWorkspaceConfigRequestDTO loadWorkspaceConfigRequestDTO) { @@ -80,7 +75,7 @@ public Response loadWorkspaceConfig(LoadWorkspaceConfigRequestDTO loadWorkspaceC //get theme info try (Response themeResponse = themeClient.getThemeByName(wrapper.getTheme())) { var theme = themeResponse.readEntity(Theme.class); - result.setTheme(mapper.createTheme(theme, uriInfo.getPath())); + result.setTheme(mapper.createTheme(theme)); } return Response.ok(result).build(); diff --git a/src/main/java/org/tkit/onecx/shell/bff/rs/mappers/WorkspaceConfigMapper.java b/src/main/java/org/tkit/onecx/shell/bff/rs/mappers/WorkspaceConfigMapper.java index 64063b2..1b5512d 100644 --- a/src/main/java/org/tkit/onecx/shell/bff/rs/mappers/WorkspaceConfigMapper.java +++ b/src/main/java/org/tkit/onecx/shell/bff/rs/mappers/WorkspaceConfigMapper.java @@ -132,19 +132,13 @@ default SlotDTO createSlot(WorkspaceWrapperSlot slot) { } @Mapping(target = "properties", ignore = true) - ThemeDTO createTheme(Theme themeInfo, String path); + ThemeDTO createTheme(Theme themeInfo); @AfterMapping - default void createThemeAfter(@MappingTarget ThemeDTO target, Theme themeInfo, String path) { + default void createThemeAfter(@MappingTarget ThemeDTO target, Theme themeInfo) { if (themeInfo != null) { target.setProperties(String.valueOf(themeInfo.getProperties())); } - if (target.getFaviconUrl() == null) { - target.setFaviconUrl(path + "/themes/" + target.getName() + "/favicon"); - } - if (target.getLogoUrl() == null) { - target.setLogoUrl(path + "/themes/" + target.getName() + "/logo"); - } } default LoadProductRequestPSV1 create(WorkspaceWrapper wrapper) { diff --git a/src/test/java/org/tkit/onecx/shell/bff/rs/WorkspaceConfigRestControllerTest.java b/src/test/java/org/tkit/onecx/shell/bff/rs/WorkspaceConfigRestControllerTest.java index ff49887..7506edb 100644 --- a/src/test/java/org/tkit/onecx/shell/bff/rs/WorkspaceConfigRestControllerTest.java +++ b/src/test/java/org/tkit/onecx/shell/bff/rs/WorkspaceConfigRestControllerTest.java @@ -313,7 +313,8 @@ void loadWorkspaceConfigByBaseUrlTest() { Assertions.assertEquals(productResponse.getProducts().get(0).getMicrofrontends().get(0).getEndpoints().size(), output.getRoutes().get(0).getEndpoints().size()); Assertions.assertEquals("endpoint1", output.getRoutes().get(0).getEndpoints().get(0).getName()); - Assertions.assertEquals("/workspaceConfig/themes/theme1/logo", output.getTheme().getLogoUrl()); + Assertions.assertNull(output.getTheme().getLogoUrl()); + Assertions.assertNotNull(output.getTheme().getFaviconUrl()); mockServerClient.clear("mockWS"); mockServerClient.clear("mockPS"); mockServerClient.clear("mockTheme");