Skip to content

Commit

Permalink
Introduce changes to keep all the attributes required by the IDrive i…
Browse files Browse the repository at this point in the history
…nterface, when picking a drive by its name in the list of available drives.

Add a toolbar to all the drive filebrowsers.
  • Loading branch information
HaudinFlorence committed Nov 15, 2023
1 parent 0654a2c commit 19db95c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 18 deletions.
23 changes: 14 additions & 9 deletions src/drivelistmanager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,20 @@ export function DriveListManagerComponent(props: IProps) {

const updateSelectedDrives = (item: string, isName: boolean) => {
updatedSelectedDrives = [...props.model.selectedDrives];
let pickedDrive: IDrive;
if (isName) {
pickedDrive = { name: item, url: '' };
} else {
if (item !== driveUrl) {
setDriveUrl(item);
let pickedDrive: IDrive = { name: '', url: '' };

props.model.availableDrives.forEach(drive => {
if (isName) {
if (item === drive.name) {
pickedDrive = drive;
}
} else {
if (item !== driveUrl) {
setDriveUrl(item);
}
pickedDrive = { name: '', url: driveUrl };
}
pickedDrive = { name: '', url: driveUrl };
}
});

const checkDrive = isDriveAlreadySelected(
pickedDrive,
Expand All @@ -174,7 +179,7 @@ export function DriveListManagerComponent(props: IProps) {
if (checkDrive === false) {
updatedSelectedDrives.push(pickedDrive);
} else {
console.log('The selected drive is already in the list');
console.warn('The selected drive is already in the list');
}

setSelectedDrives(updatedSelectedDrives);
Expand Down
31 changes: 22 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const availableList1 = [
},
{
name: 'WaterMelonDrive',
url: '/WaterMelonDrive/url'
url: '/watermelondrive/url'
},
{
name: 'MangoDrive',
Expand All @@ -66,34 +66,34 @@ const availableList1 = [
},
{
name: '',
url: '/mydrive/url'
url: '/apple/url'
},
{
name: 'RaspberryDrive',
url: '/raspberrydrive/url'
},

{
name: 'PineAppleDrive',
url: ''
name: 'PineappleDrive',
url: '/pineappledrive/url'
},

{ name: 'PomeloDrive', url: '/https://pomelodrive/url' },
{
name: 'OrangeDrive',
url: ''
url: 'orangedrive/url'
},
{
name: 'TomatoDrive',
url: ''
url: 'tomatodrive/url'
},
{
name: '',
url: 'superDrive/url'
url: 'plumedrive/url'
},
{
name: 'AvocadoDrive',
url: ''
url: 'avocadodrive/url'
}
];

Expand Down Expand Up @@ -192,6 +192,19 @@ export async function activateAddDrivesPlugin(
refreshInterval: 300000
});

if (settingRegistry) {
setToolbar(
driveBrowser,
createToolbarFactory(
toolbarRegistry,
settingRegistry,
FILE_BROWSER_FACTORY,
FILE_BROWSER_PLUGIN_ID,
translator
)
);
}

panel.addWidget(driveBrowser);
}

Expand All @@ -218,7 +231,7 @@ export async function activateAddDrivesPlugin(
console.log('response:', response);
addDriveContentsToPanel(panel, drive1);
} else {
console.log('Error, connection with the drive was not possible');
console.warn('Connection with the drive was not possible');
}
}
}
Expand Down

0 comments on commit 19db95c

Please sign in to comment.