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

Addon-links: Update linkTo type to accept function #8117

Merged
merged 4 commits into from
Sep 28, 2019

Conversation

SiAdcock
Copy link
Contributor

@SiAdcock SiAdcock commented Sep 18, 2019

What I did

Updates the linkTo() type to accept a function as the second parameter. This is inline with the documentation and DefinitelyTyped.

How to test

  • Is this testable with Jest or Chromatic screenshots? No
  • Does this need a new example in the kitchen sink apps? No
  • Does this need an update to the documentation? No

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

@vercel
Copy link

vercel bot commented Sep 18, 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-siadcock-sa-update-linkto-type.storybook.now.sh

@shilman shilman added addon: links bug patch:yes Bugfix & documentation PR that need to be picked to main branch typescript labels Sep 19, 2019
@shilman
Copy link
Member

shilman commented Sep 19, 2019

@kroeder @gaetanmaisse @emilio-martinez can you review this?

@ndelangen ndelangen self-assigned this Sep 24, 2019
Functionality to support navigation by (storyId || kind || kind + storyName || storyName) is now implemented in the linkTo
itself.

It uses the global scope storyStore & clientApi, which isn't good, but we will refactor that later.

The navigate function now refuses to navigate to a story that does not exist.

hrefTo function also no longer throws an error when kind isn't provided

Add test to assert this functionality actually works
@ndelangen
Copy link
Member

I did some testing and found the addon-link not working correctly.

After some experimentation I found that the kind + storyname sometimes broke. especially if kind is not provided.

I changed the code so the addon resolves the correct StoryItem from the storystore and gets it's name & kind.

If it cannot find a StoryItem, it logs an error and does not navigate,

FIX the broken addon links.

Functionality to support navigation by (storyId || kind || kind + storyName || storyName) is now implemented in the linkTo
itself.

It uses the global scope storyStore & clientApi, which isn't good, but we will refactor that later.

The navigate function now refuses to navigate to a story that does not exist.

hrefTo function also no longer throws an error when kind isn't provided

Add test to assert this functionality actually works

@ndelangen ndelangen added this to the 5.3.0 milestone Sep 28, 2019
@ndelangen ndelangen removed the patch:yes Bugfix & documentation PR that need to be picked to main branch label Sep 28, 2019
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.

LGTM

@shilman shilman changed the title Update linkto type to accept function arg Addon-links: Update linkTo type to accept function arg Sep 28, 2019
@shilman shilman changed the title Addon-links: Update linkTo type to accept function arg Addon-links: Update linkTo type to accept function Sep 28, 2019
@shilman shilman merged commit 4c0effd into storybookjs:next Sep 28, 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.

3 participants