Skip to content

Commit fb409aa

Browse files
committed
mgr/dashboard: generic redirect link for a table item
Fixes: https://tracker.ceph.com/issues/73638 Signed-off-by: Nizamudeen A <[email protected]>
1 parent 986f61c commit fb409aa

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,3 +477,9 @@
477477
</div>
478478
}
479479
</ng-template>
480+
481+
<ng-template #redirectTpl
482+
let-value="data.value"
483+
let-column="data.column">
484+
<a [routerLink]="column.customTemplateConfig?.redirectLink">{{value}}</a>
485+
</ng-template>

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ export class TableComponent implements AfterViewInit, OnInit, OnChanges, OnDestr
9090
tableActionTpl: TemplateRef<any>;
9191
@ViewChild('editingTpl', { static: true })
9292
editingTpl: TemplateRef<any>;
93+
@ViewChild('redirectTpl', { static: true })
94+
redirectTpl: TemplateRef<any>;
9395

9496
@ContentChild(TableDetailDirective) rowDetail!: TableDetailDirective;
9597
@ContentChild(TableActionsComponent) tableActions!: TableActionsComponent;
@@ -862,6 +864,7 @@ export class TableComponent implements AfterViewInit, OnInit, OnChanges, OnDestr
862864
this.cellTemplates.tooltip = this.tooltipTpl;
863865
this.cellTemplates.copy = this.copyTpl;
864866
this.cellTemplates.editing = this.editingTpl;
867+
this.cellTemplates.redirect = this.redirectTpl;
865868
}
866869

867870
useCustomClass(value: any): string {

src/pybind/mgr/dashboard/frontend/src/app/shared/enum/cell-template.enum.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,18 @@ export enum CellTemplate {
9999
Also need to pass forceIdentifer=true and also a unique identifier prop like
100100
identifier="uid" to the table in some cases to avoid issues.
101101
*/
102-
editing = 'editing'
102+
editing = 'editing',
103+
/*
104+
This template let's you provide a redirect url and let you redirect from when you click
105+
on the cell item. The redirect link can be provided in the customTemplateConfig
106+
// {
107+
// ...
108+
// cellTransformation: CellTemplate.redirect,
109+
// customTemplateConfig: {
110+
// redirectLink: ['dashboard', 'overview'],
111+
// }
112+
// ...
113+
// }
114+
*/
115+
redirect = 'redirect'
103116
}

0 commit comments

Comments
 (0)