forked from opensearch-project/dashboards-observability
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Toasts to Observability Dashboards (opensearch-project#435)
* Fixes * Panel View (legacy) - Duplicate - Rename Signed-off-by: Peter Fitzgibbons <[email protected]> * Toasts use hook from useOpenSearchDashboards context provider Signed-off-by: Peter Fitzgibbons <[email protected]> * Testing for CustomPanel Toast Signed-off-by: Peter Fitzgibbons <[email protected]> * update catches from comments, minor code cleaning Signed-off-by: Shenoy Pratik <[email protected]> * update tests Signed-off-by: Shenoy Pratik <[email protected]> * remove unused redux slice Signed-off-by: Shenoy Pratik <[email protected]> * revert cypress changes Signed-off-by: Shenoy Pratik <[email protected]> * add toasts to SOflyout Signed-off-by: Shenoy Pratik <[email protected]> * fix messaging for multiple delete Signed-off-by: Derek Ho <[email protected]> * fix up toast and error handling for create and delete flows Signed-off-by: Derek Ho <[email protected]> * fix up clone Signed-off-by: Derek Ho <[email protected]> * fix rename in table Signed-off-by: Derek Ho <[email protected]> * fix rename in custom panel so view Signed-off-by: Derek Ho <[email protected]> * fix up panel toasts Signed-off-by: Derek Ho <[email protected]> * fix up for flyout Signed-off-by: Derek Ho <[email protected]> * code cleanup Signed-off-by: Derek Ho <[email protected]> * finish merge Signed-off-by: Derek Ho <[email protected]> * fix up PR comments Signed-off-by: Derek Ho <[email protected]> --------- Signed-off-by: Peter Fitzgibbons <[email protected]> Signed-off-by: Shenoy Pratik <[email protected]> Signed-off-by: Derek Ho <[email protected]> Co-authored-by: Peter Fitzgibbons <[email protected]> Co-authored-by: Derek Ho <[email protected]> (cherry picked from commit a9d1d37) Signed-off-by: Derek Ho <[email protected]>
- Loading branch information
1 parent
3340703
commit 2f4ba15
Showing
14 changed files
with
1,990 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,37 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { ToastInputFields } from '../../../../../../src/core/public'; | ||
import { coreRefs } from '../../../framework/core_refs'; | ||
|
||
type Color = 'success' | 'primary' | 'warning' | 'danger' | undefined; | ||
|
||
export const useToast = () => { | ||
const toasts = coreRefs.toasts!; | ||
|
||
const setToast = (title: string, color: Color = 'success', text?: string) => { | ||
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 }; | ||
}; |
This file contains 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.