diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ApplicationController.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ApplicationController.java index c65bdaefe4b4..383562eba44f 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ApplicationController.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ApplicationController.java @@ -78,7 +78,7 @@ public Mono> create(@Valid @RequestBody Application res @PostMapping("/publish/{applicationId}") public Mono> publish(@PathVariable String applicationId) { - return applicationPageService.publish(applicationId) + return applicationPageService.publish(applicationId, true) .flatMap(application -> // This event should parallel a similar event sent from the client, so we want it to be sent by the // controller and not the service method. 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 9e9e634beda4..3c21dc78c9ad 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 @@ -15,9 +15,12 @@ import javax.validation.constraints.NotNull; import java.io.Serializable; +import java.time.Instant; import java.util.ArrayList; import java.util.List; +import static com.appsmith.server.helpers.DateUtils.ISO_FORMATTER; + @Getter @Setter @ToString @@ -64,6 +67,16 @@ public class Application extends BaseDomain { Boolean forkingEnabled; + @JsonProperty(access = JsonProperty.Access.READ_ONLY) + Instant lastDeployedAt; // when this application was last deployed + + public String getLastDeployedAt() { + if(lastDeployedAt != null) { + return ISO_FORMATTER.format(lastDeployedAt); + } + return null; + } + // 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. public Application(Application application) { diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ApplicationPageService.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ApplicationPageService.java index 5bf9371e8cc0..9477063dcd45 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ApplicationPageService.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ApplicationPageService.java @@ -34,7 +34,7 @@ public interface ApplicationPageService { Mono deleteUnpublishedPage(String id); - Mono publish(String applicationId); + Mono publish(String applicationId, boolean isPublishedManually); void generateAndSetPagePolicies(Application application, PageDTO page); 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 ea712d996afa..274f420e4abf 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 @@ -272,7 +272,7 @@ public Mono createApplication(Application application, String orgId .flatMap(savedPage -> addPageToApplication(savedApplication, savedPage, true)) // Now publish this newly created app with default states so that // launching of newly created application is possible. - .flatMap(updatedApplication -> publish(savedApplication.getId()) + .flatMap(updatedApplication -> publish(savedApplication.getId(), false) .then(applicationService.findById(savedApplication.getId(), READ_APPLICATIONS))); }); } @@ -577,7 +577,7 @@ public Mono deleteUnpublishedPage(String id) { * @return Publishes a Boolean true, when the application has been published. */ @Override - public Mono publish(String applicationId) { + public Mono publish(String applicationId, boolean isPublishedManually) { Mono applicationMono = applicationService.findById(applicationId, MANAGE_APPLICATIONS) .switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, FieldName.APPLICATION, applicationId))) .cache(); @@ -623,7 +623,9 @@ public Mono publish(String applicationId) { application.setPublishedPages(pages); application.setPublishedAppLayout(application.getUnpublishedAppLayout()); - + if(isPublishedManually) { + application.setLastDeployedAt(Instant.now()); + } // 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/main/java/com/appsmith/server/solutions/ExamplesOrganizationCloner.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ExamplesOrganizationCloner.java index dcdd2a57bff7..18f09291d9dc 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ExamplesOrganizationCloner.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ExamplesOrganizationCloner.java @@ -271,7 +271,7 @@ public Mono> cloneApplications( // view mode for the newly created user. .then(Mono.just(newApplicationIds)) .flatMapMany(Flux::fromIterable) - .flatMap(appId -> applicationPageService.publish(appId).thenReturn(appId)) + .flatMap(appId -> applicationPageService.publish(appId, false).thenReturn(appId)) .collectList(); } diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionServiceTest.java index 95dab867486a..dd7b1856b5b4 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionServiceTest.java @@ -732,7 +732,7 @@ public void checkActionInViewMode() { Mono> actionsListMono = layoutActionService.createAction(action) .then(layoutActionService.createAction(action1)) .then(layoutActionService.createAction(action2)) - .then(applicationPageService.publish(testPage.getApplicationId())) + .then(applicationPageService.publish(testPage.getApplicationId(), true)) .then(newActionService.getActionsForViewMode(testApp.getId()).collectList()); StepVerifier @@ -843,7 +843,7 @@ public void getActionInViewMode() { Mono createActionMono = layoutActionService.createAction(action); Mono> actionViewModeListMono = createActionMono // Publish the application before fetching the action in view mode - .then(applicationPageService.publish(testApp.getId())) + .then(applicationPageService.publish(testApp.getId(), true)) .then(newActionService.getActionsForViewMode(testApp.getId()).collectList()); StepVerifier.create(actionViewModeListMono) 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 134f6d3b6577..32422f8bf926 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 @@ -729,7 +729,7 @@ public void basicPublishApplicationTest() { testApplication.setName(appName); testApplication.setAppLayout(new Application.AppLayout(Application.AppLayout.Type.DESKTOP)); Mono applicationMono = applicationPageService.createApplication(testApplication, orgId) - .flatMap(application -> applicationPageService.publish(application.getId())) + .flatMap(application -> applicationPageService.publish(application.getId(), true)) .then(applicationService.findByName(appName, MANAGE_APPLICATIONS)) .cache(); @@ -780,7 +780,7 @@ public void deleteUnpublishedPageFromApplication() { page.setLayouts(layouts); return applicationPageService.createPage(page); }) - .flatMap(page -> applicationPageService.publish(page.getApplicationId())) + .flatMap(page -> applicationPageService.publish(page.getApplicationId(), true)) .then(applicationService.findByName(appName, MANAGE_APPLICATIONS)) .cache(); @@ -826,7 +826,7 @@ public void changeDefaultPageForAPublishedApplication() { page.setLayouts(layouts); return applicationPageService.createPage(page); }) - .flatMap(page -> applicationPageService.publish(page.getApplicationId())) + .flatMap(page -> applicationPageService.publish(page.getApplicationId(), true)) .then(applicationService.findByName(appName, MANAGE_APPLICATIONS)) .cache(); @@ -890,7 +890,7 @@ public void getApplicationInViewMode() { page.setLayouts(layouts); return applicationPageService.createPage(page); }) - .flatMap(page -> applicationPageService.publish(page.getApplicationId())) + .flatMap(page -> applicationPageService.publish(page.getApplicationId(), true)) .then(applicationService.findByName(appName, MANAGE_APPLICATIONS)) .cache(); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/LayoutActionServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/LayoutActionServiceTest.java index c05a9d691c69..890385b33796 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/LayoutActionServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/LayoutActionServiceTest.java @@ -295,7 +295,7 @@ public void refactorActionNameToDeletedName() { layout.setDsl(layoutActionService.unescapeMongoSpecialCharacters(layout)); LayoutDTO firstLayout = layoutActionService.updateLayout(testPage.getId(), layout.getId(), layout).block(); - applicationPageService.publish(testPage.getApplicationId()).block(); + applicationPageService.publish(testPage.getApplicationId(), true).block(); newActionService.deleteUnpublishedAction(firstAction.getId()).block(); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/PageServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/PageServiceTest.java index b1ec7cf36fb5..9ceb88a00c36 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/PageServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/PageServiceTest.java @@ -10,7 +10,6 @@ import com.appsmith.server.domains.NewAction; import com.appsmith.server.domains.Plugin; import com.appsmith.server.domains.User; -import com.appsmith.server.domains.ApplicationPage; import com.appsmith.server.dtos.ActionDTO; import com.appsmith.server.dtos.ApplicationPagesDTO; import com.appsmith.server.dtos.LayoutDTO; @@ -47,7 +46,6 @@ import java.util.Map; import java.util.Set; import java.util.UUID; -import java.util.stream.Collectors; import static com.appsmith.server.acl.AclPermission.MANAGE_PAGES; import static com.appsmith.server.acl.AclPermission.READ_ACTIONS; @@ -362,7 +360,7 @@ public void reuseDeletedPageName() { PageDTO firstPage = applicationPageService.createPage(testPage).block(); // Publish the application - applicationPageService.publish(application.getId()); + applicationPageService.publish(application.getId(), true); //Delete Page in edit mode applicationPageService.deleteUnpublishedPage(firstPage.getId()).block();