diff --git a/plugins/plugin-client-common/src/components/Client/Screenshot.tsx b/plugins/plugin-client-common/src/components/Client/Screenshot.tsx index 824a93c93a5..506bd126304 100644 --- a/plugins/plugin-client-common/src/components/Client/Screenshot.tsx +++ b/plugins/plugin-client-common/src/components/Client/Screenshot.tsx @@ -17,7 +17,8 @@ import * as React from 'react' import { Event, NativeImage } from 'electron' import { i18n, eventChannelUnsafe } from '@kui-shell/core' -import { Button, ToastNotification } from 'carbon-components-react' +import Alert from '../spi/Alert' +import { Button } from 'carbon-components-react' import '../../../web/css/static/Screenshot.scss' @@ -257,26 +258,33 @@ export default class Screenshot extends React.PureComponent { ) } + private closeNotification() { + this.setState({ isActive: false, captured: undefined }) + } + /** Render a ToastNotification to tell the user what we captured */ private notification() { if (this.state && this.state.captured) { const timeout = 10 * 1000 + const alert = { + type: 'success' as const, + title: strings('Screenshot'), + body: strings('Successfully captured a screenshot to the clipboard') + } + return ( - this.setState({ isActive: false, captured: undefined })} + onCloseButtonClick={this.closeNotification.bind(this)} >
{this.saveToDiskButton()}
-
+ ) } } diff --git a/plugins/plugin-client-common/src/components/spi/Alert/impl/Carbon.tsx b/plugins/plugin-client-common/src/components/spi/Alert/impl/Carbon.tsx index 5bb0e3ffd45..6884bb56dba 100644 --- a/plugins/plugin-client-common/src/components/spi/Alert/impl/Carbon.tsx +++ b/plugins/plugin-client-common/src/components/spi/Alert/impl/Carbon.tsx @@ -25,18 +25,21 @@ export default class Alert extends React.PureComponent { public render() { return ( + onCloseButtonClick={this.props.onCloseButtonClick} + > + {this.props.children} + ) } } diff --git a/plugins/plugin-client-common/src/components/spi/Alert/model.ts b/plugins/plugin-client-common/src/components/spi/Alert/model.ts index ce8154713c7..b061810d5e6 100644 --- a/plugins/plugin-client-common/src/components/spi/Alert/model.ts +++ b/plugins/plugin-client-common/src/components/spi/Alert/model.ts @@ -13,10 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import * as React from 'react' import { ToolbarAlert } from '@kui-shell/core' interface Props { alert: ToolbarAlert + id?: string + timeout?: number + children?: React.ReactNode + className?: string + onCloseButtonClick?: () => void } export default Props