Skip to content

Commit 23c2cda

Browse files
committed
mgr/dashboard: enable editing of cluster api url on multi-cluster edit form and fix password field as required
- Removes unnecessary comments - Alias name can keep its name when editing Fixes: https://tracker.ceph.com/issues/66770 Signed-off-by: Pedro Gonzalez Gomez <[email protected]>
1 parent c3af089 commit 23c2cda

File tree

5 files changed

+26
-13
lines changed

5 files changed

+26
-13
lines changed

src/pybind/mgr/dashboard/controllers/multi_cluster.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,13 @@ def reconnect_cluster(self, url: str, username=None, password=None,
267267
@Endpoint('PUT')
268268
@UpdatePermission
269269
# pylint: disable=unused-variable
270-
def edit_cluster(self, url, cluster_alias, username, verify=False, ssl_certificate=None):
270+
def edit_cluster(self, name, url, cluster_alias, username, verify=False, ssl_certificate=None):
271271
multicluster_config = self.load_multi_cluster_config()
272272
if "config" in multicluster_config:
273273
for key, cluster_details in multicluster_config["config"].items():
274274
for cluster in cluster_details:
275-
if cluster["url"] == url and cluster["user"] == username:
275+
if cluster["name"] == name and cluster["user"] == username:
276+
cluster['url'] = url
276277
cluster['cluster_alias'] = cluster_alias
277278
cluster['ssl_verify'] = verify
278279
cluster['ssl_certificate'] = ssl_certificate if verify else ''

src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/multi-cluster/multi-cluster-form/multi-cluster-form.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
</cd-copy-2-clipboard-button>
118118
</span>
119119
<span class="invalid-feedback"
120-
*ngIf="remoteClusterForm.showError('password', frm, 'required')"
120+
*ngIf="remoteClusterForm.showError('password', frm, 'requiredNotEdit')"
121121
i18n>This field is required.
122122
</span>
123123
</div>

src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/multi-cluster/multi-cluster-form/multi-cluster-form.component.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ export class MultiClusterFormComponent implements OnInit, OnDestroy {
5252
ngOnInit(): void {
5353
if (this.action === 'edit') {
5454
this.remoteClusterForm.get('remoteClusterUrl').setValue(this.cluster.url);
55-
this.remoteClusterForm.get('remoteClusterUrl').disable();
5655
this.remoteClusterForm.get('clusterAlias').setValue(this.cluster.cluster_alias);
5756
this.remoteClusterForm.get('ssl').setValue(this.cluster.ssl_verify);
5857
this.remoteClusterForm.get('ssl_cert').setValue(this.cluster.ssl_certificate);
@@ -76,7 +75,6 @@ export class MultiClusterFormComponent implements OnInit, OnDestroy {
7675

7776
createForm() {
7877
this.remoteClusterForm = new CdFormGroup({
79-
// showToken: new FormControl(false),
8078
username: new FormControl('', [
8179
CdValidators.custom('uniqueUrlandUser', (username: string) => {
8280
let remoteClusterUrl = '';
@@ -96,7 +94,12 @@ export class MultiClusterFormComponent implements OnInit, OnDestroy {
9694
);
9795
})
9896
]),
99-
password: new FormControl('', []),
97+
password: new FormControl(
98+
null,
99+
CdValidators.custom('requiredNotEdit', (value: string) => {
100+
return this.action !== 'edit' && !value;
101+
})
102+
),
100103
remoteClusterUrl: new FormControl(null, {
101104
validators: [
102105
CdValidators.custom('endpoint', (value: string) => {
@@ -116,19 +119,16 @@ export class MultiClusterFormComponent implements OnInit, OnDestroy {
116119
Validators.required
117120
]
118121
}),
119-
// apiToken: new FormControl('', [
120-
// CdValidators.requiredIf({
121-
// showToken: true
122-
// })
123-
// ]),
124122
clusterAlias: new FormControl(null, {
125123
validators: [
126124
Validators.required,
127125
CdValidators.custom('uniqueName', (clusterAlias: string) => {
128126
return (
129127
(this.action === 'connect' || this.action === 'edit') &&
130128
this.clusterAliasNames &&
131-
this.clusterAliasNames.indexOf(clusterAlias) !== -1
129+
this.clusterAliasNames.indexOf(clusterAlias) !== -1 &&
130+
this.cluster?.cluster_alias &&
131+
this.cluster.cluster_alias !== clusterAlias
132132
);
133133
})
134134
]
@@ -197,7 +197,14 @@ export class MultiClusterFormComponent implements OnInit, OnDestroy {
197197
case 'edit':
198198
this.subs.add(
199199
this.multiClusterService
200-
.editCluster(this.cluster.url, clusterAlias, this.cluster.user, ssl, ssl_certificate)
200+
.editCluster(
201+
this.cluster.name,
202+
url,
203+
clusterAlias,
204+
this.cluster.user,
205+
ssl,
206+
ssl_certificate
207+
)
201208
.subscribe({
202209
...commonSubscribtion,
203210
complete: () => this.handleSuccess($localize`Cluster updated successfully`)

src/pybind/mgr/dashboard/frontend/src/app/shared/api/multi-cluster.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,15 @@ export class MultiClusterService {
116116
}
117117

118118
editCluster(
119+
name: string,
119120
url: any,
120121
clusterAlias: string,
121122
username: string,
122123
verify = false,
123124
ssl_certificate = ''
124125
) {
125126
return this.http.put('api/multi-cluster/edit_cluster', {
127+
name: name,
126128
url,
127129
cluster_alias: clusterAlias,
128130
username: username,

src/pybind/mgr/dashboard/openapi.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7244,6 +7244,8 @@ paths:
72447244
properties:
72457245
cluster_alias:
72467246
type: string
7247+
name:
7248+
type: string
72477249
ssl_certificate:
72487250
type: string
72497251
url:
@@ -7254,6 +7256,7 @@ paths:
72547256
default: false
72557257
type: boolean
72567258
required:
7259+
- name
72577260
- url
72587261
- cluster_alias
72597262
- username

0 commit comments

Comments
 (0)