Skip to content

Commit f680409

Browse files
committed
update drives management dialog to include external drives
1 parent bce30a4 commit f680409

File tree

2 files changed

+53
-7
lines changed

2 files changed

+53
-7
lines changed

src/plugins/drivelistmanager.tsx

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Button, Search } from '@jupyter/react-components';
44
import { useState } from 'react';
55
import { IDriveInfo } from '../token';
66
import {
7+
addExternalDrive,
78
addPublicDrive,
89
excludeDrive,
910
getDrivesList,
@@ -19,15 +20,23 @@ interface IProps {
1920

2021
export interface IDriveInputProps {
2122
isName: boolean;
22-
value: string;
23+
driveValue: string;
24+
regionValue: string;
2325
setPublicDrive: (value: string) => void;
26+
setRegion: (value: string) => void;
2427
onSubmit: () => void;
28+
isPublic: boolean;
29+
setIsPublic: (value: boolean) => void;
2530
}
2631

2732
export function DriveInputComponent({
28-
value,
33+
driveValue,
34+
regionValue,
2935
setPublicDrive,
30-
onSubmit
36+
setRegion,
37+
onSubmit,
38+
isPublic,
39+
setIsPublic
3140
}: IDriveInputProps) {
3241
return (
3342
<div>
@@ -38,7 +47,7 @@ export function DriveInputComponent({
3847
setPublicDrive(event.target.value);
3948
}}
4049
placeholder="Enter drive name"
41-
value={value}
50+
value={driveValue}
4251
/>
4352
<Button
4453
className="input-add-drive-button"
@@ -48,6 +57,24 @@ export function DriveInputComponent({
4857
add
4958
</Button>
5059
</div>
60+
<div className="add-public-drive-section">
61+
{'Public drive?'}
62+
<input
63+
type="checkbox"
64+
checked={isPublic}
65+
onChange={event => setIsPublic(event.target.checked)}
66+
/>
67+
{!isPublic && (
68+
<input
69+
className="drive-region-input"
70+
onInput={(event: any) => {
71+
setRegion(event.target.value);
72+
}}
73+
placeholder="Region (e.g.: us-east-1)"
74+
value={regionValue}
75+
/>
76+
)}
77+
</div>
5178
</div>
5279
);
5380
}
@@ -154,6 +181,8 @@ export function DriveListManagerComponent({ model }: IProps) {
154181
const [availableDrives, setAvailableDrives] = useState<Partial<IDriveInfo>[]>(
155182
model.availableDrives
156183
);
184+
const [isPublic, setIsPublic] = useState<boolean>(false);
185+
const [driveRegion, setDriveRegion] = useState<string>('');
157186

158187
// Called after mounting.
159188
React.useEffect(() => {
@@ -168,7 +197,12 @@ export function DriveListManagerComponent({ model }: IProps) {
168197
}, [model]);
169198

170199
const onAddedPublicDrive = async () => {
171-
await addPublicDrive(publicDrive);
200+
if (isPublic) {
201+
await addPublicDrive(publicDrive);
202+
} else {
203+
await addExternalDrive(publicDrive, driveRegion);
204+
setDriveRegion('');
205+
}
172206
setPublicDrive('');
173207
await model.refresh();
174208
};
@@ -195,11 +229,15 @@ export function DriveListManagerComponent({ model }: IProps) {
195229
</div>
196230

197231
<div className="drives-manager-section">
198-
<div className="drives-section-title"> Add public drive</div>
232+
<div className="drives-section-title"> Add external drive</div>
199233
<DriveInputComponent
200234
isName={false}
201-
value={publicDrive}
235+
driveValue={publicDrive}
236+
regionValue={driveRegion}
202237
setPublicDrive={setPublicDrive}
238+
setRegion={setDriveRegion}
239+
isPublic={isPublic}
240+
setIsPublic={setIsPublic}
203241
onSubmit={onAddedPublicDrive}
204242
/>
205243
</div>

style/base.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ li {
5050
justify-content: center;
5151
}
5252

53+
.drive-region-input {
54+
height: 20px !important;
55+
width: 100%;
56+
flex: 1;
57+
justify-content: center;
58+
margin-right: 61px;
59+
}
60+
5361
.drive-data-grid {
5462
width: 380px;
5563
flex-direction: row;

0 commit comments

Comments
 (0)