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

refactor global config merging strategy on upgrade #1031

Merged
merged 8 commits into from
Jan 6, 2022

Conversation

oshi97
Copy link
Contributor

@oshi97 oshi97 commented Jan 5, 2022

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.

Propertys and CommentedOutPropertys in the original that do not exist in the incoming config
will be moved to the bottom of the config.
Comments that are neither inline nor CommentedOutPropertys 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

@oshi97 oshi97 force-pushed the dev/global-config-ugprade-refactor branch from 1342b8b to 326d7bb Compare January 5, 2022 21:53
@coveralls
Copy link

coveralls commented Jan 5, 2022

Coverage Status

Coverage remained the same at 8.828% when pulling 162c99a on dev/global-config-ugprade-refactor into 92290c8 on develop.

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
@oshi97 oshi97 force-pushed the dev/global-config-ugprade-refactor branch from 326d7bb to 04340fc Compare January 5, 2022 21:54
postupgrade/PostUpgradeHandler.js Outdated Show resolved Hide resolved
postupgrade/mergeGlobalConfigs.js Show resolved Hide resolved
postupgrade/mergeGlobalConfigs.js Outdated Show resolved Hide resolved
postupgrade/mergeGlobalConfigs.js Outdated Show resolved Hide resolved
const beforeComments = commentJsonObject[beforeSymbol] || []
const afterComments = commentJsonObject[afterSymbol] || []
beforeComments.forEach(handleComment)
const inlineComment = afterComments.find(c => c.inline);
Copy link
Collaborator

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?

Copy link
Contributor Author

@oshi97 oshi97 Jan 6, 2022

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

postupgrade/mergeGlobalConfigs.js Outdated Show resolved Hide resolved
postupgrade/mergeGlobalConfigs.js Show resolved Hide resolved
@tmeyer2115 tmeyer2115 self-requested a review January 6, 2022 16:16
Copy link
Member

@cea2aj cea2aj left a 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!

@oshi97 oshi97 merged commit 8e575d9 into develop Jan 6, 2022
@oshi97 oshi97 deleted the dev/global-config-ugprade-refactor branch January 6, 2022 17:58
@tmeyer2115 tmeyer2115 mentioned this pull request Feb 8, 2022
tmeyer2115 added a commit that referenced this pull request Feb 8, 2022
### 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants