Skip to content

Commit d2f2f9a

Browse files
committed
add commands for new funcitonalities
1 parent b8a9955 commit d2f2f9a

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

src/plugins/driveBrowserPlugin.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,5 +542,65 @@ namespace Private {
542542
icon: fileIcon.bindprops({ stylesheet: 'menuItem' }),
543543
label: 'Copy Path'
544544
});
545+
546+
app.commands.addCommand(CommandIDs.excludeDrive, {
547+
isEnabled: () => {
548+
return browser.model.path === 's3:';
549+
},
550+
execute: () => {
551+
const widget = tracker.currentWidget;
552+
if (!widget) {
553+
return;
554+
}
555+
const item = widget.selectedItems().next();
556+
if (item.done) {
557+
return;
558+
}
559+
560+
const driveName: string = item.value.name;
561+
drive.excludeDrive(driveName);
562+
},
563+
label: 'Exclude Drive',
564+
icon: driveBrowserIcon.bindprops({ stylesheet: 'menuItem' })
565+
});
566+
567+
app.contextMenu.addItem({
568+
command: CommandIDs.excludeDrive,
569+
selector:
570+
'#drive-file-browser.jp-SidePanel .jp-DirListing-content .jp-DirListing-item[data-isdir]',
571+
rank: 110
572+
});
573+
574+
app.commands.addCommand(CommandIDs.includeDrive, {
575+
isEnabled: () => {
576+
return browser.model.path === 's3:';
577+
},
578+
execute: async () => {
579+
return showDialog({
580+
title: 'Include Drive',
581+
body: new Private.AddPublicDriveHandler(drive.name),
582+
focusNodeSelector: 'input',
583+
buttons: [
584+
Dialog.cancelButton(),
585+
Dialog.okButton({
586+
label: 'Add',
587+
ariaLabel: 'Include Drive'
588+
})
589+
]
590+
}).then(result => {
591+
if (result.value) {
592+
drive.includeDrive(result.value);
593+
}
594+
});
595+
},
596+
label: 'Include Drive',
597+
icon: driveBrowserIcon.bindprops({ stylesheet: 'menuItem' })
598+
});
599+
600+
app.contextMenu.addItem({
601+
command: CommandIDs.includeDrive,
602+
selector: '#drive-file-browser.jp-SidePanel .jp-DirListing-content',
603+
rank: 110
604+
});
545605
}
546606
}

src/token.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export namespace CommandIDs {
1616
export const createNewNotebook = 'drives:create-new-notebook';
1717
export const rename = 'drives:rename';
1818
export const copyPath = 'drives:copy-path';
19+
export const excludeDrive = 'drives:exclude-drive';
20+
export const includeDrive = 'drives:include-drive';
1921
}
2022

2123
/**

0 commit comments

Comments
 (0)