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 <pjfitz@amazon.com> * Toasts use hook from useOpenSearchDashboards context provider Signed-off-by: Peter Fitzgibbons <pjfitz@amazon.com> * Testing for CustomPanel Toast Signed-off-by: Peter Fitzgibbons <pjfitz@amazon.com> * update catches from comments, minor code cleaning Signed-off-by: Shenoy Pratik <sgguruda@amazon.com> * update tests Signed-off-by: Shenoy Pratik <sgguruda@amazon.com> * remove unused redux slice Signed-off-by: Shenoy Pratik <sgguruda@amazon.com> * revert cypress changes Signed-off-by: Shenoy Pratik <sgguruda@amazon.com> * add toasts to SOflyout Signed-off-by: Shenoy Pratik <sgguruda@amazon.com> * fix messaging for multiple delete Signed-off-by: Derek Ho <dxho@amazon.com> * fix up toast and error handling for create and delete flows Signed-off-by: Derek Ho <dxho@amazon.com> * fix up clone Signed-off-by: Derek Ho <dxho@amazon.com> * fix rename in table Signed-off-by: Derek Ho <dxho@amazon.com> * fix rename in custom panel so view Signed-off-by: Derek Ho <dxho@amazon.com> * fix up panel toasts Signed-off-by: Derek Ho <dxho@amazon.com> * fix up for flyout Signed-off-by: Derek Ho <dxho@amazon.com> * code cleanup Signed-off-by: Derek Ho <dxho@amazon.com> * finish merge Signed-off-by: Derek Ho <dxho@amazon.com> * fix up PR comments Signed-off-by: Derek Ho <dxho@amazon.com> --------- Signed-off-by: Peter Fitzgibbons <pjfitz@amazon.com> Signed-off-by: Shenoy Pratik <sgguruda@amazon.com> Signed-off-by: Derek Ho <dxho@amazon.com> Co-authored-by: Peter Fitzgibbons <pjfitz@amazon.com> Co-authored-by: Derek Ho <dxho@amazon.com> (cherry picked from commit a9d1d37) Signed-off-by: Derek Ho <dxho@amazon.com>
- Loading branch information
1 parent
2b7c21a
commit ff22120
Showing
15 changed files
with
248 additions
and
270 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
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
Oops, something went wrong.