Skip to content

Commit 9bc969b

Browse files
committed
mgr/dashboard: fix host form issues
Addressing the review comments in ceph#60355 (review) Issues fixing - cluster expansion host form not closing form when submitting it - cluster expansion host form changing the location when closing it - put the helper text inside helper component since its longer - maintenance field should be hidden in cluster expansion form since its not a valid option while expanding a cluster. We already add host in _no_schedule Fixes: https://tracker.ceph.com/issues/69020 Signed-off-by: Nizamudeen A <[email protected]>
1 parent c459ea8 commit 9bc969b

File tree

3 files changed

+28
-22
lines changed

3 files changed

+28
-22
lines changed

src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/cluster.module.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import {
1212
ProgressIndicatorModule,
1313
InputModule,
1414
ModalModule,
15-
TreeviewModule
15+
TreeviewModule,
16+
ListModule
1617
} from 'carbon-components-angular';
1718

1819
import {
@@ -106,7 +107,8 @@ import { MultiClusterDetailsComponent } from './multi-cluster/multi-cluster-deta
106107
ProgressIndicatorModule,
107108
ButtonModule,
108109
InputModule,
109-
ModalModule
110+
ModalModule,
111+
ListModule
110112
],
111113
declarations: [
112114
HostsComponent,

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<cds-modal size="md"
22
[open]="open"
3-
[hasScrollingContent]="true"
4-
(overlaySelected)="closeModal()">
3+
[hasScrollingContent]="true">
54
<cds-modal-header (closeSelect)="closeModal()">
65
<h3 cdsModalHeaderHeading
76
i18n>{{ action | titlecase }} {{ resource | upperFirst }}</h3>
@@ -14,19 +13,18 @@
1413
<div cdsModalContent>
1514
<!-- Hostname -->
1615
<div class="form-item">
17-
<cds-text-label label="Hostname"
18-
for="hostname"
19-
cdRequiredField="Hostname"
16+
<cds-text-label for="hostname"
2017
[invalid]="!hostForm.controls.hostname.valid && hostForm.controls.hostname.dirty"
21-
[invalidText]="hostnameError"
22-
i18n>Hostname
18+
[invalidText]="hostnameError">
19+
<ng-container i18n>Hostname (required)</ng-container>
2320
<input cdsText
2421
type="text"
2522
placeholder="mon-123"
2623
id="hostname"
2724
name="hostname"
2825
formControlName="hostname"
2926
autofocus
27+
[invalid]="!hostForm.controls.hostname.valid && hostForm.controls.hostname.dirty"
3028
(keyup)="checkHostNameValue()">
3129
</cds-text-label>
3230
<ng-template #hostnameError>
@@ -41,10 +39,13 @@
4139
</ng-template>
4240
<cd-help-text>
4341
To add multiple hosts at once, you can enter:
44-
<ul>
45-
<li>a comma-separated list of hostnames <samp>(e.g.: example-01,example-02,example-03)</samp>,</li>
46-
<li>a range expression <samp>(e.g.: example-[01-03].ceph)</samp>,</li>
47-
<li>a comma separated range expression <samp>(e.g.: example-[01-05].lab.com,example2-[1-4].lab.com,example3-[001-006].lab.com)</samp></li>
42+
<ul cdsList>
43+
<li cdsListItem
44+
i18n>a comma-separated list of hostnames <b>(e.g.: example-01,example-02,example-03)</b>,</li>
45+
<li cdsListItem
46+
i18n>a range expression <b>(e.g.: example-[01-03].ceph)</b>,</li>
47+
<li cdsListItem
48+
i18n>a comma separated range expression <b>(e.g.: example-[01-05].lab.com,example2-[1-4].lab.com,example3-[001-006].lab.com)</b></li>
4849
</ul>
4950
</cd-help-text>
5051
</div>

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, OnInit } from '@angular/core';
1+
import { Component, Inject, OnInit, Optional } from '@angular/core';
22
import { UntypedFormControl, Validators } from '@angular/forms';
33
import { ActivatedRoute, Router } from '@angular/router';
44
import expand from 'brace-expansion';
@@ -13,8 +13,8 @@ import { CdValidators } from '~/app/shared/forms/cd-validators';
1313
import { CdTableFetchDataContext } from '~/app/shared/models/cd-table-fetch-data-context';
1414
import { FinishedTask } from '~/app/shared/models/finished-task';
1515
import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service';
16-
import { Location } from '@angular/common';
1716

17+
const HOSTS = 'hosts';
1818
@Component({
1919
selector: 'cd-host-form',
2020
templateUrl: './host-form.component.html',
@@ -33,7 +33,6 @@ export class HostFormComponent extends CdForm implements OnInit {
3333
pageURL: string;
3434
hostPattern = false;
3535
labelsOption: Array<SelectOption> = [];
36-
hideMaintenance: boolean;
3736

3837
messages = new SelectMessages({
3938
empty: $localize`There are no labels.`,
@@ -47,14 +46,18 @@ export class HostFormComponent extends CdForm implements OnInit {
4746
private hostService: HostService,
4847
private taskWrapper: TaskWrapperService,
4948
private route: ActivatedRoute,
50-
private location: Location
49+
50+
@Inject('hideMaintenance') @Optional() public hideMaintenance?: boolean
5151
) {
5252
super();
5353
this.resource = $localize`host`;
5454
this.action = this.actionLabels.ADD;
5555
}
5656

5757
ngOnInit() {
58+
if (this.router.url.includes(HOSTS)) {
59+
this.pageURL = HOSTS;
60+
}
5861
this.open = this.route.outlet === 'modal';
5962
this.createForm();
6063
const hostContext = new CdTableFetchDataContext(() => undefined);
@@ -147,7 +150,7 @@ export class HostFormComponent extends CdForm implements OnInit {
147150
this.addr = this.hostForm.get('addr').value;
148151
this.status = this.hostForm.get('maintenance').value ? 'maintenance' : '';
149152
this.allLabels = this.hostForm.get('labels').value;
150-
if (this.pageURL !== 'hosts' && !this.allLabels.includes('_no_schedule')) {
153+
if (this.pageURL !== HOSTS && !this.allLabels.includes('_no_schedule')) {
151154
this.allLabels.push('_no_schedule');
152155
}
153156
this.hostnameArray.forEach((hostName: string) => {
@@ -163,15 +166,15 @@ export class HostFormComponent extends CdForm implements OnInit {
163166
this.hostForm.setErrors({ cdSubmitButton: true });
164167
},
165168
complete: () => {
166-
this.pageURL === 'hosts'
167-
? this.router.navigate([this.pageURL, { outlets: { modal: null } }])
168-
: this.location.back();
169+
this.closeModal();
169170
}
170171
});
171172
});
172173
}
173174

174175
closeModal(): void {
175-
this.location.back();
176+
this.pageURL === HOSTS
177+
? this.router.navigate([this.pageURL, { outlets: { modal: null } }])
178+
: (this.open = false);
176179
}
177180
}

0 commit comments

Comments
 (0)