From a8f9f92b011a93140e4e7447493e602a315b26d1 Mon Sep 17 00:00:00 2001 From: Nizamudeen A Date: Mon, 15 Dec 2025 12:59:45 +0530 Subject: [PATCH] mgr/dashboard: emit success and error on copy2cliboard This is needed since the notification service we have right now is tightly coupled with the dashboard so toast won't show up in the applications where this is being consumed. So emitting an output which the application can use to show relavant toasts. Fixes: https://tracker.ceph.com/issues/74213 Signed-off-by: Nizamudeen A --- .../copy2clipboard-button.component.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/copy2clipboard-button/copy2clipboard-button.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/copy2clipboard-button/copy2clipboard-button.component.ts index a17d9e9de6cf..eef5c053d636 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/copy2clipboard-button/copy2clipboard-button.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/copy2clipboard-button/copy2clipboard-button.component.ts @@ -1,4 +1,4 @@ -import { Component, HostListener, Input } from '@angular/core'; +import { Component, EventEmitter, HostListener, Input, Output } from '@angular/core'; import { detect } from 'detect-browser'; @@ -33,6 +33,12 @@ export class Copy2ClipboardButtonComponent { @Input() text?: string; + @Output() + toastSuccess = new EventEmitter(); + + @Output() + toastError = new EventEmitter(); + icons = Icons; constructor(private notificationService: NotificationService) {} @@ -53,9 +59,11 @@ export class Copy2ClipboardButtonComponent { SUCCESS_TITLE, CLIPBOARD_SUCCESS_MESSAGE ); + this.toastSuccess.emit(); }; const showError = () => { this.notificationService.show(NotificationType.error, ERROR_TITLE, CLIPBOARD_ERROR_MESSAGE); + this.toastError.emit(); }; if (['firefox', 'ie', 'ios', 'safari'].includes(browser.name)) { // Various browsers do not support the `Permissions API`. @@ -80,6 +88,7 @@ export class Copy2ClipboardButtonComponent { } } catch (_) { this.notificationService.show(NotificationType.error, ERROR_TITLE, CLIPBOARD_ERROR_MESSAGE); + this.toastError.emit(); } } } -- 2.47.3