-
Notifications
You must be signed in to change notification settings - Fork 5
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
refactor global config merging strategy on upgrade #1031
Conversation
1342b8b
to
326d7bb
Compare
This commit refactors how global configs are merged on theme upgrades. Now, global configs will always have the same "structure" as the incoming config, instead of sometimes placing properties in seemingly random spots, if the two configs don't match up exactly in terms of structure. Per Rose's request, the sdkVersion is now always updated to the incoming config's value. Besides that, preexisting properties will favor the original config, while commented out properties will favor the incoming config. Properties and comments in the original that do no exist in the incoming config will be moved to the bottom of the config. J=SLAP-1717 TEST=manual,auto ran an upgrade
326d7bb
to
04340fc
Compare
postupgrade/mergeGlobalConfigs.js
Outdated
const beforeComments = commentJsonObject[beforeSymbol] || [] | ||
const afterComments = commentJsonObject[afterSymbol] || [] | ||
beforeComments.forEach(handleComment) | ||
const inlineComment = afterComments.find(c => c.inline); |
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.
The interior of this forEach
loop is a bit difficult to follow. What are the beforeComments
and afterComments
exactly? Are these the commented out properties that occur in a specific block of the config? That specific block is keyed by key
?
How are normal, un-commented properties getting added to the list of tokens? Could we update some names here to make clearer what's happening?
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.
should be a bit clearer now though it's inherently a little low level
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.
I'm a fan of the use of tokens here!
### Features - Multi-lang versions of the `document-standard` result card and the `documentsearch-standard` direct answer card have been added. (#1041, #1039) - We automatically bump the `sdkVersion` in the `global_config` on upgrade. (#1031) ### Changes - RTF styling was added to the `event-standard`, `faq-accordion`, and `location-standard` cards. (#1037) - The default `universalSectionTemplate` for a `vertical-grid` page was updated to `grid-three-columns`. (#1038) ### Bugfixes - When clicking outside the iFrame'd experience, the query suggestions dropdown now closes. (#1034) - There was a bug with the custom `card` command. If the new card's name contained the name of the forked card, the former would not be added properly. This is now fixed. (#1036) - Previously, if there was a Map on the Universal page, a user could get stuck on the Map while scrolling down the page. This has been fixed. (#1030, #1042)
This commit refactors how global configs are merged on theme upgrades.
Now, global configs will always have the same "structure" as the incoming
config, instead of sometimes placing properties in seemingly random spots,
if the two configs don't match up exactly in terms of structure.
Per Rose's request, the sdkVersion is now always updated to the incoming
config's value. Besides that, preexisting properties will favor the
original config, while commented out properties will favor the incoming config.
Property
s andCommentedOutProperty
s in the original that do not exist in the incoming configwill be moved to the bottom of the config.
Comments that are neither inline nor
CommentedOutProperty
s will be ignored gracefully, and an error message displayed.J=SLAP-1717
TEST=manual,auto
ran an upgrade from 1.26 to this branch
ran an upgrade from 1.26 to this branch, but with the global config changed to have all values replaced with new ones, and with an extra prop at the bottom