From: Nizamudeen A Date: Fri, 10 Apr 2026 06:25:27 +0000 (+0530) Subject: mgr/dashboard: table cell inline edit emit editing state X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=18607c563d929fb0740ea7d10b101a8642d83709;p=ceph.git mgr/dashboard: table cell inline edit emit editing state - Emit the editing state so that the consuming component can manipulate that to add some extra validations - Replace button with cds-icon-button. - Replace submit button with tertiary instead of ghost for visibility. - Also added a cancel button to cancel the ongoing edit Fixes: https://tracker.ceph.com/issues/75949 Signed-off-by: Nizamudeen A --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.html b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.html index 21cd4f873dbc..6f5c54f177b9 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.html @@ -467,13 +467,22 @@
- + + + + +
@@ -486,12 +495,12 @@
- +
} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts index 7b6baeb809e3..3ee596f212e1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts @@ -285,6 +285,9 @@ export class TableComponent implements AfterViewInit, OnInit, OnChanges, OnDestr row: any; }>(); + @Output() + isCellEditingEvent = new EventEmitter(); + /** * Use this variable to access the selected row(s). */ @@ -1445,6 +1448,7 @@ export class TableComponent implements AfterViewInit, OnInit, OnChanges, OnDestr } this.formGroup?.get(key).setValue(value); this.editStates[rowId][column.prop] = value; + this.isCellEditingEvent.emit(true); } saveCellItem(row: any, colProp: string) { @@ -1471,4 +1475,27 @@ export class TableComponent implements AfterViewInit, OnInit, OnChanges, OnDestr valueChange(rowId: string, colProp: string, value: string) { this.editStates[rowId][colProp] = value; } + + cancelCellEdit(rowId: string, colProp: string, event?: Event) { + if (event) { + event.preventDefault(); + event.stopPropagation(); + } + const key = `${rowId}-${colProp}`; + if (!this.formGroup.controls[key]) { + return; + } + + if (this.editStates[rowId]) { + delete this.editStates[rowId][colProp]; + } + this.editingCells.clear(); + this.isCellEditingEvent.emit(false); + + setTimeout(() => { + if (this.formGroup.controls[key]) { + this.formGroup.removeControl(key); + } + }, 0); + } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/enum/icons.enum.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/enum/icons.enum.ts index 290da0e09cbb..7479cb9be8cc 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/enum/icons.enum.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/enum/icons.enum.ts @@ -169,7 +169,8 @@ export const ICON_TYPE = { checkMarkOutline: 'checkmark--outline', arrowUpRight: ' arrow--up-right', inProgress: 'in-progress', - arrowDown: 'arrow--down' + arrowDown: 'arrow--down', + destroy: 'close' } as const; export const EMPTY_STATE_IMAGE = {