Skip to content

Commit 79a193b

Browse files
authored
Merge pull request ceph#65285 from rhcs-dashboard/table-actions
mgr/dashboard: add customizations to table-actions Reviewed-by: Afreen Misbah <[email protected]>
2 parents 785976e + dd06c75 commit 79a193b

File tree

9 files changed

+66
-63
lines changed

9 files changed

+66
-63
lines changed

src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
<cd-table-actions [permission]="{read: true}"
2727
[selection]="selection"
2828
dropDownOnly="Cluster-wide configuration"
29-
btnColor="light"
29+
[dropDownOnlyOffset]="{ x: 110, y: 0 }"
30+
[dropDownOnlyBtnColor]="'tertiary'"
3031
class="btn-group"
3132
id="cluster-wide-actions"
3233
[tableActions]="clusterWideActions">

src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.html

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,25 @@
1818
routerLink="/services">
1919
Cluster->Services</a>
2020
</cd-alert-panel>
21-
<cd-table-actions class="btn-group mb-4 me-2"
22-
[permission]="permissions.rgw"
23-
[selection]="selection"
24-
[tableActions]="multisiteReplicationActions">
25-
</cd-table-actions>
26-
<cd-table-actions *ngIf="showMigrateAndReplicationActions"
27-
class="btn-group mb-4 me-2 secondary"
28-
[permission]="permissions.rgw"
29-
[btnColor]="'light'"
30-
[selection]="selection"
31-
[tableActions]="migrateTableAction">
32-
</cd-table-actions>
33-
<cd-table-actions *ngIf="!showMigrateAndReplicationActions"
34-
class="btn-group mb-4 me-2"
35-
[permission]="permissions.rgw"
36-
[selection]="selection"
37-
[tableActions]="createTableActions"
38-
[primaryDropDown]="true">
39-
</cd-table-actions>
40-
<cd-table-actions class="btn-group mb-4 me-2"
41-
[permission]="permissions.rgw"
42-
[btnColor]="'light'"
43-
[selection]="selection"
44-
[tableActions]="importAction">
45-
</cd-table-actions>
46-
<cd-table-actions class="btn-group mb-4 me-2"
47-
[permission]="permissions.rgw"
48-
[btnColor]="'light'"
49-
[selection]="selection"
50-
[tableActions]="exportAction">
51-
</cd-table-actions>
21+
<div [cdsStack]="'horizontal'"
22+
[gap]="4">
23+
<cd-table-actions [permission]="permissions.rgw"
24+
[selection]="selection"
25+
[tableActions]="multisiteReplicationActions">
26+
</cd-table-actions>
27+
<cd-table-actions *ngIf="showMigrateAndReplicationActions"
28+
[permission]="permissions.rgw"
29+
[selection]="selection"
30+
[tableActions]="migrateTableAction">
31+
</cd-table-actions>
32+
<cd-table-actions [permission]="permissions.rgw"
33+
[selection]="selection"
34+
[tableActions]="createTableActions"
35+
dropDownOnly="Actions"
36+
[dropDownOnlyBtnColor]="'tertiary'"
37+
[dropDownOnlyOffset]="{ x: 45, y: 0 }">
38+
</cd-table-actions>
39+
</div>
5240
</div>
5341
<div class="card">
5442
<div class="card-header"

src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,9 @@
1717
padding-block: 0.5rem;
1818
width: 100%;
1919
}
20+
21+
::ng-deep cds-overflow-menu .cds--btn--icon-only {
22+
position: relative;
23+
top: 4px;
24+
width: auto;
25+
}

