Merge branch 'release' of github.com:appsmithorg/appsmith into release

This commit is contained in:
Arpit Mohan 2020-07-13 23:30:39 +05:30
commit fbf4e4f7d2
6 changed files with 104 additions and 3 deletions

View File

@ -5,6 +5,7 @@ import com.appsmith.server.constants.Url;
import com.appsmith.server.domains.Action; import com.appsmith.server.domains.Action;
import com.appsmith.server.domains.Layout; import com.appsmith.server.domains.Layout;
import com.appsmith.server.dtos.ActionMoveDTO; import com.appsmith.server.dtos.ActionMoveDTO;
import com.appsmith.server.dtos.ActionViewDTO;
import com.appsmith.server.dtos.ExecuteActionDTO; import com.appsmith.server.dtos.ExecuteActionDTO;
import com.appsmith.server.dtos.RefactorNameDTO; import com.appsmith.server.dtos.RefactorNameDTO;
import com.appsmith.server.dtos.ResponseDTO; import com.appsmith.server.dtos.ResponseDTO;
@ -14,17 +15,20 @@ import com.appsmith.server.services.LayoutActionService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.List;
@RestController @RestController
@RequestMapping(Url.ACTION_URL) @RequestMapping(Url.ACTION_URL)
@ -77,4 +81,10 @@ public class ActionController extends BaseController<ActionService, Action, Stri
return layoutActionService.refactorActionName(refactorNameDTO) return layoutActionService.refactorActionName(refactorNameDTO)
.map(created -> new ResponseDTO<>(HttpStatus.OK.value(), created, null)); .map(created -> new ResponseDTO<>(HttpStatus.OK.value(), created, null));
} }
@GetMapping("/view")
public Mono<ResponseDTO<List<ActionViewDTO>>> getActionsForViewMode(@RequestParam String applicationId) {
return service.getActionsForViewMode(applicationId).collectList()
.map(actions -> new ResponseDTO<>(HttpStatus.OK.value(), actions, null));
}
} }

View File

@ -0,0 +1,16 @@
package com.appsmith.server.dtos;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.Set;
@Getter
@Setter
@NoArgsConstructor
public class ActionViewDTO {
String id;
String name;
Set<String> jsonPathKeys;
}

View File

@ -3,10 +3,12 @@ package com.appsmith.server.services;
import com.appsmith.external.models.ActionExecutionResult; import com.appsmith.external.models.ActionExecutionResult;
import com.appsmith.server.acl.AclPermission; import com.appsmith.server.acl.AclPermission;
import com.appsmith.server.domains.Action; import com.appsmith.server.domains.Action;
import com.appsmith.server.dtos.ActionViewDTO;
import com.appsmith.server.dtos.ExecuteActionDTO; import com.appsmith.server.dtos.ExecuteActionDTO;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -30,4 +32,6 @@ public interface ActionService extends CrudService<Action, String> {
Flux<Action> findByPageId(String pageId, AclPermission permission); Flux<Action> findByPageId(String pageId, AclPermission permission);
Flux<ActionViewDTO> getActionsForViewMode(String applicationId);
} }

View File

