Skip to content
Merged
Changes from all commits
Commits
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 @@ -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