Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public Mono<ResponseDTO<Application>> create(@Valid @RequestBody Application res

@PostMapping("/publish/{applicationId}")
public Mono<ResponseDTO<Boolean>> 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public interface ApplicationPageService {

Mono<PageDTO> deleteUnpublishedPage(String id);

Mono<Application> publish(String applicationId);
Mono<Application> publish(String applicationId, boolean isPublishedManually);

void generateAndSetPagePolicies(Application application, PageDTO page);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public Mono<Application> 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)));
});
}
Expand Down Expand Up @@ -577,7 +577,7 @@ public Mono<PageDTO> deleteUnpublishedPage(String id) {
* @return Publishes a Boolean true, when the application has been published.
*/
@Override
public Mono<Application> publish(String applicationId) {
public Mono<Application> publish(String applicationId, boolean isPublishedManually) {
Mono<Application> applicationMono = applicationService.findById(applicationId, MANAGE_APPLICATIONS)
.switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, FieldName.APPLICATION, applicationId)))
.cache();
Expand Down Expand Up @@ -623,7 +623,9 @@ public Mono<Application> 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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public Mono<List<String>> 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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ public void checkActionInViewMode() {
Mono<List<ActionViewDTO>> 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
Expand Down Expand Up @@ -843,7 +843,7 @@ public void getActionInViewMode() {
Mono<ActionDTO> createActionMono = layoutActionService.createAction(action);
Mono<List<ActionViewDTO>> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ public void basicPublishApplicationTest() {
testApplication.setName(appName);
testApplication.setAppLayout(new Application.AppLayout(Application.AppLayout.Type.DESKTOP));
Mono<Application> 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();

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down