]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: enable editing of cluster api url on multi-cluster edit form and fix... 58167/head
authorPedro Gonzalez Gomez <pegonzal@redhat.com>
Thu, 20 Jun 2024 14:22:40 +0000 (16:22 +0200)
committerPedro Gonzalez Gomez <pegonzal@redhat.com>
Thu, 4 Jul 2024 19:13:24 +0000 (21:13 +0200)
- Removes unnecessary comments
- Alias name can keep its name when editing

Fixes: https://tracker.ceph.com/issues/66770
Signed-off-by: Pedro Gonzalez Gomez <pegonzal@redhat.com>
src/pybind/mgr/dashboard/controllers/multi_cluster.py
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/multi-cluster/multi-cluster-form/multi-cluster-form.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/multi-cluster/multi-cluster-form/multi-cluster-form.component.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/api/multi-cluster.service.ts
src/pybind/mgr/dashboard/openapi.yaml

index 8fdecf99d44489e62dad20c2aceb62ae6c6c54e7..87cc8314ae4b8c0b21e109f9d12536bed6ed939d 100644 (file)
@@ -267,12 +267,13 @@ class MultiCluster(RESTController):
     @Endpoint('PUT')
     @UpdatePermission
     # pylint: disable=unused-variable
-    def edit_cluster(self, url, cluster_alias, username, verify=False, ssl_certificate=None):
+    def edit_cluster(self, name, url, cluster_alias, username, verify=False, ssl_certificate=None):
         multicluster_config = self.load_multi_cluster_config()
         if "config" in multicluster_config:
             for key, cluster_details in multicluster_config["config"].items():
                 for cluster in cluster_details:
-                    if cluster["url"] == url and cluster["user"] == username:
+                    if cluster["name"] == name and cluster["user"] == username:
+                        cluster['url'] = url
                         cluster['cluster_alias'] = cluster_alias
                         cluster['ssl_verify'] = verify
                         cluster['ssl_certificate'] = ssl_certificate if verify else ''
index 6cc09c772b18f5edcf28c176326eb3a28da0ad80..4bdb2ad45c99130de4f6c04c21e48875416c84c8 100644 (file)
                 </cd-copy-2-clipboard-button>
               </span>
               <span class="invalid-feedback"
-                    *ngIf="remoteClusterForm.showError('password', frm, 'required')"
+                    *ngIf="remoteClusterForm.showError('password', frm, 'requiredNotEdit')"
                     i18n>This field is required.
               </span>
             </div>
index 32548f63c8a3583de5e6f79a3c6f3feddf255429..596ddff11ecf5a2f10e0410d21d489a2fc8caf46 100644 (file)
@@ -52,7 +52,6 @@ export class MultiClusterFormComponent implements OnInit, OnDestroy {
   ngOnInit(): void {
     if (this.action === 'edit') {
       this.remoteClusterForm.get('remoteClusterUrl').setValue(this.cluster.url);
-      this.remoteClusterForm.get('remoteClusterUrl').disable();
       this.remoteClusterForm.get('clusterAlias').setValue(this.cluster.cluster_alias);
       this.remoteClusterForm.get('ssl').setValue(this.cluster.ssl_verify);
       this.remoteClusterForm.get('ssl_cert').setValue(this.cluster.ssl_certificate);
@@ -76,7 +75,6 @@ export class MultiClusterFormComponent implements OnInit, OnDestroy {
 
   createForm() {
     this.remoteClusterForm = new CdFormGroup({
-      // showToken: new FormControl(false),
       username: new FormControl('', [
         CdValidators.custom('uniqueUrlandUser', (username: string) => {
           let remoteClusterUrl = '';
@@ -96,7 +94,12 @@ export class MultiClusterFormComponent implements OnInit, OnDestroy {
           );
         })
       ]),
-      password: new FormControl('', []),
+      password: new FormControl(
+        null,
+        CdValidators.custom('requiredNotEdit', (value: string) => {
+          return this.action !== 'edit' && !value;
+        })
+      ),
       remoteClusterUrl: new FormControl(null, {
         validators: [
           CdValidators.custom('endpoint', (value: string) => {
@@ -116,11 +119,6 @@ export class MultiClusterFormComponent implements OnInit, OnDestroy {
           Validators.required
         ]
       }),
-      // apiToken: new FormControl('', [
-      //   CdValidators.requiredIf({
-      //     showToken: true
-      //   })
-      // ]),
       clusterAlias: new FormControl(null, {
         validators: [
           Validators.required,
@@ -128,7 +126,9 @@ export class MultiClusterFormComponent implements OnInit, OnDestroy {
             return (
               (this.action === 'connect' || this.action === 'edit') &&
               this.clusterAliasNames &&
-              this.clusterAliasNames.indexOf(clusterAlias) !== -1
+              this.clusterAliasNames.indexOf(clusterAlias) !== -1 &&
+              this.cluster?.cluster_alias &&
+              this.cluster.cluster_alias !== clusterAlias
             );
           })
         ]
@@ -197,7 +197,14 @@ export class MultiClusterFormComponent implements OnInit, OnDestroy {
       case 'edit':
         this.subs.add(
           this.multiClusterService
-            .editCluster(this.cluster.url, clusterAlias, this.cluster.user, ssl, ssl_certificate)
+            .editCluster(
+              this.cluster.name,
+              url,
+              clusterAlias,
+              this.cluster.user,
+              ssl,
+              ssl_certificate
+            )
             .subscribe({
               ...commonSubscribtion,
               complete: () => this.handleSuccess($localize`Cluster updated successfully`)
index 5a03abd22ff74751c729537ba62e7928364f0c93..df901697e68274764f8db27d01dfe2454108b216 100644 (file)
@@ -116,6 +116,7 @@ export class MultiClusterService {
   }
 
   editCluster(
+    name: string,
     url: any,
     clusterAlias: string,
     username: string,
@@ -123,6 +124,7 @@ export class MultiClusterService {
     ssl_certificate = ''
   ) {
     return this.http.put('api/multi-cluster/edit_cluster', {
+      name: name,
       url,
       cluster_alias: clusterAlias,
       username: username,
index 99c4ee54f0b8ba3e23cb3647d3a9b67e861c124a..ae2fdd8bb02c1635c115ea4a218fcdb40e262476 100644 (file)
@@ -7244,6 +7244,8 @@ paths:
               properties:
                 cluster_alias:
                   type: string
+                name:
+                  type: string
                 ssl_certificate:
                   type: string
                 url:
@@ -7254,6 +7256,7 @@ paths:
                   default: false
                   type: boolean
               required:
+              - name
               - url
               - cluster_alias
               - username