-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Feature: Add experimental status API #22890
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks okay, I can imagine that we'd want more meta info about the status:
type StatusUpdate = {
status: Status;
reporter: string; // addon name, or similar
summary?: string;
description?: string;
};
setStatus({
status: "error",
reporter: "@storybook/addon-a11y",
summary: "The story fails 2 accessibility tests",
description: 'The following tests failed: "missing-label", "img-missing-alt"'
})
@JReinhold you suggestion would have to look like this: setStatus({
'a-story-id': {
'storybook/addon-a11y': {
status: "error",
reporter: "@storybook/addon-a11y",
summary: "The story fails 2 accessibility tests",
description: 'The following tests failed: "missing-label", "img-missing-alt"'
}
}
}) The API needs to be able to set the status of multiple stories in 1 API-call to minimize re-renders. |
@ndelangen should you be able to set >1 different addon at once though? I was thinking more like: setStatus(
'storybook/addon-a11y', {
'a-story-id': {
status: "error",
summary: "The story fails 2 accessibility tests",
description: 'The following tests failed: "missing-label", "img-missing-alt"'
}
}) |
When reading the data from store later, having the relationship be: story_id => give me all statusses Is easier & faster when the story_id is the primary key. I made it this structure with the sidebar needing this data later in mind. I could -for sure- have the API be one way, and the actual data the other way, complicating the API code a little bit, but I'm more concerned about the confusion it would bring to addon-creators. |
I think @ndelangen's API suggestion makes the most sense. But given that the change is keyed by addon id, we don't necessarily need the reporter too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job & nice tests!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading the comments, I agree with the status object { status, reporter, description, details }
(exact structure TBD) suggestion. I also think @tmeasday 's suggestion of setStatus('addon-id', statusObject)
makes sense. We can store the data however we want, but that seems like a good API simplification
I would have thought addon creators needing to know to set the right |
I'll make the change, thank you for the comments, all! |
So here's the next iteration: storybook/code/lib/manager-api/src/tests/stories.test.ts Lines 1703 to 1731 in dbfb567
The reason for this change is: The user of the API only has to state their addon_id once. The update object now has a bunch of presentational fields on it, like 'title' & 'description'. The enum value is now This has me thinking if this API is pretty much all we need for "reports". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM apart from some small quality of life improvements.
This is a proposal/implementation of a new (manager) API for storybook.
This adds the ability to assign a status to stories. Multiple statusses to be exact.
This status information can then be used in the sidebar, or addons.
The API allows addons to call:
api.setStatus({})
.You can see tests in this PR for more in-depth examples.
I am considering adding for information, it would be nice if there was also a displayname, perhaps and some additional information the addon could except for just the raw "statuc" (which is a enum in this proposal).
Feedback is welcome.
Use-cases for this API:
The a11y addon could use this addon to set which stories have passed the check, and which ones need attention.
The coverage addon can highlight which stories fall below the coverage threshold.
The plan is that long-term there will be a "run report/testrunner over all my stories" within storybook itself.
Setting a status will be a key way to store information about individual stories from addons, that then can be consumed everywhere.