]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: support custom prop for table item redirection 66407/head
authorNizamudeen A <nia@redhat.com>
Tue, 25 Nov 2025 11:31:31 +0000 (17:01 +0530)
committerNizamudeen A <nia@redhat.com>
Mon, 1 Dec 2025 07:31:10 +0000 (13:01 +0530)
use an extra customTemplateConfig called `customRowProperty` where
you can provide the key of the property you wish to route, instead of
relying on the cell's prop itself

Fixes: https://tracker.ceph.com/issues/73989
Signed-off-by: Nizamudeen A <nia@redhat.com>
src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.html
src/pybind/mgr/dashboard/frontend/src/app/shared/enum/cell-template.enum.ts

index 3817c24967e748c46c0aea2c7d83a09507d0ddfe..82f844de5b3ef033011b09426d005024a6a93178 100644 (file)
 
 <ng-template #redirectTpl
              let-value="data.value"
+             let-row="data.row"
              let-column="data.column">
+@if (column.customTemplateConfig?.customRowProperty && row[column.customTemplateConfig?.customRowProperty]) {
+  <a [routerLink]="row[column.customTemplateConfig?.customRowProperty]">{{value}}</a>
+} @else if (column.customTemplateConfig?.redirectLink) {
   <a [routerLink]="column.customTemplateConfig?.redirectLink | redirectLinkResolver:value">{{value}}</a>
+} @else {
+  {{ value }}
+}
 </ng-template>
index 622aa1fdd90134ddfbf5712d9d7102c0c5e56891..50971bb9311ebfedde6f400be952625c171a22cb 100644 (file)
@@ -113,6 +113,18 @@ export enum CellTemplate {
   // }
   // you can also use '::prop' in the redirectLink array to replace it with the cell value.
   // e.g ['dashboard', '::prop', 'details']
+  //
+  // if you want to use some other property of the row for redirection instead of the cell value,
+  // you can use the 'customRowProperty' property in the customTemplateConfig to specify
+  // the property name.
+  // {
+  //    ...
+  //    cellTransformation: CellTemplate.redirect,
+  //    customTemplateConfig: {
+  //          customRowProperty: 'otherPropertyName'}
+  //    }
+  //    ...
+  // }
   */
   redirect = 'redirect'
 }