Default state for mongo actions that were already configured (#4873)
* Default state for mongo actions that were already configured * Clean up
This commit is contained in:
parent
8fea689b4d
commit
226c0720bd
|
|
@ -50,6 +50,7 @@ import com.appsmith.server.services.OrganizationService;
|
|||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.github.cloudyrock.mongock.ChangeLog;
|
||||
import com.github.cloudyrock.mongock.ChangeSet;
|
||||
import com.github.cloudyrock.mongock.decorator.impl.MongockTemplate;
|
||||
import com.google.gson.Gson;
|
||||
import com.mongodb.MongoClient;
|
||||
import com.mongodb.MongoException;
|
||||
|
|
@ -2257,4 +2258,34 @@ public class DatabaseChangelog {
|
|||
// Delete all the existing mongo datasource structures by setting the key to null.
|
||||
mongoOperations.updateMulti(query, update, Datasource.class);
|
||||
}
|
||||
|
||||
@ChangeSet(order = "069", id = "set-mongo-actions-type-to-raw", author = "")
|
||||
public void setMongoActionInputToRaw(MongockTemplate mongockTemplate) {
|
||||
|
||||
// All the existing mongo actions at this point will only have ever been in the raw format
|
||||
// For these actions to be readily available to users, we need to set their input type to raw manually
|
||||
// This is required because since the mongo form, the default input type on the UI has been set to FORM
|
||||
Plugin mongoPlugin = mongockTemplate.findOne(query(where("packageName").is("mongo-plugin")), Plugin.class);
|
||||
|
||||
// Fetch all the actions built on top of a mongo database, not having any value set for input type
|
||||
assert mongoPlugin != null;
|
||||
List<NewAction> rawMongoActions = mongockTemplate.find(
|
||||
query(new Criteria().andOperator(
|
||||
where(fieldName(QNewAction.newAction.pluginId)).is(mongoPlugin.getId()))),
|
||||
NewAction.class
|
||||
)
|
||||
.stream()
|
||||
.filter(mongoAction -> {
|
||||
final List<Property> pluginSpecifiedTemplates = mongoAction.getUnpublishedAction().getActionConfiguration().getPluginSpecifiedTemplates();
|
||||
return pluginSpecifiedTemplates != null && pluginSpecifiedTemplates.size() == 1;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (NewAction action : rawMongoActions) {
|
||||
List<Property> pluginSpecifiedTemplates = action.getUnpublishedAction().getActionConfiguration().getPluginSpecifiedTemplates();
|
||||
pluginSpecifiedTemplates.add(new Property(null, "RAW"));
|
||||
|
||||
mongockTemplate.save(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user