chore: consolidated response of block API (#34167)
## Description Return all the entities created as a part of the building block import Fixes #34122 ## Automation /ok-to-test tags="@tag.Templates" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/9482200897> > Commit: b78a8e5bab9c5191448593de958068477008c3d0 > Cypress dashboard url: <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9482200897&attempt=1" target="_blank">Click here!</a> <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced import functionality to include new lists for actions, action collections, datasources, and custom JavaScript libraries. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
parent
b61577da47
commit
ed8a4eba68
|
|
@ -1,6 +1,10 @@
|
|||
package com.appsmith.server.dtos;
|
||||
|
||||
import com.appsmith.external.dtos.DslExecutableDTO;
|
||||
import com.appsmith.external.models.Datasource;
|
||||
import com.appsmith.server.domains.ActionCollection;
|
||||
import com.appsmith.server.domains.CustomJSLib;
|
||||
import com.appsmith.server.domains.NewAction;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -10,4 +14,16 @@ public class BuildingBlockResponseDTO {
|
|||
String widgetDsl;
|
||||
|
||||
List<DslExecutableDTO> onPageLoadActions;
|
||||
|
||||
// New actions created in the current flow
|
||||
List<NewAction> newActionList;
|
||||
|
||||
// New actionCollection created in the current flow
|
||||
List<ActionCollection> actionCollectionList;
|
||||
|
||||
// All datasource in the workspace
|
||||
List<Datasource> datasourceList;
|
||||
|
||||
// All libraries used in the current application
|
||||
List<CustomJSLib> customJSLibList;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.appsmith.server.acl.AclPermission;
|
|||
import com.appsmith.server.actioncollections.base.ActionCollectionService;
|
||||
import com.appsmith.server.applications.base.ApplicationService;
|
||||
import com.appsmith.server.constants.FieldName;
|
||||
import com.appsmith.server.datasources.base.DatasourceService;
|
||||
import com.appsmith.server.domains.ActionCollection;
|
||||
import com.appsmith.server.domains.Application;
|
||||
import com.appsmith.server.domains.CustomJSLib;
|
||||
|
|
@ -28,6 +29,7 @@ import com.appsmith.server.exceptions.AppsmithException;
|
|||
import com.appsmith.server.helpers.ImportArtifactPermissionProvider;
|
||||
import com.appsmith.server.imports.importable.ImportableService;
|
||||
import com.appsmith.server.imports.internal.ImportService;
|
||||
import com.appsmith.server.jslibs.base.CustomJSLibService;
|
||||
import com.appsmith.server.newactions.base.NewActionService;
|
||||
import com.appsmith.server.newpages.base.NewPageService;
|
||||
import com.appsmith.server.refactors.applications.RefactoringService;
|
||||
|
|
@ -90,6 +92,8 @@ public class PartialImportServiceCEImpl implements PartialImportServiceCE {
|
|||
private final ApplicationPageService applicationPageService;
|
||||
private final NewActionService newActionService;
|
||||
private final ActionCollectionService actionCollectionService;
|
||||
private final DatasourceService datasourceService;
|
||||
private final CustomJSLibService customJSLibService;
|
||||
|
||||
@Override
|
||||
public Mono<Application> importResourceInPage(
|
||||
|
|
@ -469,18 +473,46 @@ public class PartialImportServiceCEImpl implements PartialImportServiceCE {
|
|||
}
|
||||
});
|
||||
});
|
||||
// Fetch the datasource and customJsLibs
|
||||
Mono<List<Datasource>> datasourceList = datasourceService
|
||||
.getAllByWorkspaceIdWithStorages(
|
||||
buildingBlockDTO.getWorkspaceId(), AclPermission.MANAGE_DATASOURCES)
|
||||
.collectList();
|
||||
Mono<List<CustomJSLib>> customJSLibs = customJSLibService.getAllJSLibsInContext(
|
||||
buildingBlockDTO.getApplicationId(), CreatorContextType.APPLICATION, branchName, false);
|
||||
|
||||
// Fetch all actions and action collections and update the onPageLoadActions with correct ids
|
||||
return actionCollectionService
|
||||
.findByPageId(buildingBlockDTO.getPageId())
|
||||
.collectList()
|
||||
.zipWith(newActionService
|
||||
.findByPageId(buildingBlockDTO.getPageId())
|
||||
.collectList())
|
||||
return Mono.zip(
|
||||
actionCollectionService
|
||||
.findByPageId(buildingBlockDTO.getPageId())
|
||||
.collectList(),
|
||||
newActionService
|
||||
.findByPageId(buildingBlockDTO.getPageId())
|
||||
.collectList(),
|
||||
datasourceList,
|
||||
customJSLibs)
|
||||
.flatMap(tuple -> {
|
||||
List<ActionCollection> actionCollections = tuple.getT1();
|
||||
List<NewAction> newActions = tuple.getT2();
|
||||
|
||||
buildingBlockResponseDTO.setDatasourceList(tuple.getT3());
|
||||
buildingBlockResponseDTO.setCustomJSLibList(tuple.getT4());
|
||||
// Filter the newly created actions and actionCollection
|
||||
buildingBlockResponseDTO.setNewActionList(newActions.stream()
|
||||
.filter(newAction -> buildingBlockImportDTO
|
||||
.getRefactoredEntityNameMap()
|
||||
.containsValue(newAction
|
||||
.getUnpublishedAction()
|
||||
.getName()))
|
||||
.toList());
|
||||
buildingBlockResponseDTO.setActionCollectionList(actionCollections.stream()
|
||||
.filter(actionCollection -> buildingBlockImportDTO
|
||||
.getRefactoredEntityNameMap()
|
||||
.containsValue(actionCollection
|
||||
.getUnpublishedCollection()
|
||||
.getName()))
|
||||
.toList());
|
||||
|
||||
actionCollections.forEach(actionCollection -> {
|
||||
if (newOnPageLoadActionNames.contains(actionCollection
|
||||
.getUnpublishedCollection()
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.appsmith.server.imports.internal.partial;
|
|||
import com.appsmith.external.models.Datasource;
|
||||
import com.appsmith.server.actioncollections.base.ActionCollectionService;
|
||||
import com.appsmith.server.applications.base.ApplicationService;
|
||||
import com.appsmith.server.datasources.base.DatasourceService;
|
||||
import com.appsmith.server.domains.ActionCollection;
|
||||
import com.appsmith.server.domains.CustomJSLib;
|
||||
import com.appsmith.server.domains.NewAction;
|
||||
|
|
@ -10,6 +11,7 @@ import com.appsmith.server.domains.NewPage;
|
|||
import com.appsmith.server.domains.Plugin;
|
||||
import com.appsmith.server.imports.importable.ImportableService;
|
||||
import com.appsmith.server.imports.internal.ImportService;
|
||||
import com.appsmith.server.jslibs.base.CustomJSLibService;
|
||||
import com.appsmith.server.newactions.base.NewActionService;
|
||||
import com.appsmith.server.newpages.base.NewPageService;
|
||||
import com.appsmith.server.refactors.applications.RefactoringService;
|
||||
|
|
@ -60,7 +62,9 @@ public class PartialImportServiceImpl extends PartialImportServiceCEImpl impleme
|
|||
WidgetRefactorUtil widgetRefactorUtil,
|
||||
ApplicationPageService applicationPageService,
|
||||
NewActionService newActionService,
|
||||
ActionCollectionService actionCollectionService) {
|
||||
ActionCollectionService actionCollectionService,
|
||||
DatasourceService datasourceService,
|
||||
CustomJSLibService customJSLibService) {
|
||||
super(
|
||||
importService,
|
||||
workspaceService,
|
||||
|
|
@ -86,6 +90,8 @@ public class PartialImportServiceImpl extends PartialImportServiceCEImpl impleme
|
|||
widgetRefactorUtil,
|
||||
applicationPageService,
|
||||
newActionService,
|
||||
actionCollectionService);
|
||||
actionCollectionService,
|
||||
datasourceService,
|
||||
customJSLibService);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user