-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
UI: Add isolation mode shortcut #33074
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
Open
yannbf
wants to merge
19
commits into
next
Choose a base branch
from
yann/add-isolation-mode-shortcut
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
a0745ab
UI: Add isolation mode shortcut
yannbf 50cc86d
Core: Add openInIsolation method to Storybook API
yannbf 32fc146
Document api methods
yannbf a25cbd7
move openInIsolation to story module
yannbf e1d1ab4
Merge branch 'next' into yann/add-isolation-mode-shortcut
ndelangen 0ac7ecd
Merge branch 'next' into yann/add-isolation-mode-shortcut
yannbf e4ca504
Merge branch 'yann/add-isolation-mode-shortcut' of github.com:storybo…
yannbf eb99b4d
Merge branch 'next' into yann/add-isolation-mode-shortcut
ndelangen cb0846b
Merge branch 'next' into yann/add-isolation-mode-shortcut
yannbf 27582a0
remove unnecessary types
yannbf 19b37e9
Merge branch 'yann/add-isolation-mode-shortcut' of github.com:storybo…
yannbf b1f7c9f
Merge branch 'next' into yann/add-isolation-mode-shortcut
yannbf 2c0792d
Merge branch 'next' into yann/add-isolation-mode-shortcut
yannbf 577be7b
fix tests
yannbf 2c7459d
Merge branch 'next' into yann/add-isolation-mode-shortcut
ndelangen e6d9ba4
Merge branch 'next' into yann/add-isolation-mode-shortcut
ndelangen 86fcfd2
Merge branch 'next' into yann/add-isolation-mode-shortcut
yannbf 1c4b8fc
Merge branch 'next' into yann/add-isolation-mode-shortcut
yannbf edc546d
Merge branch 'next' into yann/add-isolation-mode-shortcut
valentinpalkovic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| ```js | ||
| import { addons } from '@storybook/manager-api'; | ||
| import { CheckIcon } from '@storybook/icons'; | ||
|
|
||
| addons.register('my-organisation/my-addon', (api) => { | ||
| // Add a simple notification | ||
| api.addNotification({ | ||
| id: 'my-notification', | ||
| content: { | ||
| headline: 'Action completed', | ||
| subHeadline: 'Your changes have been saved successfully', | ||
| }, | ||
| duration: 5000, // 5 seconds | ||
| }); | ||
|
|
||
| // Add a notification with an icon | ||
| api.addNotification({ | ||
| id: 'success-notification', | ||
| content: { | ||
| headline: 'Success!', | ||
| subHeadline: 'Operation completed successfully', | ||
| }, | ||
| icon: <CheckIcon />, | ||
| duration: 3000, | ||
| }); | ||
| }); | ||
| ``` | ||
ndelangen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| ```js | ||
| addons.register('my-organisation/my-addon', (api) => { | ||
| // Get data about the currently selected story | ||
| const storyData = api.getCurrentStoryData(); | ||
| console.log('Current story:', storyData.id, storyData.title); | ||
| }); | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| ```js | ||
| addons.register('my-organisation/my-addon', (api) => { | ||
| // Open a file in the editor | ||
| api.openInEditor({ | ||
| file: './src/components/Button.tsx', | ||
| }); | ||
|
|
||
| // Handle the api response | ||
| api | ||
| .openInEditor({ | ||
| file: './src/components/Button.tsx', | ||
| line: 42, | ||
| column: 15, | ||
| }) | ||
| .then((response) => { | ||
| if (response.error) { | ||
| console.error('Failed to open file:', response.error); | ||
| } else { | ||
| console.log('File opened successfully'); | ||
| } | ||
| }); | ||
| }); | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| ```js | ||
| addons.register('my-organisation/my-addon', (api) => { | ||
| // Open the current story in isolation mode | ||
| api.openInIsolation('button--primary'); | ||
|
|
||
| // Open a story from an external ref in isolation | ||
| api.openInIsolation('external-button--secondary', 'external-ref'); | ||
|
|
||
| // Open a story in docs view mode | ||
| api.openInIsolation('button--primary', null, 'docs'); | ||
| }); | ||
| ``` | ||
yannbf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| ```js | ||
| addons.register('my-organisation/my-addon', (api) => { | ||
| // Toggle fullscreen mode | ||
| api.toggleFullscreen(); | ||
|
|
||
| // Enable fullscreen | ||
| api.toggleFullscreen(true); | ||
|
|
||
| // Disable fullscreen | ||
| api.toggleFullscreen(false); | ||
| }); | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| ```js | ||
| addons.register('my-organisation/my-addon', (api) => { | ||
| // Toggle panel visibility | ||
| api.togglePanel(); | ||
|
|
||
| // Show the panel | ||
| api.togglePanel(true); | ||
|
|
||
| // Hide the panel | ||
| api.togglePanel(false); | ||
| }); | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🛠️ Refactor suggestion | 🟠 Major
Add validation for invalid
refIdto match existing patterns.The implementation should validate that
refIdexists in therefsmap when provided, similar to theresolveStorymethod (line 350-353). Currently, if an invalidrefIdis provided, the code silently falls back to the local iframe URL, which could mask configuration errors.Apply this diff to add validation:
openInIsolation: (storyId, refId, viewMode) => { const { location } = global.document; const { refs, customQueryParams, viewMode: currentViewMode } = store.getState(); - // Get the ref object from refs map using refId + // Validate and get the ref object from refs map using refId + if (refId && !refs[refId]) { + logger.warn(`Ref with id ${refId} does not exist`); + return; + } + const ref = refId ? refs[refId] : null; let baseUrl = `${location.origin}${location.pathname}`;This ensures consistent behavior across the API and provides clear feedback when an invalid
refIdis used.🤖 Prompt for AI Agents