Use a new API to set (unset) execute on load for an action. (#443)
This commit is contained in:
parent
f0a05e8a3f
commit
e59ec2a8a9
|
|
@ -52,4 +52,5 @@ public class FieldName {
|
|||
"}";
|
||||
public static String ANONYMOUS_USER = "anonymousUser";
|
||||
public static String USERNAMES = "usernames";
|
||||
public static String ACTION = "action";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,4 +89,11 @@ public class ActionController extends BaseController<ActionService, Action, Stri
|
|||
return service.getActionsForViewMode(applicationId).collectList()
|
||||
.map(actions -> new ResponseDTO<>(HttpStatus.OK.value(), actions, null));
|
||||
}
|
||||
|
||||
@PutMapping("/executeOnLoad/{id}")
|
||||
public Mono<ResponseDTO<Action>> setExecuteOnLoad(@PathVariable String id, @RequestParam Boolean flag) {
|
||||
log.debug("Going to set execute on load for action id {} to {}", id, flag);
|
||||
return service.setExecuteOnLoad(id, flag)
|
||||
.map(action -> new ResponseDTO<>(HttpStatus.OK.value(), action, null));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.appsmith.server.domains;
|
|||
import com.appsmith.external.models.ActionConfiguration;
|
||||
import com.appsmith.external.models.BaseDomain;
|
||||
import com.appsmith.external.models.Property;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
|
@ -67,6 +68,9 @@ public class Action extends BaseDomain {
|
|||
@Transient
|
||||
String pluginId;
|
||||
|
||||
@JsonIgnore
|
||||
Boolean userSetOnLoad = false;
|
||||
|
||||
Documentation documentation;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -33,4 +33,6 @@ public interface ActionService extends CrudService<Action, String> {
|
|||
|
||||
Flux<ActionViewDTO> getActionsForViewMode(String applicationId);
|
||||
|
||||
Mono<Action> setExecuteOnLoad(String id, Boolean isExecuteOnLoad);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ import java.util.stream.Collectors;
|
|||
|
||||
import static com.appsmith.server.acl.AclPermission.EXECUTE_ACTIONS;
|
||||
import static com.appsmith.server.acl.AclPermission.EXECUTE_DATASOURCES;
|
||||
import static com.appsmith.server.acl.AclPermission.MANAGE_ACTIONS;
|
||||
import static com.appsmith.server.acl.AclPermission.MANAGE_DATASOURCES;
|
||||
import static com.appsmith.server.acl.AclPermission.MANAGE_PAGES;
|
||||
import static com.appsmith.server.acl.AclPermission.READ_ACTIONS;
|
||||
|
|
@ -584,10 +585,21 @@ public class ActionServiceImpl extends BaseService<ActionRepository, Action, Str
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Action> setExecuteOnLoad(String id, Boolean isExecuteOnLoad) {
|
||||
return repository.findById(id, MANAGE_ACTIONS)
|
||||
.switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, FieldName.ACTION, id)))
|
||||
.flatMap(action -> {
|
||||
action.setUserSetOnLoad(true);
|
||||
action.setExecuteOnLoad(isExecuteOnLoad);
|
||||
return repository.save(action);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Action> delete(String id) {
|
||||
Mono<Action> actionMono = repository.findById(id)
|
||||
.switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, "action", id)));
|
||||
.switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, FieldName.ACTION, id)));
|
||||
return actionMono
|
||||
.flatMap(toDelete -> repository.delete(toDelete).thenReturn(toDelete))
|
||||
.flatMap(analyticsService::sendDeleteEvent);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user