]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: emit success and error on copy2cliboard 66630/head
authorNizamudeen A <nia@redhat.com>
Mon, 15 Dec 2025 07:29:45 +0000 (12:59 +0530)
committerNizamudeen A <nia@redhat.com>
Mon, 15 Dec 2025 07:29:45 +0000 (12:59 +0530)
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 <nia@redhat.com>
src/pybind/mgr/dashboard/frontend/src/app/shared/components/copy2clipboard-button/copy2clipboard-button.component.ts

index a17d9e9de6cffbb50634fa248e414e4f0481b294..eef5c053d636be91e17a9c5a0dbb62ff8017d237 100644 (file)
@@ -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<void>();
+
+  @Output()
+  toastError = new EventEmitter<void>();
+
   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();
     }
   }
 }