Update to Storybook 10 - #205
Conversation
It is pinned to @typescript-eslint/parser 5.x and blocks us from upgrading Typescript. The whole CRA project is deprecated anyways https://github.com/react/create-react-app/blob/main/packages/eslint-config-react-app/package.json We also remove eslint-plugin-flowtype since we don't use Flow at all
There was a problem hiding this comment.
Pull request overview
Upgrades the Storybook tooling from v6 to v10, replacing the legacy globals-based addon integration with a channel/event-based approach and migrating story/decorator typings to the new @storybook/react-webpack5 package. The auth and project-selection toolbar addons are rewritten against storybook/manager-api and storybook/internal/components, and a shared preview decorator listens to those channel events to inject accessToken / iTwinId into story args.
Changes:
- Migrate Storybook config to v10 (
main.ts, newpreview.tsx, framework@storybook/react-webpack5, SWC compiler, droppedaddon-essentials/addon-actions/addon-linksand@storybook/addons/api/components/theming). - Rewrite
storybook-auth-addonandsrc/addonmanager entries to usestorybook/manager-api,storybook/internal/components,@storybook/icons, and a customACCESS_TOKEN_EVENT/ITWIN_ID_EVENTchannel instead ofuseGlobals/updateGlobals. - Update all
*.stories.tsxfiles to useStoryFn/Metafrom@storybook/react-webpack5, remove thewithAccessTokenOverride/withITwinIdOverrideHOCs, and adapt a few stories (decorators for CreateIModel/UpdateIModel, removed hard-codediTwinIddefault).
Reviewed changes
Copilot reviewed 26 out of 27 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/apps/storybook/package.json | Switch deps/scripts to Storybook 10 + SWC + react-webpack5. |
| packages/apps/storybook/.storybook/main.ts | New TS Storybook config replacing main.js, with framework, addons and webpack aliases. |
| packages/apps/storybook/.storybook/main.js | Removed (replaced by main.ts). |
| packages/apps/storybook/.storybook/preview.tsx | New decorator that subscribes to channel events and injects accessToken/iTwinId into args. |
| packages/apps/storybook/.storybook/preview.js | Removed (replaced by preview.tsx). |
| packages/apps/storybook/.storybook/itwinTheme.js | Update create import to storybook/theming. |
| packages/apps/storybook/src/addon/manager.jsx | Rewrite project toolbar addon for Storybook 10 (channel events, click-trigger tooltip, SvgItwin icon). |
| packages/apps/storybook/src/addon/preset.js | New preset registering manager.jsx. |
| packages/modules/storybook-auth-addon/manager.jsx | Rewrite auth addon for Storybook 10 with channel events and @storybook/icons. |
| packages/modules/storybook-auth-addon/preset.js | New preset registering manager.jsx. |
| packages/modules/storybook-auth-addon/package.json | Replace `@storybook/addons |
| packages/apps/storybook/src/utils/storyHelp.ts | Drop withAccessTokenOverride / withITwinIdOverride HOCs and Story import. |
| packages/apps/storybook/src/**/(*.stories.tsx) | Replace Story with StoryFn from @storybook/react-webpack5, drop HOC wrappers, minor cleanups (decorators, void on fire-and-forget call, formatting). |
Comments suppressed due to low confidence (2)
packages/modules/storybook-auth-addon/manager.jsx:133
- The previous implementation rendered an animated
Loaderspinner while authentication was in flight; it has been replaced with the static text<span>...</span>, which is a visual regression (no longer indicates progress, and is not accessible as a busy indicator). Consider using an actual spinner component from@storybook/iconsorstorybook/internal/componentsinstead of a literal ellipsis string.
packages/apps/storybook/src/addon/manager.jsx:141 - The previous IconButton had
onClick={() => updateGlobals({ iTwinId: "" })}to clear the currently-selected iTwin, andonMouseEnter={() => fetchProjects()}to prefetch the favorites list. Both handlers were removed and the new code only fetches projects when the tooltip becomes visible. SinceWithTooltipnow usestrigger="click", clicking the button only opens the tooltip — there is no longer any way to clear the selection directly from the toolbar (the user has to open the menu and click the active item). The title still advertises "(click to unselect)" when something is selected, which is misleading. Either restore an onClick that clearsselectedId(and emits the event) or update the title text to match the new behavior.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This reverts commit 373d4f9.
9c67282 to
550b434
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 34 out of 35 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (5)
packages/modules/storybook-auth-addon/manager.jsx:91
- In the
catchblock,setState({ loading: false })will replace the entire addon state value, clearingemail/accessTokenunexpectedly. Use a merging functional update (or set all fields explicitly).
packages/apps/storybook/src/addon/manager.jsx:138 - The tooltip trigger is
click, but the IconButton no longer has an onClick that clears the selection. The title string still says "(click to unselect)", which is misleading (unselecting currently requires clicking the active project inside the tooltip list). Consider updating the title to match the actual interaction.
packages/modules/storybook-auth-addon/manager.jsx:15 - Importing UI components from
storybook/internal/componentsrelies on Storybook internal (non-public) APIs that may change without notice. For addon UIs, prefer the public@storybook/componentspackage (and adjust dependencies accordingly) to avoid breakage across Storybook updates.
packages/apps/storybook/src/addon/manager.jsx:16 storybook/internal/componentsis an internal import path and not a stable public API. For a custom manager addon, prefer importingIconButton,WithTooltip, etc. from the supported@storybook/componentspackage (and ensure it is listed in dependencies) to reduce upgrade risk.
packages/apps/storybook/src/addon/manager.jsx:73useAddonStatebehaves like ReactuseState(it replaces the stored value; it does not merge objects). ThissetState({ projects: ... })call will replace the full{ mustLoad, projects, ... }state, which can makestate.mustLoadbecomeundefinedand changefetchProjectscontrol flow. The same issue applies to the latersetState({ projects: projects })after a successful fetch—use a functional update that preserves other fields (and consider settingmustLoad: falseafter the initial load).
Based on #202
Update to Storybook 10
Replace
withAccessTokenOverrideHOC with Storybook argsUse Storybook channels for auth add on
Fixed dark mode
Updated Storybook add-on buttons etc... to non-deprecated components
Fixes #108