From 8e30a389e4a9492f4f7c01967a07a5f2a84415d7 Mon Sep 17 00:00:00 2001 From: Anagh Hegde Date: Thu, 12 Dec 2024 18:32:49 +0530 Subject: [PATCH] fix: conditionally set FqN name for partial import (#37694) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description The fullyQulifiedName aka path for used for js objects was set to actions as well during the partial import. This was causing the diff in actual name and fullyQualifiedName when the name is edited in UI. Hence few of the actions were failing in view mode. Fixes https://github.com/appsmithorg/appsmith/issues/33651 ## Automation /ok-to-test tags="@tag.ImportExport, @tag.Git" ### :mag: Cypress test results > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: e60ca39ba2fdc5f19976ea3cbfc47a1b89a75a3f > Cypress dashboard. > Tags: `@tag.ImportExport, @tag.Git` > Spec: >
Thu, 12 Dec 2024 05:52:15 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No ## Summary by CodeRabbit - **New Features** - Improved action refactoring functionality, ensuring consistent naming conventions across different plugin types. - Enhanced handling of action references during refactoring, ensuring robust updates and checks for action configurations. - **Bug Fixes** - Fixed issues related to the retrieval and updating of actions based on context, improving overall efficiency. --------- Co-authored-by: sondermanish --- .../com/appsmith/external/models/ce/ActionCE_DTO.java | 7 ++++--- .../importable/NewActionImportableServiceCEImpl.java | 11 +++++++++-- .../refactors/NewActionRefactoringServiceCEImpl.java | 7 ++++++- 3 files changed, 19 insertions(+), 6 deletions(-) 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 52b4ea3e73..dcd2639ec3 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 @@ -25,6 +25,7 @@ import lombok.Setter; import lombok.ToString; import lombok.experimental.FieldNameConstants; import org.springframework.data.annotation.Transient; +import org.springframework.util.StringUtils; import java.time.Instant; import java.util.HashMap; @@ -199,11 +200,11 @@ public class ActionCE_DTO implements Identifiable, Executable { @Override @JsonView({Views.Internal.class}) public String getValidName() { - if (this.fullyQualifiedName == null) { - return this.name; - } else { + if (StringUtils.hasText(this.fullyQualifiedName)) { return this.fullyQualifiedName; } + + return this.name; } @Override diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/importable/NewActionImportableServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/importable/NewActionImportableServiceCEImpl.java index 3d87c2fdcb..3755272f84 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/importable/NewActionImportableServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/importable/NewActionImportableServiceCEImpl.java @@ -2,6 +2,7 @@ package com.appsmith.server.newactions.importable; import com.appsmith.external.models.ActionDTO; import com.appsmith.external.models.Datasource; +import com.appsmith.external.models.PluginType; import com.appsmith.external.models.Policy; import com.appsmith.server.actioncollections.base.ActionCollectionService; import com.appsmith.server.constants.FieldName; @@ -482,11 +483,17 @@ public class NewActionImportableServiceCEImpl implements ImportableServiceCE newActionService.generateActionByViewMode(branchedAction, false)) .flatMap(action -> { action.setName(refactorEntityNameDTO.getNewName()); - if (StringUtils.hasLength(refactorEntityNameDTO.getCollectionName())) { + if (!PluginType.JS.equals(action.getPluginType())) { + return newActionService.updateUnpublishedAction(action.getId(), action); + } + + if (StringUtils.hasText(refactorEntityNameDTO.getCollectionName())) { action.setFullyQualifiedName(refactorEntityNameDTO.getNewFullyQualifiedName()); } + return newActionService.updateUnpublishedAction(action.getId(), action); }) .then();