]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: fix SMB custom DNS button and linked_to_cluster col
authorPedro Gonzalez Gomez <pegonzal@ibm.com>
Tue, 26 Aug 2025 12:05:45 +0000 (14:05 +0200)
committerPedro Gonzalez Gomez <pegonzal@ibm.com>
Wed, 24 Sep 2025 15:34:30 +0000 (17:34 +0200)
- The button 'add custom DNS' in smb cluster form should only appear for active directory where is relevant.

- The linked_to_cluster column data is missing from smb standalone

- Some refactoring to remove magic strings and use FormControl for publicAddrs field

Fixes: https://tracker.ceph.com/issues/73096
Signed-off-by: Pedro Gonzalez Gomez <pegonzal@ibm.com>
(cherry picked from commit 9ce943e21558d17b3a214840b39bb57eab0cbd85)

src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-cluster-form/smb-cluster-form.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-cluster-form/smb-cluster-form.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-cluster-form/smb-cluster-form.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-usersgroups-list/smb-usersgroups-list.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb.model.ts

index 45a95a32b557d60fc8030b5e6dbb2e28c3e6f1c1..9050551866d4617e478925748bda58fcc4546343 100644 (file)
@@ -73,7 +73,7 @@
 
       <!-- Domain Settings -->
       <div class="form-item"
-           *ngIf="this.smbForm.get('auth_mode').value === 'active-directory'">
+           *ngIf="this.smbForm.get('auth_mode').value === AUTHMODE.ActiveDirectory">
         <div cdsCol
              [columnNumbers]="{ md: 12 }"
              class="d-flex">
                     *ngFor="let _ of joinSources.controls; index as i">
         <div
           cdsRow
-          *ngIf="this.smbForm.get('auth_mode').value === 'user' && usersGroups$ | async as usersGroups"
+          *ngIf="this.smbForm.get('auth_mode').value === AUTHMODE.User && usersGroups$ | async as usersGroups"
           class="form-item form-item-append"
         >
           <div
       </ng-container>
 
       <div class="form-item"
-           *ngIf="this.smbForm.get('auth_mode').value === 'user'">
+           *ngIf="this.smbForm.get('auth_mode').value === AUTHMODE.User">
         <button cdsButton="tertiary"
                 type="button"
                 (click)="addUserGroupSetting()"
           <div class="form-item">
             <cds-select
               label="Placement"
-              for="placement"
               formControlName="placement"
               id="placement"
             >
         </div>
 
         <!-- Custom DNS -->
-        <ng-container formArrayName="custom_dns"
-                      *ngFor="let _ of custom_dns.controls; index as i">
-          <div cdsRow
-               class="form-item form-item-append">
-            <div cdsCol
-                 [columnNumbers]="{ lg: 14 }">
-              <cds-text-label
-                for="custom_dns"
-                i18n
-              >DNS
-              <input cdsText
-                     [formControlName]="i"
-                     placeholder="192.168.76.204"/>
-              </cds-text-label>
-            </div>
-            <div
-              cdsCol
-              [columnNumbers]="{ lg: 1 }"
-              class="item-action-btn spacing"
-            >
-              <cds-icon-button
-                kind="danger"
-                size="sm"
-                (click)="removeCustomDNS(i)"
+        @if (this.smbForm.get('auth_mode').value === AUTHMODE.ActiveDirectory) {
+          <ng-container formArrayName="custom_dns"
+                        *ngFor="let _ of custom_dns.controls; index as i">
+            <div cdsRow
+                 class="form-item form-item-append">
+              <div cdsCol
+                   [columnNumbers]="{ lg: 14 }">
+                <cds-text-label
+                  for="custom_dns"
+                  i18n
+                >DNS
+                <input cdsText
+                       [formControlName]="i"
+                       placeholder="192.168.76.204"/>
+                </cds-text-label>
+              </div>
+              <div
+                cdsCol
+                [columnNumbers]="{ lg: 1 }"
+                class="item-action-btn spacing"
               >
-                <svg
-                  cdsIcon="trash-can"
-                  size="32"
-                  class="cds--btn__icon"
+                <cds-icon-button
+                  kind="danger"
+                  size="sm"
+                  (click)="removeCustomDNS(i)"
                 >
-                </svg>
-              </cds-icon-button>
+                  <svg
+                    cdsIcon="trash-can"
+                    size="32"
+                    class="cds--btn__icon"
+                  >
+                  </svg>
+                </cds-icon-button>
+              </div>
             </div>
-          </div>
-        </ng-container>
+          </ng-container>
 
-        <div class="form-item">
-          <button cdsButton="tertiary"
-                  type="button"
-                  (click)="addCustomDns()"
-                  i18n>
-            Add custom DNS
-            <svg
-              cdsIcon="add"
-              size="32"
-              class="cds--btn__icon"
-              icon></svg>
-          </button>
-          <cd-helper i18n>One or more IP Addresses that will be
-            applied to the Samba containers to override
-            the default DNS resolver(s). This option is
-            intended to be used when the host Ceph node
-            is not configured to resolve DNS entries within
-            AD domain(s).
-          </cd-helper>
-        </div>
+          <div class="form-item">
+            <button cdsButton="tertiary"
+                    type="button"
+                    (click)="addCustomDns()"
+                    i18n>
+              Add custom DNS
+              <svg
+                cdsIcon="add"
+                size="32"
+                class="cds--btn__icon"
+                icon></svg>
+            </button>
+            <cd-helper i18n>One or more IP Addresses that will be
+              applied to the Samba containers to override
+              the default DNS resolver(s). This option is
+              intended to be used when the host Ceph node
+              is not configured to resolve DNS entries within
+              AD domain(s).
+            </cd-helper>
+          </div>
+        }
 
         <!-- Clustering -->
         <div class="form-item">
           </cds-select>
         </div>
 
