]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard : Cephfs Mirroring Entity Deselect fix 67487/head
authorDnyaneshwari Talwekar <dtalwekar@li-4c4c4544-0038-3510-8056-b5c04f473234.ibm.com>
Tue, 24 Feb 2026 15:51:56 +0000 (21:21 +0530)
committerDnyaneshwari Talwekar <dtalwekar@li-4c4c4544-0038-3510-8056-b5c04f473234.ibm.com>
Tue, 24 Feb 2026 16:13:43 +0000 (21:43 +0530)
Signed-off-by: Dnyaneshwari Talwekar <dtalweka@redhat.com>
Fixes: https://tracker.ceph.com/issues/75140
src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-mirroring-entity/cephfs-mirroring-entity.component.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts

index 1fad704c9b557d57259effe2de1adcd0736066a0..8bba56da5d4c5bff3f508ad73fe7c9f1d8ced9bb 100644 (file)
@@ -1,9 +1,20 @@
-import { Component, OnInit, Output, EventEmitter, Input, inject } from '@angular/core';
+import {
+  Component,
+  OnInit,
+  OnChanges,
+  SimpleChanges,
+  Output,
+  EventEmitter,
+  Input,
+  inject,
+  ViewChild
+} from '@angular/core';
 import { BehaviorSubject, Observable, of } from 'rxjs';
 import { catchError, map, switchMap, defaultIfEmpty } from 'rxjs/operators';
 
 import { CdTableColumn } from '~/app/shared/models/cd-table-column';
 import { CdTableSelection } from '~/app/shared/models/cd-table-selection';
+import { TableComponent } from '~/app/shared/datatable/table/table.component';
 import { CdTableFetchDataContext } from '~/app/shared/models/cd-table-fetch-data-context';
 import { CephfsService } from '~/app/shared/api/cephfs.service';
 import { ClusterService } from '~/app/shared/api/cluster.service';
@@ -23,7 +34,8 @@ import { CephAuthUser } from '~/app/shared/models/cluster.model';
   styleUrls: ['./cephfs-mirroring-entity.component.scss'],
   standalone: false
 })
-export class CephfsMirroringEntityComponent extends CdForm implements OnInit {
+export class CephfsMirroringEntityComponent extends CdForm implements OnInit, OnChanges {
+  @ViewChild('table') table: TableComponent;
   columns: CdTableColumn[];
   selection = new CdTableSelection();
 
@@ -55,6 +67,12 @@ export class CephfsMirroringEntityComponent extends CdForm implements OnInit {
   private taskWrapperService = inject(TaskWrapperService);
   private formBuilder = inject(CdFormBuilder);
 
+  ngOnChanges(changes: SimpleChanges): void {
+    if (changes['selectedFilesystem'] && !changes['selectedFilesystem'].firstChange) {
+      this.resetSelection();
+    }
+  }
+
   ngOnInit(): void {
     const noClientPrefix: ValidatorFn = (control: AbstractControl): ValidationErrors | null => {
       const value = (control.value ?? '').toString().trim();
@@ -200,7 +218,20 @@ export class CephfsMirroringEntityComponent extends CdForm implements OnInit {
   updateSelection(selection: CdTableSelection) {
     this.selection = selection;
     const selectedRow = selection?.first();
-    this.entitySelected.emit(selectedRow ? selectedRow.entity : null);
+    if (!selectedRow) {
+      this.selection.selected = [];
+      this.entitySelected.emit(null);
+      return;
+    }
+    this.entitySelected.emit(selectedRow.entity);
+  }
+
+  resetSelection() {
+    if (this.table) {
+      this.table.model.selectAll(false);
+    }
+    this.selection = new CdTableSelection();
+    this.entitySelected.emit(null);
   }
 
   onCreateEntitySelected() {
@@ -213,6 +244,7 @@ export class CephfsMirroringEntityComponent extends CdForm implements OnInit {
     this.isCreatingNewEntity = false;
     this.showSelectRequirementsWarning = true;
     this.showSelectEntityInfo = true;
+    this.resetSelection();
   }
 
   onDismissCreateRequirementsWarning() {
index 081c2433fb1a25b7e3ede5d60eb6a2b577b87f27..2ce7a5182d4374e3d180f8149eb52b75bfafc3e3 100644 (file)
@@ -1147,8 +1147,6 @@ export class TableComponent implements AfterViewInit, OnInit, OnChanges, OnDestr
   onDeselect(deselectedRowIndex: number) {
     this.model.selectRow(deselectedRowIndex, false);
     if (this.selectionType === 'single' || this.selectionType === 'singleRadio') {
-      this.selection.selected = [];
-      this.updateSelection.emit(this.selection);
       return;
     }
     this._toggleSelection(deselectedRowIndex, false);