-
Notifications
You must be signed in to change notification settings - Fork 78
Toast on CustomPanels #415
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { CoreStart, ToastsStart } from '../../../../src/core/public'; | ||
|
|
||
| export interface ObservabilityAppServices extends CoreStart { | ||
| toasts: ToastsStart; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import React from 'react'; | ||
| import { useOpenSearchDashboards } from '../../../../../../src/plugins/opensearch_dashboards_react/public'; | ||
| import { ToastInputFields } from '../../../../../../src/core/public'; | ||
| import { ObservabilityAppServices } from '../../../../common/types/shared'; | ||
|
|
||
| type Color = 'success' | 'primary' | 'warning' | 'danger' | undefined; | ||
|
|
||
| export const useToast = () => { | ||
| const { | ||
| services: { toasts }, | ||
| } = useOpenSearchDashboards<ObservabilityAppServices>(); | ||
|
|
||
| const setToast = (title: string, color: Color = 'success', text?, side?: string) => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can remove the side parameter, if not being used.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Side is used when toast during flyout. So unless toast on right-side is OK while visualization flyout and others are active, only then could we remove it. Side is being passed-through on OSD API
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I may be missing something here. Can you please explain how are you using/passing down the side parameter in this function? |
||
| const newToast: ToastInputFields = { | ||
| id: new Date().toISOString(), | ||
| title, | ||
| text, | ||
| }; | ||
| switch (color) { | ||
| case 'danger': { | ||
| toasts.addDanger(newToast); | ||
| break; | ||
| } | ||
| case 'warning': { | ||
| toasts.addWarning(newToast); | ||
| break; | ||
| } | ||
| default: { | ||
| toasts.addSuccess(newToast); | ||
| break; | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| return { setToast }; | ||
| }; | ||
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.
I feel the
.only,commented codeandconsole.logadditions were part of cypress debugging. We can remove these.