diff --git a/app/client/src/sagas/JSPaneSagas.ts b/app/client/src/sagas/JSPaneSagas.ts index 9401bd260685..392478283b0c 100644 --- a/app/client/src/sagas/JSPaneSagas.ts +++ b/app/client/src/sagas/JSPaneSagas.ts @@ -670,24 +670,19 @@ function* handleUpdateJSCollectionBody( actionPayload.payload.id, ); - // @ts-expect-error: Object jsCollection is possibly undefined - jsCollection["body"] = actionPayload.payload.body; try { if (jsCollection) { - // TODO: Fix this the next time the file is edited - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const response: ApiResponse = + const response: ApiResponse = yield JSActionAPI.updateJSCollectionBody( jsCollection.id, - jsCollection.body, + actionPayload.payload.body, ); const isValidResponse: boolean = yield validateResponse(response); if (isValidResponse) { - // since server is not sending the info about whether the js collection is main or not - // we are retaining it manually + const serverData = response.data; const updatedJSCollection: JSCollection = { - ...jsCollection, + ...serverData, isMainJSCollection: !!jsCollection.isMainJSCollection, }; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/ActionCollectionControllerCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/ActionCollectionControllerCE.java index 164c9bac5029..2fe79587fc78 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/ActionCollectionControllerCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/ActionCollectionControllerCE.java @@ -117,7 +117,7 @@ public Mono> updateActionCollection( @JsonView(Views.Public.class) @PutMapping("/{id}/body") - public Mono> updateActionCollectionBody( + public Mono> updateActionCollectionBody( @PathVariable String id, @Valid @RequestBody ActionCollectionDTO resource) { log.debug("Going to update action collection body with id: {}", id); return layoutCollectionService diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCE.java index 9fabaeb3ef26..7293421c068b 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCE.java @@ -14,7 +14,7 @@ public interface LayoutCollectionServiceCE { Mono moveCollection(ActionCollectionMoveDTO actionCollectionMoveDTO); - Mono updateUnpublishedActionCollectionBody(String id, ActionCollectionDTO actionCollectionDTO); + Mono updateUnpublishedActionCollectionBody(String id, ActionCollectionDTO actionCollectionDTO); Mono updateUnpublishedActionCollection(String id, ActionCollectionDTO actionCollectionDTO); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCEImpl.java index b572452139f8..3e0b5a785162 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCEImpl.java @@ -273,7 +273,8 @@ public Mono moveCollection(ActionCollectionMoveDTO actionCo } @Override - public Mono updateUnpublishedActionCollectionBody(String id, ActionCollectionDTO actionCollectionDTO) { + public Mono updateUnpublishedActionCollectionBody( + String id, ActionCollectionDTO actionCollectionDTO) { if (id == null) { return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.ID)); @@ -299,7 +300,13 @@ public Mono updateUnpublishedActionCollectionBody(String id, ActionColl updateObj.set(path, actionCollectionDTO.getBody()); updateObj.set(updatedAtPath, Instant.now()); - return actionCollectionRepository.updateByIdWithoutPermissionCheck(dbActionCollection.getId(), updateObj); + return actionCollectionRepository + .updateByIdWithoutPermissionCheck(dbActionCollection.getId(), updateObj) + .then(actionCollectionService.findById(id, actionPermission.getEditPermission())) + .flatMap(actionCollectionRepository::setUserPermissionsInObject) + .flatMap(actionCollection -> + actionCollectionService.generateActionCollectionByViewMode(actionCollection, false)) + .flatMap(dto -> actionCollectionService.populateActionCollectionByViewMode(dto, false)); }); }