Merge branch 'bug/copy-3p-action' into 'release'

Create action with template id was leading to mock response. Removed this.

See merge request theappsmith/internal-tools-server!312
This commit is contained in:
Trisha Anand 2020-04-29 10:19:01 +00:00
commit 90ac43a831

View File

@ -1,23 +1,15 @@
package com.appsmith.server.services;
import com.appsmith.external.models.ActionConfiguration;
import com.appsmith.external.models.DatasourceConfiguration;
import com.appsmith.external.models.Property;
import com.appsmith.server.domains.Action;
import com.appsmith.server.domains.Collection;
import com.appsmith.server.domains.Datasource;
import com.appsmith.server.exceptions.AppsmithError;
import com.appsmith.server.exceptions.AppsmithException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.util.ArrayList;
import java.util.List;
@Service
@Slf4j
public class ActionCollectionServiceImpl implements ActionCollectionService {
@ -83,10 +75,6 @@ public class ActionCollectionServiceImpl implements ActionCollectionService {
*/
@Override
public Mono<Action> createAction(Action action) {
if (action.getTemplateId() != null) {
return createMockDataAction(action);
}
if (action.getCollectionId() == null) {
return actionService.create(action);
}
@ -97,28 +85,6 @@ public class ActionCollectionServiceImpl implements ActionCollectionService {
.flatMap(savedAction -> collectionService.addSingleActionToCollection(finalAction.getCollectionId(), savedAction));
}
private Mono<Action> createMockDataAction(Action action) {
action.setName("ResultActionAPI");
Datasource datasource = new Datasource();
DatasourceConfiguration datasourceConfiguration = new DatasourceConfiguration();
datasourceConfiguration.setUrl("http://google.com");
datasource.setDatasourceConfiguration(datasourceConfiguration);
ActionConfiguration actionConfiguration = new ActionConfiguration();
actionConfiguration.setPath("/viewSomething");
actionConfiguration.setHttpMethod(HttpMethod.GET);
List<Property> headers = new ArrayList<>();
Property header = new Property();
header.setKey("key");
header.setValue("value");
headers.add(header);
actionConfiguration.setHeaders(headers);
action.setActionConfiguration(actionConfiguration);
action.setDatasource(datasource);
return Mono.just(action);
}
@Override
public Mono<Action> updateAction(String id, Action action) {
//The change was not in CollectionId, just go ahead and update normally