From a813e9cff4f7c0d474acb5144a4defd4add48762 Mon Sep 17 00:00:00 2001 From: Pedro Gonzalez Gomez Date: Wed, 16 Apr 2025 11:48:01 +0200 Subject: [PATCH] mgr/dashboard: fix smb edit resources - Fixes smb cluster edit due to wrong path - Disables authId and usersGroupsId for ad/standalone edit - Removes hardcoded paths by unifyng all smb resources path with constants - Renames smb/clusters -> smb/cluster path for consistency - Reorders task messages Fixes: https://tracker.ceph.com/issues/70946 Signed-off-by: Pedro Gonzalez Gomez --- .../frontend/src/app/app-routing.module.ts | 4 +- .../smb-cluster-form.component.ts | 12 +-- .../smb-cluster-list.component.ts | 12 +-- .../smb-domain-setting-modal.component.ts | 4 +- .../smb-join-auth-form.component.spec.ts | 2 +- .../smb-join-auth-form.component.ts | 8 +- .../smb-join-auth-list.component.ts | 8 +- .../smb-share-form.component.ts | 18 ++-- .../smb-share-list.component.ts | 10 ++- .../ceph/smb/smb-tabs/smb-tabs.component.html | 6 +- .../smb/smb-tabs/smb-tabs.component.spec.ts | 2 +- .../ceph/smb/smb-tabs/smb-tabs.component.ts | 10 ++- .../smb-usersgroups-form.component.spec.ts | 2 +- .../smb-usersgroups-form.component.ts | 8 +- .../smb-usersgroups-list.component.ts | 8 +- .../frontend/src/app/ceph/smb/smb.model.ts | 2 - .../shared/services/task-message.service.ts | 87 ++++++++++--------- 17 files changed, 102 insertions(+), 101 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts index 59c576330d94c..c8f9de71e022c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts @@ -454,8 +454,8 @@ const routes: Routes = [ children: [ { path: '', component: SmbClusterListComponent }, { - path: 'clusters', - data: { breadcrumbs: 'Clusters' }, + path: 'cluster', + data: { breadcrumbs: 'Cluster' }, children: [ { path: '', component: SmbClusterListComponent }, { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-cluster-form/smb-cluster-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-cluster-form/smb-cluster-form.component.ts index 3c30a9abcc412..78bb616246f52 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-cluster-form/smb-cluster-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-cluster-form/smb-cluster-form.component.ts @@ -34,8 +34,9 @@ import { SmbService } from '~/app/shared/api/smb.service'; import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service'; import { SmbDomainSettingModalComponent } from '../smb-domain-setting-modal/smb-domain-setting-modal.component'; import { CephServicePlacement } from '~/app/shared/models/service.interface'; -import { USERSGROUPS_URL } from '../smb-usersgroups-list/smb-usersgroups-list.component'; import { UpperFirstPipe } from '~/app/shared/pipes/upper-first.pipe'; +import { CLUSTER_PATH } from '../smb-cluster-list/smb-cluster-list.component'; +import { USERSGROUPS_PATH } from '../smb-usersgroups-list/smb-usersgroups-list.component'; @Component({ selector: 'cd-smb-cluster-form', @@ -82,7 +83,7 @@ export class SmbClusterFormComponent extends CdForm implements OnInit { ngOnInit() { this.action = this.actionLabels.CREATE; this.usersGroups$ = this.smbService.listUsersGroups(); - if (this.router.url.startsWith(`/cephfs/smb/${URLVerbs.EDIT}`)) { + if (this.router.url.startsWith(`/${CLUSTER_PATH}/${URLVerbs.EDIT}`)) { this.isEdit = true; } this.smbService.modalData$.subscribe((data: DomainSettings) => { @@ -297,18 +298,17 @@ export class SmbClusterFormComponent extends CdForm implements OnInit { handleTaskRequest(urlVerb: string) { const requestModel = this.buildRequest(); - const BASE_URL = 'smb/cluster'; const component = this; const cluster_id = this.smbForm.get('cluster_id').value; this.taskWrapperService .wrapTaskAroundCall({ - task: new FinishedTask(`${BASE_URL}/${urlVerb}`, { cluster_id }), + task: new FinishedTask(`${CLUSTER_PATH}/${urlVerb}`, { cluster_id }), call: this.smbService.createCluster(requestModel) }) .subscribe({ complete: () => { - this.router.navigate([`cephfs/smb`]); + this.router.navigate([CLUSTER_PATH]); }, error: () => { component.smbForm.setErrors({ cdSubmitButton: true }); @@ -439,7 +439,7 @@ export class SmbClusterFormComponent extends CdForm implements OnInit { } navigateCreateUsersGroups() { - this.router.navigate([`${USERSGROUPS_URL}/${URLVerbs.CREATE}`]); + this.router.navigate([`${USERSGROUPS_PATH}/${URLVerbs.CREATE}`]); } addCustomDns() { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-cluster-list/smb-cluster-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-cluster-list/smb-cluster-list.component.ts index 2cc53a8241d3c..88c4b4c9bcd2f 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-cluster-list/smb-cluster-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-cluster-list/smb-cluster-list.component.ts @@ -4,7 +4,7 @@ import { BehaviorSubject, Observable, of } from 'rxjs'; import _ from 'lodash'; -import { ActionLabelsI18n } from '~/app/shared/constants/app.constants'; +import { ActionLabelsI18n, URLVerbs } from '~/app/shared/constants/app.constants'; import { TableComponent } from '~/app/shared/datatable/table/table.component'; import { CdTableAction } from '~/app/shared/models/cd-table-action'; import { CdTableColumn } from '~/app/shared/models/cd-table-column'; @@ -24,12 +24,13 @@ import { DeleteConfirmationModalComponent } from '~/app/shared/components/delete import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service'; import { FinishedTask } from '~/app/shared/models/finished-task'; -const BASE_URL = 'cephfs/smb/clusters'; +export const CLUSTER_PATH = 'cephfs/smb/cluster'; + @Component({ selector: 'cd-smb-cluster-list', templateUrl: './smb-cluster-list.component.html', styleUrls: ['./smb-cluster-list.component.scss'], - providers: [{ provide: URLBuilderService, useValue: new URLBuilderService(BASE_URL) }] + providers: [{ provide: URLBuilderService, useValue: new URLBuilderService(CLUSTER_PATH) }] }) export class SmbClusterListComponent extends ListWithDetails implements OnInit { @ViewChild('table', { static: true }) @@ -87,7 +88,7 @@ export class SmbClusterListComponent extends ListWithDetails implements OnInit { permission: 'delete', icon: Icons.destroy, click: () => this.removeSMBClusterModal(), - name: this.actionLabels.REMOVE + name: this.actionLabels.DELETE } ]; @@ -116,10 +117,9 @@ export class SmbClusterListComponent extends ListWithDetails implements OnInit { this.modalService.show(DeleteConfirmationModalComponent, { itemDescription: $localize`Cluster`, itemNames: [cluster_id], - actionDescription: $localize`remove`, submitActionObservable: () => this.taskWrapper.wrapTaskAroundCall({ - task: new FinishedTask('smb/cluster/remove', { + task: new FinishedTask(`${CLUSTER_PATH}/${URLVerbs.DELETE}`, { cluster_id: cluster_id }), call: this.smbService.removeCluster(cluster_id) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-domain-setting-modal/smb-domain-setting-modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-domain-setting-modal/smb-domain-setting-modal.component.ts index 24415b9b1d80f..c995a0a325808 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-domain-setting-modal/smb-domain-setting-modal.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-domain-setting-modal/smb-domain-setting-modal.component.ts @@ -12,7 +12,7 @@ import { CdForm } from '~/app/shared/forms/cd-form'; import { DomainSettings, JoinSource, SMBJoinAuth } from '../smb.model'; import { Observable } from 'rxjs'; import { Router } from '@angular/router'; -import { JOINAUTH_URL } from '../smb-join-auth-list/smb-join-auth-list.component'; +import { JOIN_AUTH_PATH } from '../smb-join-auth-list/smb-join-auth-list.component'; @Component({ selector: 'cd-smb-domain-setting-modal', @@ -99,7 +99,7 @@ export class SmbDomainSettingModalComponent extends CdForm implements OnInit { navigateCreateJoinSource() { this.closeModal(); - this.router.navigate([`${JOINAUTH_URL}/${URLVerbs.CREATE}`]); + this.router.navigate([`${JOIN_AUTH_PATH}/${URLVerbs.CREATE}`]); } removeJoinSource(index: number) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-join-auth-form/smb-join-auth-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-join-auth-form/smb-join-auth-form.component.spec.ts index 810a5c9625d82..1db85d9993ff7 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-join-auth-form/smb-join-auth-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-join-auth-form/smb-join-auth-form.component.spec.ts @@ -73,7 +73,7 @@ describe('SmbJoinAuthFormComponent', () => { it('should get resource data and set form fields with it', () => { expect(getJoinAuth).toHaveBeenCalled(); - expect(component.form.value).toEqual({ + expect(component.form.getRawValue()).toEqual({ authId: 'foo', username: 'user', password: 'pass', diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-join-auth-form/smb-join-auth-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-join-auth-form/smb-join-auth-form.component.ts index 308ad15f36d63..b727998d77ba8 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-join-auth-form/smb-join-auth-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-join-auth-form/smb-join-auth-form.component.ts @@ -11,7 +11,7 @@ import { FinishedTask } from '~/app/shared/models/finished-task'; import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service'; import { JOIN_AUTH_RESOURCE, SMBCluster, SMBJoinAuth } from '../smb.model'; import { Observable } from 'rxjs'; -import { JOINAUTH_URL } from '../smb-join-auth-list/smb-join-auth-list.component'; +import { JOIN_AUTH_PATH } from '../smb-join-auth-list/smb-join-auth-list.component'; import { Location } from '@angular/common'; @Component({ @@ -38,7 +38,7 @@ export class SmbJoinAuthFormComponent extends CdForm implements OnInit { private location: Location ) { super(); - this.editing = this.router.url.startsWith(`${JOINAUTH_URL}/${URLVerbs.EDIT}`); + this.editing = this.router.url.startsWith(`/${JOIN_AUTH_PATH}/${URLVerbs.EDIT}`); this.resource = $localize`Active directory (AD) access resource`; } @@ -49,6 +49,7 @@ export class SmbJoinAuthFormComponent extends CdForm implements OnInit { if (this.editing) { this.action = this.actionLabels.UPDATE; + this.form.get('authId').disable(); let editingAuthId: string; this.route.params.subscribe((params: { authId: string }) => { editingAuthId = params.authId; @@ -83,7 +84,6 @@ export class SmbJoinAuthFormComponent extends CdForm implements OnInit { const username = this.form.getValue('username'); const password = this.form.getValue('password'); const linkedToCluster = this.form.getValue('linkedToCluster'); - const BASE_URL = 'smb/ad/'; const joinAuth: SMBJoinAuth = { resource_type: JOIN_AUTH_RESOURCE, @@ -93,7 +93,7 @@ export class SmbJoinAuthFormComponent extends CdForm implements OnInit { }; const self = this; - let taskUrl = `${BASE_URL}${this.editing ? URLVerbs.EDIT : URLVerbs.CREATE}`; + let taskUrl = `${JOIN_AUTH_PATH}/${this.editing ? URLVerbs.EDIT : URLVerbs.CREATE}`; this.taskWrapperService .wrapTaskAroundCall({ task: new FinishedTask(taskUrl, { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-join-auth-list/smb-join-auth-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-join-auth-list/smb-join-auth-list.component.ts index 7ed04f0c738db..c34090e78460d 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-join-auth-list/smb-join-auth-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-join-auth-list/smb-join-auth-list.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { Observable, BehaviorSubject, of } from 'rxjs'; import { switchMap, catchError } from 'rxjs/operators'; import { SmbService } from '~/app/shared/api/smb.service'; -import { ActionLabelsI18n } from '~/app/shared/constants/app.constants'; +import { ActionLabelsI18n, URLVerbs } from '~/app/shared/constants/app.constants'; import { CdTableAction } from '~/app/shared/models/cd-table-action'; import { CdTableColumn } from '~/app/shared/models/cd-table-column'; import { CdTableFetchDataContext } from '~/app/shared/models/cd-table-fetch-data-context'; @@ -18,13 +18,13 @@ import { ModalCdsService } from '~/app/shared/services/modal-cds.service'; import { FinishedTask } from '~/app/shared/models/finished-task'; import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service'; -export const JOINAUTH_URL = '/cephfs/smb/active-directory'; +export const JOIN_AUTH_PATH = 'cephfs/smb/active-directory'; @Component({ selector: 'cd-smb-join-auth-list', templateUrl: './smb-join-auth-list.component.html', styleUrls: ['./smb-join-auth-list.component.scss'], - providers: [{ provide: URLBuilderService, useValue: new URLBuilderService(JOINAUTH_URL) }] + providers: [{ provide: URLBuilderService, useValue: new URLBuilderService(JOIN_AUTH_PATH) }] }) export class SmbJoinAuthListComponent implements OnInit { columns: CdTableColumn[]; @@ -114,7 +114,7 @@ export class SmbJoinAuthListComponent implements OnInit { itemNames: [authId], submitActionObservable: () => this.taskWrapper.wrapTaskAroundCall({ - task: new FinishedTask('smb/ad/remove', { + task: new FinishedTask(`${JOIN_AUTH_PATH}/${URLVerbs.DELETE}`, { authId: authId }), call: this.smbService.deleteJoinAuth(authId) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-share-form/smb-share-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-share-form/smb-share-form.component.ts index 8c9ff5ea10895..b8824cb879a88 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-share-form/smb-share-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-share-form/smb-share-form.component.ts @@ -11,14 +11,7 @@ import { map } from 'rxjs/operators'; import { ActionLabelsI18n, URLVerbs } from '~/app/shared/constants/app.constants'; import { FinishedTask } from '~/app/shared/models/finished-task'; -import { - Filesystem, - PROVIDER, - SHARE_RESOURCE, - SHARE_URL, - ShareRequestModel, - SMBShare -} from '../smb.model'; +import { Filesystem, PROVIDER, SHARE_RESOURCE, ShareRequestModel, SMBShare } from '../smb.model'; import { CephfsSubvolumeGroup } from '~/app/shared/models/cephfs-subvolume-group.model'; import { CephfsSubvolume } from '~/app/shared/models/cephfs-subvolume.model'; @@ -27,6 +20,8 @@ import { NfsService } from '~/app/shared/api/nfs.service'; import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service'; import { CephfsSubvolumeGroupService } from '~/app/shared/api/cephfs-subvolume-group.service'; import { CephfsSubvolumeService } from '~/app/shared/api/cephfs-subvolume.service'; +import { CLUSTER_PATH } from '../smb-cluster-list/smb-cluster-list.component'; +import { SHARE_PATH } from '../smb-share-list/smb-share-list.component'; @Component({ selector: 'cd-smb-share-form', @@ -58,7 +53,7 @@ export class SmbShareFormComponent extends CdForm implements OnInit { ) { super(); this.resource = $localize`Share`; - this.isEdit = this.router.url.startsWith(`${SHARE_URL}${URLVerbs.EDIT}`); + this.isEdit = this.router.url.startsWith(`/${SHARE_PATH}/${URLVerbs.EDIT}`); this.action = this.isEdit ? this.actionLabels.EDIT : this.actionLabels.CREATE; } ngOnInit() { @@ -230,18 +225,17 @@ export class SmbShareFormComponent extends CdForm implements OnInit { handleTaskRequest(urlVerb: string) { const requestModel = this.buildRequest(); - const BASE_URL = 'smb/share'; const component = this; const share_id = this.smbShareForm.get('share_id').value; this.taskWrapperService .wrapTaskAroundCall({ - task: new FinishedTask(`${BASE_URL}/${urlVerb}`, { share_id }), + task: new FinishedTask(`${SHARE_PATH}/${urlVerb}`, { share_id }), call: this.smbService.createShare(requestModel) }) .subscribe({ complete: () => { - this.router.navigate([`cephfs/smb`]); + this.router.navigate([CLUSTER_PATH]); }, error: () => { component.smbShareForm.setErrors({ cdSubmitButton: true }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-share-list/smb-share-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-share-list/smb-share-list.component.ts index e37dd69ff042a..45a421e41f849 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-share-list/smb-share-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-share-list/smb-share-list.component.ts @@ -6,7 +6,7 @@ import { CdTableAction } from '~/app/shared/models/cd-table-action'; import { CdTableColumn } from '~/app/shared/models/cd-table-column'; import { CdTableFetchDataContext } from '~/app/shared/models/cd-table-fetch-data-context'; import { Permission } from '~/app/shared/models/permissions'; -import { SHARE_URL, SMBShare } from '../smb.model'; +import { SMBShare } from '../smb.model'; import { SmbService } from '~/app/shared/api/smb.service'; import { AuthStorageService } from '~/app/shared/services/auth-storage.service'; import { CdTableSelection } from '~/app/shared/models/cd-table-selection'; @@ -19,6 +19,8 @@ import { ModalCdsService } from '~/app/shared/services/modal-cds.service'; import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service'; +export const SHARE_PATH = 'cephfs/smb/share'; + @Component({ selector: 'cd-smb-share-list', templateUrl: './smb-share-list.component.html', @@ -93,7 +95,7 @@ export class SmbShareListComponent implements OnInit { name: `${this.actionLabels.CREATE}`, permission: 'create', icon: Icons.add, - routerLink: () => ['/cephfs/smb/share/create', this.clusterId], + routerLink: () => [`/${SHARE_PATH}/${URLVerbs.CREATE}`, this.clusterId], canBePrimary: (selection: CdTableSelection) => !selection.hasSingleSelection }, { @@ -101,7 +103,7 @@ export class SmbShareListComponent implements OnInit { permission: 'update', icon: Icons.edit, routerLink: () => [ - `${SHARE_URL}${URLVerbs.EDIT}`, + `/${SHARE_PATH}/${URLVerbs.EDIT}`, this.clusterId, this.selection.first().name ] @@ -144,7 +146,7 @@ export class SmbShareListComponent implements OnInit { itemNames: [`Share: ${share_id} (${name}) from cluster: ${cluster_id}`], submitActionObservable: () => this.taskWrapper.wrapTaskAroundCall({ - task: new FinishedTask('smb/share/delete', { + task: new FinishedTask(`${SHARE_PATH}/${URLVerbs.DELETE}`, { share_id: share_id }), call: this.smbService.deleteShare(cluster_id, share_id) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-tabs/smb-tabs.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-tabs/smb-tabs.component.html index 6031de18adfc2..ce2469909ebd0 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-tabs/smb-tabs.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-tabs/smb-tabs.component.html @@ -4,10 +4,10 @@ isNavigation="true" [cacheActive]="false"> + [active]="activeTab === Tabs.cluster" + (selected)="onSelected(Tabs.cluster)"> { it('should display the heading text in the tab', () => { const tabs = fixture.debugElement.queryAll(By.css('cds-tab')); expect(tabs.length).toBe(4); - expect(tabs[0].attributes['heading']).toBe('Clusters'); + expect(tabs[0].attributes['heading']).toBe('Cluster'); expect(tabs[1].attributes['heading']).toBe('Active Directory'); expect(tabs[2].attributes['heading']).toBe('Standalone'); expect(tabs[3].attributes['heading']).toBe('Overview'); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-tabs/smb-tabs.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-tabs/smb-tabs.component.ts index fb0be8fff30cc..b1d3695bd1565 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-tabs/smb-tabs.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-tabs/smb-tabs.component.ts @@ -1,8 +1,10 @@ import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; +const SMB_PATH = 'cephfs/smb'; + enum TABS { - clusters = 'clusters', + cluster = 'cluster', activeDirectory = 'active-directory', standalone = 'standalone', overview = 'overview' @@ -15,18 +17,18 @@ enum TABS { }) export class SmbTabsComponent implements OnInit { selectedTab: TABS; - activeTab: TABS = TABS.clusters; + activeTab: TABS = TABS.cluster; constructor(private router: Router) {} ngOnInit(): void { const currentPath = this.router.url; - this.activeTab = Object.values(TABS).find((tab) => currentPath.includes(tab)) || TABS.clusters; + this.activeTab = Object.values(TABS).find((tab) => currentPath.includes(tab)) || TABS.cluster; } onSelected(tab: TABS) { this.selectedTab = tab; - this.router.navigate([`/cephfs/smb/${tab}`]); + this.router.navigate([`${SMB_PATH}/${tab}`]); } public get Tabs(): typeof TABS { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-usersgroups-form/smb-usersgroups-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-usersgroups-form/smb-usersgroups-form.component.spec.ts index 19752c47d583f..39c9fe51cf664 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-usersgroups-form/smb-usersgroups-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-usersgroups-form/smb-usersgroups-form.component.spec.ts @@ -86,7 +86,7 @@ describe('SmbUsersgroupsFormComponent', () => { it('should get resource data and set form fields with it', () => { expect(getUsersGroups).toHaveBeenCalled(); - expect(component.form.value).toEqual({ + expect(component.form.getRawValue()).toEqual({ usersGroupsId: 'foo', users: [ { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-usersgroups-form/smb-usersgroups-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-usersgroups-form/smb-usersgroups-form.component.ts index 472815c765cda..8c8ade9731362 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-usersgroups-form/smb-usersgroups-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-usersgroups-form/smb-usersgroups-form.component.ts @@ -20,7 +20,7 @@ import { FinishedTask } from '~/app/shared/models/finished-task'; import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service'; import { Group, SMBCluster, SMBUsersGroups, User, USERSGROUPS_RESOURCE } from '../smb.model'; import { Location } from '@angular/common'; -import { USERSGROUPS_URL } from '../smb-usersgroups-list/smb-usersgroups-list.component'; +import { USERSGROUPS_PATH } from '../smb-usersgroups-list/smb-usersgroups-list.component'; @Component({ selector: 'cd-smb-usersgroups-form', @@ -51,7 +51,7 @@ export class SmbUsersgroupsFormComponent extends CdForm implements OnInit, OnDes private location: Location ) { super(); - this.editing = this.router.url.startsWith(`${USERSGROUPS_URL}/${URLVerbs.EDIT}`); + this.editing = this.router.url.startsWith(`/${USERSGROUPS_PATH}/${URLVerbs.EDIT}`); this.resource = $localize`users and groups access resource`; effect(() => { const formData = this.uploadedData(); @@ -68,6 +68,7 @@ export class SmbUsersgroupsFormComponent extends CdForm implements OnInit, OnDes this.createForm(); if (this.editing) { this.action = this.actionLabels.UPDATE; + this.form.get('usersGroupsId').disable(); let editingUsersGroupId: string; this.route.params.subscribe((params: { usersGroupsId: string }) => { editingUsersGroupId = params.usersGroupsId; @@ -138,9 +139,8 @@ export class SmbUsersgroupsFormComponent extends CdForm implements OnInit, OnDes }; const self = this; - const BASE_URL = 'smb/standalone/'; - let taskUrl = `${BASE_URL}${this.editing ? URLVerbs.EDIT : URLVerbs.CREATE}`; + let taskUrl = `${USERSGROUPS_PATH}/${this.editing ? URLVerbs.EDIT : URLVerbs.CREATE}`; this.taskWrapperService .wrapTaskAroundCall({ task: new FinishedTask(taskUrl, { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-usersgroups-list/smb-usersgroups-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-usersgroups-list/smb-usersgroups-list.component.ts index 2d52f53e990b1..b56468b32767b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-usersgroups-list/smb-usersgroups-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-usersgroups-list/smb-usersgroups-list.component.ts @@ -4,7 +4,7 @@ import { BehaviorSubject, Observable, of } from 'rxjs'; import _ from 'lodash'; -import { ActionLabelsI18n } from '~/app/shared/constants/app.constants'; +import { ActionLabelsI18n, URLVerbs } from '~/app/shared/constants/app.constants'; import { CdTableAction } from '~/app/shared/models/cd-table-action'; import { CdTableColumn } from '~/app/shared/models/cd-table-column'; import { CdTableFetchDataContext } from '~/app/shared/models/cd-table-fetch-data-context'; @@ -23,13 +23,13 @@ import { FinishedTask } from '~/app/shared/models/finished-task'; import { ModalCdsService } from '~/app/shared/services/modal-cds.service'; import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service'; -export const USERSGROUPS_URL = '/cephfs/smb/standalone'; +export const USERSGROUPS_PATH = 'cephfs/smb/standalone'; @Component({ selector: 'cd-smb-users-list', templateUrl: './smb-usersgroups-list.component.html', styleUrls: ['./smb-usersgroups-list.component.scss'], - providers: [{ provide: URLBuilderService, useValue: new URLBuilderService(USERSGROUPS_URL) }] + providers: [{ provide: URLBuilderService, useValue: new URLBuilderService(USERSGROUPS_PATH) }] }) export class SmbUsersgroupsListComponent extends ListWithDetails implements OnInit { @ViewChild('groupsNamesTpl', { static: true }) @@ -130,7 +130,7 @@ export class SmbUsersgroupsListComponent extends ListWithDetails implements OnIn itemNames: [usersGroupsId], submitActionObservable: () => this.taskWrapper.wrapTaskAroundCall({ - task: new FinishedTask('smb/standalone/remove', { + task: new FinishedTask(`${USERSGROUPS_PATH}/${URLVerbs.DELETE}`, { usersGroupsId: usersGroupsId }), call: this.smbService.deleteUsersgroups(usersGroupsId) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb.model.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb.model.ts index 5cf912bfdd41c..07d0dca39fb09 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb.model.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb.model.ts @@ -145,6 +145,4 @@ export const USERSGROUPS_RESOURCE = 'ceph.smb.usersgroups' as const; export const PROVIDER = 'samba-vfs'; -export const SHARE_URL = '/cephfs/smb/share/'; - type Clustering = 'default' | 'never' | 'always'; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-message.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-message.service.ts index 27c469fe647d4..87bee9a139b00 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-message.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-message.service.ts @@ -404,28 +404,6 @@ export class TaskMessageService { 'nfs/delete': this.newTaskMessage(this.commonOperations.delete, (metadata) => this.nfs(metadata) ), - // smb - 'smb/cluster/remove': this.newTaskMessage(this.commonOperations.remove, (metadata) => - this.smbCluster(metadata) - ), - 'smb/ad/create': this.newTaskMessage(this.commonOperations.create, (metadata) => - this.smbJoinAuth(metadata) - ), - 'smb/ad/edit': this.newTaskMessage(this.commonOperations.update, (metadata) => - this.smbJoinAuth(metadata) - ), - 'smb/ad/remove': this.newTaskMessage(this.commonOperations.remove, (metadata) => - this.smbJoinAuth(metadata) - ), - 'smb/standalone/create': this.newTaskMessage(this.commonOperations.create, (metadata) => - this.smbUsersgroups(metadata) - ), - 'smb/standalone/edit': this.newTaskMessage(this.commonOperations.update, (metadata) => - this.smbUsersgroups(metadata) - ), - 'smb/standalone/remove': this.newTaskMessage(this.commonOperations.remove, (metadata) => - this.smbUsersgroups(metadata) - ), // Grafana tasks 'grafana/dashboards/update': this.newTaskMessage( this.commonOperations.update, @@ -511,26 +489,53 @@ export class TaskMessageService { (metadata) => this.snapshotSchedule(metadata) ), // smb - 'smb/cluster/create': this.newTaskMessage(this.commonOperations.create, (metadata) => - this.smbCluster(metadata) + 'cephfs/smb/cluster/create': this.newTaskMessage( + this.commonOperations.create, + (metadata: { cluster_id: string }) => this.smbCluster(metadata) ), - 'smb/share/create': this.newTaskMessage(this.commonOperations.create, (metadata) => - this.smbShare(metadata) + 'cephfs/smb/cluster/edit': this.newTaskMessage( + this.commonOperations.update, + (metadata: { cluster_id: string }) => this.smbCluster(metadata) + ), + 'cephfs/smb/cluster/delete': this.newTaskMessage( + this.commonOperations.delete, + (metadata: { cluster_id: string }) => this.smbCluster(metadata) ), - 'smb/share/edit': this.newTaskMessage(this.commonOperations.update, (metadata) => - this.smbCluster(metadata) + 'cephfs/smb/share/create': this.newTaskMessage( + this.commonOperations.create, + (metadata: Record<'share_id', string>) => this.smbShare(metadata) ), - 'smb/share/delete': this.newTaskMessage(this.commonOperations.delete, (metadata) => - this.smbShare(metadata) + 'cephfs/smb/share/edit': this.newTaskMessage( + this.commonOperations.update, + (metadata: Record<'share_id', string>) => this.smbShare(metadata) ), - 'cephfs/smb/joinauth/create': this.newTaskMessage(this.commonOperations.create, (metadata) => - this.smbJoinAuth(metadata) + 'cephfs/smb/share/delete': this.newTaskMessage( + this.commonOperations.delete, + (metadata: Record<'share_id', string>) => this.smbShare(metadata) ), - 'cephfs/smb/standalone/create': this.newTaskMessage(this.commonOperations.create, (metadata) => - this.smbUsersgroups(metadata) + 'cephfs/smb/active-directory/create': this.newTaskMessage( + this.commonOperations.create, + (metadata: { authId: string }) => this.smbJoinAuth(metadata) ), - 'smb/cluster/edit': this.newTaskMessage(this.commonOperations.update, (metadata) => - this.smbCluster(metadata) + 'cephfs/smb/active-directory/edit': this.newTaskMessage( + this.commonOperations.update, + (metadata: { authId: string }) => this.smbJoinAuth(metadata) + ), + 'cephfs/smb/active-directory/delete': this.newTaskMessage( + this.commonOperations.delete, + (metadata: { authId: string }) => this.smbJoinAuth(metadata) + ), + 'cephfs/smb/standalone/create': this.newTaskMessage( + this.commonOperations.create, + (metadata: { usersGroupsId: string }) => this.smbUsersgroups(metadata) + ), + 'cephfs/smb/standalone/edit': this.newTaskMessage( + this.commonOperations.update, + (metadata: { usersGroupsId: string }) => this.smbUsersgroups(metadata) + ), + 'cephfs/smb/standalone/delete': this.newTaskMessage( + this.commonOperations.delete, + (metadata: { usersGroupsId: string }) => this.smbUsersgroups(metadata) ) }; @@ -595,7 +600,11 @@ export class TaskMessageService { } smbCluster(metadata: { cluster_id: string }) { - return $localize`SMB Cluster '${metadata.cluster_id}'`; + return $localize`SMB cluster '${metadata.cluster_id}'`; + } + + smbShare(metadata: Record<'share_id', string>) { + return $localize`SMB share '${metadata?.share_id}'`; } smbJoinAuth(metadata: { authId: string }) { @@ -649,10 +658,6 @@ export class TaskMessageService { return $localize`snapshot schedule for path '${metadata?.path}'`; } - smbShare(metadata: Record<'share_id', string>) { - return $localize`SMB share '${metadata?.share_id}'`; - } - crudMessageId(id: string) { return $localize`${id}`; } -- 2.39.5