diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/BuildingBlockResponseDTO.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/BuildingBlockResponseDTO.java index 655b6f22b3..1b31474357 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/BuildingBlockResponseDTO.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/BuildingBlockResponseDTO.java @@ -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 onPageLoadActions; + + // New actions created in the current flow + List newActionList; + + // New actionCollection created in the current flow + List actionCollectionList; + + // All datasource in the workspace + List datasourceList; + + // All libraries used in the current application + List customJSLibList; } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/partial/PartialImportServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/partial/PartialImportServiceCEImpl.java index db80d3ac15..1104aeb233 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/partial/PartialImportServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/partial/PartialImportServiceCEImpl.java @@ -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 importResourceInPage( @@ -469,18 +473,46 @@ public class PartialImportServiceCEImpl implements PartialImportServiceCE { } }); }); + // Fetch the datasource and customJsLibs + Mono> datasourceList = datasourceService + .getAllByWorkspaceIdWithStorages( + buildingBlockDTO.getWorkspaceId(), AclPermission.MANAGE_DATASOURCES) + .collectList(); + Mono> 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 actionCollections = tuple.getT1(); List 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() diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/partial/PartialImportServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/partial/PartialImportServiceImpl.java index 6cb4bf4734..1e9638bef4 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/partial/PartialImportServiceImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/imports/internal/partial/PartialImportServiceImpl.java @@ -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); } }