99 excludeDrive ,
1010 getDrivesList ,
1111 getExcludedDrives ,
12- includeDrive
12+ includeDrive ,
13+ mountDrive
1314} from '../requests' ;
1415import { ISignal , Signal } from '@lumino/signaling' ;
1516import { driveBrowserIcon , addIcon , removeIcon } from '../icons' ;
@@ -27,6 +28,7 @@ export interface IDriveInputProps {
2728 onSubmit : ( ) => void ;
2829 isPublic : boolean ;
2930 setIsPublic : ( value : boolean ) => void ;
31+ mountError : string ;
3032}
3133
3234export function DriveInputComponent ( {
@@ -36,7 +38,8 @@ export function DriveInputComponent({
3638 setRegion,
3739 onSubmit,
3840 isPublic,
39- setIsPublic
41+ setIsPublic,
42+ mountError
4043} : IDriveInputProps ) {
4144 return (
4245 < div >
@@ -75,6 +78,11 @@ export function DriveInputComponent({
7578 />
7679 ) }
7780 </ div >
81+ { mountError && (
82+ < div className = "add-public-drive-section" >
83+ < p className = "error" > { mountError } </ p >
84+ </ div >
85+ ) }
7886 </ div >
7987 ) ;
8088}
@@ -183,6 +191,7 @@ export function DriveListManagerComponent({ model }: IProps) {
183191 ) ;
184192 const [ isPublic , setIsPublic ] = useState < boolean > ( false ) ;
185193 const [ driveRegion , setDriveRegion ] = useState < string > ( '' ) ;
194+ const [ mountError , setMountError ] = useState < string > ( '' ) ;
186195
187196 // Called after mounting.
188197 React . useEffect ( ( ) => {
@@ -197,14 +206,24 @@ export function DriveListManagerComponent({ model }: IProps) {
197206 } , [ model ] ) ;
198207
199208 const onAddedPublicDrive = async ( ) => {
200- if ( isPublic ) {
201- await addPublicDrive ( publicDrive ) ;
209+ // Check if user has access to drive.
210+ const result = await mountDrive ( publicDrive , {
211+ provider : 's3'
212+ } ) ;
213+ if ( result && result . error ) {
214+ // Show error in case of failure.
215+ setMountError ( result . error . message ) ;
202216 } else {
203- await addExternalDrive ( publicDrive , driveRegion ) ;
217+ // Proceed with adding the drive otherwise.
218+ if ( isPublic ) {
219+ await addPublicDrive ( publicDrive ) ;
220+ } else {
221+ await addExternalDrive ( publicDrive , driveRegion ) ;
222+ setDriveRegion ( '' ) ;
223+ }
204224 setDriveRegion ( '' ) ;
225+ await model . refresh ( ) ;
205226 }
206- setPublicDrive ( '' ) ;
207- await model . refresh ( ) ;
208227 } ;
209228
210229 return (
@@ -239,6 +258,7 @@ export function DriveListManagerComponent({ model }: IProps) {
239258 isPublic = { isPublic }
240259 setIsPublic = { setIsPublic }
241260 onSubmit = { onAddedPublicDrive }
261+ mountError = { mountError }
242262 />
243263 </ div >
244264
0 commit comments