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

Shared config updates #452

Merged
merged 7 commits into from
Aug 17, 2023
Merged

Shared config updates #452

merged 7 commits into from
Aug 17, 2023

Conversation

DavieReid
Copy link
Contributor

It is possible to have a source that is considered a "child" of another source. Consider:

  • Source A contains a lot of product docs and defines a shared config for the products site (parent source)
  • Source B contains docs for a single product and does not have any shared config. (child source)

To a Mosaic site, the product of Source B should work the same as all the other products from Source A. This includes using the shared config of Source A in pages that come from Source B.

This change adds the above feature by allowing a source to apply it's shared config to another source if they share the same namespace

Timeline

  • Source A loads it pages and the shared config plugin creates the shared-config
  • Source B loads its pages and writes to the global config explaining that it doesn't have any shared config and that it has namespace "whatever"
  • The afterUpdate plugin lifecycle triggers for all sources
  • Source A detects that it has the same namespace as Source B
  • For each index page in Source B, Source A works out what the closest shared config file should be
  • Source A then creates a file in the shared filesystem so that Source B now has a shared config

@DavieReid DavieReid requested a review from a team as a code owner August 17, 2023 11:28
@changeset-bot
Copy link

changeset-bot bot commented Aug 17, 2023

🦋 Changeset detected

Latest commit: 5ddf549

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 24 packages
Name Type
@jpmorganchase/mosaic-core Patch
@jpmorganchase/mosaic-plugins Patch
@jpmorganchase/mosaic-site Patch
@jpmorganchase/mosaic-types Patch
@jpmorganchase/mosaic-cli Patch
@jpmorganchase/mosaic-labs-components Patch
@jpmorganchase/mosaic-components Patch
@jpmorganchase/mosaic-content-editor-plugin Patch
@jpmorganchase/mosaic-create-site Patch
@jpmorganchase/mosaic-from-http-request Patch
@jpmorganchase/mosaic-layouts Patch
@jpmorganchase/mosaic-open-api-component Patch
@jpmorganchase/mosaic-schemas Patch
@jpmorganchase/mosaic-serialisers Patch
@jpmorganchase/mosaic-site-components Patch
@jpmorganchase/mosaic-site-middleware Patch
@jpmorganchase/mosaic-site-preset-styles Patch
@jpmorganchase/mosaic-source-git-repo Patch
@jpmorganchase/mosaic-source-http Patch
@jpmorganchase/mosaic-source-local-folder Patch
@jpmorganchase/mosaic-standard-generator Patch
@jpmorganchase/mosaic-store Patch
@jpmorganchase/mosaic-theme Patch
@jpmorganchase/mosaic-workflows Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Aug 17, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mosaic ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 17, 2023 0:38am

namespace
}
};
config.setData({ applyNamespaceSharedConfig });
Copy link
Contributor Author

@DavieReid DavieReid Aug 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the config object is persisted across plugin lifecycle events. So this source is writing to the global config in the hope another source that does have a shared config will apply it.

This is picked up in the afterUpdate event

.map(key => applyNamespaceSharedConfig?.[key] || []);

for (const namespaceSharedConfig of namespaceSharedConfigs) {
if (await mutableFilesystem.promises.exists(namespaceSharedConfig.rootPath)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to guard against the actual write of the shared config.json that is a copy. It might trigger afterUpdate again but not 100% sure

@coveralls
Copy link

Pull Request Test Coverage Report for Build 5890938994

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 63.124%

Totals Coverage Status
Change from base Build 5856537148: 0.0%
Covered Lines: 1307
Relevant Lines: 1803

💛 - Coveralls

@DavieReid DavieReid merged commit f67a1b5 into main Aug 17, 2023
7 checks passed
@DavieReid DavieReid deleted the shared-config-updates branch August 17, 2023 12:57
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.

3 participants