]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard:Fixed issue with clipboard icon
authorAfreen Misbah <afreen@ibm.com>
Thu, 10 Jul 2025 20:29:12 +0000 (01:59 +0530)
committerAfreen Misbah <afreen@ibm.com>
Tue, 26 Aug 2025 14:08:08 +0000 (19:38 +0530)
- clipboard icon not displaying breaking several places
- cliboard icon on click gets filed primary green color losing the visibilty of icon. The icon now remain visible on click
- clipboard button for path and copy in tables on mouseover does not give `hand` but `cursor`. which was not ideal from a usability standpoint. This behavior has been updated to use the hand cursor making the interaction semantically correct and more intuitive for users.

Signed-off-by: Afreen Misbah <afreen@ibm.com>
(cherry picked from commit 1dd42e1a339ef4cf1f3253534646aa6c9342233d)

Conflicts:
       src/pybind/mgr/dashboard/frontend/src/app/shared/components/copy2clipboard-button/copy2clipboard-button.component.html

12 files changed:
src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-snapshotschedule-list/cephfs-snapshotschedule-list.component.html
src/pybind/mgr/dashboard/frontend/src/app/shared/components/card-row/card-row.component.html
src/pybind/mgr/dashboard/frontend/src/app/shared/components/copy2clipboard-button/copy2clipboard-button.component.html
src/pybind/mgr/dashboard/frontend/src/app/shared/components/copy2clipboard-button/copy2clipboard-button.component.scss
src/pybind/mgr/dashboard/frontend/src/app/shared/components/copy2clipboard-button/copy2clipboard-button.component.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/components/icon/icon.component.html
src/pybind/mgr/dashboard/frontend/src/app/shared/components/icon/icon.component.scss
src/pybind/mgr/dashboard/frontend/src/app/shared/components/icon/icon.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/components/icon/icon.component.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.html
src/pybind/mgr/dashboard/frontend/src/app/shared/enum/icons.enum.ts
src/pybind/mgr/dashboard/frontend/src/styles/_carbon-defaults.scss

index ee790712d16810112268808a62b96c2f1ebbedd6..46d6c0f1848a390b51b1e8f8ba6d46ea6c6ec6c9 100644 (file)
   </ng-template>
 
   <ng-template #fullpathForSelectionTpl>
-    <span
-      data-toggle="tooltip"
-      [title]="row.pathForSelection"
-      class="font-monospace"
-      >{{ row.pathForSelection?.split?.("@")?.[0] }}
-      <cd-copy-2-clipboard-button
-        *ngIf="row.pathForSelection"
-        [source]="row.pathForSelection?.split?.('@')?.[0]"
-        [byId]="false"
-        [showIconOnly]="true"
-      >
-      </cd-copy-2-clipboard-button>
-    </span>
+    <cd-copy-2-clipboard-button
+      *ngIf="row.pathForSelection"
+      [source]="row.pathForSelection?.split?.('@')?.[0]"
+      [byId]="false"
+      [size]="lg"
+      [text]="row.pathForSelection?.split?.('@')?.[0]"
+    >
+    </cd-copy-2-clipboard-button>
   </ng-template>
 </ng-template>
 
index 2a41e3e7faaab2e6f406f25666003e715dba0f43..80e150ded48ef7a01e03ca21b4e51b76ce15e02e 100644 (file)
@@ -71,7 +71,7 @@
       {{ data.info }}
     </span>
     <cd-icon
-       type="info">
+       type="infoCircle">
     </cd-icon >
   </span>
   <span *ngIf="data.warn || data.categoryPgAmount?.warning"
   </span>
   }
 </ng-template>