src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.ts

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ export class RgwMultisiteDetailsComponent implements OnDestroy, OnInit {
6868
selection = new CdTableSelection();
6969
createTableActions: CdTableAction[];
7070
migrateTableAction: CdTableAction[];
71-
importAction: CdTableAction[];
72-
exportAction: CdTableAction[];
7371
multisiteReplicationActions: CdTableAction[];
7472
loadingIndicator = true;
7573

@@ -236,40 +234,31 @@ export class RgwMultisiteDetailsComponent implements OnDestroy, OnInit {
236234
permission: 'create',
237235
icon: Icons.add,
238236
name: this.actionLabels.CREATE + ' Realm',
239-
click: () => this.openModal('realm')
237+
click: () => this.openModal('realm'),
238+
visible: () => !this.showMigrateAndReplicationActions
240239
},
241240
{
242241
permission: 'create',
243242
icon: Icons.add,
244243
name: this.actionLabels.CREATE + ' Zone Group',
245244
click: () => this.openModal('zonegroup'),
246-
disable: () => this.getDisable()
245+
disable: () => this.getDisable(),
246+
visible: () => !this.showMigrateAndReplicationActions
247247
},
248248
{
249249
permission: 'create',
250250
icon: Icons.add,
251251
name: this.actionLabels.CREATE + ' Zone',
252-
click: () => this.openModal('zone')
253-
}
254-
];
255-
this.migrateTableAction = [
256-
{
257-
permission: 'create',
258-
icon: Icons.wrench,
259-
name: this.actionLabels.MIGRATE,
260-
click: () => this.openMigrateModal()
261-
}
262-
];
263-
this.importAction = [
252+
click: () => this.openModal('zone'),
253+
visible: () => !this.showMigrateAndReplicationActions
254+
},
264255
{
265256
permission: 'create',
266257
icon: Icons.download,
267258
name: this.actionLabels.IMPORT,
268259
click: () => this.openImportModal(),
269260
disable: () => this.getDisableImport()
270-
}
271-
];
272-
this.exportAction = [
261+
},
273262
{
274263
permission: 'create',
275264
icon: Icons.upload,
@@ -278,6 +267,14 @@ export class RgwMultisiteDetailsComponent implements OnDestroy, OnInit {
278267
disable: () => this.getDisableExport()
279268
}
280269
];
270+
this.migrateTableAction = [
271+
{
272+
permission: 'create',
273+
icon: Icons.wrench,
274+
name: this.actionLabels.MIGRATE,
275+
click: () => this.openMigrateModal()
276+
}
277+
];
281278
this.multisiteReplicationActions = [
282279
{
283280
permission: 'create',

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import CheckIcon from '@carbon/icons/es/checkmark/16';
2525
import CloseIcon from '@carbon/icons/es/close/16';
2626
import MaximizeIcon from '@carbon/icons/es/maximize/16';
2727
import ArrowDown from '@carbon/icons/es/caret--down/16';
28+
import ChevronDwon from '@carbon/icons/es/chevron--down/16';
2829

2930
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
3031
import { FormlyModule } from '@ngx-formly/core';
@@ -136,7 +137,8 @@ export class DataTableModule {
136137
CheckIcon,
137138
CloseIcon,
138139
MaximizeIcon,
139-
ArrowDown
140+
ArrowDown,
141+
ChevronDwon
140142
]);
141143
}
142144
}

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
[cdsOverflowMenu]="overflowMenuTpl"
2222
data-testid="table-action-btn">
2323
<svg
24-
[cdsIcon]="icons.downArrow"
25-
[size]="icons.size16"></svg>
24+
[cdsIcon]="icons.chevronDown"></svg>
2625
</button>
2726
<ng-template #overflowMenuTpl>
2827
<ng-container *ngFor="let action of dropDownActions">
@@ -47,15 +46,14 @@
4746
<button [cdsButton]="currentAction.buttonKind"
4847
class="caret-btn">
4948
<svg class="cds--btn__icon"
50-
cdsIcon="caret--down"
51-
size="16"></svg>
49+
[cdsIcon]="icons.chevronDown"></svg>
5250
</button>
5351
</ng-template>
5452

5553
<ng-template #dropDownOnlyTpl>
5654
<cds-overflow-menu [customTrigger]="customTrigger"
5755
[flip]="true"
58-
[offset]="{ x: 105, y: 0 }"
56+
[offset]="dropDownOnlyOffset"
5957
data-testid="table-action-btn"
6058
class="d-flex justify-content-end">
6159
<ng-container *ngFor="let action of dropDownActions">
@@ -76,10 +74,9 @@
7674
</ng-template>
7775

7876
<ng-template #customTrigger>
79-
<button cdsButton="tertiary">
77+
<button [cdsButton]="dropDownOnlyBtnColor">
8078
<span i18n>{{ dropDownOnly }}</span>
81-
<svg class="cds--btn__icon"
82-
cdsIcon="caret--down"
83-
size="16"></svg>
79+
<svg class="override-position-static cds--btn__icon"
80+
[cdsIcon]="icons.chevronDown"></svg>
8481
</button>
8582
</ng-template>

src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-actions/table-actions.component.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,13 @@ button.dropdown-item:hover {
3232
justify-content: center;
3333
width: 3rem;
3434
}
35+
36+
// https://github.com/carbon-design-system/carbon-components-angular/blob/v5.56.2/src/dialog/overflow-menu/overflow-menu.component.ts#52
37+
// Its always applying .cds--btn--icon-only which is making position static and svg color fill to var(--cds-icon-primary, #f8f9fa)
38+
.override-position-static.cds--btn__icon {
39+
position: absolute;
40+
}
41+
42+
.cds--overflow-menu-options__option {
43+
min-width: fit-content;
44+
}

src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table-actions/table-actions.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ export class TableActionsComponent implements OnChanges, OnInit {
2020
@Input()
2121
tableActions: CdTableAction[];
2222
@Input()
23-
btnColor = 'accent';
24-
23+
dropDownOnlyBtnColor = 'primary';
24+
@Input()
25+
dropDownOnlyOffset = { x: 105, y: 0 };
2526
// Use this if you just want to display a drop down button,
2627
// labeled with the given text, with all actions in it.
2728
// This disables the main action button.

src/pybind/mgr/dashboard/frontend/src/app/shared/enum/icons.enum.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export enum Icons {
8585
dataTable = 'data-table',
8686
idea = 'idea',
8787
userAccessLocked = 'user--access-locked', // User access locked
88+
chevronDown = 'chevron--down',
8889
/* Icons for special effect */
8990
size16 = '16',
9091
size20 = '20',

0 commit comments

Comments
 (0)