Skip to content

Commit 7d55db5

Browse files
committed
mgr/dashboard: carbonize general components and styles
alert-panel and some other general components Fixes: https://tracker.ceph.com/issues/67231 Signed-off-by: Nizamudeen A <[email protected]>
1 parent 2fa0e43 commit 7d55db5

File tree

14 files changed

+233
-159
lines changed

14 files changed

+233
-159
lines changed
Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,19 @@
1-
<cds-actionable-notification
2-
class="mb-1"
3-
[notificationObj]="notificationContent"
4-
*ngIf="size === 'slim'; else normal">
5-
</cds-actionable-notification>
6-
7-
<ng-template #normal>
8-
<ngb-alert type="{{ bootstrapClass }}"
9-
[dismissible]="dismissible"
10-
(closed)="onClose()"
11-
[ngClass]="spacingClass">
12-
<table>
13-
<ng-container *ngIf="size === 'normal'">
14-
<tr>
15-
<td *ngIf="showIcon"
16-
rowspan="2"
17-
class="alert-panel-icon">
18-
<i [ngClass]="[icons.large3x]"
19-
class="alert-{{ bootstrapClass }} {{ typeIcon }}"
20-
aria-hidden="true"></i>
21-
</td>
22-
<td *ngIf="showTitle"
23-
class="alert-panel-title">{{ title }}</td>
24-
</tr>
25-
<tr>
26-
<td class="alert-panel-text">
27-
<ng-container *ngTemplateOutlet="content"></ng-container>
28-
</td>
29-
</tr>
30-
</ng-container>
31-
</table>
32-
</ngb-alert>
33-
</ng-template>
1+
<cds-actionable-notification class="mb-1"
2+
[ngClass]="spacingClass"
3+
[notificationObj]="notificationContent"
4+
(close)="onClose()"></cds-actionable-notification>
345

356
<ng-template #content>
367
<ng-content></ng-content>
378
</ng-template>
389

39-
<ng-template #closeTpl>
10+
<ng-template #actionTpl>
4011
<button cdsActionableButton
4112
cdsButton="ghost"
4213
size="md"
4314
title="Close"
44-
(click)="onClose()"
45-
*ngIf="dismissible">
46-
<svg class="cds--btn__icon"
47-
cdsIcon="close"
48-
size="16"></svg>
15+
(click)="onAction()"
16+
*ngIf="actionName"
17+
i18n>{{ actionName }}
4918
</button>
5019
</ng-template>

