Skip to content

Commit 8a0fe0b

Browse files
committed
update to IDriveInfo interface
1 parent fa5e5c1 commit 8a0fe0b

File tree

3 files changed

+28
-20
lines changed

3 files changed

+28
-20
lines changed

src/contents.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { Signal, ISignal } from '@lumino/signaling';
55
import { Contents, ServerConnection } from '@jupyterlab/services';
66
import { PathExt } from '@jupyterlab/coreutils';
7-
import { IDrivesList } from './token';
7+
import { IDriveInfo } from './token';
88

99
let data: Contents.IModel = {
1010
name: '',
@@ -28,21 +28,21 @@ export class Drive implements Contents.IDrive {
2828
constructor(options: Drive.IOptions = {}) {
2929
this._serverSettings = ServerConnection.makeSettings();
3030
this._name = options.name ?? '';
31-
this._drivesList = options.drivesList ?? { names: [] };
31+
this._drivesList = options.drivesList ?? [];
3232
//this._apiEndpoint = options.apiEndpoint ?? SERVICE_DRIVE_URL;
3333
}
3434

3535
/**
3636
* The drives list getter.
3737
*/
38-
get drivesList(): IDrivesList {
38+
get drivesList(): IDriveInfo[] {
3939
return this._drivesList;
4040
}
4141

4242
/**
4343
* The drives list setter.
4444
* */
45-
set drivesList(list: IDrivesList) {
45+
set drivesList(list: IDriveInfo[]) {
4646
this._drivesList = list;
4747
}
4848

@@ -204,12 +204,12 @@ export class Drive implements Contents.IDrive {
204204
};
205205
} else {
206206
const drivesList: Contents.IModel[] = [];
207-
for (const drive of this._drivesList.names) {
207+
for (const drive of this._drivesList) {
208208
drivesList.push({
209-
name: drive,
210-
path: drive,
209+
name: drive.name,
210+
path: drive.name,
211211
last_modified: '',
212-
created: '',
212+
created: drive.creationDate,
213213
content: [],
214214
format: 'json',
215215
mimetype: '',
@@ -593,7 +593,7 @@ export class Drive implements Contents.IDrive {
593593
}*/
594594

595595
// private _apiEndpoint: string;
596-
private _drivesList: IDrivesList = { names: [] };
596+
private _drivesList: IDriveInfo[] = [];
597597
private _serverSettings: ServerConnection.ISettings;
598598
private _name: string = '';
599599
private _provider: string = '';
@@ -613,7 +613,7 @@ export namespace Drive {
613613
/**
614614
* List of available drives.
615615
*/
616-
drivesList?: IDrivesList;
616+
drivesList?: IDriveInfo[];
617617

618618
/**
619619
* The name for the `Drive`, which is used in file

src/index.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { DriveListModel, DriveListView, IDrive } from './drivelistmanager';
2727
import { DriveIcon, driveBrowserIcon } from './icons';
2828
import { Drive } from './contents';
2929
import { getDrivesList } from './requests';
30-
import { IDrivesList } from './token';
30+
import { IDriveInfo, IDrivesList } from './token';
3131

3232
/**
3333
* The command IDs used by the driveBrowser plugin.
@@ -155,20 +155,25 @@ const openDriveDialogPlugin: JupyterFrontEndPlugin<void> = {
155155
/**
156156
* The drives list provider.
157157
*/
158-
const drivesListProvider: JupyterFrontEndPlugin<IDrivesList> = {
158+
const drivesListProvider: JupyterFrontEndPlugin<IDriveInfo[]> = {
159159
id: '@jupyter/drives:drives-list',
160160
description: 'The drives list provider.',
161161
provides: IDrivesList,
162-
activate: async (_: JupyterFrontEnd): Promise<IDrivesList> => {
163-
const driveNames: string[] = [];
162+
activate: async (_: JupyterFrontEnd): Promise<IDriveInfo[]> => {
163+
const drives: IDriveInfo[] = [];
164164

165165
const response = await getDrivesList();
166166
if (response.code === 200) {
167167
for (const d of response.data) {
168-
driveNames.push(d.name);
168+
drives.push({
169+
name: d.name,
170+
region: d.region,
171+
provider: d.provider,
172+
creationDate: d.creation_date
173+
});
169174
}
170175
}
171-
return { names: driveNames };
176+
return drives;
172177
}
173178
};
174179

@@ -198,7 +203,7 @@ const driveFileBrowser: JupyterFrontEndPlugin<void> = {
198203
toolbarRegistry: IToolbarWidgetRegistry,
199204
settingsRegistry: ISettingRegistry,
200205
translator: ITranslator,
201-
drivesList: IDrivesList,
206+
drivesList: IDriveInfo[],
202207
router: IRouter | null,
203208
tree: JupyterFrontEnd.ITreeResolver | null,
204209
labShell: ILabShell | null,

src/token.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import { Token } from '@lumino/coreutils';
22

3-
export const IDrivesList = new Token<IDrivesList>(
3+
export const IDrivesList = new Token<IDriveInfo[]>(
44
'@jupyter/drives:drives-list-provider'
55
);
66

7-
export interface IDrivesList {
8-
names: string[];
7+
export interface IDriveInfo {
8+
name: string;
9+
region: string;
10+
provider: string;
11+
creationDate: string;
912
}

0 commit comments

Comments
 (0)