-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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: added an autocommit migration for theme settings. #35554
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ | |
import com.appsmith.external.models.Property; | ||
import com.appsmith.server.constants.ApplicationConstants; | ||
import com.appsmith.server.constants.ResourceModes; | ||
import com.appsmith.server.domains.Application; | ||
import com.appsmith.server.domains.ApplicationDetail; | ||
import com.appsmith.server.domains.ApplicationPage; | ||
import com.appsmith.server.domains.CustomJSLib; | ||
import com.appsmith.server.domains.NewAction; | ||
|
@@ -1181,4 +1183,52 @@ private static Set<String> getInvalidDynamicBindingPathsInAction( | |
} | ||
return pathsToRemove; | ||
} | ||
|
||
public static void migrateThemeSettingsForAnvil(ApplicationJson applicationJson) { | ||
if (applicationJson == null || applicationJson.getExportedApplication() == null) { | ||
return; | ||
} | ||
|
||
Application exportedApplication = applicationJson.getExportedApplication(); | ||
ApplicationDetail applicationDetail = exportedApplication.getApplicationDetail(); | ||
ApplicationDetail unpublishedApplicationDetail = exportedApplication.getUnpublishedApplicationDetail(); | ||
|
||
if (applicationDetail == null) { | ||
applicationDetail = new ApplicationDetail(); | ||
exportedApplication.setApplicationDetail(applicationDetail); | ||
} | ||
|
||
if (unpublishedApplicationDetail == null) { | ||
unpublishedApplicationDetail = new ApplicationDetail(); | ||
exportedApplication.setUnpublishedApplicationDetail(unpublishedApplicationDetail); | ||
} | ||
|
||
Application.ThemeSetting themeSetting = applicationDetail.getThemeSetting(); | ||
Application.ThemeSetting unpublishedThemeSetting = unpublishedApplicationDetail.getThemeSetting(); | ||
if (themeSetting == null) { | ||
themeSetting = new Application.ThemeSetting(); | ||
} | ||
|
||
if (unpublishedThemeSetting == null) { | ||
unpublishedThemeSetting = new Application.ThemeSetting(); | ||
} | ||
|
||
applicationDetail.setThemeSetting(themeSetting); | ||
unpublishedApplicationDetail.setThemeSetting(unpublishedThemeSetting); | ||
} | ||
|
||
public static void setThemeSettings(Application.ThemeSetting themeSetting) { | ||
if (themeSetting.getAppMaxWidth() == null) { | ||
themeSetting.setAppMaxWidth(Application.ThemeSetting.AppMaxWidth.LARGE); | ||
} | ||
|
||
// since these are primitive values we don't have concept of null, hence putting it to the default of 1. | ||
if (themeSetting.getDensity() == 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When would we arrive at this scenario? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are not expected to land on this scenario by default, Even if we don't have the density and sizing values not present while deserialising we would start with 1, right? (if not then it's for that). |
||
themeSetting.setDensity(1); | ||
} | ||
|
||
if (themeSetting.getSizing() == 0) { | ||
themeSetting.setSizing(1); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will you be cleaning this up later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, that is when we remove a secondary class with autocommit flags.