diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/CommonConfig.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/CommonConfig.java index 0351e9614f..9e5c99544a 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/CommonConfig.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/CommonConfig.java @@ -3,7 +3,6 @@ package com.appsmith.server.configurations; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; import lombok.Getter; import lombok.Setter; import org.springframework.beans.factory.annotation.Value; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/PageController.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/PageController.java index f3639283f4..2d6125757f 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/PageController.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/PageController.java @@ -32,4 +32,10 @@ public class PageController extends BaseController { .collectList() .map(resources -> new ResponseDTO<>(HttpStatus.OK.value(), resources, null)); } + + @GetMapping("/{pageId}/view") + public Mono> getPageView(@PathVariable String pageId) { + return service.getPage(pageId, true) + .map(page -> new ResponseDTO<>(HttpStatus.OK.value(), page, null)); + } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/LayoutServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/LayoutServiceImpl.java index 5e14a2552f..95fdc4337b 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/LayoutServiceImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/LayoutServiceImpl.java @@ -58,7 +58,7 @@ public class LayoutServiceImpl implements LayoutService { public Mono getLayout(String pageId, String layoutId, Boolean viewMode) { return pageService.findByIdAndLayoutsId(pageId, layoutId) .switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.PAGEID + " or " + FieldName.LAYOUTID))) - .flatMap(pageService::doesPageIdBelongToCurrentUserOrganization) + .flatMap(pageService::doesPageBelongToCurrentUserOrganization) //The pageId given is correct and belongs to the current user's organization. .map(page -> { List layoutList = page.getLayouts(); @@ -73,7 +73,7 @@ public class LayoutServiceImpl implements LayoutService { public Mono updateLayout(String pageId, String layoutId, Layout layout) { return pageService.findByIdAndLayoutsId(pageId, layoutId) .switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.PAGEID + " or " + FieldName.LAYOUTID))) - .flatMap(pageService::doesPageIdBelongToCurrentUserOrganization) + .flatMap(pageService::doesPageBelongToCurrentUserOrganization) //The pageId given is correct and belongs to the current user's organization. .map(page -> { List layoutList = page.getLayouts(); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/PageService.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/PageService.java index b9d309b258..8726109db9 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/PageService.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/PageService.java @@ -13,11 +13,13 @@ public interface PageService extends CrudService { Mono findByIdAndLayoutsId(String pageId, String layoutId); - Mono doesPageIdBelongToCurrentUserOrganization(Page page); + Mono doesPageBelongToCurrentUserOrganization(Page page); Mono findByName(String name); Mono deleteAll(); Flux findNamesByApplicationId(String applicationId); + + Mono getPage(String pageId, Boolean viewMode); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/PageServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/PageServiceImpl.java index 74c0cb5511..adcbc9ec53 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/PageServiceImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/PageServiceImpl.java @@ -86,7 +86,7 @@ public class PageServiceImpl extends BaseService i } @Override - public Mono doesPageIdBelongToCurrentUserOrganization(Page page) { + public Mono doesPageBelongToCurrentUserOrganization(Page page) { Mono userMono = sessionUserService.getCurrentUser(); final String[] username = {null}; @@ -121,4 +121,21 @@ public class PageServiceImpl extends BaseService i public Flux findNamesByApplicationId(String applicationId) { return repository.findByApplicationId(applicationId); } + + @Override + public Mono getPage(String pageId, Boolean viewMode) { + return repository.findById(pageId) + .switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.PAGEID))) + .flatMap(this::doesPageBelongToCurrentUserOrganization) + //The pageId given is correct and belongs to the current user's organization. + .map(page -> { + List layoutList = page.getLayouts(); + // Set the view mode for all the layouts in the page. This ensures that we send the correct DSL + // back to the client + layoutList.stream() + .forEach(layout -> layout.setViewMode(viewMode)); + page.setLayouts(layoutList); + return page; + }); + } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/SignupServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/SignupServiceImpl.java index d26df0ad85..7ca765e182 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/SignupServiceImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/SignupServiceImpl.java @@ -9,7 +9,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import reactor.core.publisher.Mono; -import java.util.ArrayList; import java.util.HashSet; import java.util.Set;