diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ce/ActionCE_DTO.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ce/ActionCE_DTO.java index 9bbc40ac69..c60e5b05aa 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ce/ActionCE_DTO.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ce/ActionCE_DTO.java @@ -7,6 +7,7 @@ import com.appsmith.external.helpers.Identifiable; import com.appsmith.external.models.ActionConfiguration; import com.appsmith.external.models.ActionProvider; import com.appsmith.external.models.AnalyticsInfo; +import com.appsmith.external.models.CreatorContextType; import com.appsmith.external.models.Datasource; import com.appsmith.external.models.DefaultResources; import com.appsmith.external.models.Documentation; @@ -75,6 +76,9 @@ public class ActionCE_DTO implements Identifiable, Executable { @JsonView(Views.Public.class) String pageId; + @JsonView(Views.Public.class) + CreatorContextType contextType; + @JsonView(Views.Public.class) String collectionId; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/base/ActionCollectionServiceCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/base/ActionCollectionServiceCE.java index d09f4c0090..fd6f04a770 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/base/ActionCollectionServiceCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/base/ActionCollectionServiceCE.java @@ -1,6 +1,7 @@ package com.appsmith.server.actioncollections.base; import com.appsmith.external.models.ActionDTO; +import com.appsmith.external.models.CreatorContextType; import com.appsmith.server.acl.AclPermission; import com.appsmith.server.domains.ActionCollection; import com.appsmith.server.domains.NewPage; @@ -68,4 +69,7 @@ public interface ActionCollectionServiceCE extends CrudService findAllActionCollectionsByContextIdAndContextTypeAndViewMode( + String contextId, CreatorContextType contextType, AclPermission permission, boolean viewMode); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/base/ActionCollectionServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/base/ActionCollectionServiceCEImpl.java index 35210774e5..390324d2b1 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/base/ActionCollectionServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/base/ActionCollectionServiceCEImpl.java @@ -1,6 +1,7 @@ package com.appsmith.server.actioncollections.base; import com.appsmith.external.models.ActionDTO; +import com.appsmith.external.models.CreatorContextType; import com.appsmith.external.models.DefaultResources; import com.appsmith.external.models.Policy; import com.appsmith.server.acl.AclPermission; @@ -620,4 +621,15 @@ public class ActionCollectionServiceCEImpl extends BaseService findAllActionCollectionsByContextIdAndContextTypeAndViewMode( + String contextId, CreatorContextType contextType, AclPermission permission, boolean viewMode) { + if (viewMode) { + return repository.findAllPublishedActionCollectionsByContextIdAndContextType( + contextId, contextType, permission); + } + return repository.findAllUnpublishedActionCollectionsByContextIdAndContextType( + contextId, contextType, permission); + } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ce/ActionCollectionCE_DTO.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ce/ActionCollectionCE_DTO.java index 9976638a46..c482972775 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ce/ActionCollectionCE_DTO.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ce/ActionCollectionCE_DTO.java @@ -2,6 +2,7 @@ package com.appsmith.server.dtos.ce; import com.appsmith.external.exceptions.ErrorDTO; import com.appsmith.external.models.ActionDTO; +import com.appsmith.external.models.CreatorContextType; import com.appsmith.external.models.DefaultResources; import com.appsmith.external.models.JSValue; import com.appsmith.external.models.PluginType; @@ -50,6 +51,9 @@ public class ActionCollectionCE_DTO { @JsonView(Views.Public.class) String pageId; + @JsonView(Views.Public.class) + CreatorContextType contextType; + // This field will only be populated if this collection is bound to one plugin (eg: JS) @JsonView(Views.Public.class) String pluginId; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCE.java index 0391928779..7bf94aa324 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCE.java @@ -1,6 +1,7 @@ package com.appsmith.server.newactions.base; import com.appsmith.external.models.ActionDTO; +import com.appsmith.external.models.CreatorContextType; import com.appsmith.external.models.Executable; import com.appsmith.external.models.MustacheBindingToken; import com.appsmith.server.acl.AclPermission; @@ -136,4 +137,11 @@ public interface NewActionServiceCE extends CrudService { Flux countActionsByPluginType(String applicationId); Flux findByListOfPageIds(List unpublishedPages, Optional optionalPermission); + + Flux findAllActionsByContextIdAndContextTypeAndViewMode( + String contextId, + CreatorContextType contextType, + AclPermission permission, + boolean viewMode, + boolean includeJs); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCEImpl.java index 298a561035..8b6bca2c3d 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCEImpl.java @@ -6,6 +6,7 @@ import com.appsmith.external.helpers.MustacheHelper; import com.appsmith.external.models.ActionConfiguration; import com.appsmith.external.models.ActionDTO; import com.appsmith.external.models.ActionProvider; +import com.appsmith.external.models.CreatorContextType; import com.appsmith.external.models.Datasource; import com.appsmith.external.models.DatasourceConfiguration; import com.appsmith.external.models.DefaultResources; @@ -1726,4 +1727,19 @@ public class NewActionServiceCEImpl extends BaseService unpublishedPages, Optional optionalPermission) { return repository.findByListOfPageIds(unpublishedPages, optionalPermission); } + + @Override + public Flux findAllActionsByContextIdAndContextTypeAndViewMode( + String contextId, + CreatorContextType contextType, + AclPermission permission, + boolean viewMode, + boolean includeJs) { + if (viewMode) { + return repository.findAllPublishedActionsByContextIdAndContextType( + contextId, contextType, permission, includeJs); + } + return repository.findAllUnpublishedActionsByContextIdAndContextType( + contextId, contextType, permission, includeJs); + } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomActionCollectionRepositoryCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomActionCollectionRepositoryCE.java index 0db6f97ecf..6e31c8b72a 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomActionCollectionRepositoryCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomActionCollectionRepositoryCE.java @@ -1,5 +1,6 @@ package com.appsmith.server.repositories.ce; +import com.appsmith.external.models.CreatorContextType; import com.appsmith.server.acl.AclPermission; import com.appsmith.server.domains.ActionCollection; import com.appsmith.server.repositories.AppsmithRepository; @@ -54,4 +55,10 @@ public interface CustomActionCollectionRepositoryCE extends AppsmithRepository> bulkUpdate(List actionCollections); Flux findAllByApplicationIds(List applicationIds, List includeFields); + + Flux findAllUnpublishedActionCollectionsByContextIdAndContextType( + String contextId, CreatorContextType contextType, AclPermission permission); + + Flux findAllPublishedActionCollectionsByContextIdAndContextType( + String contextId, CreatorContextType contextType, AclPermission permission); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomActionCollectionRepositoryCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomActionCollectionRepositoryCEImpl.java index 4934ae66fa..2af549e481 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomActionCollectionRepositoryCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomActionCollectionRepositoryCEImpl.java @@ -1,5 +1,6 @@ package com.appsmith.server.repositories.ce; +import com.appsmith.external.models.CreatorContextType; import com.appsmith.external.models.QBranchAwareDomain; import com.appsmith.server.acl.AclPermission; import com.appsmith.server.constants.FieldName; @@ -269,4 +270,28 @@ public class CustomActionCollectionRepositoryCEImpl extends BaseAppsmithReposito Criteria applicationCriteria = Criteria.where(FieldName.APPLICATION_ID).in(applicationIds); return queryAll(List.of(applicationCriteria), includeFields, null, null, NO_RECORD_LIMIT); } + + @Override + public Flux findAllUnpublishedActionCollectionsByContextIdAndContextType( + String contextId, CreatorContextType contextType, AclPermission permission) { + String contextIdPath = fieldName(QActionCollection.actionCollection.unpublishedCollection) + "." + + fieldName(QActionCollection.actionCollection.unpublishedCollection.pageId); + String contextTypePath = fieldName(QActionCollection.actionCollection.unpublishedCollection) + "." + + fieldName(QActionCollection.actionCollection.unpublishedCollection.contextType); + Criteria contextIdAndContextTypeCriteria = + where(contextIdPath).is(contextId).and(contextTypePath).is(contextType); + return queryAll(List.of(contextIdAndContextTypeCriteria), Optional.of(permission)); + } + + @Override + public Flux findAllPublishedActionCollectionsByContextIdAndContextType( + String contextId, CreatorContextType contextType, AclPermission permission) { + String contextIdPath = fieldName(QActionCollection.actionCollection.publishedCollection) + "." + + fieldName(QActionCollection.actionCollection.publishedCollection.pageId); + String contextTypePath = fieldName(QActionCollection.actionCollection.publishedCollection) + "." + + fieldName(QActionCollection.actionCollection.publishedCollection.contextType); + Criteria contextIdAndContextTypeCriteria = + where(contextIdPath).is(contextId).and(contextTypePath).is(contextType); + return queryAll(List.of(contextIdAndContextTypeCriteria), Optional.of(permission)); + } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCE.java index c3bda9cc5a..1ad0f9d01b 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCE.java @@ -1,5 +1,6 @@ package com.appsmith.server.repositories.ce; +import com.appsmith.external.models.CreatorContextType; import com.appsmith.server.acl.AclPermission; import com.appsmith.server.domains.NewAction; import com.appsmith.server.dtos.PluginTypeAndCountDTO; @@ -84,4 +85,10 @@ public interface CustomNewActionRepositoryCE extends AppsmithRepository countActionsByPluginType(String applicationId); Flux findAllByApplicationIdsWithoutPermission(List applicationIds, List includeFields); + + Flux findAllUnpublishedActionsByContextIdAndContextType( + String contextId, CreatorContextType contextType, AclPermission permission, boolean includeJs); + + Flux findAllPublishedActionsByContextIdAndContextType( + String contextId, CreatorContextType contextType, AclPermission permission, boolean includeJs); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCEImpl.java index fa09372d18..e263413b50 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCEImpl.java @@ -1,5 +1,6 @@ package com.appsmith.server.repositories.ce; +import com.appsmith.external.models.CreatorContextType; import com.appsmith.external.models.PluginType; import com.appsmith.external.models.QActionConfiguration; import com.appsmith.external.models.QBranchAwareDomain; @@ -642,4 +643,59 @@ public class CustomNewActionRepositoryCEImpl extends BaseAppsmithRepositoryImpl< Criteria applicationCriteria = Criteria.where(FieldName.APPLICATION_ID).in(applicationIds); return queryAll(List.of(applicationCriteria), includeFields, null, null, NO_RECORD_LIMIT); } + + @Override + public Flux findAllUnpublishedActionsByContextIdAndContextType( + String contextId, CreatorContextType contextType, AclPermission permission, boolean includeJs) { + List criteriaList = new ArrayList<>(); + + String contextIdPath = fieldName(QNewAction.newAction.unpublishedAction) + "." + + fieldName(QNewAction.newAction.unpublishedAction.pageId); + String contextTypePath = fieldName(QNewAction.newAction.unpublishedAction) + "." + + fieldName(QNewAction.newAction.unpublishedAction.contextType); + Criteria contextIdAndContextTypeCriteria = + where(contextIdPath).is(contextId).and(contextTypePath).is(contextType); + + criteriaList.add(contextIdAndContextTypeCriteria); + + Criteria jsInclusionOrExclusionCriteria; + if (includeJs) { + jsInclusionOrExclusionCriteria = + where(fieldName(QNewAction.newAction.pluginType)).is(PluginType.JS); + } else { + jsInclusionOrExclusionCriteria = + where(fieldName(QNewAction.newAction.pluginType)).ne(PluginType.JS); + } + + criteriaList.add(jsInclusionOrExclusionCriteria); + + return queryAll(List.of(contextIdAndContextTypeCriteria), Optional.of(permission)); + } + + @Override + public Flux findAllPublishedActionsByContextIdAndContextType( + String contextId, CreatorContextType contextType, AclPermission permission, boolean includeJs) { + List criteriaList = new ArrayList<>(); + String contextIdPath = fieldName(QNewAction.newAction.publishedAction) + "." + + fieldName(QNewAction.newAction.publishedAction.pageId); + String contextTypePath = fieldName(QNewAction.newAction.publishedAction) + "." + + fieldName(QNewAction.newAction.publishedAction.contextType); + Criteria contextIdAndContextTypeCriteria = + where(contextIdPath).is(contextId).and(contextTypePath).is(contextType); + + criteriaList.add(contextIdAndContextTypeCriteria); + + Criteria jsInclusionOrExclusionCriteria; + if (includeJs) { + jsInclusionOrExclusionCriteria = + where(fieldName(QNewAction.newAction.pluginType)).is(PluginType.JS); + } else { + jsInclusionOrExclusionCriteria = + where(fieldName(QNewAction.newAction.pluginType)).ne(PluginType.JS); + } + + criteriaList.add(jsInclusionOrExclusionCriteria); + + return queryAll(List.of(contextIdAndContextTypeCriteria), Optional.of(permission)); + } }