diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Plugin.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Plugin.java index a113def4e5..9a5fffbdb7 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Plugin.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Plugin.java @@ -44,4 +44,7 @@ public class Plugin extends BaseDomain { // must be able to mark a plugin for defaultInstall on all organization creations @JsonIgnore Boolean defaultInstall; + + Boolean allowUserDatasources = true; + } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/DatabaseChangelog.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/DatabaseChangelog.java index b8e7ea66e0..644bf2ccd3 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/DatabaseChangelog.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/DatabaseChangelog.java @@ -27,6 +27,7 @@ import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.index.CompoundIndexDefinition; import org.springframework.data.mongodb.core.index.Index; import org.springframework.data.mongodb.core.index.IndexOperations; +import org.springframework.data.mongodb.core.query.Criteria; import java.util.concurrent.TimeUnit; @@ -224,4 +225,21 @@ public class DatabaseChangelog { } } + @ChangeSet(order = "006", id = "hide-rapidapi-plugin", author = "") + public void hideRapidApiPluginFromCreateDatasource(MongoTemplate mongoTemplate) { + final Plugin rapidApiPlugin = mongoTemplate.findOne( + org.springframework.data.mongodb.core.query.Query.query(Criteria.where("packageName").is("rapidapi-plugin")), + Plugin.class + ); + + if (rapidApiPlugin == null) { + log.error("Couldn't find rapidapi-plugin, to set it's `allowUserDatasources` to false."); + + } else { + rapidApiPlugin.setAllowUserDatasources(false); + mongoTemplate.save(rapidApiPlugin); + + } + } + } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionCollectionServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionCollectionServiceImpl.java index afb610cfaa..e319bbd5af 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionCollectionServiceImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionCollectionServiceImpl.java @@ -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 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 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 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 updateAction(String id, Action action) { //The change was not in CollectionId, just go ahead and update normally