chore: Add contextId and contextType in executables (#28799)
## Description This PR adds ~contextId~ and contextType fields in the executables i.e. ActionCE_DTO and ActionCollectionCE_DTO. The eventual plan is to move pageId to contextId with contextType as PAGE. #### PR fixes following issue(s) Fixes https://github.com/appsmithorg/appsmith/issues/28797 #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change - Chore (housekeeping or task changes that don't impact user perception) ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
This commit is contained in:
parent
52ab5d46bc
commit
ac97f39f86
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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<ActionCollection,
|
|||
|
||||
void populateDefaultResources(
|
||||
ActionCollection actionCollection, ActionCollection branchedActionCollection, String branchName);
|
||||
|
||||
Flux<ActionCollection> findAllActionCollectionsByContextIdAndContextTypeAndViewMode(
|
||||
String contextId, CreatorContextType contextType, AclPermission permission, boolean viewMode);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<ActionCollectionR
|
|||
// Set policies from existing branch object
|
||||
actionCollection.setPolicies(branchedActionCollection.getPolicies());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<ActionCollection> findAllActionCollectionsByContextIdAndContextTypeAndViewMode(
|
||||
String contextId, CreatorContextType contextType, AclPermission permission, boolean viewMode) {
|
||||
if (viewMode) {
|
||||
return repository.findAllPublishedActionCollectionsByContextIdAndContextType(
|
||||
contextId, contextType, permission);
|
||||
}
|
||||
return repository.findAllUnpublishedActionCollectionsByContextIdAndContextType(
|
||||
contextId, contextType, permission);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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<NewAction, String> {
|
|||
Flux<PluginTypeAndCountDTO> countActionsByPluginType(String applicationId);
|
||||
|
||||
Flux<NewAction> findByListOfPageIds(List<String> unpublishedPages, Optional<AclPermission> optionalPermission);
|
||||
|
||||
Flux<NewAction> findAllActionsByContextIdAndContextTypeAndViewMode(
|
||||
String contextId,
|
||||
CreatorContextType contextType,
|
||||
AclPermission permission,
|
||||
boolean viewMode,
|
||||
boolean includeJs);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<NewActionRepository, New
|
|||
List<String> unpublishedPages, Optional<AclPermission> optionalPermission) {
|
||||
return repository.findByListOfPageIds(unpublishedPages, optionalPermission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<NewAction> 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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<A
|
|||
Mono<List<BulkWriteResult>> bulkUpdate(List<ActionCollection> actionCollections);
|
||||
|
||||
Flux<ActionCollection> findAllByApplicationIds(List<String> applicationIds, List<String> includeFields);
|
||||
|
||||
Flux<ActionCollection> findAllUnpublishedActionCollectionsByContextIdAndContextType(
|
||||
String contextId, CreatorContextType contextType, AclPermission permission);
|
||||
|
||||
Flux<ActionCollection> findAllPublishedActionCollectionsByContextIdAndContextType(
|
||||
String contextId, CreatorContextType contextType, AclPermission permission);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<ActionCollection> 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<ActionCollection> 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));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<NewActio
|
|||
Flux<PluginTypeAndCountDTO> countActionsByPluginType(String applicationId);
|
||||
|
||||
Flux<NewAction> findAllByApplicationIdsWithoutPermission(List<String> applicationIds, List<String> includeFields);
|
||||
|
||||
Flux<NewAction> findAllUnpublishedActionsByContextIdAndContextType(
|
||||
String contextId, CreatorContextType contextType, AclPermission permission, boolean includeJs);
|
||||
|
||||
Flux<NewAction> findAllPublishedActionsByContextIdAndContextType(
|
||||
String contextId, CreatorContextType contextType, AclPermission permission, boolean includeJs);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<NewAction> findAllUnpublishedActionsByContextIdAndContextType(
|
||||
String contextId, CreatorContextType contextType, AclPermission permission, boolean includeJs) {
|
||||
List<Criteria> 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<NewAction> findAllPublishedActionsByContextIdAndContextType(
|
||||
String contextId, CreatorContextType contextType, AclPermission permission, boolean includeJs) {
|
||||
List<Criteria> 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));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user