chore: Split ActionViewDTO (#29157)
> Pull Request Template > > Use this template to quickly create a well written pull request. Delete all quotes before creating the pull request. > ## Description > Add a TL;DR when description is extra long (helps content team) > > Please include a summary of the changes and which issue has been fixed. Please also include relevant motivation > and context. List any dependencies that are required for this change > > Links to Notion, Figma or any other documents that might be relevant to the PR > > #### PR fixes following issue(s) Fixes #29155 #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Chore (housekeeping or task changes that don't impact user perception) - This change requires a documentation update > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
This commit is contained in:
parent
da2e1c2822
commit
8fc45fef8d
|
|
@ -1,50 +1,13 @@
|
||||||
package com.appsmith.server.dtos;
|
package com.appsmith.server.dtos;
|
||||||
|
|
||||||
import com.appsmith.external.models.DefaultResources;
|
import com.appsmith.server.dtos.ce.ActionViewCE_DTO;
|
||||||
import com.appsmith.external.views.Views;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonView;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static com.appsmith.external.constants.ActionConstants.DEFAULT_ACTION_EXECUTION_TIMEOUT_MS;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@ToString
|
@ToString
|
||||||
public class ActionViewDTO {
|
public class ActionViewDTO extends 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<String> 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -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<String> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -75,6 +75,8 @@ public interface NewActionServiceCE extends CrudService<NewAction, String> {
|
||||||
|
|
||||||
Flux<ActionViewDTO> getActionsForViewMode(String defaultApplicationId, String branchName);
|
Flux<ActionViewDTO> getActionsForViewMode(String defaultApplicationId, String branchName);
|
||||||
|
|
||||||
|
ActionViewDTO generateActionViewDTO(NewAction action, ActionDTO actionDTO);
|
||||||
|
|
||||||
Mono<ActionDTO> deleteUnpublishedAction(String id);
|
Mono<ActionDTO> deleteUnpublishedAction(String id);
|
||||||
|
|
||||||
Flux<ActionDTO> getUnpublishedActions(MultiValueMap<String, String> params, Boolean includeJsActions);
|
Flux<ActionDTO> getUnpublishedActions(MultiValueMap<String, String> params, Boolean includeJsActions);
|
||||||
|
|
|
||||||
|
|
@ -780,42 +780,38 @@ public class NewActionServiceCEImpl extends BaseService<NewActionRepository, New
|
||||||
// No need to sort the results
|
// No need to sort the results
|
||||||
return findAllByApplicationIdAndViewMode(applicationId, true, actionPermission.getExecutePermission(), null)
|
return findAllByApplicationIdAndViewMode(applicationId, true, actionPermission.getExecutePermission(), null)
|
||||||
.filter(newAction -> !PluginType.JS.equals(newAction.getPluginType()))
|
.filter(newAction -> !PluginType.JS.equals(newAction.getPluginType()))
|
||||||
.map(action -> {
|
.map(action -> generateActionViewDTO(action, action.getPublishedAction()));
|
||||||
ActionViewDTO actionViewDTO = new ActionViewDTO();
|
}
|
||||||
actionViewDTO.setId(action.getDefaultResources().getActionId());
|
|
||||||
actionViewDTO.setName(action.getPublishedAction().getValidName());
|
@Override
|
||||||
actionViewDTO.setPageId(action.getPublishedAction().getPageId());
|
public ActionViewDTO generateActionViewDTO(NewAction action, ActionDTO actionDTO) {
|
||||||
actionViewDTO.setConfirmBeforeExecute(
|
ActionViewDTO actionViewDTO = new ActionViewDTO();
|
||||||
action.getPublishedAction().getConfirmBeforeExecute());
|
actionViewDTO.setId(action.getDefaultResources().getActionId());
|
||||||
// Update defaultResources
|
actionViewDTO.setName(actionDTO.getValidName());
|
||||||
DefaultResources defaults = action.getDefaultResources();
|
actionViewDTO.setPageId(actionDTO.getPageId());
|
||||||
// Consider a situation when action is not published but user is viewing in deployed mode
|
actionViewDTO.setConfirmBeforeExecute(actionDTO.getConfirmBeforeExecute());
|
||||||
if (action.getPublishedAction().getDefaultResources() != null) {
|
// Update defaultResources
|
||||||
defaults.setPageId(action.getPublishedAction()
|
DefaultResources defaults = action.getDefaultResources();
|
||||||
.getDefaultResources()
|
// Consider a situation when action is not published but user is viewing in deployed mode
|
||||||
.getPageId());
|
if (actionDTO.getDefaultResources() != null) {
|
||||||
defaults.setCollectionId(action.getPublishedAction()
|
defaults.setPageId(actionDTO.getDefaultResources().getPageId());
|
||||||
.getDefaultResources()
|
defaults.setCollectionId(actionDTO.getDefaultResources().getCollectionId());
|
||||||
.getCollectionId());
|
} else {
|
||||||
} else {
|
defaults.setPageId(null);
|
||||||
defaults.setPageId(null);
|
defaults.setCollectionId(null);
|
||||||
defaults.setCollectionId(null);
|
}
|
||||||
}
|
actionViewDTO.setDefaultResources(defaults);
|
||||||
actionViewDTO.setDefaultResources(defaults);
|
if (actionDTO.getJsonPathKeys() != null && !actionDTO.getJsonPathKeys().isEmpty()) {
|
||||||
if (action.getPublishedAction().getJsonPathKeys() != null
|
Set<String> jsonPathKeys;
|
||||||
&& !action.getPublishedAction().getJsonPathKeys().isEmpty()) {
|
jsonPathKeys = new HashSet<>();
|
||||||
Set<String> jsonPathKeys;
|
jsonPathKeys.addAll(actionDTO.getJsonPathKeys());
|
||||||
jsonPathKeys = new HashSet<>();
|
actionViewDTO.setJsonPathKeys(jsonPathKeys);
|
||||||
jsonPathKeys.addAll(action.getPublishedAction().getJsonPathKeys());
|
}
|
||||||
actionViewDTO.setJsonPathKeys(jsonPathKeys);
|
if (actionDTO.getActionConfiguration() != null) {
|
||||||
}
|
actionViewDTO.setTimeoutInMillisecond(
|
||||||
if (action.getPublishedAction().getActionConfiguration() != null) {
|
actionDTO.getActionConfiguration().getTimeoutInMillisecond());
|
||||||
actionViewDTO.setTimeoutInMillisecond(action.getPublishedAction()
|
}
|
||||||
.getActionConfiguration()
|
return actionViewDTO;
|
||||||
.getTimeoutInMillisecond());
|
|
||||||
}
|
|
||||||
return actionViewDTO;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user