@ -23,6 +23,7 @@ import com.appsmith.server.domains.Page;
import com.appsmith.server.domains.Plugin; import com.appsmith.server.domains.Plugin;
import com.appsmith.server.domains.PluginType; import com.appsmith.server.domains.PluginType;
import com.appsmith.server.domains.User; import com.appsmith.server.domains.User;
import com.appsmith.server.dtos.ActionViewDTO;
import com.appsmith.server.dtos.ExecuteActionDTO; import com.appsmith.server.dtos.ExecuteActionDTO;
import com.appsmith.server.exceptions.AppsmithError; import com.appsmith.server.exceptions.AppsmithError;
import com.appsmith.server.exceptions.AppsmithException; import com.appsmith.server.exceptions.AppsmithException;
@ -515,6 +516,33 @@ public class ActionServiceImpl extends BaseService<ActionRepository, Action, Str
return repository.findByPageId(pageId, permission); return repository.findByPageId(pageId, permission);
} }
@Override
public Flux<ActionViewDTO> getActionsForViewMode(String applicationId) {
Sort sort = Sort.by(FieldName.NAME);
if (applicationId == null || applicationId.isEmpty()) {
return Flux.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.APPLICATION_ID));
}
return pageService
.findNamesByApplicationId(applicationId)
.switchIfEmpty(Mono.error(new AppsmithException(
AppsmithError.NO_RESOURCE_FOUND, "pages for application", applicationId))
)
.map(applicationPagesDTO -> applicationPagesDTO.getPages())
.flatMapMany(Flux::fromIterable)
.map(pageNameIdDTO -> pageNameIdDTO.getId())
.collectList()
.flatMapMany(pages -> repository.findAllActionsByNameAndPageIds(null, pages, READ_ACTIONS, sort))
.map(action -> {
ActionViewDTO actionViewDTO = new ActionViewDTO();
actionViewDTO.setId(action.getId());
actionViewDTO.setName(action.getName());
actionViewDTO.setJsonPathKeys(new HashSet<>());
actionViewDTO.getJsonPathKeys().addAll(action.getJsonPathKeys());
return actionViewDTO;
});
}
@Override @Override
public Mono<Action> delete(String id) { public Mono<Action> delete(String id) {
Mono<Action> actionMono = repository.findById(id) Mono<Action> actionMono = repository.findById(id)

View File

@ -17,6 +17,7 @@ import com.appsmith.server.domains.Page;
import com.appsmith.server.domains.Plugin; import com.appsmith.server.domains.Plugin;
import com.appsmith.server.domains.User; import com.appsmith.server.domains.User;
import com.appsmith.server.dtos.ActionMoveDTO; import com.appsmith.server.dtos.ActionMoveDTO;
import com.appsmith.server.dtos.ActionViewDTO;
import com.appsmith.server.dtos.ExecuteActionDTO; import com.appsmith.server.dtos.ExecuteActionDTO;
import com.appsmith.server.exceptions.AppsmithError; import com.appsmith.server.exceptions.AppsmithError;
import com.appsmith.server.exceptions.AppsmithException; import com.appsmith.server.exceptions.AppsmithException;
@ -43,8 +44,10 @@ import reactor.test.StepVerifier;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Stream;
import static com.appsmith.server.acl.AclPermission.MANAGE_ACTIONS; import static com.appsmith.server.acl.AclPermission.MANAGE_ACTIONS;
import static com.appsmith.server.acl.AclPermission.READ_ACTIONS; import static com.appsmith.server.acl.AclPermission.READ_ACTIONS;
@ -454,6 +457,36 @@ public class ActionServiceTest {
.verifyComplete(); .verifyComplete();
} }
@Test
@WithUserDetails(value = "api_user")
public void checkActionInViewMode() {
Mockito.when(pluginExecutorHelper.getPluginExecutor(Mockito.any())).thenReturn(Mono.just(new MockPluginExecutor()));
String key = "bodyMustacheKey";
Action action = new Action();
action.setName("actionInViewMode");
action.setPageId(testPage.getId());
ActionConfiguration actionConfiguration = new ActionConfiguration();
actionConfiguration.setHttpMethod(HttpMethod.GET);
actionConfiguration.setBody("{{"+key+"}}");
action.setActionConfiguration(actionConfiguration);
action.setDatasource(datasource);
Mono<List<ActionViewDTO>> actionsListMono = actionService.create(action)
.then(actionService.getActionsForViewMode(testApp.getId()).collectList());
StepVerifier
.create(actionsListMono)
.assertNext(actionsList -> {
assertThat(actionsList.size()).isGreaterThan(0);
ActionViewDTO actionViewDTO = actionsList.stream().filter(action1 -> action1.getName().equals(action.getName())).findFirst().get();
assertThat(actionViewDTO).isNotNull();
assertThat(actionViewDTO.getJsonPathKeys()).containsAll(Set.of(key));
})
.verifyComplete();
}
private void executeAndAssertAction(ExecuteActionDTO executeActionDTO, ActionConfiguration actionConfiguration, ActionExecutionResult mockResult) { private void executeAndAssertAction(ExecuteActionDTO executeActionDTO, ActionConfiguration actionConfiguration, ActionExecutionResult mockResult) {
Mono<ActionExecutionResult> actionExecutionResultMono = executeAction(executeActionDTO, actionConfiguration, mockResult); Mono<ActionExecutionResult> actionExecutionResultMono = executeAction(executeActionDTO, actionConfiguration, mockResult);

View File

@ -52,6 +52,7 @@ declare -A osInfo;
osInfo[/etc/debian_version]="apt-get" osInfo[/etc/debian_version]="apt-get"
osInfo[/etc/centos-release]="yum" osInfo[/etc/centos-release]="yum"
osInfo[/etc/redhat-release]="yum" osInfo[/etc/redhat-release]="yum"
osInfo[/System/Library/CoreServices/SystemVersion.plist]="brew"
# Checking OS and assiging package manager # Checking OS and assiging package manager
desired_os=0 desired_os=0
@ -105,6 +106,8 @@ if [ $setup_domain == "Y" -o $setup_domain == "y" -o $setup_domain == "yes" -o $
echo "Would you like to provision an SSL certificate for your custom domain / subdomain?" echo "Would you like to provision an SSL certificate for your custom domain / subdomain?"
read -p '(Your DNS records must be updated for us to provision SSL) [Y/n]: ' setup_ssl read -p '(Your DNS records must be updated for us to provision SSL) [Y/n]: ' setup_ssl
setup_ssl=${setup_ssl:-Y} setup_ssl=${setup_ssl:-Y}
else
setup_ssl="n"
fi fi
if [ $setup_ssl == "Y" -o $setup_ssl == "y" -o $setup_ssl == "yes" -o $setup_ssl == "Yes" ];then if [ $setup_ssl == "Y" -o $setup_ssl == "y" -o $setup_ssl == "yes" -o $setup_ssl == "Yes" ];then
@ -127,11 +130,18 @@ cd ..
# Role - Docker # Role - Docker
if ! is_command_present docker ;then if ! is_command_present docker ;then
if [ $package_manager == "apt-get" -o $package_manager == "yum" ];then
install_docker install_docker
else
echo "Please follow below link to Install Docker Desktop on Mac:"
echo "https://docs.docker.com/docker-for-mac/install/"
fi
fi fi
# Starting docker service # Starting docker service
start_docker if [ $package_manager == "yum" -o $package_manager == "apt-get" ];then
start_docker
fi
# Role - Folder # Role - Folder
for directory_name in nginx certbot mongo/db opa/config appsmith-server/config for directory_name in nginx certbot mongo/db opa/config appsmith-server/config