+        <div
+          *ngIf="(this.smbForm.get('count').value > 1 && this.smbForm.get('clustering').value.toLowerCase() == CLUSTERING.Default) || this.smbForm.get('clustering').value.toLowerCase() == CLUSTERING.Always"
+          class="form-item"
+        >
+
         <!-- Public addrs -->
         <ng-container formArrayName="public_addrs"
                       *ngFor="let _ of public_addrs.controls; index as i">
               <div cdsCol
                    [columnNumbers]="{ lg: 7 }">
                 <cds-text-label
-                  for="public_addrs"
+                  for="address"
                   i18n
                   helperText="This address will be assigned to one of the host's network devices and managed automatically."
                   i18n-helperText
                   cdrequiredField
-                  [invalid]="smbForm?.controls['public_addrs']?.controls[i].controls.address.invalid && smbForm?.controls['public_addrs']?.controls[i].controls.address.dirty"
+                  [invalid]="smbForm?.controls['public_addrs']?.controls[i]?.controls?.address?.invalid && smbForm?.controls['public_addrs']?.controls[i]?.controls?.address?.dirty"
                   [invalidText]="addressError"
                 >Address
                   <input
                     type="text"
                     formControlName="address"
                     placeholder="192.168.4.51/24"
-                    [invalid]="smbForm?.controls['public_addrs'].controls[i].controls.address.invalid && smbForm?.controls['public_addrs']?.controls[i].controls.address.dirty"
+                    [invalid]="smbForm?.controls['public_addrs'].controls[i].controls?.address?.invalid && smbForm?.controls['public_addrs']?.controls[i]?.controls?.address?.dirty"
                   />
                 </cds-text-label>
                 <ng-template #addressError>
               <div cdsCol
                    [columnNumbers]="{ lg: 7 }">
                 <cds-text-label
-                  for="public_addrs"
+                  for="destination"
                   i18n
                   helperText="Defines where the system will assign the managed IPs. Each string value must be a network address."
                   i18n-helperText
             </div>
           </ng-container>
         </ng-container>
-        <div
-          *ngIf="(this.smbForm.get('count').value > 1 && this.smbForm.get('clustering').value.toLowerCase() == CLUSTERING.Default) || this.smbForm.get('clustering').value.toLowerCase() == CLUSTERING.Always"
-          class="form-item"
-        >
           <button cdsButton="tertiary"
                   type="button"
                   (click)="addPublicAddrs()"