-<cd-icon
-       type="progress">
-    </cd-icon >
+
 <ng-template #osdSummary>
   @if (data === null) {
   <ng-container *ngTemplateOutlet="loadingTpl"></ng-container>
index 8581a51109aca0dfc5d4753fdd79e2217e533c12..4046a4e2a21535097975f949b142787f1a71c3da 100644 (file)
@@ -1,17 +1,15 @@
-<i [ngClass]="[icons.clipboard, icons.large]"
-   (click)="onClick()"
-   class="text-primary ms-2"
-   title="Copy to Clipboard"
-   *ngIf="showIconOnly; else withButtonTpl"></i>
 
-<ng-template #withButtonTpl>
-
-  <cds-icon-button kind="tertiary"
-                   size="md"
-                   title="Copy to Clipboard"
-                   (click)="onClick()">
-    <svg cdsIcon="copy"
-         size="32"
-         class="cds--btn__icon"></svg>
-  </cds-icon-button>
-</ng-template>
+<button cdsButton="ghost"
+        class="clipboard-btn"
+        [ngClass]="{'clipboard-btn-with-text': text}"
+        [size]="size"
+        description="Copy to Clipboard"
+        i18n-description
+        (click)="onClick()">
+  @if(text) {
+  <span data-toggle="tooltip"
+        [title]="text"
+        class="cds--type-mono">{{text}}</span>
+  }
+  <cd-icon type="copy"></cd-icon>
+</button>
index b6b8ca77e8adbcfca8a1f019404328e7cf9c8510..2b82b76f5a512cb9de784507b5182e5dbf5af22d 100644 (file)
@@ -11,14 +11,21 @@ import { Icons } from '~/app/shared/enum/icons.enum';
   styleUrls: ['./copy2clipboard-button.component.scss']
 })
 export class Copy2ClipboardButtonComponent {
+  // The text to be copied
   @Input()
   private source: string;
 
+  // Optional: Extracts text to be copied by "id" attribute
   @Input()
   byId = true;
 
+  // Size of the button
   @Input()
-  showIconOnly = false;
+  size = 'md';
+
+  // Optional: Adds text to the left of copy icon
+  @Input()
+  text?: string;
 
   icons = Icons;
 
index 2e6522bd9389124ff97b792d8373779f06df0b80..f1182dd46d037e9c1cf9f5e4f0a73bfb1cde6292 100644 (file)
@@ -1,23 +1,3 @@
-@if (type === ICON_TYPE.danger) {
-    <svg class = "danger-icon"
-         [cdsIcon]="ICONS.danger"
-         [size]="size"></svg>
-}
-
-@if (type === ICON_TYPE.info) {
-    <svg class = "info-icon"
-         [cdsIcon]="ICONS.infoCircle"
-         [size]="size"></svg>
-}
-
-@if (type === ICON_TYPE.success) {
-    <svg class = "success-icon"
-         [cdsIcon]="ICONS.success"
-         [size]="size"></svg>
-}
-
-@if (type === ICON_TYPE.warning) {
-    <svg class = "warning-icon"
-         [cdsIcon]="ICONS.warning"
-         [size]="size"></svg>
-}
+<svg  [cdsIcon]="icon"
+      [size]="size"
+      [class]="type+'-icon'"></svg>
index e0a3d2050b34ea22f906139a0731462763ad2400..96e563783678d246cf45fa308a521d190d4bb079 100644 (file)
@@ -8,7 +8,9 @@
   color: theme.$support-error;
 }
 
