Skip to content

FIX singleton module issue for manager & theme not being set correctly #5679

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 8 commits into from
Feb 21, 2019

Conversation

ndelangen
Copy link
Member

Issue: #5663

What I did

  • enforce singleton modules of storybook packages for the manager
  • add a safety check for theme

if no proper theme is provided, we use light / shallow-merge in light base
@ndelangen ndelangen added this to the v5.0.0 milestone Feb 20, 2019
@ndelangen ndelangen self-assigned this Feb 20, 2019
@ndelangen ndelangen changed the title Fix/5651 FIX singleton module issue for manager & theme not being set correctly Feb 20, 2019
@@ -177,3 +178,35 @@ export const create = (vars: ThemeVar, rest?: Rest): Theme => ({

...(rest || {}),
});

export const ensure = (input: any): Theme => {
Copy link
Member

Choose a reason for hiding this comment

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

I don't like this safety check. I feel like this is going to hide bugs. Can we fail fast here instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fail when anything is missing in the theme?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, so the stack trace leads you to the error check, rather than in the depths of some component where it's unclear whether it's a bug in the theme or a bug in the component.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree on your point that it may hide bugs, but I think throwing on a missing property will cause issues later if we're adding something to the theme.

In that scenario, anything we add to the theme object, will break every theme users have made.

I think some grace is appropriate here, likely the worst that is to happen is, some styling inconsistency in someone's storybook, not broken one.

Copy link
Member Author

Choose a reason for hiding this comment

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

My suggestion:

screenshot 2019-02-20 at 21 46 41

The storybook continues to function with the light theme merged in.

Copy link
Member

Choose a reason for hiding this comment

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

OK, this looks better to me. Thanks!

@codecov
Copy link

codecov bot commented Feb 20, 2019

Codecov Report

Merging #5679 into next will decrease coverage by 0.11%.
The diff coverage is 8.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##             next    #5679      +/-   ##
==========================================
- Coverage   33.35%   33.24%   -0.12%     
==========================================
  Files         647      648       +1     
  Lines        9332     9363      +31     
  Branches     1324     1330       +6     
==========================================
  Hits         3113     3113              
- Misses       5604     5635      +31     
  Partials      615      615
Impacted Files Coverage Δ
lib/ui/src/core/context.js 9.52% <0%> (-0.48%) ⬇️
.../core/src/server/manager/manager-webpack.config.js 0% <0%> (ø) ⬆️
lib/ui/src/index.js 63.63% <0%> (ø) ⬆️
lib/theming/src/index.ts 0% <0%> (ø) ⬆️
lib/theming/src/ensure.ts 0% <0%> (ø)
lib/client-logger/src/index.ts 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c5d8d17...f526ad3. Read the comment docs.

Copy link
Member

@tmeasday tmeasday left a comment

Choose a reason for hiding this comment

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

I like this, the resolve solution for singletons is about the best we can do.

Also warning on missing theme props is probably what we want.

👍

@shilman shilman merged commit 0c8b869 into next Feb 21, 2019
@shilman shilman deleted the fix/5651 branch February 21, 2019 06:02
@shilman shilman added the patch:done Patch/release PRs already cherry-picked to main/release branch label Feb 21, 2019
shilman added a commit that referenced this pull request Feb 21, 2019
FIX singleton module issue for manager & theme not being set correctly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug patch:done Patch/release PRs already cherry-picked to main/release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants