Skip to content

Commit

Permalink
fix: conditionally set FqN name for partial import (#37694)
Browse files Browse the repository at this point in the history
## 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 #33651

## Automation

/ok-to-test tags="@tag.ImportExport, @tag.Git"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/12290147226>
> Commit: e60ca39
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12290147226&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.ImportExport, @tag.Git`
> Spec:
> <hr>Thu, 12 Dec 2024 05:52:15 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## 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.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: sondermanish <[email protected]>
  • Loading branch information
AnaghHegde and sondermanish authored Dec 12, 2024
1 parent 749f11b commit 8e30a38
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
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;
Expand Down Expand Up @@ -199,11 +200,11 @@ public void setPolicies(Set<Policy> policies) {
@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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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;
Expand Down Expand Up @@ -482,11 +483,17 @@ private void updateActionNameBeforeMerge(
}
String oldId = newAction.getId().split("_")[1];
newAction.setId(newNameAction + "_" + oldId);

if (PluginType.JS.equals(newAction.getPluginType())) {
newAction.getUnpublishedAction().setFullyQualifiedName(newNameAction);
}

newAction.getUnpublishedAction().setName(newNameAction);
newAction.getUnpublishedAction().setFullyQualifiedName(newNameAction);
if (newAction.getPublishedAction() != null) {
newAction.getPublishedAction().setName(newNameAction);
newAction.getPublishedAction().setFullyQualifiedName(newNameAction);
if (PluginType.JS.equals(newAction.getPluginType())) {
newAction.getPublishedAction().setFullyQualifiedName(newNameAction);
}
}
mappedImportableResourcesDTO.getRefactoringNameReference().put(oldNameAction, newNameAction);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,14 @@ public Mono<Void> updateRefactoredEntity(RefactorEntityNameDTO refactorEntityNam
.map(branchedAction -> 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();
Expand Down

0 comments on commit 8e30a38

Please sign in to comment.