Skip to content

Commit

Permalink
NAS-131423: App deletion should ask the user if the ixvolumes should …
Browse files Browse the repository at this point in the history
…be deleted (#10776)
  • Loading branch information
AlexKarpov98 authored Oct 2, 2024
1 parent 4b52496 commit 303e5cc
Show file tree
Hide file tree
Showing 94 changed files with 141 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ <h1 mat-dialog-title>{{ options.title | translate }}</h1>
@if (options.secondaryCheckbox) {
<span>
<mat-checkbox
color="primary"
class="confirm-checkbox secondary-checkbox"
ixTest="secondary-confirmation"
[(ngModel)]="isSecondaryCheckboxChecked"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe('AppInfoCardComponent', () => {
installedApps$: of([]),
}),
mockProvider(DialogService, {
confirm: jest.fn(() => of(true)),
confirm: jest.fn(() => of({ confirmed: true, secondaryCheckbox: true })),
jobDialog: jest.fn(() => ({
afterClosed: () => of(null),
})),
Expand Down Expand Up @@ -188,10 +188,12 @@ describe('AppInfoCardComponent', () => {
expect(spectator.inject(DialogService).confirm).toHaveBeenCalledWith({
title: 'Delete',
message: 'Delete test-user-app-name?',
secondaryCheckbox: true,
secondaryCheckboxText: 'Remove iX Volumes',
});
expect(spectator.inject(WebSocketService).job).toHaveBeenCalledWith(
'app.delete',
[app.name, { remove_images: true }],
[app.name, { remove_images: true, remove_ix_volumes: true }],
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,16 @@ export class AppInfoCardComponent {
this.dialogService.confirm({
title: helptextApps.apps.delete_dialog.title,
message: this.translate.instant('Delete {name}?', { name }),
secondaryCheckbox: true,
secondaryCheckboxText: this.translate.instant('Remove iX Volumes'),
})
.pipe(filter(Boolean), untilDestroyed(this))
.subscribe(() => this.executeDelete(name));
.pipe(filter(({ confirmed }) => Boolean(confirmed)), untilDestroyed(this))
.subscribe(({ secondaryCheckbox }) => this.executeDelete(name, secondaryCheckbox));
}

executeDelete(name: string): void {
executeDelete(name: string, removeIxVolumes = false): void {
this.dialogService.jobDialog(
this.ws.job('app.delete', [name, { remove_images: true }]),
this.ws.job('app.delete', [name, { remove_images: true, remove_ix_volumes: removeIxVolumes }]),
{ title: helptextApps.apps.delete_dialog.job },
)
.afterClosed()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { HarnessLoader } from '@angular/cdk/testing';
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { ReactiveFormsModule } from '@angular/forms';
import { MatMenuHarness } from '@angular/material/menu/testing';
import { MatTableModule } from '@angular/material/table';
import { ActivatedRoute, Router } from '@angular/router';
import {
Expand All @@ -12,6 +15,7 @@ import { mockWebSocket } from 'app/core/testing/utils/mock-websocket.utils';
import { AppState } from 'app/enums/app-state.enum';
import { JobState } from 'app/enums/job-state.enum';
import { App } from 'app/interfaces/app.interface';
import { DialogService } from 'app/modules/dialog/dialog.service';
import { EmptyComponent } from 'app/modules/empty/empty.component';
import { SearchInput1Component } from 'app/modules/forms/search-input1/search-input1.component';
import { FakeProgressBarComponent } from 'app/modules/loader/components/fake-progress-bar/fake-progress-bar.component';
Expand All @@ -26,10 +30,12 @@ import { AppsStatsService } from 'app/pages/apps/store/apps-stats.service';
import { AppsStore } from 'app/pages/apps/store/apps-store.service';
import { DockerStore } from 'app/pages/apps/store/docker.store';
import { InstalledAppsStore } from 'app/pages/apps/store/installed-apps-store.service';
import { WebSocketService } from 'app/services/ws.service';
import { selectAdvancedConfig, selectSystemConfigState } from 'app/store/system-config/system-config.selectors';

describe('InstalledAppsComponent', () => {
let spectator: Spectator<InstalledAppsComponent>;
let loader: HarnessLoader;

const app = {
id: 'ix-test-app',
Expand Down Expand Up @@ -70,6 +76,12 @@ describe('InstalledAppsComponent', () => {
isLoading$: of(false),
availableApps$: of([]),
}),
mockProvider(DialogService, {
confirm: jest.fn(() => of({ confirmed: true, secondaryCheckbox: true })),
jobDialog: jest.fn(() => ({
afterClosed: () => of(null),
})),
}),
provideMockStore({
selectors: [
{
Expand Down Expand Up @@ -110,6 +122,8 @@ describe('InstalledAppsComponent', () => {

beforeEach(() => {
spectator = createComponent();
loader = TestbedHarnessEnvironment.loader(spectator.fixture);
spectator.component.dataSource = [app];
});

it('shows a list of installed apps', () => {
Expand All @@ -135,4 +149,24 @@ describe('InstalledAppsComponent', () => {
spectator.query(AppRowComponent).stopApp.emit();
expect(spectator.inject(ApplicationsService).stopApplication).toHaveBeenCalledWith('test-app');
});

it('removes selected applications', async () => {
spectator.component.selection.select(app.name);

const menu = await loader.getHarness(MatMenuHarness.with({ triggerText: 'Select action' }));
await menu.open();
await menu.clickItem({ text: 'Delete All Selected' });

expect(spectator.inject(DialogService).confirm).toHaveBeenCalledWith({
title: 'Delete',
message: 'Delete test-app?',
secondaryCheckbox: true,
secondaryCheckboxText: 'Remove iX Volumes',
});

expect(spectator.inject(WebSocketService).job).toHaveBeenCalledWith(
'core.bulk',
['app.delete', [[app.name, { remove_images: true, remove_ix_volumes: true }]]],
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,15 @@ export class InstalledAppsComponent implements OnInit, AfterViewInit {
this.dialogService.confirm({
title: helptextApps.apps.delete_dialog.title,
message: this.translate.instant('Delete {name}?', { name }),
secondaryCheckbox: true,
secondaryCheckboxText: this.translate.instant('Remove iX Volumes'),
})
.pipe(filter(Boolean), untilDestroyed(this))
.subscribe(() => {
.pipe(filter(({ confirmed }) => Boolean(confirmed)), untilDestroyed(this))
.subscribe(({ secondaryCheckbox }) => {
this.dialogService.jobDialog(
this.ws.job('core.bulk', ['app.delete', checkedNames.map((item) => [item])]),
this.ws.job('core.bulk', ['app.delete', checkedNames.map(
(item) => [item, { remove_images: true, remove_ix_volumes: secondaryCheckbox }],
)]),
{ title: helptextApps.apps.delete_dialog.job },
)
.afterClosed()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<ix-label [label]="'Select disks you want to use' | translate"></ix-label>
@for (item of poolAndDisks | keyvalue; track item.key) {
<mat-checkbox
color="primary"
[ixTest]="[item.key, 'exported_pool']"
[value]="item.key"
(change)="checkboxChanged($event)"
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/af.json
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/az.json
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/be.json
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/bn.json
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/br.json
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/bs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2681,6 +2681,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/cy.json
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -2326,6 +2326,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove this error to try again": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/dsb.json
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/en-au.json
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/en-gb.json
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/eo.json
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/es-ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -1778,6 +1778,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove this error to try again": "",
"Remove {label} item": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/es-co.json
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/es-mx.json
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/es-ni.json
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/es-ve.json
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -2995,6 +2995,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/et.json
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/eu.json
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/fa.json
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,7 @@
"Remove device {name}?": "",
"Remove file": "",
"Remove file?": "",
"Remove iX Volumes": "",
"Remove preset": "",
"Remove the ACL and permissions from child datasets of the current dataset": "",
"Remove the existing API key and generate a new random key. A dialog shows the new key and has an option to copy the key. Back up and secure the API key! The key string is displayed only one time, at creation.": "",
Expand Down
Loading

0 comments on commit 303e5cc

Please sign in to comment.