Skip to content

Commit 5257f5d

Browse files
committed
add frontend function for excluding drive
1 parent e94b260 commit 5257f5d

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

src/contents.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import {
2222
copyObjects,
2323
presignedLink,
2424
createDrive,
25-
getDrivesList
25+
getDrivesList,
26+
excludeDrive
2627
} from './requests';
2728

2829
let data: Contents.IModel = {
@@ -683,6 +684,26 @@ export class Drive implements Contents.IDrive {
683684
return data;
684685
}
685686

687+
/**
688+
* Exclude drive from browser.
689+
*
690+
* @param driveName: The name of drive to exclude.
691+
*
692+
* @returns A promise which resolves with the contents model.
693+
*/
694+
async excludeDrive(driveName: string): Promise<Contents.IModel> {
695+
data = await excludeDrive(driveName);
696+
697+
Contents.validateContentsModel(data);
698+
this._fileChanged.emit({
699+
type: 'new',
700+
oldValue: null,
701+
newValue: data
702+
});
703+
704+
return data;
705+
}
706+
686707
/**
687708
* Create a checkpoint for a file.
688709
*

src/requests.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,31 @@ export async function setListingLimit(newLimit: number) {
3737
});
3838
}
3939

40+
/**
41+
* Exclude drive from being listed inside the DriveBrowser.
42+
*
43+
* @returns
44+
*/
45+
export async function excludeDrive(driveName: string) {
46+
await requestAPI<any>('drives/config', 'POST', {
47+
exclude_drive_name: driveName
48+
});
49+
50+
data = {
51+
name: driveName,
52+
path: driveName,
53+
last_modified: '',
54+
created: '',
55+
content: [],
56+
format: 'json',
57+
mimetype: '',
58+
size: 0,
59+
writable: true,
60+
type: 'directory'
61+
};
62+
return data;
63+
}
64+
4065
/**
4166
* Fetch the list of available drives.
4267
* @returns The list of available drives.

0 commit comments

Comments
 (0)