mirror of
https://github.com/ceph/ceph
synced 2025-01-21 02:31:19 +00:00
mgr/dashboard: disable create snapshot with subvolumes
Signed-off-by: Pere Diaz Bou <pdiazbou@redhat.com>
This commit is contained in:
parent
5e654b4c94
commit
b38259b629
@ -1073,5 +1073,39 @@ describe('CephfsDirectoriesComponent', () => {
|
||||
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();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -219,7 +219,8 @@ export class CephfsDirectoriesComponent implements OnInit, OnChanges {
|
||||
icon: Icons.add,
|
||||
permission: 'create',
|
||||
canBePrimary: (selection) => !selection.hasSelection,
|
||||
click: () => this.createSnapshot()
|
||||
click: () => this.createSnapshot(),
|
||||
disable: () => this.disableCreateSnapshot()
|
||||
},
|
||||
{
|
||||
name: this.actionLabels.DELETE,
|
||||
@ -233,6 +234,16 @@ export class CephfsDirectoriesComponent implements OnInit, OnChanges {
|
||||
};
|
||||
}
|
||||
|
||||
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 = [];
|
||||
|
Loading…
Reference in New Issue
Block a user