index 1fa45cd8ae1b0d655cf6af447d1d6cd8e3c69fe4..b15e40a24e2712dab64deb7d1533ec960897d247 100644 (file)
@@ -81,7 +81,7 @@ describe('SmbClusterFormComponent', () => {
   });
 
   it('should check submit request', () => {
-    component.smbForm.get('auth_mode').setValue(AUTHMODE.activeDirectory);
+    component.smbForm.get('auth_mode').setValue(AUTHMODE.ActiveDirectory);
     component.smbForm.get('domain_settings').setValue('test-realm');
     component.smbForm.get('cluster_id').setValue('cluster-id');
     component.submitAction();
index a104c59c24b2c58da4c2e39d0b76a054cf212471..98cfc5bea3f17f965d92793995aba343919c668c 100644 (file)
@@ -51,6 +51,7 @@ export class SmbClusterFormComponent extends CdForm implements OnInit {
   orchStatus$: Observable<any>;
   allClustering: string[] = [];
   CLUSTERING = CLUSTERING;
+  AUTHMODE = AUTHMODE;
   selectedLabels: string[] = [];
   selectedHosts: string[] = [];
   action: string;
@@ -130,7 +131,7 @@ export class SmbClusterFormComponent extends CdForm implements OnInit {
             customDnsFormArray.push(new FormControl(dns));
           });
         }
-        if (this.clusterResponse.auth_mode == AUTHMODE.activeDirectory) {
+        if (this.clusterResponse.auth_mode == AUTHMODE.ActiveDirectory) {
           this.domainSettingsObject = this.clusterResponse?.domain_settings;
           this.smbForm.get('domain_settings').setValue(this.domainSettingsObject.realm);
         } else {
@@ -187,13 +188,13 @@ export class SmbClusterFormComponent extends CdForm implements OnInit {
         validators: [Validators.required]
       }),
       auth_mode: [
-        AUTHMODE.activeDirectory,
+        AUTHMODE.ActiveDirectory,
         {
           validators: [Validators.required]
         }
       ],
       domain_settings: [null],
-      placement: [{}],
+      placement: [],
       hosts: [[]],
       label: [
         null,
@@ -229,7 +230,7 @@ export class SmbClusterFormComponent extends CdForm implements OnInit {
     const userGroupSettingsControl = this.smbForm.get('joinSources') as FormArray;
 
     // User Group Setting should be optional if authMode is "Active Directory"
-    if (authMode === AUTHMODE.activeDirectory) {
+    if (authMode === AUTHMODE.ActiveDirectory) {
       if (userGroupSettingsControl) {
         userGroupSettingsControl.clear();
       }
@@ -285,7 +286,7 @@ export class SmbClusterFormComponent extends CdForm implements OnInit {
     }
 
     // Domain Setting should be mandatory if authMode is "Active Directory"
-    if (authMode === AUTHMODE.activeDirectory && !domainSettingsControl.value) {
+    if (authMode === AUTHMODE.ActiveDirectory && !domainSettingsControl.value) {
       domainSettingsControl.setErrors({ required: true });
       this.smbForm.markAllAsTouched();
       return;
@@ -381,7 +382,7 @@ export class SmbClusterFormComponent extends CdForm implements OnInit {
       requestModel.cluster_resource.clustering = rawFormValue.clustering.toLowerCase();
     }
 
-    if (rawFormValue.placement.count) {
+    if (rawFormValue.placement?.count) {
       requestModel.cluster_resource.count = rawFormValue.placement.count;
     }
 
@@ -450,8 +451,8 @@ export class SmbClusterFormComponent extends CdForm implements OnInit {
 
   addPublicAddrs() {
     const control = this.formBuilder.group({
-      address: ['', Validators.required],
-      destination: ['']
+      address: new FormControl('', { validators: [Validators.required] }),
+      destination: new FormControl('')
     });
     this.public_addrs.push(control);
   }
index b56468b32767bb87d6748a94f7de88629f253dfc..4de3c88794fcc1910412f042e98e986e1dfd3b3f 100644 (file)
@@ -76,7 +76,7 @@ export class SmbUsersgroupsListComponent extends ListWithDetails implements OnIn
       },
       {
         name: $localize`Linked to cluster`,
-        prop: 'values.linked_to_cluster',
+        prop: 'linked_to_cluster',
         flexGrow: 2
       }
     ];
index 07d0dca39fb097b93823db2deeda10aa938507b4..97b123fd86b24ac57dc23d2d8daf589fbfed37bd 100644 (file)
@@ -68,7 +68,7 @@ export const RESOURCE = {
 
 export const AUTHMODE = {
   User: 'user',
-  activeDirectory: 'active-directory'
+  ActiveDirectory: 'active-directory'
 };
 
 export const PLACEMENT = {