Skip to content

Commit

Permalink
NAS-125831 / 24.04 / Remove pool.dataset.path_in_locked_datasets (#9372)
Browse files Browse the repository at this point in the history
* NAS-125831: Remove pool.dataset.path_in_locked_datasets

* NAS-125831: NAS-125768: Cloud Credential Creation Error is not shown, instead infinite loading

* NAS-125831: PR update
  • Loading branch information
AlexKarpov98 authored Dec 27, 2023
1 parent 2498639 commit fc687b1
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 89 deletions.
1 change: 0 additions & 1 deletion src/app/interfaces/api/api-call-directory.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Dataset, ExtraDatasetQueryOptions>; response: Dataset[] };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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' } },
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
64 changes: 25 additions & 39 deletions src/app/pages/sharing/smb/smb-list/smb-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,26 +115,23 @@ export class SmbListComponent implements EntityTableConfig<SmbShare> {
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();
});
});
}
},
},
{
Expand All @@ -145,26 +142,15 @@ export class SmbListComponent implements EntityTableConfig<SmbShare> {
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,
},
});
}
},
},
{
Expand Down

0 comments on commit fc687b1

Please sign in to comment.