Skip to content

Commit 1dd42e1

Browse files
committed
mgr/dashboard:Fixed issue with clipboard icon
- 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 <[email protected]>
1 parent fa51604 commit 1dd42e1

File tree

12 files changed

+77
-84
lines changed

12 files changed

+77
-84
lines changed

src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-snapshotschedule-list/cephfs-snapshotschedule-list.component.html

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,14 @@
3838
</ng-template>
3939

4040
<ng-template #fullpathForSelectionTpl>
41-
<span
42-
data-toggle="tooltip"
43-
[title]="row.pathForSelection"
44-
class="font-monospace"
45-
>{{ row.pathForSelection?.split?.("@")?.[0] }}
46-
<cd-copy-2-clipboard-button
47-
*ngIf="row.pathForSelection"
48-
[source]="row.pathForSelection?.split?.('@')?.[0]"
49-
[byId]="false"
50-
[showIconOnly]="true"
51-
>
52-
</cd-copy-2-clipboard-button>
53-
</span>
41+
<cd-copy-2-clipboard-button
42+
*ngIf="row.pathForSelection"
43+
[source]="row.pathForSelection?.split?.('@')?.[0]"
44+
[byId]="false"
45+
[size]="lg"
46+
[text]="row.pathForSelection?.split?.('@')?.[0]"
47+
>
48+
</cd-copy-2-clipboard-button>
5449
</ng-template>
5550
</ng-template>
5651

src/pybind/mgr/dashboard/frontend/src/app/shared/components/card-row/card-row.component.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
{{ data.info }}
6363
</span>
6464
<cd-icon
65-
type="info">
65+
type="infoCircle">
6666
</cd-icon >
6767
</span>
6868
<span *ngIf="data.warn || data.categoryPgAmount?.warning"
@@ -99,9 +99,7 @@
9999
</i>
100100
</span>
101101
</ng-template>
102-
<cd-icon
103-
type="progress">
104-
</cd-icon >
102+
105103
<ng-template #osdSummary>
106104
<span *ngIf="data.up === data.in">
107105
{{ data.up }}
Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11

2-
<svg [cdsIcon]="icons.clipboard"
3-
[size]="icons.size16"
4-
(click)="onClick()"
5-
class="text-primary ms-2"
6-
title="Copy to Clipboard"
7-
i18n-title
8-
*ngIf="showIconOnly; else withButtonTpl"></svg>
9-
10-
<ng-template #withButtonTpl>
11-
12-
<cds-icon-button kind="tertiary"
13-
size="md"
14-
title="Copy to Clipboard"
15-
(click)="onClick()">
16-
<svg [cdsIcon]="icons.copy"
17-
[size]="icons.size16"
18-
class="cds--btn__icon"></svg>
19-
</cds-icon-button>
20-
</ng-template>
2+
<button cdsButton="ghost"
3+
class="clipboard-btn"
4+
[ngClass]="{'clipboard-btn-with-text': text}"
5+
[size]="size"
6+
description="Copy to Clipboard"
7+
i18n-description
8+
(click)="onClick()">
9+
@if(text) {
10+
<span data-toggle="tooltip"
11+
[title]="text"
12+
class="cds--type-mono">{{text}}</span>
13+
}
14+
<cd-icon type="copy"></cd-icon>
15+
</button>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.clipboard-btn {
2+
border: none;
3+
box-shadow: none;
4+
outline: none;
5+
}
6+
7+
.clipboard-btn-with-text {
8+
color: inherit;
9+
}

