Skip to content

Commit a2b8af5

Browse files
authored
Merge pull request #23 from martinRenou/disable_rename_copy
Disable rename and copy menus
2 parents aa0f354 + 576da91 commit a2b8af5

File tree

5 files changed

+110
-4
lines changed

5 files changed

+110
-4
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ graft jupyterlab_filesystem_access/labextension
1111

1212
# Javascript files
1313
graft src
14+
graft schema
1415
graft style
1516
prune **/node_modules
1617
prune lib

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
},
1919
"files": [
2020
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
21-
"style/**/*.{css,js,eot,gif,html,jpg,json,png,svg,woff2,ttf}"
21+
"style/**/*.{css,js,eot,gif,html,jpg,json,png,svg,woff2,ttf}",
22+
"schema/*.json"
2223
],
2324
"main": "lib/index.js",
2425
"types": "lib/index.d.ts",
@@ -57,14 +58,15 @@
5758
"@jupyterlab/apputils": "^3.3.0",
5859
"@jupyterlab/filebrowser": "^3.3.0",
5960
"@jupyterlab/services": "^6.3.0",
61+
"@jupyterlab/settingregistry": "^3.3.3",
6062
"@jupyterlab/translation": "^3.3.0",
6163
"@jupyterlab/ui-components": "^3.3.0"
6264
},
6365
"devDependencies": {
6466
"@jupyterlab/builder": "^3.3.0",
67+
"@types/wicg-file-system-access": "^2020.9.5",
6568
"@typescript-eslint/eslint-plugin": "^5.16.0",
6669
"@typescript-eslint/parser": "^5.16.0",
67-
"@types/wicg-file-system-access": "^2020.9.5",
6870
"eslint": "^8.11.0",
6971
"eslint-config-prettier": "^8.5.0",
7072
"eslint-plugin-prettier": "^4.0.0",
@@ -88,7 +90,8 @@
8890
},
8991
"jupyterlab": {
9092
"extension": true,
91-
"outputDir": "jupyterlab_filesystem_access/labextension"
93+
"outputDir": "jupyterlab_filesystem_access/labextension",
94+
"schemaDir": "schema"
9295
},
9396
"jupyter-releaser": {
9497
"hooks": {

schema/plugin.json

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"jupyter.lab.shortcuts": [],
3+
"title": "File Browser Access",
4+
"description": "File Browser Access settings.",
5+
"type": "object",
6+
"properties": {},
7+
"jupyter.lab.menus": {
8+
"context": [
9+
{
10+
"command": "filebrowser:rename",
11+
"selector": ".jp-DirListing-item[data-isdir]",
12+
"rank": 5,
13+
"disabled": true
14+
},
15+
{
16+
"command": "filebrowser:rename",
17+
"selector": ".jp-FileBrowser:not([data-is-filesystem-access]) .jp-DirListing-item[data-isdir]",
18+
"rank": 5
19+
},
20+
{
21+
"command": "filebrowser:cut",
22+
"selector": ".jp-DirListing-item[data-isdir]",
23+
"rank": 7,
24+
"disabled": true
25+
},
26+
{
27+
"command": "filebrowser:cut",
28+
"selector": ".jp-FileBrowser:not([data-is-filesystem-access]) .jp-DirListing-item[data-isdir]",
29+
"rank": 7
30+
},
31+
{
32+
"command": "filebrowser:copy",
33+
"selector": ".jp-DirListing-item[data-isdir=\"false\"]",
34+
"rank": 8,
35+
"disabled": true
36+
},
37+
{
38+
"command": "filebrowser:copy",
39+
"selector": ".jp-FileBrowser:not([data-is-filesystem-access]) .jp-DirListing-item[data-isdir=\"false\"]",
40+
"rank": 8
41+
},
42+
{
43+
"command": "filebrowser:paste",
44+
"selector": ".jp-DirListing-content",
45+
"rank": 8.5,
46+
"disabled": true
47+
},
48+
{
49+
"command": "filebrowser:paste",
50+
"selector": ".jp-FileBrowser:not([data-is-filesystem-access]) .jp-DirListing-content",
51+
"rank": 8.5
52+
},
53+
{
54+
"command": "filebrowser:duplicate",
55+
"selector": ".jp-DirListing-item[data-isdir=\"false\"]",
56+
"rank": 9,
57+
"disabled": true
58+
},
59+
{
60+
"command": "filebrowser:duplicate",
61+
"selector": ".jp-FileBrowser:not([data-is-filesystem-access]) .jp-DirListing-item[data-isdir=\"false\"]",
62+
"rank": 9
63+
}
64+
]
65+
},
66+
"additionalProperties": false
67+
}

src/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import {
33
JupyterFrontEndPlugin
44
} from '@jupyterlab/application';
55

6+
import { ISettingRegistry } from '@jupyterlab/settingregistry';
7+
68
import { ToolbarButton } from '@jupyterlab/apputils';
79

810
import { IFileBrowserFactory } from '@jupyterlab/filebrowser';
@@ -19,11 +21,13 @@ import { FileSystemDrive } from './drive';
1921
const plugin: JupyterFrontEndPlugin<void> = {
2022
id: 'jupyterlab-filesystem-access:plugin',
2123
requires: [IFileBrowserFactory, ITranslator],
24+
optional: [ISettingRegistry],
2225
autoStart: true,
2326
activate: (
2427
app: JupyterFrontEnd,
2528
browser: IFileBrowserFactory,
26-
translator: ITranslator
29+
translator: ITranslator,
30+
settingRegistry: ISettingRegistry | null
2731
) => {
2832
if (!window.showDirectoryPicker) {
2933
// bail if the browser does not support the File System API
@@ -33,6 +37,10 @@ const plugin: JupyterFrontEndPlugin<void> = {
3337
return;
3438
}
3539

40+
if (settingRegistry) {
41+
settingRegistry.load(plugin.id);
42+
}
43+
3644
const { serviceManager } = app;
3745
const { createFileBrowser } = browser;
3846

@@ -49,6 +57,9 @@ const plugin: JupyterFrontEndPlugin<void> = {
4957
widget.title.caption = trans.__('Local File System');
5058
widget.title.icon = listIcon;
5159

60+
// Adding a data attribute
61+
widget.node.setAttribute('data-is-filesystem-access', '');
62+
5263
const openDirectoryButton = new ToolbarButton({
5364
icon: folderIcon,
5465
onClick: async () => {

yarn.lock

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,19 @@
464464
ajv "^6.12.3"
465465
json5 "^2.1.1"
466466

467+
"@jupyterlab/settingregistry@^3.3.3":
468+
version "3.3.3"
469+
resolved "https://registry.yarnpkg.com/@jupyterlab/settingregistry/-/settingregistry-3.3.3.tgz#6ec7221481e54eb7a1f5b9275b8981dd4ebc10bc"
470+
integrity sha512-1lEgrp3Zeatmv9IiSlS5QR8r2NhLtvRPb4mGO4MTEsqNeZaxcTv8belmnYPE+iuPqVKW2C5Fb1ek7/HeZQYHKA==
471+
dependencies:
472+
"@jupyterlab/statedb" "^3.3.3"
473+
"@lumino/commands" "^1.12.0"
474+
"@lumino/coreutils" "^1.5.3"
475+
"@lumino/disposable" "^1.4.3"
476+
"@lumino/signaling" "^1.4.3"
477+
ajv "^6.12.3"
478+
json5 "^2.1.1"
479+
467480
"@jupyterlab/shared-models@^3.3.2":
468481
version "3.3.2"
469482
resolved "https://registry.yarnpkg.com/@jupyterlab/shared-models/-/shared-models-3.3.2.tgz#a6ca48947161895e7abbb1707ecdc1702da9a3e7"
@@ -487,6 +500,17 @@
487500
"@lumino/properties" "^1.2.3"
488501
"@lumino/signaling" "^1.4.3"
489502

503+
"@jupyterlab/statedb@^3.3.3":
504+
version "3.3.3"
505+
resolved "https://registry.yarnpkg.com/@jupyterlab/statedb/-/statedb-3.3.3.tgz#7c7177609bc5d86663406191967b7866845b93ba"
506+
integrity sha512-ElKGUCipWmFLURSDJIfyCliaJLA0Nmlq4H/bWg0aSqtg75ByqvXJ0AYwFkg1RP291AMh9f22NMmPF1jScTzJbQ==
507+
dependencies:
508+
"@lumino/commands" "^1.12.0"
509+
"@lumino/coreutils" "^1.5.3"
510+
"@lumino/disposable" "^1.4.3"
511+
"@lumino/properties" "^1.2.3"
512+
"@lumino/signaling" "^1.4.3"
513+
490514
"@jupyterlab/statusbar@^3.3.2":
491515
version "3.3.2"
492516
resolved "https://registry.yarnpkg.com/@jupyterlab/statusbar/-/statusbar-3.3.2.tgz#e5339e17ceae640e179d6c698234bcb3bcec0fb6"

0 commit comments

Comments
 (0)