Skip to content

Commit 25621b2

Browse files
author
Dnyaneshwari
committed
mgr/dashboard: file/smb: Create SMB share dialog is missing a share name input
Fixes: https://tracker.ceph.com/issues/73472 Signed-off-by: Dnyaneshwari Talwekar <[email protected]>
1 parent ef04e24 commit 25621b2

File tree

3 files changed

+109
-73
lines changed

3 files changed

+109
-73
lines changed

src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-share-form/smb-share-form.component.html

Lines changed: 90 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,53 @@
1111
</div>
1212

1313
<!-- Share Id -->
14-
<div class="form-item">
15-
<cds-text-label
16-
labelInputID="share_id"
17-
i18n
18-
helperText="Unique share identifier"
19-
i18n-helperText
20-
cdRequiredField="Share Name"
21-
[invalid]="smbShareForm.controls.share_id.invalid && smbShareForm.controls.share_id.dirty"
22-
[invalidText]="shareError"
23-
>Share Name
24-
<input
25-
cdsText
26-
type="text"
27-
id="share_id"
28-
formControlName="share_id"
29-
[invalid]="smbShareForm.controls.share_id.invalid && smbShareForm.controls.share_id.dirty"
30-
/>
31-
</cds-text-label>
32-
<ng-template #shareError>
33-
<span
34-
class="invalid-feedback"
35-
*ngIf="smbShareForm.showError('share_id', formDir, 'required')"
14+
<div class="form-item form-item-append"
15+
cdsRow>
16+
<div cdsCol>
17+
<cds-text-label
18+
labelInputID="share_id"
3619
i18n
37-
>This field is required.</span
38-
>
39-
</ng-template>
20+
helperText="A unique identifier for share"
21+
i18n-helperText
22+
cdRequiredField="Share ID"
23+
[invalid]="
24+
smbShareForm.controls.share_id.invalid && smbShareForm.controls.share_id.dirty
25+
"
26+
[invalidText]="shareError"
27+
>Share ID
28+
<input
29+
cdsText
30+
type="text"
31+
id="share_id"
32+
formControlName="share_id"
33+
[invalid]="
34+
smbShareForm.controls.share_id.invalid && smbShareForm.controls.share_id.dirty
35+
"
36+
[invalidText]="shareError"
37+
/>
38+
</cds-text-label>
39+
<ng-template #shareError>
40+
<span
41+
class="invalid-feedback"
42+
*ngIf="smbShareForm.showError('share_id', formDir, 'required')"
43+
i18n
44+
>This field is required.</span
45+
>
46+
</ng-template>
47+
</div>
48+
49+
<!-- Share Name -->
50+
<div cdsCol>
51+
<cds-text-label labelInputID="name"
52+
i18n
53+
helperText="Name of the Share"
54+
i18n-helperText>Share Name
55+
<input cdsText
56+
type="text"
57+
id="name"
58+
formControlName="name" />
59+
</cds-text-label>
60+
</div>
4061
</div>
4162

4263
<!-- Volume -->
@@ -49,7 +70,8 @@
4970
(change)="volumeChangeHandler()"
5071
[invalid]="smbShareForm.controls.volume.invalid && smbShareForm.controls.volume.dirty"
5172
[invalidText]="volumeError"
52-
i18n-label>
73+
i18n-label
74+
>
5375
<option *ngIf="allFsNames?.length === 0"
5476
value=""
5577
i18n>
@@ -84,7 +106,8 @@
84106
id="subvolume_group"
85107
(change)="getSubVol()"
86108
[skeleton]="allsubvolgrps === null"
87-
i18n-label>
109+
i18n-label
110+
>
88111
<option *ngIf="allsubvolgrps === null"
89112
value=""
90113
i18n>Loading...</option>
@@ -137,50 +160,50 @@
137160
</cds-select>
138161
</div>
139162

140-
<!-- Path -->
141-
<div class="form-item form-item-append"
142-
cdsRow>
143-
<div cdsCol>
144-
<cds-text-label labelInputID="prefixedPath"
145-
i18n
146-
helperText="A path is a relative path.">Prefixed Path
147-
<input cdsText
148-
type="text"
149-
id="prefixedPath"
150-
formControlName="prefixedPath" />
151-
</cds-text-label>
152-
</div>
153-
<div cdsCol>
154-
<cds-text-label
155-
labelInputID="inputPath"
156-
i18n
157-
[invalid]="
158-
smbShareForm.controls.inputPath.invalid && smbShareForm.controls.inputPath.dirty
159-
"
160-
[invalidText]="pathError"
161-
helperText="A relative path in a cephFS file system."
162-
cdRequiredField="Path"
163-
>Input Path
164-
<input
165-
cdsText
166-
type="text"
167-
id="inputPath"
168-
formControlName="inputPath"
163+
<!-- Path -->
164+
<div class="form-item form-item-append"
165+
cdsRow>
166+
<div cdsCol>
167+
<cds-text-label labelInputID="prefixedPath"
168+
i18n
169+
helperText="A path is a relative path.">Prefixed Path
170+
<input cdsText
171+
type="text"
172+
id="prefixedPath"
173+
formControlName="prefixedPath" />
174+
</cds-text-label>
175+
</div>
176+
<div cdsCol>
177+
<cds-text-label
178+
labelInputID="inputPath"
179+
i18n
169180
[invalid]="
170181
smbShareForm.controls.inputPath.invalid && smbShareForm.controls.inputPath.dirty
171182
"
172-
/>
173-
</cds-text-label>
174-
<ng-template #pathError>
175-
<span
176-
class="invalid-feedback"
177-
*ngIf="smbShareForm.showError('inputPath', formDir, 'required')"
178-
i18n
179-
>This field is required.</span
180-
>
181-
</ng-template>
183+
[invalidText]="pathError"
184+
helperText="A relative path in a cephFS file system."
185+
cdRequiredField="Path"
186+
>Input Path
187+
<input
188+
cdsText
189+
type="text"
190+
id="inputPath"
191+
formControlName="inputPath"
192+
[invalid]="
193+
smbShareForm.controls.inputPath.invalid && smbShareForm.controls.inputPath.dirty
194+
"
195+
/>
196+
</cds-text-label>
197+
<ng-template #pathError>
198+
<span
199+
class="invalid-feedback"
200+
*ngIf="smbShareForm.showError('inputPath', formDir, 'required')"
201+
i18n
202+
>This field is required.</span
203+
>
204+
</ng-template>
205+
</div>
182206
</div>
183-
</div>
184207

