Skip to content

Commit

Permalink
fix: added fix for vanishing appdetails (#33698)
Browse files Browse the repository at this point in the history
## Description
- modified logic to copy the ApplicationDetails object of the
importedApplication to existing application

Fixes #24920

## Automation

/ok-to-test tags="@tag.All"

### 🔍 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/9207111058>
> Commit: 9d426c0
> Cypress dashboard url: <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9207111058&attempt=1"
target="_blank">Click here!</a>

<!-- end of auto-generated comment: Cypress test results  -->





## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No
  • Loading branch information
sondermanish authored May 23, 2024
1 parent 8480704 commit 9911049
Showing 1 changed file with 3 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.appsmith.external.models.Datasource;
import com.appsmith.server.constants.FieldName;
import com.appsmith.server.domains.Application;
import com.appsmith.server.domains.ApplicationDetail;
import com.appsmith.server.dtos.ApplicationJson;
import com.appsmith.server.dtos.ArtifactExchangeJson;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -80,39 +79,13 @@ public static String sanitizeDatasourceInActionDTO(
return "";
}

/**
* This function sets the current applicationDetail properties to null if the user wants to discard the changes
* and accept from the git repo which doesn't contain these.
* @param importedApplicationDetail
* @param existingApplicationDetail
*/
private static void setPropertiesToApplicationDetail(
ApplicationDetail importedApplicationDetail, ApplicationDetail existingApplicationDetail) {
// If the initial commit to git doesn't contain these keys and if we want to discard the changes,
// the function copyNestedNonNullProperties ignore these properties and the changes are not discarded
if (importedApplicationDetail != null && existingApplicationDetail != null) {
if (importedApplicationDetail.getAppPositioning() == null) {
existingApplicationDetail.setAppPositioning(null);
}

if (importedApplicationDetail.getNavigationSetting() == null) {
existingApplicationDetail.setNavigationSetting(null);
}

if (importedApplicationDetail.getThemeSetting() == null) {
existingApplicationDetail.setThemeSetting(null);
}
}
}

public static void setPropertiesToExistingApplication(
Application importedApplication, Application existingApplication) {
importedApplication.setId(existingApplication.getId());

ApplicationDetail importedUnpublishedAppDetail = importedApplication.getUnpublishedApplicationDetail();
ApplicationDetail importedPublishedAppDetail = importedApplication.getPublishedApplicationDetail();
ApplicationDetail existingUnpublishedAppDetail = existingApplication.getUnpublishedApplicationDetail();
ApplicationDetail existingPublishedAppDetail = existingApplication.getPublishedApplicationDetail();
// Since we don't want to merge the ApplicationDetailObjects we would just assign the imported values directly
existingApplication.setPublishedApplicationDetail(importedApplication.getPublishedApplicationDetail());
existingApplication.setUnpublishedApplicationDetail(importedApplication.getUnpublishedApplicationDetail());

// For the existing application we don't need to default
// value of the flag
Expand All @@ -125,22 +98,13 @@ public static void setPropertiesToExistingApplication(
// These properties are not present in the application when it is created, hence the initial commit
// to git doesn't contain these keys and if we want to discard the changes, the function
// copyNestedNonNullProperties ignore these properties and the changes are not discarded
if (importedUnpublishedAppDetail == null) {
existingApplication.setUnpublishedApplicationDetail(null);
}
if (importedPublishedAppDetail == null) {
existingApplication.setPublishedApplicationDetail(null);
}
if (importedApplication.getPublishedAppLayout() == null) {
existingApplication.setPublishedAppLayout(null);
}
if (importedApplication.getUnpublishedAppLayout() == null) {
existingApplication.setUnpublishedAppLayout(null);
}

setPropertiesToApplicationDetail(importedUnpublishedAppDetail, existingUnpublishedAppDetail);
setPropertiesToApplicationDetail(importedPublishedAppDetail, existingPublishedAppDetail);

copyNestedNonNullProperties(importedApplication, existingApplication);
}

Expand Down

0 comments on commit 9911049

Please sign in to comment.