Skip to content

Commit b6fd1fc

Browse files
Add a getDrivesList request and a createDrivesList in index.ts to get the informations about the list of drives and create the corresponding new Drive instances with faked contents at thi stage.
1 parent f25ec49 commit b6fd1fc

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

src/index.ts

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import {
2424
/*FilenameSearcher, IScore, */ SidePanel
2525
} from '@jupyterlab/ui-components';
2626

27+
import { IBucket } from './s3requests';
28+
2729
/**
2830
* The class name added to the filebrowser filterbox node.
2931
*/
@@ -48,6 +50,46 @@ namespace CommandIDs {
4850
console.log('JupyterLab extension @jupyter/drives is activated!');
4951
}
5052
};*/
53+
54+
async function createDrivesList(manager: IDocumentManager) {
55+
/*const s3BucketsList: IBucket[] = await getDrivesList();*/
56+
const s3BucketsList: IBucket[] = [
57+
{
58+
creation_date: '2023-12-15T13:27:57.000Z',
59+
name: 'jupyter-drive-bucket1',
60+
provider: 'S3',
61+
region: 'us-east-1',
62+
status: 'active'
63+
},
64+
{
65+
creation_date: '2023-12-19T08:57:29.000Z',
66+
name: 'jupyter-drive-bucket2',
67+
provider: 'S3',
68+
region: 'us-east-1',
69+
status: 'inactive'
70+
},
71+
{
72+
creation_date: '2023-12-19T09:07:29.000Z',
73+
name: 'jupyter-drive-bucket3',
74+
provider: 'S3',
75+
region: 'us-east-1',
76+
status: 'active'
77+
}
78+
];
79+
80+
const availableS3Buckets: Drive[] = [];
81+
s3BucketsList.forEach(item => {
82+
const drive = new Drive();
83+
drive.name = item.name;
84+
drive.baseUrl = '';
85+
drive.region = item.region;
86+
drive.status = item.status;
87+
drive.provider = item.provider;
88+
manager.services.contents.addDrive(drive);
89+
availableS3Buckets.push(drive);
90+
});
91+
return availableS3Buckets;
92+
}
5193
const AddDrivesPlugin: JupyterFrontEndPlugin<void> = {
5294
id: '@jupyter/drives:add-drives',
5395
description: 'Open a dialog to select drives to be added in the filebrowser.',
@@ -112,7 +154,8 @@ export async function activateAddDrivesPlugin(
112154
}
113155

114156
app.commands.addCommand(CommandIDs.addDriveBrowser, {
115-
execute: args => {
157+
execute: async args => {
158+
const driveList = await createDrivesList(manager);
116159
function createSidePanel(driveName: string) {
117160
const panel = new SidePanel();
118161
panel.title.icon = DriveIcon;

src/s3requests.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { requestAPI } from './handler';
2+
3+
export interface IBucket {
4+
name: string;
5+
region: string;
6+
provider: string;
7+
creation_date: string;
8+
status: string;
9+
}
10+
11+
export async function getDrivesList() {
12+
return await requestAPI<Array<IBucket>>('drives', {
13+
method: 'GET'
14+
});
15+
}

0 commit comments

Comments
 (0)