Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: conditionally set FqN name for partial import #37694

Merged
merged 17 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading