From: Nizamudeen A Date: Mon, 15 Dec 2025 07:29:45 +0000 (+0530) Subject: mgr/dashboard: emit success and error on copy2cliboard X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F66630%2Fhead;p=ceph.git 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 --- 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(); } } }