Skip to content

Commit b82dbed

Browse files
authored
Merge pull request ceph#62845 from rhcs-dashboard/fix-path
mgr/dashboard: fix smb edit resources Reviewed-by: Afreen Misbah <[email protected]>
2 parents 743aa34 + a813e9c commit b82dbed

File tree

17 files changed

+102
-101
lines changed

17 files changed

+102
-101
lines changed

src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,8 @@ const routes: Routes = [
454454
children: [
455455
{ path: '', component: SmbClusterListComponent },
456456
{
457-
path: 'clusters',
458-
data: { breadcrumbs: 'Clusters' },
457+
path: 'cluster',
458+
data: { breadcrumbs: 'Cluster' },
459459
children: [
460460
{ path: '', component: SmbClusterListComponent },
461461
{

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ import { SmbService } from '~/app/shared/api/smb.service';
3434
import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service';
3535
import { SmbDomainSettingModalComponent } from '../smb-domain-setting-modal/smb-domain-setting-modal.component';
3636
import { CephServicePlacement } from '~/app/shared/models/service.interface';
37-
import { USERSGROUPS_URL } from '../smb-usersgroups-list/smb-usersgroups-list.component';
3837
import { UpperFirstPipe } from '~/app/shared/pipes/upper-first.pipe';
38+
import { CLUSTER_PATH } from '../smb-cluster-list/smb-cluster-list.component';
39+
import { USERSGROUPS_PATH } from '../smb-usersgroups-list/smb-usersgroups-list.component';
3940

4041
@Component({
4142
selector: 'cd-smb-cluster-form',
@@ -82,7 +83,7 @@ export class SmbClusterFormComponent extends CdForm implements OnInit {
8283
ngOnInit() {
8384
this.action = this.actionLabels.CREATE;
8485
this.usersGroups$ = this.smbService.listUsersGroups();
85-
if (this.router.url.startsWith(`/cephfs/smb/${URLVerbs.EDIT}`)) {
86+
if (this.router.url.startsWith(`/${CLUSTER_PATH}/${URLVerbs.EDIT}`)) {
8687
this.isEdit = true;
8788
}
8889
this.smbService.modalData$.subscribe((data: DomainSettings) => {
@@ -297,18 +298,17 @@ export class SmbClusterFormComponent extends CdForm implements OnInit {
297298

298299
handleTaskRequest(urlVerb: string) {
299300
const requestModel = this.buildRequest();
300-
const BASE_URL = 'smb/cluster';
301301
const component = this;
302302
const cluster_id = this.smbForm.get('cluster_id').value;
303303

304304
this.taskWrapperService
305305
.wrapTaskAroundCall({
306-
task: new FinishedTask(`${BASE_URL}/${urlVerb}`, { cluster_id }),
306+
task: new FinishedTask(`${CLUSTER_PATH}/${urlVerb}`, { cluster_id }),
307307
call: this.smbService.createCluster(requestModel)
308308
})
309309
.subscribe({
310310
complete: () => {
311-
this.router.navigate([`cephfs/smb`]);
311+
this.router.navigate([CLUSTER_PATH]);
312312
},
313313
error: () => {
314314
component.smbForm.setErrors({ cdSubmitButton: true });
@@ -439,7 +439,7 @@ export class SmbClusterFormComponent extends CdForm implements OnInit {
439439
}
440440

441441
navigateCreateUsersGroups() {
442-
this.router.navigate([`${USERSGROUPS_URL}/${URLVerbs.CREATE}`]);
442+
this.router.navigate([`${USERSGROUPS_PATH}/${URLVerbs.CREATE}`]);
443443
}
444444

445445
addCustomDns() {

src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-cluster-list/smb-cluster-list.component.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { BehaviorSubject, Observable, of } from 'rxjs';
44

55
import _ from 'lodash';
66

7-
import { ActionLabelsI18n } from '~/app/shared/constants/app.constants';
7+
import { ActionLabelsI18n, URLVerbs } from '~/app/shared/constants/app.constants';
88
import { TableComponent } from '~/app/shared/datatable/table/table.component';
99
import { CdTableAction } from '~/app/shared/models/cd-table-action';
1010
import { CdTableColumn } from '~/app/shared/models/cd-table-column';
@@ -24,12 +24,13 @@ import { DeleteConfirmationModalComponent } from '~/app/shared/components/delete
2424
import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service';
2525
import { FinishedTask } from '~/app/shared/models/finished-task';
2626

27-
const BASE_URL = 'cephfs/smb/clusters';
27+
export const CLUSTER_PATH = 'cephfs/smb/cluster';
28+
2829
@Component({
2930
selector: 'cd-smb-cluster-list',
3031
templateUrl: './smb-cluster-list.component.html',
3132
styleUrls: ['./smb-cluster-list.component.scss'],
32-
providers: [{ provide: URLBuilderService, useValue: new URLBuilderService(BASE_URL) }]
33+
providers: [{ provide: URLBuilderService, useValue: new URLBuilderService(CLUSTER_PATH) }]
3334
})
3435
export class SmbClusterListComponent extends ListWithDetails implements OnInit {
3536
@ViewChild('table', { static: true })
@@ -87,7 +88,7 @@ export class SmbClusterListComponent extends ListWithDetails implements OnInit {
8788
permission: 'delete',
8889
icon: Icons.destroy,
8990
click: () => this.removeSMBClusterModal(),
90-
name: this.actionLabels.REMOVE
91+
name: this.actionLabels.DELETE
9192
}
9293
];
9394

@@ -116,10 +117,9 @@ export class SmbClusterListComponent extends ListWithDetails implements OnInit {
116117
this.modalService.show(DeleteConfirmationModalComponent, {
117118
itemDescription: $localize`Cluster`,
118119
itemNames: [cluster_id],
119-
actionDescription: $localize`remove`,
120120
submitActionObservable: () =>
121121
this.taskWrapper.wrapTaskAroundCall({
122-
task: new FinishedTask('smb/cluster/remove', {
122+
task: new FinishedTask(`${CLUSTER_PATH}/${URLVerbs.DELETE}`, {
123123
cluster_id: cluster_id
124124
}),
125125
call: this.smbService.removeCluster(cluster_id)

src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-domain-setting-modal/smb-domain-setting-modal.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { CdForm } from '~/app/shared/forms/cd-form';
1212
import { DomainSettings, JoinSource, SMBJoinAuth } from '../smb.model';
1313
import { Observable } from 'rxjs';
1414
import { Router } from '@angular/router';
15-
import { JOINAUTH_URL } from '../smb-join-auth-list/smb-join-auth-list.component';
15+
import { JOIN_AUTH_PATH } from '../smb-join-auth-list/smb-join-auth-list.component';
1616

1717
@Component({
1818
selector: 'cd-smb-domain-setting-modal',
@@ -99,7 +99,7 @@ export class SmbDomainSettingModalComponent extends CdForm implements OnInit {
9999

100100
navigateCreateJoinSource() {
101101
this.closeModal();
102-
this.router.navigate([`${JOINAUTH_URL}/${URLVerbs.CREATE}`]);
102+
this.router.navigate([`${JOIN_AUTH_PATH}/${URLVerbs.CREATE}`]);
103103
}
104104

105105
removeJoinSource(index: number) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ describe('SmbJoinAuthFormComponent', () => {
7373

7474
it('should get resource data and set form fields with it', () => {
7575
expect(getJoinAuth).toHaveBeenCalled();
76-
expect(component.form.value).toEqual({
76+
expect(component.form.getRawValue()).toEqual({
7777
authId: 'foo',
7878
username: 'user',
7979
password: 'pass',

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { FinishedTask } from '~/app/shared/models/finished-task';
1111
import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service';
1212
import { JOIN_AUTH_RESOURCE, SMBCluster, SMBJoinAuth } from '../smb.model';
1313
import { Observable } from 'rxjs';
14-
import { JOINAUTH_URL } from '../smb-join-auth-list/smb-join-auth-list.component';
14+
import { JOIN_AUTH_PATH } from '../smb-join-auth-list/smb-join-auth-list.component';
1515
import { Location } from '@angular/common';
1616

1717
@Component({
@@ -38,7 +38,7 @@ export class SmbJoinAuthFormComponent extends CdForm implements OnInit {
3838
private location: Location
3939
) {
4040
super();
41-
this.editing = this.router.url.startsWith(`${JOINAUTH_URL}/${URLVerbs.EDIT}`);
41+
this.editing = this.router.url.startsWith(`/${JOIN_AUTH_PATH}/${URLVerbs.EDIT}`);
4242
this.resource = $localize`Active directory (AD) access resource`;
4343
}
4444

@@ -49,6 +49,7 @@ export class SmbJoinAuthFormComponent extends CdForm implements OnInit {
4949

5050
if (this.editing) {
5151
this.action = this.actionLabels.UPDATE;
52+
this.form.get('authId').disable();
5253
let editingAuthId: string;
5354
this.route.params.subscribe((params: { authId: string }) => {
5455
editingAuthId = params.authId;
@@ -83,7 +84,6 @@ export class SmbJoinAuthFormComponent extends CdForm implements OnInit {
8384
const username = this.form.getValue('username');
8485
const password = this.form.getValue('password');
8586
const linkedToCluster = this.form.getValue('linkedToCluster');
86-
const BASE_URL = 'smb/ad/';
8787

8888
const joinAuth: SMBJoinAuth = {
8989
resource_type: JOIN_AUTH_RESOURCE,
@@ -93,7 +93,7 @@ export class SmbJoinAuthFormComponent extends CdForm implements OnInit {
9393
};
9494

9595
const self = this;
96-
let taskUrl = `${BASE_URL}${this.editing ? URLVerbs.EDIT : URLVerbs.CREATE}`;
96+
let taskUrl = `${JOIN_AUTH_PATH}/${this.editing ? URLVerbs.EDIT : URLVerbs.CREATE}`;
9797
this.taskWrapperService
9898
.wrapTaskAroundCall({
9999
task: new FinishedTask(taskUrl, {

src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-join-auth-list/smb-join-auth-list.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
22
import { Observable, BehaviorSubject, of } from 'rxjs';
33
import { switchMap, catchError } from 'rxjs/operators';
44
import { SmbService } from '~/app/shared/api/smb.service';
5-
import { ActionLabelsI18n } from '~/app/shared/constants/app.constants';
5+
import { ActionLabelsI18n, URLVerbs } from '~/app/shared/constants/app.constants';
66
import { CdTableAction } from '~/app/shared/models/cd-table-action';
77
import { CdTableColumn } from '~/app/shared/models/cd-table-column';
88
import { CdTableFetchDataContext } from '~/app/shared/models/cd-table-fetch-data-context';
@@ -18,13 +18,13 @@ import { ModalCdsService } from '~/app/shared/services/modal-cds.service';
1818
import { FinishedTask } from '~/app/shared/models/finished-task';
1919
import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service';
2020

21-
export const JOINAUTH_URL = '/cephfs/smb/active-directory';
21+
export const JOIN_AUTH_PATH = 'cephfs/smb/active-directory';
2222

2323
@Component({
2424
selector: 'cd-smb-join-auth-list',
2525
templateUrl: './smb-join-auth-list.component.html',
2626
styleUrls: ['./smb-join-auth-list.component.scss'],
27-
providers: [{ provide: URLBuilderService, useValue: new URLBuilderService(JOINAUTH_URL) }]
27+
providers: [{ provide: URLBuilderService, useValue: new URLBuilderService(JOIN_AUTH_PATH) }]
2828
})
2929
export class SmbJoinAuthListComponent implements OnInit {
3030
columns: CdTableColumn[];
@@ -114,7 +114,7 @@ export class SmbJoinAuthListComponent implements OnInit {
114114
itemNames: [authId],
115115
submitActionObservable: () =>
116116
this.taskWrapper.wrapTaskAroundCall({
117-
task: new FinishedTask('smb/ad/remove', {
117+
task: new FinishedTask(`${JOIN_AUTH_PATH}/${URLVerbs.DELETE}`, {
118118
authId: authId
119119
}),
120120
call: this.smbService.deleteJoinAuth(authId)

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

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,7 @@ import { map } from 'rxjs/operators';
1111
import { ActionLabelsI18n, URLVerbs } from '~/app/shared/constants/app.constants';
1212
import { FinishedTask } from '~/app/shared/models/finished-task';
1313

14-
import {
15-
Filesystem,
16-
PROVIDER,
17-
SHARE_RESOURCE,
18-
SHARE_URL,
19-
ShareRequestModel,
20-
SMBShare
21-
} from '../smb.model';
14+
import { Filesystem, PROVIDER, SHARE_RESOURCE, ShareRequestModel, SMBShare } from '../smb.model';
2215
import { CephfsSubvolumeGroup } from '~/app/shared/models/cephfs-subvolume-group.model';
2316
import { CephfsSubvolume } from '~/app/shared/models/cephfs-subvolume.model';
2417

@@ -27,6 +20,8 @@ import { NfsService } from '~/app/shared/api/nfs.service';
2720
import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service';
2821
import { CephfsSubvolumeGroupService } from '~/app/shared/api/cephfs-subvolume-group.service';
2922
import { CephfsSubvolumeService } from '~/app/shared/api/cephfs-subvolume.service';
23+
import { CLUSTER_PATH } from '../smb-cluster-list/smb-cluster-list.component';
24+
import { SHARE_PATH } from '../smb-share-list/smb-share-list.component';
3025

3126
@Component({
3227
selector: 'cd-smb-share-form',
@@ -58,7 +53,7 @@ export class SmbShareFormComponent extends CdForm implements OnInit {
5853
) {
5954
super();
6055
this.resource = $localize`Share`;
61-
this.isEdit = this.router.url.startsWith(`${SHARE_URL}${URLVerbs.EDIT}`);
56+
this.isEdit = this.router.url.startsWith(`/${SHARE_PATH}/${URLVerbs.EDIT}`);
6257
this.action = this.isEdit ? this.actionLabels.EDIT : this.actionLabels.CREATE;
6358
}
6459
ngOnInit() {
@@ -230,18 +225,17 @@ export class SmbShareFormComponent extends CdForm implements OnInit {
230225

231226
handleTaskRequest(urlVerb: string) {
232227
const requestModel = this.buildRequest();
233-
const BASE_URL = 'smb/share';
234228
const component = this;
235229
const share_id = this.smbShareForm.get('share_id').value;
236230

237231
this.taskWrapperService
238232
.wrapTaskAroundCall({
239-
task: new FinishedTask(`${BASE_URL}/${urlVerb}`, { share_id }),
233+
task: new FinishedTask(`${SHARE_PATH}/${urlVerb}`, { share_id }),
240234
call: this.smbService.createShare(requestModel)
241235
})
242236
.subscribe({
243237
complete: () => {
244-
this.router.navigate([`cephfs/smb`]);
238+
this.router.navigate([CLUSTER_PATH]);
245239
},
246240
error: () => {
247241
component.smbShareForm.setErrors({ cdSubmitButton: true });

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { CdTableAction } from '~/app/shared/models/cd-table-action';
66
import { CdTableColumn } from '~/app/shared/models/cd-table-column';
77
import { CdTableFetchDataContext } from '~/app/shared/models/cd-table-fetch-data-context';
88
import { Permission } from '~/app/shared/models/permissions';
9-
import { SHARE_URL, SMBShare } from '../smb.model';
9+
import { SMBShare } from '../smb.model';
1010
import { SmbService } from '~/app/shared/api/smb.service';
1111
import { AuthStorageService } from '~/app/shared/services/auth-storage.service';
1212
import { CdTableSelection } from '~/app/shared/models/cd-table-selection';
@@ -19,6 +19,8 @@ import { ModalCdsService } from '~/app/shared/services/modal-cds.service';
1919
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
2020
import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service';
2121

22+
export const SHARE_PATH = 'cephfs/smb/share';
23+
2224
@Component({
2325
selector: 'cd-smb-share-list',
2426
templateUrl: './smb-share-list.component.html',
@@ -93,15 +95,15 @@ export class SmbShareListComponent implements OnInit {
9395
name: `${this.actionLabels.CREATE}`,
9496
permission: 'create',
9597
icon: Icons.add,
96-
routerLink: () => ['/cephfs/smb/share/create', this.clusterId],
98+
routerLink: () => [`/${SHARE_PATH}/${URLVerbs.CREATE}`, this.clusterId],
9799
canBePrimary: (selection: CdTableSelection) => !selection.hasSingleSelection
98100
},
99101
{
100102
name: this.actionLabels.EDIT,
101103
permission: 'update',
102104
icon: Icons.edit,
103105
routerLink: () => [
104-
`${SHARE_URL}${URLVerbs.EDIT}`,
106+
`/${SHARE_PATH}/${URLVerbs.EDIT}`,
105107
this.clusterId,
106108
this.selection.first().name
107109
]
@@ -144,7 +146,7 @@ export class SmbShareListComponent implements OnInit {
144146
itemNames: [`Share: ${share_id} (${name}) from cluster: ${cluster_id}`],
145147
submitActionObservable: () =>
146148
this.taskWrapper.wrapTaskAroundCall({
147-
task: new FinishedTask('smb/share/delete', {
149+
task: new FinishedTask(`${SHARE_PATH}/${URLVerbs.DELETE}`, {
148150
share_id: share_id
149151
}),
150152
call: this.smbService.deleteShare(cluster_id, share_id)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
isNavigation="true"
55
[cacheActive]="false">
66
<cds-tab
7-
heading="Clusters"
7+
heading="Cluster"
88
i18n-heading
9-
[active]="activeTab === Tabs.clusters"
10-
(selected)="onSelected(Tabs.clusters)">
9+
[active]="activeTab === Tabs.cluster"
10+
(selected)="onSelected(Tabs.cluster)">
1111
</cds-tab>
1212
<cds-tab
1313
heading="Active Directory"

0 commit comments

Comments
 (0)