src/pybind/mgr/dashboard/frontend/src/app/shared/components/copy2clipboard-button/copy2clipboard-button.component.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,21 @@ import { Icons } from '~/app/shared/enum/icons.enum';
1111
styleUrls: ['./copy2clipboard-button.component.scss']
1212
})
1313
export class Copy2ClipboardButtonComponent {
14+
// The text to be copied
1415
@Input()
1516
private source: string;
1617

18+
// Optional: Extracts text to be copied by "id" attribute
1719
@Input()
1820
byId = true;
1921

22+
// Size of the button
2023
@Input()
21-
showIconOnly = false;
24+
size = 'md';
25+
26+
// Optional: Adds text to the left of copy icon
27+
@Input()
28+
text?: string;
2229

2330
icons = Icons;
2431

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,3 @@
1-
@if (type === ICON_TYPE.danger) {
2-
<svg class = "danger-icon"
3-
[cdsIcon]="ICONS.danger"
4-
[size]="size"></svg>
5-
}
6-
7-
@if (type === ICON_TYPE.info) {
8-
<svg class = "info-icon"
9-
[cdsIcon]="ICONS.infoCircle"
10-
[size]="size"></svg>
11-
}
12-
13-
@if (type === ICON_TYPE.success) {
14-
<svg class = "success-icon"
15-
[cdsIcon]="ICONS.success"
16-
[size]="size"></svg>
17-
}
18-
19-
@if (type === ICON_TYPE.warning) {
20-
<svg class = "warning-icon"
21-
[cdsIcon]="ICONS.warning"
22-
[size]="size"></svg>
23-
}
1+
<svg [cdsIcon]="icon"
2+
[size]="size"
3+
[class]="type+'-icon'"></svg>

src/pybind/mgr/dashboard/frontend/src/app/shared/components/icon/icon.component.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
color: theme.$support-error;
99
}
1010

11-
.info-icon {
11+
//@TODO: this naming needs to be changed
12+
// Do this after converting Icons enum to const
13+
.infoCircle-icon {
1214
color: theme.$support-info;
1315
}
1416

src/pybind/mgr/dashboard/frontend/src/app/shared/components/icon/icon.component.spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import { ComponentFixture, TestBed } from '@angular/core/testing';
22

3+
import { configureTestBed } from '~/testing/unit-test-helper';
34
import { IconComponent } from './icon.component';
45

56
describe('IconComponent', () => {
67
let component: IconComponent;
78
let fixture: ComponentFixture<IconComponent>;
89

9-
beforeEach(async () => {
10-
await TestBed.configureTestingModule({
11-
imports: [IconComponent]
12-
}).compileComponents();
10+
configureTestBed({
11+
declarations: [IconComponent],
12+
imports: []
13+
});
1314

15+
beforeEach(() => {
1416
fixture = TestBed.createComponent(IconComponent);
1517
component = fixture.componentInstance;
1618
fixture.detectChanges();
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
import { Component, Input } from '@angular/core';
2-
import { ICON_TYPE, Icons, IconsSize } from '../../enum/icons.enum';
1+
import { Component, Input, OnInit } from '@angular/core';
2+
import { ICON_TYPE, Icons, IconSize } from '../../enum/icons.enum';
33

44
@Component({
55
selector: 'cd-icon',
66
templateUrl: './icon.component.html',
77
styleUrl: './icon.component.scss'
88
})
9-
export class IconComponent {
9+
export class IconComponent implements OnInit {
1010
@Input() type!: keyof typeof ICON_TYPE;
11-
@Input() size: IconsSize = IconsSize.size16;
11+
@Input() size: IconSize = IconSize.size16;
1212

13-
readonly ICONS = Icons;
14-
readonly ICON_TYPE = ICON_TYPE;
13+
icon: string;
14+
15+
ngOnInit() {
16+
this.icon = Icons[this.type];
17+
}
1518
}

src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.html

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -379,23 +379,20 @@
379379

380380
<ng-template #pathTpl
381381
let-value="data.value">
382-
<span data-toggle="tooltip"
383-
[title]="value"
384-
class="font-monospace">{{ value | path }}
385-
<cd-copy-2-clipboard-button *ngIf="value"
386-
[source]="value"
387-
[byId]="false"
388-
[showIconOnly]="true">
389-
</cd-copy-2-clipboard-button>
390-
</span>
382+
<cd-copy-2-clipboard-button *ngIf="value"
383+
[source]="value"
384+
[byId]="false"
385+
size="lg"
386+
text="{{ value | path }}">
387+
</cd-copy-2-clipboard-button>
391388
</ng-template>
392389

393390
<ng-template #copyTpl
394391
let-value="data.value">
395-
<span class="font-monospace">{{value}}</span>
396392
<cd-copy-2-clipboard-button *ngIf="value"
397393
[source]="value"
398394
[byId]="false"
399-
[showIconOnly]="true">
395+
[size]="lg"
396+
[text]="value">
400397
</cd-copy-2-clipboard-button>
401398
</ng-template>

0 commit comments

Comments
 (0)