src/pybind/mgr/dashboard/frontend/src/app/shared/components/alert-panel/alert-panel.component.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,25 @@ import { Icons } from '~/app/shared/enum/icons.enum';
1919
export class AlertPanelComponent implements OnInit {
2020
@ViewChild('content', { static: true })
2121
alertContent: TemplateRef<any>;
22-
@ViewChild('closeTpl', { static: true })
23-
closeTpl: TemplateRef<any>;
22+
@ViewChild('actionTpl', { static: true })
23+
actionTpl: TemplateRef<any>;
2424

2525
@Input()
2626
title = '';
2727
@Input()
28-
bootstrapClass = '';
29-
@Input()
3028
type: 'warning' | 'error' | 'info' | 'success' | 'danger';
3129
@Input()
32-
typeIcon: Icons | string;
30+
showTitle = true;
3331
@Input()
3432
size: 'slim' | 'normal' = 'normal';
3533
@Input()
36-
showIcon = true;
37-
@Input()
38-
showTitle = true;
39-
@Input()
4034
dismissible = false;
4135
@Input()
4236
spacingClass = '';
37+
@Input()
38+
actionName = '';
39+
@Input()
40+
lowContrast = true;
4341

4442
/**
4543
* The event that is triggered when the close button (x) has been
@@ -48,50 +46,52 @@ export class AlertPanelComponent implements OnInit {
4846
@Output()
4947
dismissed = new EventEmitter();
5048

49+
/**
50+
* The event that is triggered when the action button has been
51+
* pressed.
52+
*/
53+
@Output()
54+
action = new EventEmitter();
55+
5156
icons = Icons;
5257

5358
notificationContent: NotificationContent;
5459

5560
ngOnInit() {
5661
const type: NotificationType = this.type === 'danger' ? 'error' : this.type;
57-
this.notificationContent = {
58-
type: type,
59-
template: this.alertContent,
60-
actionsTemplate: this.closeTpl,
61-
showClose: false,
62-
title: this.title
63-
};
64-
6562
switch (this.type) {
6663
case 'warning':
6764
this.title = this.title || $localize`Warning`;
68-
this.typeIcon = this.typeIcon || Icons.warning;
69-
this.bootstrapClass = this.bootstrapClass || 'warning';
7065
break;
7166
case 'error':
7267
this.title = this.title || $localize`Error`;
73-
this.typeIcon = this.typeIcon || Icons.destroyCircle;
74-
this.bootstrapClass = this.bootstrapClass || 'danger';
7568
break;
7669
case 'info':
7770
this.title = this.title || $localize`Information`;
78-
this.typeIcon = this.typeIcon || Icons.infoCircle;
79-
this.bootstrapClass = this.bootstrapClass || 'info';
8071
break;
8172
case 'success':
8273
this.title = this.title || $localize`Success`;
83-
this.typeIcon = this.typeIcon || Icons.check;
84-
this.bootstrapClass = this.bootstrapClass || 'success';
8574
break;
8675
case 'danger':
8776
this.title = this.title || $localize`Danger`;
88-
this.typeIcon = this.typeIcon || Icons.warning;
89-
this.bootstrapClass = this.bootstrapClass || 'danger';
9077
break;
9178
}
79+
80+
this.notificationContent = {
81+
type: type,
82+
template: this.alertContent,
83+
actionsTemplate: this.actionTpl,
84+
showClose: this.dismissible,
85+
title: this.showTitle ? this.title : '',
86+
lowContrast: this.lowContrast
87+
};
9288
}
9389

9490
onClose(): void {
9591
this.dismissed.emit();
9692
}
93+
94+
onAction(): void {
95+
this.action.emit();
96+
}
9797
}

src/pybind/mgr/dashboard/frontend/src/app/shared/components/components.module.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ import {
1919
UIShellModule,
2020
ButtonModule,
2121
NotificationModule,
22-
IconModule
22+
IconModule,
23+
IconService,
24+
TooltipModule,
25+
GridModule,
26+
AccordionModule,
27+
LoadingModule
2328
} from 'carbon-components-angular';
2429

2530
import { MotdComponent } from '~/app/shared/components/motd/motd.component';
@@ -64,6 +69,9 @@ import { HelpTextComponent } from './help-text/help-text.component';
6469
import { FormAdvancedFieldsetComponent } from './form-advanced-fieldset/form-advanced-fieldset.component';
6570
import { UpgradableComponent } from './upgradable/upgradable.component';
6671

