From 079e185ed268206d9ffeb333e1b0a769c377e81b Mon Sep 17 00:00:00 2001 From: Shrikant Kandula Date: Tue, 28 Apr 2020 12:44:56 +0000 Subject: [PATCH 1/2] Add `allowUserDatasources` to plugins to hide from create datasource UI. --- .../com/appsmith/server/domains/Plugin.java | 3 ++ .../server/migrations/DatabaseChangelog.java | 36 +++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) 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 04ea6c6663..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 @@ -1,7 +1,21 @@ package com.appsmith.server.migrations; -import com.appsmith.server.domains.*; -import com.appsmith.server.services.ApplicationService; +import com.appsmith.server.domains.Action; +import com.appsmith.server.domains.Application; +import com.appsmith.server.domains.Collection; +import com.appsmith.server.domains.Config; +import com.appsmith.server.domains.Datasource; +import com.appsmith.server.domains.InviteUser; +import com.appsmith.server.domains.Organization; +import com.appsmith.server.domains.Page; +import com.appsmith.server.domains.PasswordResetToken; +import com.appsmith.server.domains.Permission; +import com.appsmith.server.domains.Plugin; +import com.appsmith.server.domains.PluginType; +import com.appsmith.server.domains.Query; +import com.appsmith.server.domains.Role; +import com.appsmith.server.domains.Setting; +import com.appsmith.server.domains.User; import com.appsmith.server.services.OrganizationService; import com.github.cloudyrock.mongock.ChangeLog; import com.github.cloudyrock.mongock.ChangeSet; @@ -13,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; @@ -210,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); + + } + } + } From 89f179397f29c2ada24e36488435a190aca0e270 Mon Sep 17 00:00:00 2001 From: Trisha Anand Date: Wed, 29 Apr 2020 10:19:01 +0000 Subject: [PATCH 2/2] Create action with template id was leading to mock response. Removing this to allow for copy of actions which have been created using 3p API --- .../services/ActionCollectionServiceImpl.java | 34 ------------------- 1 file changed, 34 deletions(-) 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