185208
<!-- Browseable -->
186209
<div class="form-item">

src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-share-form/smb-share-form.component.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ describe('SmbShareFormComponent', () => {
8383
component.smbShareForm.setValue({
8484
share_id: 'share1',
8585
volume: 'fs1',
86+
name: 'My Share',
8687
subvolume_group: 'group1',
8788
subvolume: 'subvol1',
8889
prefixedPath: '/volumes/fs1/group1/subvol1',

src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-share-form/smb-share-form.component.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,30 @@ export class SmbShareFormComponent extends CdForm implements OnInit {
7070
this.shareResponse = resp;
7171
this.smbShareForm.get('share_id').setValue(this.shareResponse.share_id);
7272
this.smbShareForm.get('share_id').disable();
73-
this.smbShareForm.get('volume').setValue(this.shareResponse.cephfs.volume);
74-
this.smbShareForm.get('subvolume_group').setValue(this.shareResponse.cephfs.subvolumegroup);
75-
this.smbShareForm.get('subvolume').setValue(this.shareResponse.cephfs.subvolume);
76-
this.smbShareForm.get('inputPath').setValue(this.shareResponse.cephfs.path);
73+
this.smbShareForm.get('name').setValue(this.shareResponse.name);
74+
this.smbShareForm.get('name').disable();
75+
this.smbShareForm.get('volume').setValue(this.shareResponse?.cephfs?.volume);
76+
this.smbShareForm
77+
.get('subvolume_group')
78+
.setValue(this.shareResponse?.cephfs?.subvolumegroup);
79+
this.smbShareForm.get('subvolume').setValue(this.shareResponse?.cephfs?.subvolume);
80+
this.smbShareForm.get('inputPath').setValue(this.shareResponse?.cephfs?.path);
7781
if (this.shareResponse.readonly) {
7882
this.smbShareForm.get('readonly').setValue(this.shareResponse.readonly);
7983
}
8084
if (this.shareResponse.browseable) {
8185
this.smbShareForm.get('browseable').setValue(this.shareResponse.browseable);
8286
}
8387

84-
this.getSubVolGrp(this.shareResponse.cephfs.volume);
88+
this.getSubVolGrp(this.shareResponse?.cephfs?.volume);
8589
});
8690
}
91+
this.smbShareForm.get('share_id')?.valueChanges.subscribe((value) => {
92+
const shareName = this.smbShareForm.get('name');
93+
if (shareName && !shareName.dirty) {
94+
shareName.setValue(value, { emitEvent: false });
95+
}
96+
});
8797
this.loadingReady();
8898
}
8999

@@ -92,6 +102,7 @@ export class SmbShareFormComponent extends CdForm implements OnInit {
92102
share_id: new FormControl('', {
93103
validators: [Validators.required]
94104
}),
105+
name: new FormControl(''),
95106
volume: new FormControl('', {
96107
validators: [Validators.required]
97108
}),
@@ -195,11 +206,13 @@ export class SmbShareFormComponent extends CdForm implements OnInit {
195206
const rawFormValue = _.cloneDeep(this.smbShareForm.value);
196207
const correctedPath = rawFormValue.inputPath;
197208
const shareId = this.smbShareForm.get('share_id')?.value;
209+
const shareName = this.smbShareForm.get('name').value;
198210
const requestModel: ShareRequestModel = {
199211
share_resource: {
200212
resource_type: SHARE_RESOURCE,
201213
cluster_id: this.clusterId,
202214
share_id: shareId,
215+
name: shareName,
203216
cephfs: {
204217
volume: rawFormValue.volume,
205218
path: correctedPath,
@@ -211,7 +224,6 @@ export class SmbShareFormComponent extends CdForm implements OnInit {
211224
readonly: rawFormValue.readonly
212225
}
213226
};
214-
215227
return requestModel;
216228
}
217229

0 commit comments

Comments
 (0)