expect(component.loadingIndicator).toBe(true);
});
});
+ describe('disable create snapshot', () => {
+ let actions: CdTableAction[];
+ beforeEach(() => {
+ actions = component.snapshot.tableActions;
+ mockLib.mkDir('/', 'volumes', 2, 2);
+ mockLib.mkDir('/volumes', 'group1', 2, 2);
+ mockLib.mkDir('/volumes/group1', 'subvol', 2, 2);
+ mockLib.mkDir('/volumes/group1/subvol', 'subfile', 2, 2);
+ });
+
+ const empty = (): CdTableSelection => new CdTableSelection();
+
+ it('should return a descriptive message to explain why it is disabled', () => {
+ const path = '/volumes/group1/subvol/subfile';
+ const res = 'Cannot create snapshots for files/folders in the subvolume subvol';
+ mockLib.selectNode(path);
+ expect(actions[0].disable(empty())).toContain(res);
+ });
+
+ it('should return false if it is not a subvolume node', () => {
+ const testCases = [
+ '/volumes/group1/subvol',
+ '/volumes/group1',
+ '/volumes',
+ '/',
+ '/a',
+ '/a/b'
+ ];
+ testCases.forEach((testCase) => {
+ mockLib.selectNode(testCase);
+ expect(actions[0].disable(empty())).toBeFalsy();
+ });
+ });
+ });
});
});
icon: Icons.add,
permission: 'create',
canBePrimary: (selection) => !selection.hasSelection,
- click: () => this.createSnapshot()
+ click: () => this.createSnapshot(),
+ disable: () => this.disableCreateSnapshot()
},
{
name: this.actionLabels.DELETE,
};
}
+ private disableCreateSnapshot(): string | boolean {
+ const folders = this.selectedDir.path.split('/').slice(1);
+ // With deph of 4 or more we have the subvolume files/folders for which we cannot create
+ // a snapshot. Somehow, you can create a snapshot of the subvolume but not its files.
+ if (folders.length >= 4 && folders[0] === 'volumes') {
+ return $localize`Cannot create snapshots for files/folders in the subvolume ${folders[2]}`;
+ }
+ return false;
+ }
+
ngOnChanges() {
this.selectedDir = undefined;
this.dirs = [];