-.info-icon {
+//@TODO: this naming needs to be changed
+// Do this after converting Icons enum to const
+.infoCircle-icon {
   color: theme.$support-info;
 }
 
index c14459401a61740d4e147899598b2d55019d3c3e..720480b0960e58490c185c1d35b495b1b3876211 100644 (file)
@@ -1,16 +1,18 @@
 import { ComponentFixture, TestBed } from '@angular/core/testing';
 
+import { configureTestBed } from '~/testing/unit-test-helper';
 import { IconComponent } from './icon.component';
 
 describe('IconComponent', () => {
   let component: IconComponent;
   let fixture: ComponentFixture<IconComponent>;
 
-  beforeEach(async () => {
-    await TestBed.configureTestingModule({
-      imports: [IconComponent]
-    }).compileComponents();
+  configureTestBed({
+    declarations: [IconComponent],
+    imports: []
+  });
 
+  beforeEach(() => {
     fixture = TestBed.createComponent(IconComponent);
     component = fixture.componentInstance;
     fixture.detectChanges();
index 82bb1981836aadd6bfb71c46192319ef5d0a6eb7..ef3ad63500f27780dca4ca039aff3dbf326eebc3 100644 (file)
@@ -1,15 +1,18 @@
-import { Component, Input } from '@angular/core';
-import { ICON_TYPE, Icons, IconsSize } from '../../enum/icons.enum';
+import { Component, Input, OnInit } from '@angular/core';
+import { ICON_TYPE, IconSize } from '../../enum/icons.enum';
 
 @Component({
   selector: 'cd-icon',
   templateUrl: './icon.component.html',
   styleUrl: './icon.component.scss'
 })
-export class IconComponent {
+export class IconComponent implements OnInit {
   @Input() type!: keyof typeof ICON_TYPE;
-  @Input() size: IconsSize = IconsSize.size16;
+  @Input() size: IconSize = IconSize.size16;
 
-  readonly ICONS = Icons;
-  readonly ICON_TYPE = ICON_TYPE;
+  icon: string;
+
+  ngOnInit() {
+    this.icon = ICON_TYPE[this.type];
+  }
 }
index 971bd96a4abffdb04f24d681307bb7edf348bf42..b3f18340821faef65ca1110827bb683058d039e1 100644 (file)
 
 <ng-template #pathTpl
              let-value="data.value">
-  <span data-toggle="tooltip"
-        [title]="value"
-        class="font-monospace">{{ value | path }}
-    <cd-copy-2-clipboard-button *ngIf="value"
-                                [source]="value"
-                                [byId]="false"
-                                [showIconOnly]="true">
-    </cd-copy-2-clipboard-button>
-  </span>
+  <cd-copy-2-clipboard-button *ngIf="value"
+                              [source]="value"
+                              [byId]="false"
+                              size="lg"
+                              text="{{ value | path }}">
+  </cd-copy-2-clipboard-button>
 </ng-template>
 
 <ng-template #copyTpl
              let-value="data.value">
-  <span class="font-monospace">{{value}}</span>
   <cd-copy-2-clipboard-button *ngIf="value"
                               [source]="value"
                               [byId]="false"
-                              [showIconOnly]="true">
+                              [size]="lg"
+                              [text]="value">
   </cd-copy-2-clipboard-button>
 </ng-template>
index 458ca296f60a72d799519ebfb8d7503de4642a4a..e6afb14ef803b3242bda9815ff1b80dddedb72c9 100644 (file)
@@ -98,7 +98,7 @@ export enum Icons {
   inverse = 'fa fa-inverse' // To get an alternative icon color
 }
 
-export enum IconsSize {
+export enum IconSize {
   size16 = '16',
   size20 = '20',
   size24 = '24',
@@ -107,7 +107,7 @@ export enum IconsSize {
 
 export const ICON_TYPE = {
   danger: 'warning--filled',
-  info: 'information--filled',
+  infoCircle: 'information--filled',
   success: 'checkmark--filled',
   warning: 'warning--alt--filled'
-} as const;
\ No newline at end of file
+} as const;
index 61ad991178a7a19375b75221ebb2dca469fb5253..32b13c08012b3e22f4eac686f561b9957467a9ef 100644 (file)
@@ -42,6 +42,10 @@ Custom theme
 Datatable
 ******************************************/
 
+:root {
+  @include type.type-classes();
+}
+
 tr.cds--expandable-row > td:first-of-type {
   background-color: vv.$white !important;
   padding-inline-start: 1rem !important;