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

Addons: Disable option for addon tab #6923

Merged
merged 12 commits into from
Jul 4, 2019

Conversation

jsomsanith-tlnd
Copy link
Contributor

@jsomsanith-tlnd jsomsanith-tlnd commented May 31, 2019

Issue: #6849

What I did

The issue above ask for a feature to disable a11y panel for a single story. But the idea of this PR is to provide a solution at a common level instead of at addon level.

The principle :

  • addons register their tab panel, passing the parameter key
  • user can then disable a panel for a group of stories or a specific story
storiesOf('My Component', module)
  // disable the a11y tab for all "My Component" stories
  .addParameters({
    a11y: { disabled: true },
  })
  .add('story 1', story1)
  .add('story 2', story2);
storiesOf('My Component', module)
  // disable the a11y tab for only "story 1"
  .add('story 1', story1, {  a11y: { disabled: true } })
  .add('story 2', story2);

How to test

  • Is this testable with Jest or Chromatic screenshots? Yes
  • Does this need a new example in the kitchen sink apps? Yes, a Addon panel example has been added
  • Does this need an update to the documentation? Yes, it's a common addon behavior, but addons need to pass the param key now. Documentation has been added.

If your answer is yes to any of these, please make sure to include it in your PR.

@vercel
Copy link

vercel bot commented May 31, 2019

This pull request is automatically deployed with Now.
To access deployments, click Details below or on the icon next to each push.

Latest deployment for this branch: https://monorepo-git-fork-jsomsanith-jsomsanith-featdisabletab.storybook.now.sh

@jsomsanith-tlnd jsomsanith-tlnd changed the title feat: disable option for addon tab feature request: disable option for addon tab May 31, 2019
@shilman shilman added this to the 5.2.0 milestone May 31, 2019
@tmeasday
Copy link
Member

tmeasday commented Jun 3, 2019

This seems reasonable to me

@jsomsanith-tlnd
Copy link
Contributor Author

Thanks @tmeasday, I'll work on the doc/test/kitchen sink

const mapper = ({ state, api }) => ({
panels: api.getPanels(),
panels: filterPanel(api.getPanels(), api.getParameters(state.storyId)),
Copy link
Member

Choose a reason for hiding this comment

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

should getFilteredPanels be an api?
should getPanels just return the filtered list

We should make sure this is memoized

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a getPanelForStory(storyParameters) in the addon api.
Since the api.getParameters() is in the story api, it feels wrong to use it in the addon api. My first thought is that those are separate modules.

Copy link
Member

Choose a reason for hiding this comment

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

The modules addons, layout, stories are all interconnected.

It's OK to call methods on the final / complete api in methods of the SubAPI.

It's probably not a best practice or anything, but duplicating code and making work arounds so "modules" appear self-contained when in fact they aren't really is maybe even worse?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, and I haven't noticed it but the addon api already use other apis.
Changed it :)

@ndelangen
Copy link
Member

@jsomsanith there seems to be a runtime error in the build versions, could you check it out?

Please ask me for help, if you need it, happy to pair on it if you'd like.

@ndelangen
Copy link
Member

Awesome, does anyone else want to review before I merge?

@jsomsanith
Copy link
Contributor

It’s been 15 days, when this PR will be merged ? :)

Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

SOLID 👊

@shilman shilman merged commit b9d2ba2 into storybookjs:next Jul 4, 2019
@shilman shilman changed the title feature request: disable option for addon tab Addons: Disable option for addon tab Jul 4, 2019
ndelangen added a commit that referenced this pull request Jul 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants