diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ActionViewDTO.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ActionViewDTO.java index 46a0195725..dbcca764b7 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ActionViewDTO.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ActionViewDTO.java @@ -1,50 +1,13 @@ package com.appsmith.server.dtos; -import com.appsmith.external.models.DefaultResources; -import com.appsmith.external.views.Views; -import com.fasterxml.jackson.annotation.JsonView; +import com.appsmith.server.dtos.ce.ActionViewCE_DTO; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import lombok.ToString; -import java.util.Set; - -import static com.appsmith.external.constants.ActionConstants.DEFAULT_ACTION_EXECUTION_TIMEOUT_MS; - @Getter @Setter @NoArgsConstructor @ToString -public class ActionViewDTO { - @JsonView(Views.Public.class) - String id; - - @JsonView(Views.Public.class) - String name; - - @JsonView(Views.Public.class) - String pageId; - - @JsonView(Views.Public.class) - Integer timeoutInMillisecond; - - @JsonView(Views.Public.class) - Boolean confirmBeforeExecute; - - @JsonView(Views.Public.class) - Set jsonPathKeys; - - @JsonView(Views.Internal.class) - DefaultResources defaultResources; - - // Overriding the getter to ensure that for actions missing action configuration, the timeout is - // still set for the client to use as a guideline (even though this would be an invalid action - // and hence would return an action execution error. - @JsonView(Views.Public.class) - public Integer getTimeoutInMillisecond() { - return (timeoutInMillisecond == null || timeoutInMillisecond <= 0) - ? DEFAULT_ACTION_EXECUTION_TIMEOUT_MS - : timeoutInMillisecond; - } -} +public class ActionViewDTO extends ActionViewCE_DTO {} diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ce/ActionViewCE_DTO.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ce/ActionViewCE_DTO.java new file mode 100644 index 0000000000..7a75d5d650 --- /dev/null +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ce/ActionViewCE_DTO.java @@ -0,0 +1,50 @@ +package com.appsmith.server.dtos.ce; + +import com.appsmith.external.models.DefaultResources; +import com.appsmith.external.views.Views; +import com.fasterxml.jackson.annotation.JsonView; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +import java.util.Set; + +import static com.appsmith.external.constants.ActionConstants.DEFAULT_ACTION_EXECUTION_TIMEOUT_MS; + +@Getter +@Setter +@NoArgsConstructor +@ToString +public class ActionViewCE_DTO { + @JsonView(Views.Public.class) + String id; + + @JsonView(Views.Public.class) + String name; + + @JsonView(Views.Public.class) + String pageId; + + @JsonView(Views.Public.class) + Integer timeoutInMillisecond; + + @JsonView(Views.Public.class) + Boolean confirmBeforeExecute; + + @JsonView(Views.Public.class) + Set jsonPathKeys; + + @JsonView(Views.Internal.class) + DefaultResources defaultResources; + + // Overriding the getter to ensure that for actions missing action configuration, the timeout is + // still set for the client to use as a guideline (even though this would be an invalid action + // and hence would return an action execution error. + @JsonView(Views.Public.class) + public Integer getTimeoutInMillisecond() { + return (timeoutInMillisecond == null || timeoutInMillisecond <= 0) + ? DEFAULT_ACTION_EXECUTION_TIMEOUT_MS + : timeoutInMillisecond; + } +} diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCE.java index 7a14fe0514..80a6f6911b 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCE.java @@ -75,6 +75,8 @@ public interface NewActionServiceCE extends CrudService { Flux getActionsForViewMode(String defaultApplicationId, String branchName); + ActionViewDTO generateActionViewDTO(NewAction action, ActionDTO actionDTO); + Mono deleteUnpublishedAction(String id); Flux getUnpublishedActions(MultiValueMap params, Boolean includeJsActions); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCEImpl.java index 1454d704cc..d3b8429173 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCEImpl.java @@ -780,42 +780,38 @@ public class NewActionServiceCEImpl extends BaseService !PluginType.JS.equals(newAction.getPluginType())) - .map(action -> { - ActionViewDTO actionViewDTO = new ActionViewDTO(); - actionViewDTO.setId(action.getDefaultResources().getActionId()); - actionViewDTO.setName(action.getPublishedAction().getValidName()); - actionViewDTO.setPageId(action.getPublishedAction().getPageId()); - actionViewDTO.setConfirmBeforeExecute( - action.getPublishedAction().getConfirmBeforeExecute()); - // Update defaultResources - DefaultResources defaults = action.getDefaultResources(); - // Consider a situation when action is not published but user is viewing in deployed mode - if (action.getPublishedAction().getDefaultResources() != null) { - defaults.setPageId(action.getPublishedAction() - .getDefaultResources() - .getPageId()); - defaults.setCollectionId(action.getPublishedAction() - .getDefaultResources() - .getCollectionId()); - } else { - defaults.setPageId(null); - defaults.setCollectionId(null); - } - actionViewDTO.setDefaultResources(defaults); - if (action.getPublishedAction().getJsonPathKeys() != null - && !action.getPublishedAction().getJsonPathKeys().isEmpty()) { - Set jsonPathKeys; - jsonPathKeys = new HashSet<>(); - jsonPathKeys.addAll(action.getPublishedAction().getJsonPathKeys()); - actionViewDTO.setJsonPathKeys(jsonPathKeys); - } - if (action.getPublishedAction().getActionConfiguration() != null) { - actionViewDTO.setTimeoutInMillisecond(action.getPublishedAction() - .getActionConfiguration() - .getTimeoutInMillisecond()); - } - return actionViewDTO; - }); + .map(action -> generateActionViewDTO(action, action.getPublishedAction())); + } + + @Override + public ActionViewDTO generateActionViewDTO(NewAction action, ActionDTO actionDTO) { + ActionViewDTO actionViewDTO = new ActionViewDTO(); + actionViewDTO.setId(action.getDefaultResources().getActionId()); + actionViewDTO.setName(actionDTO.getValidName()); + actionViewDTO.setPageId(actionDTO.getPageId()); + actionViewDTO.setConfirmBeforeExecute(actionDTO.getConfirmBeforeExecute()); + // Update defaultResources + DefaultResources defaults = action.getDefaultResources(); + // Consider a situation when action is not published but user is viewing in deployed mode + if (actionDTO.getDefaultResources() != null) { + defaults.setPageId(actionDTO.getDefaultResources().getPageId()); + defaults.setCollectionId(actionDTO.getDefaultResources().getCollectionId()); + } else { + defaults.setPageId(null); + defaults.setCollectionId(null); + } + actionViewDTO.setDefaultResources(defaults); + if (actionDTO.getJsonPathKeys() != null && !actionDTO.getJsonPathKeys().isEmpty()) { + Set jsonPathKeys; + jsonPathKeys = new HashSet<>(); + jsonPathKeys.addAll(actionDTO.getJsonPathKeys()); + actionViewDTO.setJsonPathKeys(jsonPathKeys); + } + if (actionDTO.getActionConfiguration() != null) { + actionViewDTO.setTimeoutInMillisecond( + actionDTO.getActionConfiguration().getTimeoutInMillisecond()); + } + return actionViewDTO; } @Override