Skip to content

Commit 61b237c

Browse files
authored
Merge pull request #41 from QuantStack/disableRename
Disable directory rename
2 parents 9782f37 + e415a79 commit 61b237c

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

schema/file-browser-toolbar.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@
88
}
99
]
1010
},
11+
"jupyter.lab.menus": {
12+
"context": [
13+
{
14+
"command": "filebrowser:rename",
15+
"selector": ".jp-DirListing-item[data-isdir]",
16+
"rank": 5,
17+
"disabled": true
18+
},
19+
{
20+
"command": "drives:rename",
21+
"selector": ".jp-DirListing-item[data-isdir]",
22+
"rank": 5
23+
}
24+
]
25+
},
1126
"jupyter.lab.setting-icon": "jupydrive-s3:drive",
1227
"jupyter.lab.setting-icon-label": "Drive Browser",
1328
"title": "Jupydrive-s3 Settings",

src/index.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
Uploader
1919
} from '@jupyterlab/filebrowser';
2020
import { IStateDB } from '@jupyterlab/statedb';
21+
import { editIcon } from '@jupyterlab/ui-components';
2122

2223
import { ISettingRegistry } from '@jupyterlab/settingregistry';
2324
import { ITranslator } from '@jupyterlab/translation';
@@ -44,6 +45,7 @@ namespace CommandIDs {
4445
export const copyToAnotherBucket = 'drives:copy-to-another-bucket';
4546
export const toggleBucketSwitching = 'drives:toggle-bucket-switching-ui';
4647
export const toggleBrowser = 'filebrowser:toggle-main';
48+
export const rename = 'drives:rename';
4749
}
4850

4951
const FILE_BROWSER_FACTORY = 'DriveBrowser';
@@ -511,6 +513,29 @@ namespace Private {
511513
'.jp-SidePanel .jp-DirListing-content .jp-DirListing-item[data-isDir]',
512514
rank: 10
513515
});
516+
517+
app.commands.addCommand(CommandIDs.rename, {
518+
execute: args => {
519+
const widget = tracker.currentWidget;
520+
521+
if (widget) {
522+
return widget.rename();
523+
}
524+
},
525+
isVisible: () =>
526+
// So long as this command only handles one file at time, don't show it
527+
// if multiple files are selected.
528+
!!tracker.currentWidget &&
529+
Array.from(tracker.currentWidget.selectedItems()).length === 1,
530+
isEnabled: () =>
531+
// Disable directory rename for S3 folders.
532+
!!tracker.currentWidget &&
533+
tracker.currentWidget?.selectedItems().next()!.value.type !==
534+
'directory',
535+
icon: editIcon.bindprops({ stylesheet: 'menuItem' }),
536+
label: 'Rename',
537+
mnemonic: 0
538+
});
514539
}
515540

516541
/**

0 commit comments

Comments
 (0)