fix: Get buckets in S3 plugin during generate CRUD page (#8781)
* Fix: Generate page fix for S3 plugin * Fixed the replacement of template variables in form data failure for S3
This commit is contained in:
parent
47511640e5
commit
b57e0c245d
|
|
@ -63,6 +63,7 @@ import static com.appsmith.external.constants.ActionConstants.ACTION_CONFIGURATI
|
|||
import static com.appsmith.external.constants.ActionConstants.ACTION_CONFIGURATION_PATH;
|
||||
import static com.appsmith.external.helpers.PluginUtils.getValueSafelyFromFormData;
|
||||
import static com.appsmith.external.helpers.PluginUtils.getValueSafelyFromFormDataOrDefault;
|
||||
import static com.appsmith.external.helpers.PluginUtils.setValueSafelyInFormData;
|
||||
import static com.external.plugins.constants.FieldName.BUCKET;
|
||||
import static com.external.plugins.constants.FieldName.COMMAND;
|
||||
import static com.external.plugins.constants.FieldName.CREATE_DATATYPE;
|
||||
|
|
@ -898,9 +899,13 @@ public class AmazonS3Plugin extends BasePlugin {
|
|||
public Mono<ActionExecutionResult> getDatasourceMetadata(List<Property> pluginSpecifiedTemplates,
|
||||
DatasourceConfiguration datasourceConfiguration) {
|
||||
|
||||
// Get the metadata from the datasource using pluginSpecifiedTemplate by executing the DB query
|
||||
// TODO : Ignore the plugin specified templates. Once trigger functionality is implemented for UQI, replace
|
||||
// this as well with trigger functions
|
||||
Map<String, Object> configMap = new HashMap<>();
|
||||
setValueSafelyInFormData(configMap, COMMAND, "LIST_BUCKETS");
|
||||
|
||||
ActionConfiguration actionConfiguration = new ActionConfiguration();
|
||||
actionConfiguration.setPluginSpecifiedTemplates(pluginSpecifiedTemplates);
|
||||
actionConfiguration.setFormData(configMap);
|
||||
return datasourceCreate(datasourceConfiguration)
|
||||
.flatMap(connection -> execute(connection, datasourceConfiguration, actionConfiguration));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ public class CreateDBTablePageSolution {
|
|||
|
||||
if (Entity.S3_PLUGIN_PACKAGE_NAME.equals(plugin.getPackageName()) && !CollectionUtils.isEmpty(templateActionList)) {
|
||||
mappedColumnsAndTableName.put(
|
||||
templateActionList.get(0).getUnpublishedAction().getActionConfiguration().getPluginSpecifiedTemplates().get(1).getValue().toString(),
|
||||
(String) templateActionList.get(0).getUnpublishedAction().getActionConfiguration().getFormData().get("bucket"),
|
||||
tableName
|
||||
);
|
||||
}
|
||||
|
|
@ -573,7 +573,17 @@ public class CreateDBTablePageSolution {
|
|||
} else {
|
||||
// Recursively replace the column names from template table with user provided table using mappedColumns
|
||||
if (property.getValue() instanceof String) {
|
||||
final Matcher matcher = WORD_PATTERN.matcher(property.getValue().toString());
|
||||
|
||||
// In case the entire value finds a match in the mappedColumns, replace it
|
||||
Pattern replacePattern = Pattern.compile(Pattern.quote(property.getValue().toString()));
|
||||
Matcher matcher = replacePattern.matcher(property.getValue().toString());
|
||||
property.setValue(matcher.replaceAll(key ->
|
||||
mappedColumns.get(key.group()) == null ? key.group() : mappedColumns.get(key.group()))
|
||||
);
|
||||
|
||||
// If the column name is present inside a string (like json), then find all the words and replace
|
||||
// the column name with user one.
|
||||
matcher = WORD_PATTERN.matcher(property.getValue().toString());
|
||||
property.setValue(matcher.replaceAll(key ->
|
||||
mappedColumns.get(key.group()) == null ? key.group() : mappedColumns.get(key.group()))
|
||||
);
|
||||
|
|
|
|||
|
|
@ -581,7 +581,7 @@ public class CreateDBTablePageSolutionTests {
|
|||
for (NewAction action : actions) {
|
||||
ActionConfiguration actionConfiguration = action.getUnpublishedAction().getActionConfiguration();
|
||||
assertThat(action.getUnpublishedAction().getDatasource().getStructure()).isNull();
|
||||
assertThat(actionConfiguration.getPluginSpecifiedTemplates().get(1).getValue().toString())
|
||||
assertThat(actionConfiguration.getFormData().get("bucket"))
|
||||
.isEqualTo(resource.getTableName());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user