diff --git a/src/app/interfaces/api/api-call-directory.interface.ts b/src/app/interfaces/api/api-call-directory.interface.ts index 84b4a48597d..0b5d17b62ac 100644 --- a/src/app/interfaces/api/api-call-directory.interface.ts +++ b/src/app/interfaces/api/api-call-directory.interface.ts @@ -625,7 +625,6 @@ export interface ApiCallDirectory { 'pool.dataset.get_instance': { params: [path: string]; response: DatasetDetails }; 'pool.dataset.get_quota': { params: DatasetQuotaQueryParams; response: DatasetQuota[] }; 'pool.dataset.inherit_parent_encryption_properties': { params: [id: string]; response: void }; - 'pool.dataset.path_in_locked_datasets': { params: [path: string]; response: boolean }; 'pool.dataset.processes': { params: [datasetId: string]; response: Process[] }; 'pool.dataset.promote': { params: [id: string]; response: void }; 'pool.dataset.query': { params: QueryParams; response: Dataset[] }; diff --git a/src/app/pages/sharing/components/shares-dashboard/smb-card/smb-card.component.spec.ts b/src/app/pages/sharing/components/shares-dashboard/smb-card/smb-card.component.spec.ts index c411c1e90e1..3f86c4f7635 100644 --- a/src/app/pages/sharing/components/shares-dashboard/smb-card/smb-card.component.spec.ts +++ b/src/app/pages/sharing/components/shares-dashboard/smb-card/smb-card.component.spec.ts @@ -2,6 +2,7 @@ import { HarnessLoader } from '@angular/cdk/testing'; import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; import { MatDialog } from '@angular/material/dialog'; import { MatSlideToggleHarness } from '@angular/material/slide-toggle/testing'; +import { Router } from '@angular/router'; import { Spectator } from '@ngneat/spectator'; import { createComponentFactory, mockProvider } from '@ngneat/spectator/jest'; import { provideMockStore } from '@ngrx/store/testing'; @@ -21,6 +22,7 @@ import { AppLoaderModule } from 'app/modules/loader/app-loader.module'; import { ServiceExtraActionsComponent } from 'app/pages/sharing/components/shares-dashboard/service-extra-actions/service-extra-actions.component'; import { ServiceStateButtonComponent } from 'app/pages/sharing/components/shares-dashboard/service-state-button/service-state-button.component'; import { SmbCardComponent } from 'app/pages/sharing/components/shares-dashboard/smb-card/smb-card.component'; +import { SmbAclComponent } from 'app/pages/sharing/smb/smb-acl/smb-acl.component'; import { SmbFormComponent } from 'app/pages/sharing/smb/smb-form/smb-form.component'; import { DialogService } from 'app/services/dialog.service'; import { IxSlideInService } from 'app/services/ix-slide-in.service'; @@ -79,7 +81,6 @@ describe('SmbCardComponent', () => { providers: [ mockWebsocket([ mockCall('sharing.smb.query', smbShares), - mockCall('pool.dataset.path_in_locked_datasets', false), mockCall('sharing.smb.delete'), mockCall('sharing.smb.update'), mockCall('sharing.smb.getacl', { share_name: 'test' } as SmbSharesec), @@ -160,27 +161,27 @@ describe('SmbCardComponent', () => { }); it('handles edit Share ACL', async () => { - const deleteIcon = await table.getHarnessInCell(IxIconHarness.with({ name: 'share' }), 1, 4); - await deleteIcon.click(); - - expect(spectator.inject(WebSocketService).call).toHaveBeenCalledWith( - 'pool.dataset.path_in_locked_datasets', - ['/mnt/APPS/smb1'], - ); + const editIcon = await table.getHarnessInCell(IxIconHarness.with({ name: 'share' }), 1, 4); + await editIcon.click(); expect(spectator.inject(WebSocketService).call).toHaveBeenCalledWith( 'sharing.smb.getacl', [{ share_name: 'homes' }], ); + + expect(spectator.inject(IxSlideInService).open).toHaveBeenCalledWith(SmbAclComponent, { data: 'test' }); }); it('handles edit Filesystem ACL', async () => { - const deleteIcon = await table.getHarnessInCell(IxIconHarness.with({ name: 'security' }), 1, 4); - await deleteIcon.click(); + const router = spectator.inject(Router); + jest.spyOn(router, 'navigate').mockImplementation(); - expect(spectator.inject(WebSocketService).call).toHaveBeenCalledWith( - 'pool.dataset.path_in_locked_datasets', - ['/mnt/APPS/smb1'], + const editIcon = await table.getHarnessInCell(IxIconHarness.with({ name: 'security' }), 1, 4); + await editIcon.click(); + + expect(router.navigate).toHaveBeenCalledWith( + ['/', 'datasets', 'acl', 'edit'], + { queryParams: { path: '/mnt/APPS/smb1' } }, ); }); }); diff --git a/src/app/pages/sharing/components/shares-dashboard/smb-card/smb-card.component.ts b/src/app/pages/sharing/components/shares-dashboard/smb-card/smb-card.component.ts index 011e50c52b7..642b7509a7f 100644 --- a/src/app/pages/sharing/components/shares-dashboard/smb-card/smb-card.component.ts +++ b/src/app/pages/sharing/components/shares-dashboard/smb-card/smb-card.component.ts @@ -137,46 +137,38 @@ export class SmbCardComponent implements OnInit { } doShareAclEdit(row: SmbShare): void { - this.ws.call('pool.dataset.path_in_locked_datasets', [row.path]).pipe(untilDestroyed(this)).subscribe( - (isLocked) => { - if (isLocked) { - this.showLockedPathDialog(row.path); - } else { - // A home share has a name (homes) set; row.name works for other shares - const searchName = row.home ? 'homes' : row.name; - this.ws.call('sharing.smb.getacl', [{ share_name: searchName }]) - .pipe(untilDestroyed(this)) - .subscribe({ - next: (shareAcl: SmbSharesec) => { - const slideInRef = this.slideInService.open(SmbAclComponent, { data: shareAcl.share_name }); + if (row.locked) { + this.showLockedPathDialog(row.path); + } else { + // A home share has a name (homes) set; row.name works for other shares + const searchName = row.home ? 'homes' : row.name; + this.ws.call('sharing.smb.getacl', [{ share_name: searchName }]) + .pipe(untilDestroyed(this)) + .subscribe({ + next: (shareAcl: SmbSharesec) => { + const slideInRef = this.slideInService.open(SmbAclComponent, { data: shareAcl.share_name }); - slideInRef.slideInClosed$.pipe(filter(Boolean), untilDestroyed(this)).subscribe(() => { - this.getSmbShares(); - }); - }, - error: (error: WebsocketError) => { - this.dialogService.error(this.errorHandler.parseWsError(error)); - }, + slideInRef.slideInClosed$.pipe(filter(Boolean), untilDestroyed(this)).subscribe(() => { + this.getSmbShares(); }); - } - }, - ); + }, + error: (error: WebsocketError) => { + this.dialogService.error(this.errorHandler.parseWsError(error)); + }, + }); + } } doFilesystemAclEdit(row: SmbShare): void { - this.ws.call('pool.dataset.path_in_locked_datasets', [row.path]).pipe(untilDestroyed(this)).subscribe( - (isLocked) => { - if (isLocked) { - this.showLockedPathDialog(row.path); - } else { - this.router.navigate(['/', 'datasets', 'acl', 'edit'], { - queryParams: { - path: row.path_local, - }, - }); - } - }, - ); + if (row.locked) { + this.showLockedPathDialog(row.path); + } else { + this.router.navigate(['/', 'datasets', 'acl', 'edit'], { + queryParams: { + path: row.path_local, + }, + }); + } } private showLockedPathDialog(path: string): void { diff --git a/src/app/pages/sharing/smb/smb-form/smb-form.component.spec.ts b/src/app/pages/sharing/smb/smb-form/smb-form.component.spec.ts index 290d32e3ee9..d4dabdfd205 100644 --- a/src/app/pages/sharing/smb/smb-form/smb-form.component.spec.ts +++ b/src/app/pages/sharing/smb/smb-form/smb-form.component.spec.ts @@ -154,7 +154,6 @@ describe('SmbFormComponent', () => { mockCall('service.restart'), mockCall('sharing.smb.presets', { ...presets }), mockCall('filesystem.acl_is_trivial', false), - mockCall('pool.dataset.path_in_locked_datasets', false), ]), mockProvider(IxSlideInService), mockProvider(Router), diff --git a/src/app/pages/sharing/smb/smb-list/smb-list.component.ts b/src/app/pages/sharing/smb/smb-list/smb-list.component.ts index ecb279bd3df..af0660feaa2 100644 --- a/src/app/pages/sharing/smb/smb-list/smb-list.component.ts +++ b/src/app/pages/sharing/smb/smb-list/smb-list.component.ts @@ -115,26 +115,23 @@ export class SmbListComponent implements EntityTableConfig { label: helptextSharingSmb.action_share_acl, onClick: (row: SmbShare) => { this.appLoader.open(); - this.ws.call('pool.dataset.path_in_locked_datasets', [row.path]).pipe(untilDestroyed(this)).subscribe( - (isLocked) => { - if (isLocked) { + + if (row.locked) { + this.appLoader.close(); + this.lockedPathDialog(row.path); + } else { + // A home share has a name (homes) set; row.name works for other shares + const searchName = row.home ? 'homes' : row.name; + this.ws.call('sharing.smb.getacl', [{ share_name: searchName }]) + .pipe(untilDestroyed(this)) + .subscribe((shareAcl) => { this.appLoader.close(); - this.lockedPathDialog(row.path); - } else { - // A home share has a name (homes) set; row.name works for other shares - const searchName = row.home ? 'homes' : row.name; - this.ws.call('sharing.smb.getacl', [{ share_name: searchName }]) - .pipe(untilDestroyed(this)) - .subscribe((shareAcl) => { - this.appLoader.close(); - const slideInRef = this.slideInService.open(SmbAclComponent, { data: shareAcl.share_name }); - slideInRef.slideInClosed$.pipe(take(1), untilDestroyed(this)).subscribe(() => { - this.entityList.getData(); - }); - }); - } - }, - ); + const slideInRef = this.slideInService.open(SmbAclComponent, { data: shareAcl.share_name }); + slideInRef.slideInClosed$.pipe(take(1), untilDestroyed(this)).subscribe(() => { + this.entityList.getData(); + }); + }); + } }, }, { @@ -145,26 +142,15 @@ export class SmbListComponent implements EntityTableConfig { matTooltip: helptextVolumes.acl_edit_msg, label: helptextSharingSmb.action_edit_acl, onClick: (row: SmbShare) => { - this.ws.call('pool.dataset.path_in_locked_datasets', [row.path]).pipe(untilDestroyed(this)).subscribe({ - next: (isLocked) => { - if (isLocked) { - this.lockedPathDialog(row.path); - } else { - this.router.navigate(['/', 'datasets', 'acl', 'edit'], { - queryParams: { - path: row.path_local, - }, - }); - } - }, - error: (error: WebsocketError) => { - this.dialogService.error({ - title: helptextSharingSmb.action_edit_acl_dialog.title, - message: error.reason, - backtrace: error.trace?.formatted, - }); - }, - }); + if (row.locked) { + this.lockedPathDialog(row.path); + } else { + this.router.navigate(['/', 'datasets', 'acl', 'edit'], { + queryParams: { + path: row.path_local, + }, + }); + } }, }, {