diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Application.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Application.java index 9a5e4a2989..26e70ca4ae 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Application.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Application.java @@ -53,7 +53,11 @@ public class Application extends BaseDomain { String icon; - AppLayout appLayout; + @JsonIgnore + AppLayout unpublishedAppLayout; + + @JsonIgnore + AppLayout publishedAppLayout; // This constructor is used during clone application. It only deeply copies selected fields. The rest are either // initialized newly or is left up to the calling function to set. @@ -65,14 +69,28 @@ public class Application extends BaseDomain { this.clonedFromApplicationId = application.getId(); this.color = application.getColor(); this.icon = application.getIcon(); - this.appLayout = application.getAppLayout() == null ? null - : new AppLayout(application.getAppLayout().type, application.getAppLayout().getWidth()); + this.unpublishedAppLayout = application.getUnpublishedAppLayout() == null ? null + : new AppLayout(application.getUnpublishedAppLayout().type, application.getUnpublishedAppLayout().getWidth()); + this.publishedAppLayout = application.getPublishedAppLayout() == null ? null + : new AppLayout(application.getPublishedAppLayout().type, application.getPublishedAppLayout().getWidth()); } public List getPages() { return Boolean.TRUE.equals(viewMode) ? publishedPages : pages; } + public AppLayout getAppLayout() { + return Boolean.TRUE.equals(viewMode) ? publishedAppLayout : unpublishedAppLayout; + } + + public void setAppLayout(AppLayout appLayout) { + if (Boolean.TRUE.equals(viewMode)) { + publishedAppLayout = appLayout; + } else { + unpublishedAppLayout = appLayout; + } + } + @Data @NoArgsConstructor @AllArgsConstructor diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ApplicationPageServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ApplicationPageServiceImpl.java index 94fa67fd50..c8cbdb93b1 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ApplicationPageServiceImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ApplicationPageServiceImpl.java @@ -451,7 +451,7 @@ public class ApplicationPageServiceImpl implements ApplicationPageService { // Create a new clone application object without the pages using the parametrized Application constructor Application newApplication = new Application(sourceApplication); newApplication.setName(newName); - + Mono userMono = sessionUserService.getCurrentUser().cache(); // First set the correct policies for the new cloned application return setApplicationPolicies(userMono, sourceApplication.getOrganizationId(), newApplication) @@ -602,6 +602,8 @@ public class ApplicationPageServiceImpl implements ApplicationPageService { application.setPublishedPages(pages); + application.setPublishedAppLayout(application.getUnpublishedAppLayout()); + // Archive the deleted pages and save the application changes and then return the pages so that // the pages can also be published return Mono.zip(archivePageListMono, applicationService.save(application)) diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationServiceTest.java index 9e86146dd2..3dbfe28bf8 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationServiceTest.java @@ -697,6 +697,7 @@ public class ApplicationServiceTest { Application testApplication = new Application(); String appName = "ApplicationServiceTest Publish Application"; testApplication.setName(appName); + testApplication.setAppLayout(new Application.AppLayout(Application.AppLayout.Type.FIXED, 1024)); Mono applicationMono = applicationPageService.createApplication(testApplication, orgId) .flatMap(application -> applicationPageService.publish(application.getId())) .then(applicationService.findByName(appName, MANAGE_APPLICATIONS)) @@ -726,6 +727,8 @@ public class ApplicationServiceTest { assertThat(newPage.getUnpublishedPage().getName()).isEqualTo(newPage.getPublishedPage().getName()); assertThat(newPage.getUnpublishedPage().getLayouts().get(0).getId()).isEqualTo(newPage.getPublishedPage().getLayouts().get(0).getId()); assertThat(newPage.getUnpublishedPage().getLayouts().get(0).getDsl()).isEqualTo(newPage.getPublishedPage().getLayouts().get(0).getDsl()); + + assertThat(application.getPublishedAppLayout()).isEqualTo(application.getUnpublishedAppLayout()); }) .verifyComplete(); }