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 @@ -11,8 +11,8 @@ public class LayoutSpanCE {

public static final String FIND_ALL_ON_LOAD_EXECUTABLES =
APPSMITH_SPAN_PREFIX + "onLoadExecutablesUtil.findAllOnLoadExecutables";
public static final String UPDATE_EXECUTABLES_EXECUTE_ONLOAD =
APPSMITH_SPAN_PREFIX + "onLoadExecutablesUtil.updateExecutablesExecuteOnLoad";
public static final String UPDATE_EXECUTABLES_RUN_BEHAVIOUR =
APPSMITH_SPAN_PREFIX + "onLoadExecutablesUtil.updateExecutablesRunBehaviour";
public static final String FIND_AND_UPDATE_LAYOUT =
APPSMITH_SPAN_PREFIX + "onLoadExecutablesUtil.findAndUpdateLayout";
public static final String UNESCAPE_MONGO_SPECIAL_CHARS = APPSMITH_SPAN_PREFIX + "unescapeMongoSpecialCharacters";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.appsmith.external.dtos;

import com.appsmith.external.models.RunBehaviourEnum;
import com.appsmith.external.views.Views;
import com.fasterxml.jackson.annotation.JsonView;
import lombok.Getter;
Expand All @@ -21,6 +22,26 @@ public class LayoutExecutableUpdateDTO {
@JsonView(Views.Public.class)
String collectionId;

@JsonView(Views.Public.class)
@Deprecated
@JsonView(Views.Internal.class)
Boolean executeOnLoad;

@Deprecated
@JsonView(Views.Public.class)
RunBehaviourEnum runBehaviour;

/**
* Custom getter for runBehaviour that provides fallback to executeOnLoad if runBehaviour is null
*
* @return The runBehaviour, or a value derived from executeOnLoad if runBehaviour is null
*/
public RunBehaviourEnum getRunBehaviour() {
if (runBehaviour != null) {
return runBehaviour;
}
if (executeOnLoad != null) {
return Boolean.TRUE.equals(executeOnLoad) ? RunBehaviourEnum.ON_PAGE_LOAD : RunBehaviourEnum.MANUAL;
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public static DataType stringToKnownDataTypeConverter(String input) {
* @param replacement value that needs to be substituted in place of mustache expression
* @param replacementDataType nullable DataType that is used to provide Plugin Specific types, by setting this
* you can override the 'DataTypeStringUtils.stringToKnownDataTypeConverter(replacement)'
* default behavior.
* default behaviour.
* @param insertedParams keeps a list of tuple (replacement, data_type)
* @param smartSubstitutionUtils provides entry to plugin specific post-processing logic applied to replacement
* value before the final substitution happens
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ public interface Executable {

Boolean getUserSetOnLoad();

@Deprecated
Boolean getExecuteOnLoad();

RunBehaviourEnum getRunBehaviour();

Set<String> getSelfReferencingDataPaths();

@JsonIgnore
Expand Down Expand Up @@ -69,13 +72,15 @@ default LayoutExecutableUpdateDTO createLayoutExecutableUpdateDTO() {

layoutExecutableUpdateDTO.setId(this.getId());
layoutExecutableUpdateDTO.setName(this.getValidName());
layoutExecutableUpdateDTO.setExecuteOnLoad(this.getExecuteOnLoad());
layoutExecutableUpdateDTO.setRunBehaviour(this.getRunBehaviour());

return layoutExecutableUpdateDTO;
}

void setExecuteOnLoad(Boolean isExecuteOnLoad);

void setRunBehaviour(RunBehaviourEnum runBehaviour);

@JsonIgnore
@Transient
Boolean isOnLoadMessageAllowed();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.appsmith.external.models;

/**
* Enum to define the behavior for running actions
* Enum to define the behaviour for running actions
*/
public enum RunBehaviorEnum {
public enum RunBehaviourEnum {
MANUAL, // Action will only run when manually triggered
ON_PAGE_LOAD // Action will run when the page loads
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import com.appsmith.external.models.PluginType;
import com.appsmith.external.models.Policy;
import com.appsmith.external.models.Property;
import com.appsmith.external.models.RunBehaviorEnum;
import com.appsmith.external.models.RunBehaviourEnum;
import com.appsmith.external.views.FromRequest;
import com.appsmith.external.views.Git;
import com.appsmith.external.views.Views;
Expand Down Expand Up @@ -103,14 +103,24 @@ public class ActionCE_DTO implements Identifiable, Executable {

/**
* @deprecated This field is deprecated and will be removed in a future release.
* Use runBehavior instead.
* Use runBehaviour instead.
*/
@Deprecated
@JsonView({Views.Public.class, FromRequest.class, Git.class})
@JsonView({Views.Internal.class, FromRequest.class, Git.class})
Boolean executeOnLoad;

@JsonView({Views.Public.class, FromRequest.class, Git.class})
RunBehaviorEnum runBehavior = RunBehaviorEnum.MANUAL;
RunBehaviourEnum runBehaviour;

public RunBehaviourEnum getRunBehaviour() {
if (runBehaviour != null) {
return runBehaviour;
}
if (executeOnLoad != null) {
return Boolean.TRUE.equals(executeOnLoad) ? RunBehaviourEnum.ON_PAGE_LOAD : RunBehaviourEnum.MANUAL;
}
return null;
}

@JsonView({Views.Public.class, FromRequest.class, Git.class})
Boolean clientSideExecution;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.appsmith.external.models.ActionDTO;
import com.appsmith.external.models.ActionExecutionResult;
import com.appsmith.external.models.RunBehaviorEnum;
import com.appsmith.external.models.RunBehaviourEnum;
import com.appsmith.external.views.FromRequest;
import com.appsmith.external.views.Views;
import com.appsmith.server.constants.FieldName;
Expand Down Expand Up @@ -117,17 +117,17 @@ public Mono<ResponseDTO<List<ActionViewDTO>>> getActionsForViewMode(
}

@JsonView(Views.Public.class)
@PutMapping("/runBehavior/{branchedActionId}")
public Mono<ResponseDTO<ActionDTO>> setRunBehavior(
@PathVariable String branchedActionId, @RequestParam RunBehaviorEnum behavior) {
log.debug("Going to set run behavior for action id {} to {}", branchedActionId, behavior);
@PutMapping("/runBehaviour/{branchedActionId}")
public Mono<ResponseDTO<ActionDTO>> setRunBehaviour(
@PathVariable String branchedActionId, @RequestParam RunBehaviourEnum behaviour) {
log.debug("Going to set run behaviour for action id {} to {}", branchedActionId, behaviour);
return layoutActionService
.setRunBehavior(branchedActionId, behavior)
.setRunBehaviour(branchedActionId, behaviour)
.map(action -> new ResponseDTO<>(HttpStatus.OK, action));
}

/**
* @deprecated This endpoint is deprecated. Use /runBehavior/{branchedActionId} instead.
* @deprecated This endpoint is deprecated. Use /runBehaviour/{branchedActionId} instead.
*/
@Deprecated
@JsonView(Views.Public.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ public static class Fields extends RefAwareDomain.Fields {
dotted(unpublishedAction, ActionDTO.Fields.contextType);
public static final String unpublishedAction_userSetOnLoad =
dotted(unpublishedAction, ActionDTO.Fields.userSetOnLoad);
public static final String unpublishedAction_executeOnLoad =
dotted(unpublishedAction, ActionDTO.Fields.executeOnLoad);
public static final String unpublishedAction_runBehaviour =
dotted(unpublishedAction, ActionDTO.Fields.runBehaviour);
public static final String unpublishedAction_fullyQualifiedName =
dotted(unpublishedAction, ActionDTO.Fields.fullyQualifiedName);
public static final String unpublishedAction_actionConfiguration_httpMethod =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.appsmith.server.dtos;

import com.appsmith.external.models.RunBehaviourEnum;
import com.appsmith.external.views.Views;
import com.fasterxml.jackson.annotation.JsonView;
import lombok.Getter;
Expand All @@ -21,6 +22,25 @@ public class LayoutExecutableUpdateDTO {
@JsonView(Views.Public.class)
String collectionId;

@JsonView(Views.Public.class)
@Deprecated
@JsonView(Views.Internal.class)
Boolean executeOnLoad;

@JsonView(Views.Public.class)
RunBehaviourEnum runBehaviour;

/**
* Custom getter for runBehaviour that provides fallback to executeOnLoad if runBehaviour is null
*
* @return The runBehaviour, or a value derived from executeOnLoad if runBehaviour is null
*/
public RunBehaviourEnum getRunBehaviour() {
if (runBehaviour != null) {
return runBehaviour;
}
if (executeOnLoad != null) {
return Boolean.TRUE.equals(executeOnLoad) ? RunBehaviourEnum.ON_PAGE_LOAD : RunBehaviourEnum.MANUAL;
}
return null;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.appsmith.server.dtos.ce;

import com.appsmith.external.models.RunBehaviourEnum;
import com.appsmith.external.views.Views;
import com.fasterxml.jackson.annotation.JsonView;
import lombok.Getter;
Expand Down Expand Up @@ -37,6 +38,23 @@ public class ActionViewCE_DTO {
@JsonView(Views.Public.class)
Set<String> jsonPathKeys;

@Deprecated
@JsonView(Views.Internal.class)
Boolean executeOnLoad;

@JsonView({Views.Public.class})
RunBehaviourEnum runBehaviour;

public RunBehaviourEnum getRunBehaviour() {
if (runBehaviour != null) {
return runBehaviour;
}
if (executeOnLoad != null) {
return Boolean.TRUE.equals(executeOnLoad) ? RunBehaviourEnum.ON_PAGE_LOAD : RunBehaviourEnum.MANUAL;
}
return null;
}

// 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
import static com.appsmith.external.constants.spans.LayoutSpan.EXTRACT_ALL_WIDGET_NAMES_AND_DYNAMIC_BINDINGS_FROM_DSL;
import static com.appsmith.external.constants.spans.LayoutSpan.FIND_ALL_ON_LOAD_EXECUTABLES;
import static com.appsmith.external.constants.spans.LayoutSpan.FIND_AND_UPDATE_LAYOUT;
import static com.appsmith.external.constants.spans.LayoutSpan.UPDATE_EXECUTABLES_EXECUTE_ONLOAD;
import static com.appsmith.external.constants.spans.LayoutSpan.UPDATE_LAYOUT_DSL_METHOD;
import static com.appsmith.external.constants.spans.LayoutSpan.UPDATE_LAYOUT_METHOD;
import static com.appsmith.external.constants.spans.PageSpan.GET_PAGE_BY_ID;
import static com.appsmith.external.constants.spans.ce.LayoutSpanCE.UPDATE_EXECUTABLES_RUN_BEHAVIOUR;
import static com.appsmith.external.constants.spans.ce.LayoutSpanCE.UPDATE_LAYOUT_BASED_ON_CONTEXT;
import static com.appsmith.server.constants.CommonConstants.EVALUATION_VERSION;
import static com.appsmith.server.helpers.ContextTypeUtils.isPageContext;
Expand Down Expand Up @@ -197,12 +197,12 @@ protected Mono<LayoutDTO> updateLayoutDsl(
return Mono.just(allOnLoadExecutables);
}
// Update these executables to be executed on load, unless the user has touched
// the executeOnLoad
// the runBehaviour
// setting for this
return onLoadExecutablesUtil
.updateExecutablesExecuteOnLoad(
.updateExecutablesRunBehaviour(
flatmapOnLoadExecutables, creatorId, executableUpdatesRef, messagesRef, creatorType)
.name(UPDATE_EXECUTABLES_EXECUTE_ONLOAD)
.name(UPDATE_EXECUTABLES_RUN_BEHAVIOUR)
.tap(Micrometer.observation(observationRegistry))
.thenReturn(allOnLoadExecutables);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ public Mono<ActionDTO> findActionDTObyIdAndViewMode(String id, Boolean viewMode,
@Override
public Flux<NewAction> findUnpublishedOnLoadActionsExplicitSetByUserInPage(String pageId) {
return repository
.findUnpublishedActionsByPageIdAndExecuteOnLoadSetByUserTrue(
.findUnpublishedActionsByPageIdAndRunbehaviourSetByUserOnPageLoad(
pageId, actionPermission.getEditPermission())
.flatMap(this::sanitizeAction);
}
Expand Down Expand Up @@ -1248,7 +1248,7 @@ private List<LayoutExecutableUpdateDTO> addActionUpdatesForActionNames(
layoutExecutableUpdateDTO.setId(pageAction.getId());
layoutExecutableUpdateDTO.setName(pageAction.getValidName());
layoutExecutableUpdateDTO.setCollectionId(pageAction.getCollectionId());
layoutExecutableUpdateDTO.setExecuteOnLoad(pageAction.getExecuteOnLoad());
layoutExecutableUpdateDTO.setRunBehaviour(pageAction.getRunBehaviour());
return layoutExecutableUpdateDTO;
})
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ Mono<List<Set<DslExecutableDTO>>> findAllOnLoadExecutables(
* @param executableUpdatesRef : Empty array list which would be set in this function with all the page actions whose
* execute on load setting has changed (whether flipped from true to false, or vice versa)
* @param messagesRef : Empty array list which would be set in this function with all the messagesRef that should be
* displayed to the developer user communicating the action executeOnLoad changes.
* displayed to the developer user communicating the action runBehaviour changes.
* @return
*/
Mono<Boolean> updateExecutablesExecuteOnLoad(
Mono<Boolean> updateExecutablesRunBehaviour(
List<Executable> onLoadExecutables,
String creatorId,
List<LayoutExecutableUpdateDTO> executableUpdatesRef,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.appsmith.external.models.EntityReferenceType;
import com.appsmith.external.models.Executable;
import com.appsmith.external.models.Property;
import com.appsmith.external.models.RunBehaviourEnum;
import com.appsmith.server.domains.ExecutableDependencyEdge;
import com.appsmith.server.domains.Layout;
import com.appsmith.server.domains.NewPage;
Expand Down Expand Up @@ -295,7 +296,7 @@ public Mono<List<Set<DslExecutableDTO>>> findAllOnLoadExecutables(
}

@Override
public Mono<Boolean> updateExecutablesExecuteOnLoad(
public Mono<Boolean> updateExecutablesRunBehaviour(
List<Executable> onLoadExecutables,
String creatorId,
List<LayoutExecutableUpdateDTO> executableUpdatesRef,
Expand All @@ -310,7 +311,7 @@ public Mono<Boolean> updateExecutablesExecuteOnLoad(
// Before we update the actions, fetch all the actions which are currently set to execute on load.
Mono<List<Executable>> existingOnLoadExecutablesMono = creatorContextExecutablesFlux
.flatMap(executable -> {
if (TRUE.equals(executable.getExecuteOnLoad())) {
if (RunBehaviourEnum.ON_PAGE_LOAD.equals(executable.getRunBehaviour())) {
return Mono.just(executable);
}
return Mono.empty();
Expand Down Expand Up @@ -364,13 +365,13 @@ public Mono<Boolean> updateExecutablesExecuteOnLoad(

// If this executable is no longer an onload executable, turn the execute on load to false
if (turnedOffExecutableNames.contains(executableName)) {
executable.setExecuteOnLoad(FALSE);
executable.setRunBehaviour(RunBehaviourEnum.MANUAL);
toUpdateExecutables.add(executable);
}

// If this executable is newly found to be on load, turn execute on load to true
if (turnedOnExecutableNames.contains(executableName)) {
executable.setExecuteOnLoad(TRUE);
executable.setRunBehaviour(RunBehaviourEnum.ON_PAGE_LOAD);
toUpdateExecutables.add(executable);
}

Expand Down Expand Up @@ -1262,7 +1263,8 @@ private Mono<Set<ExecutableDependencyEdge>> addWidgetRelationshipToGraph(
}

private boolean hasUserSetExecutableToNotRunOnPageLoad(Executable executable) {
if (TRUE.equals(executable.getUserSetOnLoad()) && !TRUE.equals(executable.getExecuteOnLoad())) {
if (TRUE.equals(executable.getUserSetOnLoad())
&& executable.getRunBehaviour() != RunBehaviourEnum.ON_PAGE_LOAD) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public interface CustomNewActionRepositoryCE extends AppsmithRepository<NewActio

Flux<NewAction> findUnpublishedActionsByNameInAndPageId(Set<String> names, String pageId, AclPermission permission);

Flux<NewAction> findUnpublishedActionsByPageIdAndExecuteOnLoadSetByUserTrue(
Flux<NewAction> findUnpublishedActionsByPageIdAndRunbehaviourSetByUserOnPageLoad(
String pageId, AclPermission permission);

Flux<NewAction> findAllActionsByNameAndPageIdsAndViewMode(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.appsmith.external.models.CreatorContextType;
import com.appsmith.external.models.PluginType;
import com.appsmith.external.models.RunBehaviourEnum;
import com.appsmith.server.acl.AclPermission;
import com.appsmith.server.domains.NewAction;
import com.appsmith.server.dtos.PluginTypeAndCountDTO;
Expand Down Expand Up @@ -178,9 +179,10 @@ public Flux<NewAction> findUnpublishedActionsByNameInAndPageId(
}

@Override
public Flux<NewAction> findUnpublishedActionsByPageIdAndExecuteOnLoadSetByUserTrue(
public Flux<NewAction> findUnpublishedActionsByPageIdAndRunbehaviourSetByUserOnPageLoad(
String pageId, AclPermission permission) {
BridgeQuery<NewAction> q = Bridge.<NewAction>isTrue(NewAction.Fields.unpublishedAction_executeOnLoad)
BridgeQuery<NewAction> q = Bridge.<NewAction>equal(
NewAction.Fields.unpublishedAction_runBehaviour, RunBehaviourEnum.ON_PAGE_LOAD)
.isTrue(NewAction.Fields.unpublishedAction_userSetOnLoad)
.equal(NewAction.Fields.unpublishedAction_pageId, pageId)
// In case an action has been deleted in edit mode, but still exists in deployed mode, NewAction object
Expand Down
Loading