]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: fix smb edit resources 62845/head
authorPedro Gonzalez Gomez <pegonzal@redhat.com>
Wed, 16 Apr 2025 09:48:01 +0000 (11:48 +0200)
committerPedro Gonzalez Gomez <pegonzal@redhat.com>
Tue, 22 Apr 2025 07:49:30 +0000 (09:49 +0200)
- 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 <pegonzal@redhat.com>
17 files changed:
src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-cluster-form/smb-cluster-form.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-cluster-list/smb-cluster-list.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-domain-setting-modal/smb-domain-setting-modal.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-join-auth-form/smb-join-auth-form.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-join-auth-form/smb-join-auth-form.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-join-auth-list/smb-join-auth-list.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-share-form/smb-share-form.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-share-list/smb-share-list.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-tabs/smb-tabs.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-tabs/smb-tabs.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-tabs/smb-tabs.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-usersgroups-form/smb-usersgroups-form.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-usersgroups-form/smb-usersgroups-form.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb-usersgroups-list/smb-usersgroups-list.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/smb/smb.model.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-message.service.ts

index 59c576330d94cf5b0c1173714d1f7aea479d415f..c8f9de71e022c65b4686790139ea9b271bcee204 100644 (file)
@@ -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 },
                   {
index 3c30a9abcc412671d867335ed00066914e0cc628..78bb616246f529e8234e44637c9f85750a96ea11 100644 (file)
@@ -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() {
index 2cc53a8241d3c2c8930d319bbb1051925280f9bc..88c4b4c9bcd2f247cdb438ee066d5b36f003d939 100644 (file)
@@ -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)
index 24415b9b1d80f0bef73ad6a80f0627da7410b03d..c995a0a32580884d3289e8e4e59a87bb8afc6e4e 100644 (file)
@@ -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) {
index 810a5c9625d82597c1e2f4e37d1e611d3cc50613..1db85d9993ff7bfb58c9f541bd68689d121a93b4 100644 (file)
@@ -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',
index 308ad15f36d6334f749ae44bab194d9bc0738506..b727998d77ba8f7a8e83ea56faaa9c759f62d39d 100644 (file)
@@ -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, {
index 7ed04f0c738db61ebbf97af05f82849fee76c653..c34090e78460dfc0b395cb4d7e6f2aab6b655146 100644 (file)
@@ -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)
index 8c9ff5ea1089583b43cdbb9b5f212e3bda59d8c6..b8824cb879a887ff02162a700b267a9c9e21c9a3 100644 (file)
@@ -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 });
index e37dd69ff042afdf231c4f966d990b94dabc5438..45a421e41f8496c8237e272d765e35b482d5c66a 100644 (file)
@@ -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)
index 6031de18adfc2866c128b720347706c20d96bb39..ce2469909ebd00f85c5ed164e67c82e1f8e2f28e 100644 (file)
@@ -4,10 +4,10 @@
   isNavigation="true"
   [cacheActive]="false">
   <cds-tab
-    heading="Clusters"
+    heading="Cluster"
     i18n-heading
-    [active]="activeTab === Tabs.clusters"
-    (selected)="onSelected(Tabs.clusters)">
+    [active]="activeTab === Tabs.cluster"
+    (selected)="onSelected(Tabs.cluster)">
   </cds-tab>
   <cds-tab
     heading="Active Directory"
index 09c7b5550a18bef548fbcc2f11ef12859fb7e44c..3b07b8c1e3690f7b54c068d1622104065ae49136 100644 (file)
@@ -24,7 +24,7 @@ describe('SmbTabsComponent', () => {
   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');
index fb0be8fff30cccfd9ebd53ea18374f931119ea07..b1d3695bd15658ae5e86e1093a482ab2279db866 100644 (file)
@@ -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 {
index 19752c47d583f1320c4042bb441a5bae35a90037..39c9fe51cf664822c2bbcf644277bcbc6eda502b 100644 (file)
@@ -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: [
           {
index 472815c765cda3891eddfe3465bacde21a33135d..8c8ade9731362d0d39919f973abc405479c26b5d 100644 (file)
@@ -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, {
index 2d52f53e990b1a017d2c49769ee9f2f34da35578..b56468b32767bb87d6748a94f7de88629f253dfc 100644 (file)
@@ -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)
index 5cf912bfdd41c82f771e932516cff3e323ce155f..07d0dca39fb097b93823db2deeda10aa938507b4 100644 (file)
@@ -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';
index 27c469fe647d4425ab20869baa7661b1a2777373..87bee9a139b00601daa050e5762414925fa6b629 100644 (file)
@@ -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}`;
   }