-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Core: Implement Story Actions API and story options menu #29532
Conversation
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 0efd85e. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
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.
13 file(s) reviewed, 15 comment(s)
Edit PR Review Bot Settings | Greptile
if (!id || Object.keys(update).length === 0) { | ||
return; | ||
} |
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.
logic: missing validation for update object structure - could allow invalid action definitions through
} | ||
}); | ||
|
||
await store.setState({ actions: newActions }, { persistence: 'session' }); |
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.
style: consider adding error handling for setState failure
// @ts-expect-error (non strict) | ||
return useMemo(() => ({ hash, entries: Object.entries(hash) }), [hash]); |
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.
logic: This ts-expect-error should be fixed rather than suppressed. The CombinedDataset type likely needs updating to match the new structure.
// @ts-expect-error (non strict) | ||
const selected: Selection = useMemo(() => storyId && { storyId, refId }, [storyId, refId]); |
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.
logic: Another ts-expect-error that should be addressed. The Selection type may need updating to handle null values properly.
}: StoryMenuProps) => { | ||
const [visible, setVisible] = useState(false); | ||
const theme = useTheme(); | ||
const emit = useChannel({}); |
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.
logic: useChannel called with empty object - no event handlers registered but events being emitted. Consider registering cleanup handlers.
const STATUS_ORDER: API_StatusValue[] = ['success', 'error', 'warn', 'pending', 'unknown']; | ||
|
||
const MenuButton = styled(StatusButton)<{ forceVisible: boolean }>(({ forceVisible }) => ({ | ||
visibility: forceVisible ? 'visible' : ('var(--story-menu-visibility, hidden)' as any), |
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.
style: CSS variable cast to any - could cause type errors. Consider using proper CSS-in-JS typing.
})), | ||
]; | ||
|
||
if (!links.some((group) => group.some(Boolean))) { |
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.
style: Boolean check on array items may give false positives for empty objects. Use explicit length check.
title: value.title, | ||
center: value.description, | ||
icon: <PlayHollowIcon color={theme.textMutedColor} />, | ||
onClick: () => emit(value.event, [storyId]), |
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.
style: Emitting event without error handling - add try/catch to handle potential event emission failures.
const managerContext: any = { | ||
api: { | ||
emit: fn().mockName('api::emit'), | ||
on: fn().mockName('api::on'), | ||
off: fn().mockName('api::off'), | ||
}, | ||
}; |
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.
style: managerContext uses 'any' type - consider adding proper typing for the API interface
Closing in favor of #29727 |
Fixes #29107, #29101
Works on #29529
Adds
experimental_updateActions
to enable addons to define runnable actions on stories. During some pairing we decided to simplify this API to just take an event which will be emitted along with an array of story IDs, rather than allowing the addon to define the payload.Adds the story options menu, with ellipsis shown only on hover. Ellipsis is replaced when there's a status icon, in which case it's permanently shown.
Uses the Story Actions API to show actions in the story menu.
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal
,ci:merged
orci:daily
GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.ts
Make sure this PR contains one of the labels below:
Available labels
bug
: Internal changes that fixes incorrect behavior.maintenance
: User-facing maintenance tasks.dependencies
: Upgrading (sometimes downgrading) dependencies.build
: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup
: Minor cleanup style change. Will not show up in release changelog.documentation
: Documentation only changes. Will not show up in release changelog.feature request
: Introducing a new feature.BREAKING CHANGE
: Changes that break compatibility in some way with current major version.other
: Changes that don't fit in the above categories.🦋 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/core
team here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>
Greptile Summary
Here's a concise summary of the key changes in this pull request:
Implements a new Story Actions API and ellipsis menu in the Storybook sidebar for running story-specific actions.
StoryMenu.tsx
component with hover-activated ellipsis menu that displays status icons and runnable actionsexperimental_updateActions
API to enable addons to define and trigger story-specific actionsThe implementation looks solid and follows existing patterns, with proper accessibility support and consistent styling. The changes enable addons to define custom actions that appear in an intuitive UI while maintaining the existing status functionality.