-
Notifications
You must be signed in to change notification settings - Fork 14
feat(autofix): Fix deprecated Configuration APIs #699
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e649cd3
feat(autofix): Fix basic deprecated Configuration APIs
RandomByte 59d826e
test: Update snapshots
maxreichmann 5c7330c
test(Configuration): Update e2e tests
maxreichmann 9592cdd
test: Finalize e2e tests
maxreichmann fc97405
test: Update snapshots
maxreichmann d31cf89
test: Remove comment in fixtures
maxreichmann a2e17c4
refactor: Address review
maxreichmann fb458cc
refactor: Revert last commit
maxreichmann 2b1422c
refactor: Revert "refactor: Revert last commit"
RandomByte b69c22b
test: Update snapshots
RandomByte bd2b209
refactor: Address review (destructuring)
maxreichmann a21e9d6
refactor: Update snapshot after rebase
maxreichmann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
60 changes: 60 additions & 0 deletions
60
test/fixtures/autofix/configurationApi/DeprecatedConfigurationApi.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| sap.ui.define([ | ||
| "sap/ui/core/Configuration", | ||
| ], (ConfigurationRenamed) => { | ||
| ConfigurationRenamed.getAccessibility(); | ||
| ConfigurationRenamed.getActiveTerminologies(); | ||
| ConfigurationRenamed.getAllowlistService(); | ||
| ConfigurationRenamed.getAnimation(); | ||
| const a = ConfigurationRenamed.getAnimation(); // Do not migrate since return value differs | ||
| ConfigurationRenamed.getAnimationMode(); | ||
| // Although the return type of the replacement is different, | ||
| // getAnimationMode() is still migratable since old and new return types are congruent: | ||
| if (ConfigurationRenamed.getAnimationMode() === ConfigurationRenamed.AnimationMode.minimal) { | ||
|
|
||
| } | ||
| ConfigurationRenamed.getCalendarType(); | ||
| ConfigurationRenamed.getCalendarWeekNumbering(); | ||
| ConfigurationRenamed.getFrameOptions(); | ||
| ConfigurationRenamed.getLanguage(); | ||
| ConfigurationRenamed.getRTL(); | ||
| ConfigurationRenamed.getSAPLogonLanguage(); | ||
| ConfigurationRenamed.getSecurityTokenHandlers(); | ||
| ConfigurationRenamed.getTheme(); | ||
| ConfigurationRenamed.getTimezone(); | ||
| ConfigurationRenamed.getUIDPrefix(); | ||
| ConfigurationRenamed.getWhitelistService(); | ||
| ConfigurationRenamed.setAnimationMode(ConfigurationRenamed.AnimationMode.minimal); | ||
| ConfigurationRenamed.setSecurityTokenHandlers([() => {console.log("*Security token handler*");}]); | ||
| ConfigurationRenamed.getLanguageTag(); | ||
| ConfigurationRenamed.getFormatLocale(); | ||
|
|
||
| // Migration to two new modules | ||
| ConfigurationRenamed.getLocale(); | ||
|
|
||
| // Complex migrations | ||
| ConfigurationRenamed.setCalendarType(sCalendarType); | ||
| ConfigurationRenamed.setCalendarWeekNumbering(sCalendarWeekNumbering); | ||
| ConfigurationRenamed.setFormatLocale(sFormatLocale); | ||
| ConfigurationRenamed.setLanguage(sLanguage, sSAPLogonLanguage); | ||
| ConfigurationRenamed.setLanguage(sLanguage); | ||
| ConfigurationRenamed.setRTL(bRTL); | ||
| ConfigurationRenamed.setTheme(sTheme); | ||
| ConfigurationRenamed.setTimezone(sTimezone); | ||
|
|
||
| // Do not migrate these methods, as they used to return "this" and now return "undefined". | ||
| // Further more, now the functionality is moved into multiple modules. | ||
| ConfigurationRenamed.setRTL(false).setLanguage("en"); | ||
| const setCalendar = (type) => ConfigurationRenamed.setCalendarType(type); | ||
| const typedCalendar = sType ? ConfigurationRenamed.setCalendarType(sType) : null; | ||
| debug("msg 2", ConfigurationRenamed.setFormatLocale(sFormatLocale)); | ||
| debug("msg 2", (ConfigurationRenamed.setFormatLocale(sFormatLocale))); | ||
| debug("msg 2", ((((ConfigurationRenamed.setFormatLocale(sFormatLocale)))))); | ||
| var time = ConfigurationRenamed.setTimezone(sTimezone); | ||
| var info = { | ||
| theme: ConfigurationRenamed.setTheme(sTheme) | ||
| }; | ||
| ConfigurationRenamed.setTheme(sTheme) ?? ConfigurationRenamed.setTimezone(sTimezone); | ||
| ConfigurationRenamed.setCalendarWeekNumbering(sCalendarWeekNumbering) ? "a" : "b"; | ||
| ConfigurationRenamed.setCalendarType(sCalendarType), ConfigurationRenamed.setCalendarWeekNumbering(sCalendarWeekNumbering); | ||
| fnCall(ConfigurationRenamed.setLanguage(sLanguage)); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
Why can't this be replaced like this in general?
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.
This comment proposes that
becomes
Now you're proposing that any usage of
Configuration.getAnimation()could safely be replaced with(Configuration.getAnimationMode() !== sap.ui.core.Configuration.AnimationMode.none), right?I guess that's correct!
Uh oh!
There was an error while loading. Please reload this page.
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 was my proposal. But meanwhile I noticed that the code in sap/Ui/core/Configuration is slightly more complex (it checks the opposite, that none of the false values are set - depends on the evolution of the enum whether this remains equivalent).
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.
Resolved due being too unsafe to migrate?