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: Git discarding null properties #25068

Merged
merged 31 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
54877ee
Merge branch 'release' of github.com:appsmithorg/appsmith into release
NilanshBansal May 12, 2023
5fa31b0
Merge branch 'release' of github.com:appsmithorg/appsmith into release
NilanshBansal May 15, 2023
9b34c1c
Merge branch 'release' of github.com:appsmithorg/appsmith into release
NilanshBansal May 22, 2023
5c98a88
Merge branch 'release' of github.com:appsmithorg/appsmith into release
NilanshBansal May 22, 2023
de8e537
Merge branch 'release' of github.com:appsmithorg/appsmith into release
NilanshBansal May 26, 2023
6161384
Merge branch 'release' of github.com:appsmithorg/appsmith into release
NilanshBansal May 29, 2023
7b641e1
Merge branch 'release' of github.com:appsmithorg/appsmith into release
NilanshBansal Jun 1, 2023
09cccf9
Merge branch 'release' of github.com:appsmithorg/appsmith into release
NilanshBansal Jun 1, 2023
c28149c
Merge branch 'release' of github.com:appsmithorg/appsmith into release
NilanshBansal Jun 2, 2023
3123ad6
Merge branch 'release' of github.com:appsmithorg/appsmith into release
NilanshBansal Jun 5, 2023
b8ed623
Merge branch 'release' of github.com:appsmithorg/appsmith into release
NilanshBansal Jun 7, 2023
e767f32
Merge branch 'release' of github.com:appsmithorg/appsmith into release
NilanshBansal Jun 7, 2023
0f40417
Merge branch 'release' of github.com:appsmithorg/appsmith into release
NilanshBansal Jun 24, 2023
b44ec5e
Merge branch 'release' of github.com:appsmithorg/appsmith into release
NilanshBansal Jun 26, 2023
c4a7345
Merge branch 'release' of github.com:appsmithorg/appsmith into release
NilanshBansal Jun 26, 2023
560aa3a
Merge branch 'release' of github.com:appsmithorg/appsmith into release
NilanshBansal Jun 28, 2023
705619a
Merge branch 'release' of github.com:appsmithorg/appsmith into release
NilanshBansal Jun 28, 2023
a03b4d5
Merge branch 'release' of github.com:appsmithorg/appsmith into release
NilanshBansal Jun 28, 2023
e60a631
Merge branch 'release' of github.com:appsmithorg/appsmith into release
NilanshBansal Jun 29, 2023
5153b16
Merge branch 'release' of github.com:appsmithorg/appsmith into release
NilanshBansal Jun 29, 2023
653cb91
Merge branch 'release' of github.com:appsmithorg/appsmith into release
NilanshBansal Jun 29, 2023
6a3d482
Merge branch 'release' of github.com:appsmithorg/appsmith into release
NilanshBansal Jul 4, 2023
449d8d6
Merge branch 'release' of github.com:appsmithorg/appsmith into release
NilanshBansal Jul 4, 2023
441b764
Merge branch 'release' of github.com:appsmithorg/appsmith into release
NilanshBansal Jul 4, 2023
859fbc4
fix: discarding git app null properties
NilanshBansal Jul 4, 2023
9a6be10
removing indendation changes
NilanshBansal Jul 4, 2023
46d9395
moved func to ImportExport utils helper
NilanshBansal Jul 4, 2023
0573cc8
added tests
NilanshBansal Jul 4, 2023
aabb729
Merge branch 'release' of github.com:appsmithorg/appsmith into fix/is…
NilanshBansal Jul 4, 2023
1286170
indent
NilanshBansal Jul 4, 2023
0905a58
asserted before also
NilanshBansal Jul 4, 2023
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
Prev Previous commit
Next Next commit
moved func to ImportExport utils helper
  • Loading branch information
NilanshBansal committed Jul 4, 2023
commit 46d93959a27cca36423a82332fc018db309d4d28
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

import com.appsmith.external.models.ActionDTO;
import com.appsmith.external.models.Datasource;
import com.appsmith.server.domains.Application;
import lombok.extern.slf4j.Slf4j;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.data.mongodb.MongoTransactionException;
import org.springframework.transaction.TransactionException;

import java.util.Map;

import static com.appsmith.external.helpers.AppsmithBeanUtils.copyNestedNonNullProperties;

@Slf4j
public class ImportExportUtils {

Expand Down Expand Up @@ -39,10 +42,10 @@ public static String getErrorMessage(Throwable throwable) {
* @return
*/
public static String sanitizeDatasourceInActionDTO(ActionDTO actionDTO,
Map<String, String> datasourceMap,
Map<String, String> pluginMap,
String workspaceId,
boolean isExporting) {
Map<String, String> datasourceMap,
Map<String, String> pluginMap,
String workspaceId,
boolean isExporting) {

if (actionDTO != null && actionDTO.getDatasource() != null) {

Expand All @@ -69,4 +72,34 @@ public static String sanitizeDatasourceInActionDTO(ActionDTO actionDTO,

return "";
}

public static void setPropertiesToExistingApplication(Application importedApplication, Application existingApplication) {
importedApplication.setId(existingApplication.getId());
// For the existing application we don't need to default
// value of the flag
// The isPublic flag has a default value as false and this
// would be confusing to user
// when it is reset to false during importing where the
// application already is present in DB
importedApplication.setIsPublic(null);
importedApplication.setPolicies(null);
// 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 (importedApplication.getUnpublishedApplicationDetail() == null) {
existingApplication.setUnpublishedApplicationDetail(null);
}
if (importedApplication.getPublishedApplicationDetail() == null) {
existingApplication.setPublishedApplicationDetail(null);
}
if (importedApplication.getPublishedAppLayout() == null) {
existingApplication.setPublishedAppLayout(null);
}
if (importedApplication.getUnpublishedAppLayout() == null) {
existingApplication.setUnpublishedAppLayout(null);
}

copyNestedNonNullProperties(importedApplication, existingApplication);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
import static com.appsmith.server.constants.ResourceModes.EDIT;
import static com.appsmith.server.constants.ResourceModes.VIEW;
import static com.appsmith.server.helpers.ImportExportUtils.sanitizeDatasourceInActionDTO;
import static com.appsmith.server.helpers.ImportExportUtils.setPropertiesToExistingApplication;
import static java.lang.Boolean.TRUE;

@Slf4j
Expand Down Expand Up @@ -836,36 +837,6 @@ private String validateApplicationJson(ApplicationJson importedDoc) {
return errorField;
}

private void setPropertiesToExistingApplication(Application importedApplication, Application existingApplication) {
importedApplication.setId(existingApplication.getId());
// For the existing application we don't need to default
// value of the flag
// The isPublic flag has a default value as false and this
// would be confusing to user
// when it is reset to false during importing where the
// application already is present in DB
importedApplication.setIsPublic(null);
importedApplication.setPolicies(null);
// 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 (importedApplication.getUnpublishedApplicationDetail() == null) {
existingApplication.setUnpublishedApplicationDetail(null);
}
if (importedApplication.getPublishedApplicationDetail() == null) {
existingApplication.setPublishedApplicationDetail(null);
}
if (importedApplication.getPublishedAppLayout() == null) {
existingApplication.setPublishedAppLayout(null);
}
if (importedApplication.getUnpublishedAppLayout() == null) {
existingApplication.setUnpublishedAppLayout(null);
}

copyNestedNonNullProperties(importedApplication, existingApplication);
}

/**
* This function will take the application reference object to hydrate the application in mongoDB
*
Expand Down