CONSOLE-5273: Expose useToast in the SDK#16400
CONSOLE-5273: Expose useToast in the SDK#16400logonoff wants to merge 1 commit intoopenshift:mainfrom
useToast in the SDK#16400Conversation
|
@logonoff: This pull request references CONSOLE-5273 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
📝 WalkthroughWalkthroughThis pull request exposes the 🚥 Pre-merge checks | ✅ 11 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (11 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@frontend/packages/console-dynamic-plugin-sdk/src/api/core-api.ts`:
- Around line 1029-1030: The JSDoc for the toast context currently only
documents addToast but the returned object also exposes removeToast; update the
doc comment for the function that returns the toast context to list both
addToast and removeToast, describing their signatures/behaviors (addToast —
adds/displays a toast; removeToast — removes a toast by id or reference) and any
return values or edge cases so consumers see the full API surface (referencing
addToast and removeToast by name in the comment).
- Line 1045: The export currently types useToast as the controller shape
UseToast instead of the hook function; change the annotation so useToast is
typed as a function returning that controller (i.e. () => UseToast) while
keeping the same module import (use the existing
require('@console/shared/.../useToast').default) and export signature so call
sites that invoke useToast() type-check correctly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: 6118f30d-b8f6-4866-80d4-8bcfb6e31ed0
📒 Files selected for processing (9)
frontend/packages/console-dynamic-plugin-sdk/docs/api.mdfrontend/packages/console-dynamic-plugin-sdk/docs/console-extensions.mdfrontend/packages/console-dynamic-plugin-sdk/src/api/core-api.tsfrontend/packages/console-dynamic-plugin-sdk/src/extensions/console-types.tsfrontend/packages/console-shared/src/components/toast/ToastContext.tsxfrontend/packages/console-shared/src/components/toast/ToastProvider.tsxfrontend/packages/console-shared/src/components/toast/__tests__/ToastProvider.spec.tsxfrontend/packages/dev-console/src/actions/export-application.tsfrontend/packages/topology/src/components/export-app/ExportApplicationModal.tsx
📜 Review details
🧰 Additional context used
🪛 LanguageTool
frontend/packages/console-dynamic-plugin-sdk/docs/console-extensions.md
[grammar] ~762-~762: Use a hyphen to join words.
Context: ...not specified, render this item as a top level link. | | insertBefore | `string...
(QB_NEW_EN_HYPHEN)
🔇 Additional comments (4)
frontend/packages/console-dynamic-plugin-sdk/docs/console-extensions.md (1)
762-762: LGTM — Documentation reordering is benign.The property table row reordering improves documentation layout consistency. These appear to be auto-generated documentation updates with no functional impact.
Also applies to: 827-827
frontend/packages/dev-console/src/actions/export-application.ts (1)
2-9: Type migration looks consistentGood update switching
toasttoUseToast; this keeps the action contract aligned with the SDK-facing toast API.frontend/packages/console-shared/src/components/toast/ToastProvider.tsx (1)
4-7: Nice consolidation of toast typingsUsing SDK
ToastOptions/UseToasthere keeps provider/context typing consistent with the public plugin API.Also applies to: 52-58
frontend/packages/topology/src/components/export-app/ExportApplicationModal.tsx (1)
39-43: Type alignment is clean across modal and launcherSwitching these signatures to
UseToastkeeps topology code aligned with the SDK contract without altering behavior.Also applies to: 255-259
49ded58 to
c83d324
Compare
57f661c to
3b956c2
Compare
3b956c2 to
fbb4d77
Compare
|
/lgtm |
|
/label plugin-api-approved
tested in demo plugin |
|
@logonoff: This PR has been marked as verified by DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
/label px-approved |
jseseCCS
left a comment
There was a problem hiding this comment.
PR looks good from docs perspective. Just a few placeholder strings to clean up before it's ready to merge. approving in good faith...
| "{{count}} Cron Job": "{{count}} Cron Job", | ||
| "{{count}} Cron Job_plural": "{{count}} Cron Jobs", | ||
| "Cron Jobs": "Cron Jobs", | ||
| "Toast Title": "Toast Title", |
There was a problem hiding this comment.
is this placeholder text that never got replaced?
| "{{count}} Cron Job_plural": "{{count}} Cron Jobs", | ||
| "Cron Jobs": "Cron Jobs", | ||
| "Toast Title": "Toast Title", | ||
| "A great way to start your day is with some toast and a cup of coffee.": "A great way to start your day is with some toast and a cup of coffee.", |
There was a problem hiding this comment.
yup - this is not a user-facing string so i'll leave it
| "Test Utilities": "Test Utilities", | ||
| "Utilities from Dynamic Plugin SDK": "Utilities from Dynamic Plugin SDK", | ||
| "Utility: consoleFetchJSON": "Utility: consoleFetchJSON", | ||
| "Utility: useToast": "Utility: useToast", |
There was a problem hiding this comment.
Change "Utility: useToast" to "Toast Notification Utility"?
There was a problem hiding this comment.
this is not a user-facing string so i'll leave it
| | Name | Value Type | Optional | Description | | ||
| | ---- | ---------- | -------- | ----------- | | ||
| | `id` | `string` | no | A unique identifier for this item. | | ||
| | `section` | `string` | yes | Navigation section to which this item belongs to. If not specified, render this item as a top level link. | |
There was a problem hiding this comment.
--> Navigation to which this item belongs.
OR
--> Navigation this item belongs to.
that old rule about no dangling prepositions is no more.
There was a problem hiding this comment.
I believe this is a pre-existing issue so I'll fix this in future work
| For older 1.x plugin SDK packages, refer to "OpenShift Console Versions vs SDK Versions" compatibility | ||
| table in [Console dynamic plugins README](./README.md). | ||
|
|
||
| ## 4.23.0-prerelease.1 - TBD |
There was a problem hiding this comment.
will someone update the TBD with an actual date before merging?
There was a problem hiding this comment.
This gets updated when the SDK gets published
|
Just a few placeholder strings to clean up before it's ready to merge. otherwise looks good! approving in good faith... |
|
/label docs-approved |
Expose a useToast hook in the plugin SDK and centralize toast types/values across packages. Added UseToast export and documentation examples in core-api and updated API/docs/CHANGELOG to announce the new hook. Introduced ToastOptions/ToastContextValues types in console-types and switched ToastContext, ToastProvider, tests, and various consumers (demo plugin, topology export, dev-console action) to use the new types. Updated dynamic-demo-plugin to demonstrate showing/dismissing toasts and adjusted tests to use AlertVariant. Small UI/layout tweaks (Gallery) for the demo page.
fbb4d77 to
1bb7a1a
Compare
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jseseCCS, logonoff, vojtechszocs The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/verified by @logonoff |
|
@logonoff: This PR has been marked as verified by DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
/test all |
|
@logonoff: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |


Solution description:
Exposes
useToastand related types incore-apias a dynamic requireTest cases:
Try it in a plugin
Summary by CodeRabbit
New Features
Documentation