diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ActionViewDTO.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ActionViewDTO.java index 22b8f13ab2..20b85a58e5 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ActionViewDTO.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/ActionViewDTO.java @@ -12,5 +12,6 @@ import java.util.Set; public class ActionViewDTO { String id; String name; + String pageId; Set jsonPathKeys; } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionServiceImpl.java index 1cc73cadf5..a02d3be493 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionServiceImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionServiceImpl.java @@ -537,8 +537,13 @@ public class ActionServiceImpl extends BaseService()); - actionViewDTO.getJsonPathKeys().addAll(action.getJsonPathKeys()); + actionViewDTO.setPageId(action.getPageId()); + if (action.getJsonPathKeys() != null && !action.getJsonPathKeys().isEmpty()) { + Set jsonPathKeys; + jsonPathKeys = new HashSet<>(); + jsonPathKeys.addAll(action.getJsonPathKeys()); + actionViewDTO.setJsonPathKeys(jsonPathKeys); + } return actionViewDTO; }); } diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionServiceTest.java index 6aec5f0292..1bd47841a5 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionServiceTest.java @@ -44,10 +44,8 @@ import reactor.test.StepVerifier; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.Set; import java.util.UUID; -import java.util.stream.Stream; import static com.appsmith.server.acl.AclPermission.MANAGE_ACTIONS; import static com.appsmith.server.acl.AclPermission.READ_ACTIONS; @@ -472,17 +470,33 @@ public class ActionServiceTest { action.setActionConfiguration(actionConfiguration); action.setDatasource(datasource); + Action action1 = new Action(); + action1.setName("actionInViewModeWithoutMustacheKey"); + action1.setPageId(testPage.getId()); + ActionConfiguration actionConfiguration1 = new ActionConfiguration(); + actionConfiguration1.setHttpMethod(HttpMethod.GET); + action1.setActionConfiguration(actionConfiguration1); + action1.setDatasource(datasource); + Mono> actionsListMono = actionService.create(action) + .then(actionService.create(action1)) .then(actionService.getActionsForViewMode(testApp.getId()).collectList()); StepVerifier .create(actionsListMono) .assertNext(actionsList -> { assertThat(actionsList.size()).isGreaterThan(0); - ActionViewDTO actionViewDTO = actionsList.stream().filter(action1 -> action1.getName().equals(action.getName())).findFirst().get(); + ActionViewDTO actionViewDTO = actionsList.stream().filter(dto -> dto.getName().equals(action.getName())).findFirst().get(); assertThat(actionViewDTO).isNotNull(); assertThat(actionViewDTO.getJsonPathKeys()).containsAll(Set.of(key)); + assertThat(actionViewDTO.getPageId()).isEqualTo(testPage.getId()); + + ActionViewDTO actionViewDTO1 = actionsList.stream().filter(dto -> dto.getName().equals(action1.getName())).findFirst().get(); + + assertThat(actionViewDTO1).isNotNull(); + assertThat(actionViewDTO1.getJsonPathKeys()).isNullOrEmpty(); + assertThat(actionViewDTO1.getPageId()).isEqualTo(testPage.getId()); }) .verifyComplete(); }