72+
// Icons
73+
import InfoIcon from '@carbon/icons/es/information/16';
74+
6775
@NgModule({
6876
imports: [
6977
CommonModule,
@@ -86,7 +94,12 @@ import { UpgradableComponent } from './upgradable/upgradable.component';
8694
UIShellModule,
8795
ButtonModule,
8896
NotificationModule,
89-
IconModule
97+
IconModule,
98+
TooltipModule,
99+
IconModule,
100+
GridModule,
101+
AccordionModule,
102+
LoadingModule
90103
],
91104
declarations: [
92105
SparklineComponent,
@@ -168,4 +181,8 @@ import { UpgradableComponent } from './upgradable/upgradable.component';
168181
UpgradableComponent
169182
]
170183
})
171-
export class ComponentsModule {}
184+
export class ComponentsModule {
185+
constructor(private iconService: IconService) {
186+
this.iconService.registerAll([InfoIcon]);
187+
}
188+
}
Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
11
<fieldset>
2-
<legend class="cd-header">
3-
<div class="accordion accordion-flush">
4-
<button class="accordion-button cd-form-advanced-fieldset-buttton p-0"
5-
type="button"
6-
id="advanced-fieldset"
7-
aria-label="toggle advanced mode"
8-
[ngClass]="{collapsed: !showAdvanced}"
9-
(click)="showAdvanced = !showAdvanced"
10-
i18n>Advanced
11-
</button>
12-
</div>
13-
</legend>
14-
<div class="accordion-collapse collapse"
15-
[ngClass]="{show: showAdvanced}">
16-
<div class="accordion-body">
17-
<div class="card-body">
18-
<ng-content></ng-content>
19-
</div>
20-
</div>
21-
</div>
2+
<cds-accordion size="lg"
3+
class="form-item">
4+
<cds-accordion-item [title]="title"
5+
i18n
6+
(selected)="showAdvanced = !showAdvanced">
7+
<ng-content></ng-content>
8+
</cds-accordion-item>
9+
</cds-accordion>
10+
11+
<ng-template #title>
12+
<h5 class="cds--accordion__title cd-header">Advanced</h5>
13+
</ng-template>
2214
</fieldset>
Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +0,0 @@
1-
/*
2-
Overrides the active and focus states of bootstrap accordion,
3-
in order to align the accordion css with rest of the form.
4-
5-
Summary of overrides:
6-
- font-size was 1 rem
7-
- color was blue when higlighted
8-
- border,outlines and box-shadow were set
9-
- accordion down button in active form was a blue svg icon
10-
11-
*/
12-
.cd-form-advanced-fieldset-buttton {
13-
--bs-accordion-btn-active-icon: var(--bs-accordion-btn-icon);
14-
background-color: inherit;
15-
border: hidden;
16-
border-color: inherit;
17-
box-shadow: none;
18-
color: inherit;
19-
font-size: inherit;
20-
outline: 0;
21-
text-decoration: none;
22-
}

src/pybind/mgr/dashboard/frontend/src/app/shared/components/helper/helper.component.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
</div>
55
<ng-content></ng-content>
66
</ng-template>
7-
<i [ngClass]="iconClass ? iconClass : [icons.questionCircle]"
8-
aria-hidden="true"
9-
[ngbPopover]="popoverTpl"
10-
(click)="$event.preventDefault();">
11-
</i>
7+
8+
<cds-tooltip [description]="popoverTpl">
9+
<svg cdsIcon="information"
10+
size="16"
11+
title="info"></svg>
12+
</cds-tooltip>
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
@use './src/styles/vendor/variables' as vv;
2-
3-
i {
4-
color: vv.$primary;
5-
cursor: pointer;
6-
padding-left: 4px;
1+
cds-tooltip {
2+
margin-left: 5px;
73
}

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { Component, Input } from '@angular/core';
22

3-
import { Icons } from '~/app/shared/enum/icons.enum';
4-
53
@Component({
64
selector: 'cd-helper',
75
templateUrl: './helper.component.html',
@@ -16,6 +14,4 @@ export class HelperComponent {
1614

1715
@Input()
1816
html: any;
19-
20-
icons = Icons;
2117
}
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<button [type]="type"
2-
class="btn btn-accent tc_submitButton"
3-
[ngClass]="btnClass"
2+
class="tc_submitButton"
43
[disabled]="loading || disabled"
54
(click)="submit($event)"
6-
[attr.aria-label]="ariaLabel">
5+
[attr.aria-label]="ariaLabel"
6+
size="xl"
7+
cdsButton="primary">
78
<ng-content></ng-content>
8-
<span *ngIf="loading">
9-
<i [ngClass]="[icons.spinner, icons.spin]"></i>
10-
</span>
9+
<cds-loading [isActive]="loading"
10+
[overlay]="false"
11+
size="sm"
12+
*ngIf="loading"></cds-loading>
1113
</button>

0 commit comments

Comments
 (0)