diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/LayoutControllerCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/LayoutControllerCE.java index 25d914c41c..6b80e1e61a 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/LayoutControllerCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/LayoutControllerCE.java @@ -6,6 +6,7 @@ import com.appsmith.server.constants.Url; import com.appsmith.server.domains.Layout; import com.appsmith.server.dtos.EntityType; import com.appsmith.server.dtos.LayoutDTO; +import com.appsmith.server.dtos.LayoutUpdateDTO; import com.appsmith.server.dtos.RefactorEntityNameDTO; import com.appsmith.server.dtos.ResponseDTO; import com.appsmith.server.dtos.UpdateMultiplePageLayoutDTO; @@ -19,7 +20,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -45,16 +45,6 @@ public class LayoutControllerCE { this.refactoringService = refactoringService; } - @JsonView(Views.Public.class) - @PostMapping("/pages/{defaultPageId}") - public Mono> createLayout( - @PathVariable String defaultPageId, - @Valid @RequestBody Layout layout, - @RequestHeader(name = FieldName.BRANCH_NAME, required = false) String branchName) { - return service.createLayout(defaultPageId, layout, branchName) - .map(created -> new ResponseDTO<>(HttpStatus.CREATED.value(), created, null)); - } - @JsonView(Views.Public.class) @GetMapping("/{layoutId}/pages/{defaultPageId}") public Mono> getLayout( @@ -83,11 +73,11 @@ public class LayoutControllerCE { @PathVariable String pageId, @RequestParam String applicationId, @PathVariable String layoutId, - @RequestBody Layout layout, + @RequestBody LayoutUpdateDTO dto, @RequestHeader(name = FieldName.BRANCH_NAME, required = false) String branchName) { log.debug("update layout received for page {}", pageId); return updateLayoutService - .updateLayout(pageId, applicationId, layoutId, layout, branchName) + .updateLayout(pageId, applicationId, layoutId, dto.toLayout(), branchName) .map(created -> new ResponseDTO<>(HttpStatus.OK.value(), created, null)); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/LayoutUpdateDTO.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/LayoutUpdateDTO.java new file mode 100644 index 0000000000..5f15368de7 --- /dev/null +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/LayoutUpdateDTO.java @@ -0,0 +1,12 @@ +package com.appsmith.server.dtos; + +import com.appsmith.server.domains.Layout; +import net.minidev.json.JSONObject; + +public record LayoutUpdateDTO(JSONObject dsl) { + public Layout toLayout() { + Layout layout = new Layout(); + layout.setDsl(dsl); + return layout; + } +} diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutServiceCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutServiceCE.java index 9c3fa758a5..dac9bcb9c9 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutServiceCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutServiceCE.java @@ -7,8 +7,6 @@ public interface LayoutServiceCE { Mono createLayout(String pageId, Layout layout); - Mono createLayout(String defaultPageId, Layout layout, String branchName); - Mono getLayout(String pageId, String layoutId, Boolean viewMode); Mono getLayout(String defaultPageId, String layoutId, Boolean viewMode, String branchName); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutServiceCEImpl.java index fef8e84e97..32fd82873a 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutServiceCEImpl.java @@ -60,17 +60,6 @@ public class LayoutServiceCEImpl implements LayoutServiceCE { .then(Mono.just(layout)); } - @Override - public Mono createLayout(String defaultPageId, Layout layout, String branchName) { - if (StringUtils.isEmpty(branchName)) { - return createLayout(defaultPageId, layout); - } - return newPageService - .findByBranchNameAndDefaultPageId(branchName, defaultPageId, pagePermission.getEditPermission()) - .flatMap(branchedPage -> createLayout(branchedPage.getId(), layout)) - .map(responseUtils::updateLayoutWithDefaultResources); - } - @Override public Mono getLayout(String pageId, String layoutId, Boolean viewMode) { return newPageService