diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionService.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionService.java index e690034b54..a447009db6 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionService.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionService.java @@ -23,4 +23,5 @@ public interface ActionService extends CrudService { Object variableSubstitution(Object configuration, Map replaceParamsMap); + Flux findByPageId(String pageId); } 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 cf3c0c1d12..c666b36943 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 @@ -464,6 +464,11 @@ public class ActionServiceImpl extends BaseService findByPageId(String pageId) { + return repository.findByPageId(pageId); + } + /** * @param template : This is the string which contains {{key}} which would be replaced with value * @param name : This is the class name of the object from which template string was created diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/LayoutActionServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/LayoutActionServiceImpl.java index 9960748427..6b33e18acb 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/LayoutActionServiceImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/LayoutActionServiceImpl.java @@ -317,7 +317,6 @@ public class LayoutActionServiceImpl implements LayoutActionService { if (pageId != null) { params.add(FieldName.PAGE_ID, pageId); } - Flux actionsInPageFlux = actionService.get(params); Mono updatePageMono = pageService .findById(pageId) @@ -349,7 +348,8 @@ public class LayoutActionServiceImpl implements LayoutActionService { return Mono.just(page); }); - Mono> updateActionsMono = actionsInPageFlux + Mono> updateActionsMono = actionService + .findByPageId(pageId) /* * Assuming that the datasource should not be dependent on the widget and hence not going through the same * to look for replacement pattern. @@ -359,7 +359,7 @@ public class LayoutActionServiceImpl implements LayoutActionService { ActionConfiguration actionConfiguration = action.getActionConfiguration(); Set jsonPathKeys = action.getJsonPathKeys(); - if (jsonPathKeys != null || !jsonPathKeys.isEmpty()) { + if (jsonPathKeys != null && !jsonPathKeys.isEmpty()) { // Since json path keys actually contain the entire inline js function instead of just the widget/action // name, we can not simply use the set.contains(obj) function. We need to iterate over all the keys // in the set and see if the old name is a substring of the json path key. @@ -387,11 +387,14 @@ public class LayoutActionServiceImpl implements LayoutActionService { return Mono.just(action); } }) + .map(savedAction -> savedAction.getName()) .collect(toSet()); - return updateActionsMono - .then(updatePageMono) - .flatMap(page -> { + return Mono.zip(updateActionsMono, updatePageMono) + .flatMap(tuple -> { + Set updatedActionNames = tuple.getT1(); + Page page = tuple.getT2(); + log.debug("Actions updated due to refactor name in page {} are : {}", pageId, updatedActionNames); List layouts = page.getLayouts(); for (Layout layout : layouts) { if (layout.getId().equals(layoutId)) {