@deephaven/file-explorer 0.22.3-beta.18 → 0.22.3-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/FileExistsError.js +0 -7
- package/dist/FileExistsError.js.map +1 -1
- package/dist/FileExplorer.d.ts +4 -4
- package/dist/FileExplorer.d.ts.map +1 -1
- package/dist/FileExplorer.js +4 -19
- package/dist/FileExplorer.js.map +1 -1
- package/dist/FileExplorerShortcuts.js.map +1 -1
- package/dist/FileExplorerToolbar.d.ts +1 -1
- package/dist/FileExplorerToolbar.d.ts.map +1 -1
- package/dist/FileExplorerToolbar.js +2 -2
- package/dist/FileExplorerToolbar.js.map +1 -1
- package/dist/FileList.d.ts +1 -1
- package/dist/FileList.d.ts.map +1 -1
- package/dist/FileList.js +18 -56
- package/dist/FileList.js.map +1 -1
- package/dist/FileListContainer.d.ts +4 -4
- package/dist/FileListContainer.d.ts.map +1 -1
- package/dist/FileListContainer.js +2 -16
- package/dist/FileListContainer.js.map +1 -1
- package/dist/FileListItemEditor.d.ts +1 -1
- package/dist/FileListItemEditor.d.ts.map +1 -1
- package/dist/FileListItemEditor.js +4 -7
- package/dist/FileListItemEditor.js.map +1 -1
- package/dist/FileNotFoundError.js +0 -4
- package/dist/FileNotFoundError.js.map +1 -1
- package/dist/FileStorage.js +2 -0
- package/dist/FileStorage.js.map +1 -1
- package/dist/FileUtils.js +19 -62
- package/dist/FileUtils.js.map +1 -1
- package/dist/NewItemModal.js +5 -65
- package/dist/NewItemModal.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/dist/FileExistsError.js
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
-
|
|
3
2
|
import { ValidationError } from '@deephaven/utils';
|
|
4
|
-
|
|
5
3
|
class FileExistsError extends ValidationError {
|
|
6
4
|
constructor(info) {
|
|
7
5
|
super('Name already exists');
|
|
8
|
-
|
|
9
6
|
_defineProperty(this, "isExistingFile", true);
|
|
10
|
-
|
|
11
7
|
_defineProperty(this, "info", void 0);
|
|
12
|
-
|
|
13
8
|
this.info = info;
|
|
14
9
|
}
|
|
15
|
-
|
|
16
10
|
}
|
|
17
|
-
|
|
18
11
|
export default FileExistsError;
|
|
19
12
|
//# sourceMappingURL=FileExistsError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileExistsError.js","names":["ValidationError","FileExistsError","constructor","info"],"sources":["../src/FileExistsError.ts"],"sourcesContent":["import { ValidationError } from '@deephaven/utils';\nimport { FileStorageItem } from './FileStorage';\n\nclass FileExistsError extends ValidationError {\n isExistingFile = true;\n\n info: FileStorageItem;\n\n constructor(info: FileStorageItem) {\n super('Name already exists');\n this.info = info;\n }\n}\n\nexport default FileExistsError;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"FileExistsError.js","names":["ValidationError","FileExistsError","constructor","info"],"sources":["../src/FileExistsError.ts"],"sourcesContent":["import { ValidationError } from '@deephaven/utils';\nimport { FileStorageItem } from './FileStorage';\n\nclass FileExistsError extends ValidationError {\n isExistingFile = true;\n\n info: FileStorageItem;\n\n constructor(info: FileStorageItem) {\n super('Name already exists');\n this.info = info;\n }\n}\n\nexport default FileExistsError;\n"],"mappings":";AAAA,SAASA,eAAe,QAAQ,kBAAkB;AAGlD,MAAMC,eAAe,SAASD,eAAe,CAAC;EAK5CE,WAAW,CAACC,IAAqB,EAAE;IACjC,KAAK,CAAC,qBAAqB,CAAC;IAAC,wCALd,IAAI;IAAA;IAMnB,IAAI,CAACA,IAAI,GAAGA,IAAI;EAClB;AACF;AAEA,eAAeF,eAAe"}
|
package/dist/FileExplorer.d.ts
CHANGED
|
@@ -15,9 +15,9 @@ export interface FileExplorerProps {
|
|
|
15
15
|
/**
|
|
16
16
|
* Component that displays and allows interaction with the file system in the provided FileStorage.
|
|
17
17
|
*/
|
|
18
|
-
export declare
|
|
19
|
-
|
|
20
|
-
displayName: string;
|
|
21
|
-
}
|
|
18
|
+
export declare function FileExplorer(props: FileExplorerProps): JSX.Element;
|
|
19
|
+
export declare namespace FileExplorer {
|
|
20
|
+
var displayName: string;
|
|
21
|
+
}
|
|
22
22
|
export default FileExplorer;
|
|
23
23
|
//# sourceMappingURL=FileExplorer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileExplorer.d.ts","sourceRoot":"","sources":["../src/FileExplorer.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAEzE,OAAO,WAAW,EAAE,EAClB,eAAe,EAGhB,MAAM,eAAe,CAAC;AACvB,OAAO,qBAAqB,CAAC;AAQ7B,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,WAAW,CAAC;IAErB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;IAC9C,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtD,QAAQ,EAAE,CAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,CAAC,cAAc,KAAK,IAAI,CAAC;IACvE,iBAAiB,CAAC,EAAE,CAAC,aAAa,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;IAE/D,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"FileExplorer.d.ts","sourceRoot":"","sources":["../src/FileExplorer.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAEzE,OAAO,WAAW,EAAE,EAClB,eAAe,EAGhB,MAAM,eAAe,CAAC;AACvB,OAAO,qBAAqB,CAAC;AAQ7B,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,WAAW,CAAC;IAErB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;IAC9C,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtD,QAAQ,EAAE,CAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,CAAC,cAAc,KAAK,IAAI,CAAC;IACvE,iBAAiB,CAAC,EAAE,CAAC,aAAa,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;IAE/D,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,GAAG,CAAC,OAAO,CAyKlE;yBAzKe,YAAY;;;AA6K5B,eAAe,YAAY,CAAC"}
|
package/dist/FileExplorer.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
2
|
-
|
|
3
2
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
4
|
-
|
|
5
3
|
import { BasicModal } from '@deephaven/components';
|
|
6
4
|
import Log from '@deephaven/log';
|
|
7
5
|
import { PromiseUtils } from '@deephaven/utils';
|
|
@@ -14,11 +12,10 @@ import FileUtils from "./FileUtils.js";
|
|
|
14
12
|
import FileExistsError from "./FileExistsError.js";
|
|
15
13
|
import FileNotFoundError from "./FileNotFoundError.js";
|
|
16
14
|
var log = Log.module('FileExplorer');
|
|
17
|
-
|
|
18
15
|
/**
|
|
19
16
|
* Component that displays and allows interaction with the file system in the provided FileStorage.
|
|
20
17
|
*/
|
|
21
|
-
export
|
|
18
|
+
export function FileExplorer(props) {
|
|
22
19
|
var {
|
|
23
20
|
storage,
|
|
24
21
|
isMultiSelect = false,
|
|
@@ -33,16 +30,13 @@ export var FileExplorer = props => {
|
|
|
33
30
|
var [table, setTable] = useState();
|
|
34
31
|
useEffect(function initializeTable() {
|
|
35
32
|
var tablePromise;
|
|
36
|
-
|
|
37
33
|
function initTable() {
|
|
38
34
|
return _initTable.apply(this, arguments);
|
|
39
35
|
}
|
|
40
|
-
|
|
41
36
|
function _initTable() {
|
|
42
37
|
_initTable = _asyncToGenerator(function* () {
|
|
43
38
|
log.debug('initTable');
|
|
44
39
|
tablePromise = PromiseUtils.makeCancelable(storage.getTable(), t => t.close());
|
|
45
|
-
|
|
46
40
|
try {
|
|
47
41
|
setTable(yield tablePromise);
|
|
48
42
|
} catch (e) {
|
|
@@ -53,7 +47,6 @@ export var FileExplorer = props => {
|
|
|
53
47
|
});
|
|
54
48
|
return _initTable.apply(this, arguments);
|
|
55
49
|
}
|
|
56
|
-
|
|
57
50
|
initTable();
|
|
58
51
|
return () => {
|
|
59
52
|
tablePromise.cancel();
|
|
@@ -92,17 +85,13 @@ export var FileExplorer = props => {
|
|
|
92
85
|
var handleRename = useCallback((item, newName) => {
|
|
93
86
|
var name = item.filename;
|
|
94
87
|
var isDir = isDirectory(item);
|
|
95
|
-
|
|
96
88
|
if (isDir && !name.endsWith('/')) {
|
|
97
89
|
name = "".concat(name, "/");
|
|
98
90
|
}
|
|
99
|
-
|
|
100
91
|
var destination = "".concat(FileUtils.getParent(name)).concat(newName);
|
|
101
|
-
|
|
102
92
|
if (isDir && !destination.endsWith('/')) {
|
|
103
93
|
destination = "".concat(destination, "/");
|
|
104
94
|
}
|
|
105
|
-
|
|
106
95
|
log.debug2('handleRename', name, destination);
|
|
107
96
|
storage.moveFile(name, destination).catch(handleError);
|
|
108
97
|
onRename(name, destination);
|
|
@@ -113,21 +102,18 @@ export var FileExplorer = props => {
|
|
|
113
102
|
// Same name is fine
|
|
114
103
|
return undefined;
|
|
115
104
|
}
|
|
116
|
-
|
|
117
105
|
FileUtils.validateName(newName);
|
|
118
106
|
var newValue = "".concat(FileUtils.getPath(renameItem.filename)).concat(newName);
|
|
119
|
-
|
|
120
107
|
try {
|
|
121
108
|
var fileInfo = yield storage.info(newValue);
|
|
122
109
|
throw new FileExistsError(fileInfo);
|
|
123
110
|
} catch (e) {
|
|
124
111
|
if (!(e instanceof FileNotFoundError)) {
|
|
125
112
|
throw e;
|
|
126
|
-
}
|
|
127
|
-
|
|
113
|
+
}
|
|
114
|
+
// The file does not exist, fine to save at that path
|
|
128
115
|
}
|
|
129
116
|
});
|
|
130
|
-
|
|
131
117
|
return function (_x, _x2) {
|
|
132
118
|
return _ref.apply(this, arguments);
|
|
133
119
|
};
|
|
@@ -137,7 +123,6 @@ export var FileExplorer = props => {
|
|
|
137
123
|
if (itemsToDelete.length === 1) {
|
|
138
124
|
return "Are you sure you want to delete \"".concat(itemsToDelete[0].filename, "\"?");
|
|
139
125
|
}
|
|
140
|
-
|
|
141
126
|
return "Are you sure you want to delete the selected files?";
|
|
142
127
|
}, [itemsToDelete]);
|
|
143
128
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -162,7 +147,7 @@ export var FileExplorer = props => {
|
|
|
162
147
|
onConfirm: handleDeleteConfirm,
|
|
163
148
|
confirmButtonText: "Delete"
|
|
164
149
|
}));
|
|
165
|
-
}
|
|
150
|
+
}
|
|
166
151
|
FileExplorer.displayName = 'FileExplorer';
|
|
167
152
|
export default FileExplorer;
|
|
168
153
|
//# sourceMappingURL=FileExplorer.js.map
|
package/dist/FileExplorer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileExplorer.js","names":["BasicModal","Log","PromiseUtils","React","useCallback","useEffect","useMemo","useState","DEFAULT_ROW_HEIGHT","isDirectory","FileListContainer","FileUtils","FileExistsError","FileNotFoundError","log","module","FileExplorer","props","storage","isMultiSelect","focusedPath","onDelete","undefined","onRename","onSelect","onSelectionChange","rowHeight","itemsToDelete","setItemsToDelete","table","setTable","initializeTable","tablePromise","initTable","debug","makeCancelable","getTable","t","close","e","isCanceled","error","cancel","handleError","handleDelete","files","handleDeleteConfirm","forEach","file","deleteFile","makePath","filename","handleDeleteCancel","handleMove","path","filesToMove","reducePaths","map","newFile","isPath","getBaseName","substring","length","moveFile","then","catch","handleRename","item","newName","name","isDir","endsWith","destination","getParent","debug2","handleValidateRename","renameItem","basename","validateName","newValue","getPath","fileInfo","info","isDeleteConfirmationShown","deleteConfirmationMessage","displayName"],"sources":["../src/FileExplorer.tsx"],"sourcesContent":["import { BasicModal } from '@deephaven/components';\nimport Log from '@deephaven/log';\nimport { CancelablePromise, PromiseUtils } from '@deephaven/utils';\nimport React, { useCallback, useEffect, useMemo, useState } from 'react';\nimport { DEFAULT_ROW_HEIGHT } from './FileList';\nimport FileStorage, {\n FileStorageItem,\n FileStorageTable,\n isDirectory,\n} from './FileStorage';\nimport './FileExplorer.scss';\nimport FileListContainer from './FileListContainer';\nimport FileUtils from './FileUtils';\nimport FileExistsError from './FileExistsError';\nimport FileNotFoundError from './FileNotFoundError';\n\nconst log = Log.module('FileExplorer');\n\nexport interface FileExplorerProps {\n storage: FileStorage;\n\n isMultiSelect?: boolean;\n focusedPath?: string;\n\n onDelete?: (files: FileStorageItem[]) => void;\n onRename?: (oldName: string, newName: string) => void;\n onSelect: (file: FileStorageItem, event: React.SyntheticEvent) => void;\n onSelectionChange?: (selectedItems: FileStorageItem[]) => void;\n\n /** Height of each item in the list */\n rowHeight?: number;\n}\n\n/**\n * Component that displays and allows interaction with the file system in the provided FileStorage.\n */\nexport const FileExplorer = (props: FileExplorerProps): JSX.Element => {\n const {\n storage,\n isMultiSelect = false,\n focusedPath,\n onDelete = () => undefined,\n onRename = () => undefined,\n onSelect,\n onSelectionChange,\n rowHeight = DEFAULT_ROW_HEIGHT,\n } = props;\n const [itemsToDelete, setItemsToDelete] = useState<FileStorageItem[]>([]);\n const [table, setTable] = useState<FileStorageTable>();\n\n useEffect(\n function initializeTable() {\n let tablePromise: CancelablePromise<FileStorageTable>;\n async function initTable() {\n log.debug('initTable');\n\n tablePromise = PromiseUtils.makeCancelable(storage.getTable(), t =>\n t.close()\n );\n\n try {\n setTable(await tablePromise);\n } catch (e) {\n if (!PromiseUtils.isCanceled(e)) {\n log.error('Unable to initialize table', e);\n }\n }\n }\n initTable();\n return () => {\n tablePromise.cancel();\n };\n },\n [storage]\n );\n\n const handleError = useCallback((e: Error) => {\n if (!PromiseUtils.isCanceled(e)) {\n log.error(e);\n }\n }, []);\n\n const handleDelete = useCallback((files: FileStorageItem[]) => {\n log.debug('handleDelete, pending confirmation', files);\n setItemsToDelete(files);\n }, []);\n\n const handleDeleteConfirm = useCallback(() => {\n log.debug('handleDeleteConfirm', itemsToDelete);\n itemsToDelete.forEach(file =>\n storage.deleteFile(\n isDirectory(file) ? FileUtils.makePath(file.filename) : file.filename\n )\n );\n onDelete(itemsToDelete);\n setItemsToDelete([]);\n }, [itemsToDelete, onDelete, storage]);\n\n const handleDeleteCancel = useCallback(() => {\n log.debug('handleDeleteCancel');\n setItemsToDelete([]);\n }, []);\n\n const handleMove = useCallback(\n (files: FileStorageItem[], path: string) => {\n const filesToMove = FileUtils.reducePaths(\n files.map(file =>\n isDirectory(file) ? FileUtils.makePath(file.filename) : file.filename\n )\n );\n\n filesToMove.forEach(file => {\n const newFile = FileUtils.isPath(file)\n ? `${path}${FileUtils.getBaseName(\n file.substring(0, file.length - 1)\n )}/`\n : `${path}${FileUtils.getBaseName(file)}`;\n storage\n .moveFile(file, newFile)\n .then(() => {\n // Each moved file triggers a rename so parent knows something has happened\n // We signal each individually if for some reason there's an error moving one of the files\n onRename(file, newFile);\n })\n .catch(handleError);\n });\n },\n [handleError, onRename, storage]\n );\n\n const handleRename = useCallback(\n (item: FileStorageItem, newName: string) => {\n let name = item.filename;\n const isDir = isDirectory(item);\n if (isDir && !name.endsWith('/')) {\n name = `${name}/`;\n }\n let destination = `${FileUtils.getParent(name)}${newName}`;\n if (isDir && !destination.endsWith('/')) {\n destination = `${destination}/`;\n }\n log.debug2('handleRename', name, destination);\n storage.moveFile(name, destination).catch(handleError);\n onRename(name, destination);\n },\n [handleError, onRename, storage]\n );\n\n const handleValidateRename = useCallback(\n async (renameItem: FileStorageItem, newName: string): Promise<void> => {\n if (newName === renameItem.basename) {\n // Same name is fine\n return undefined;\n }\n FileUtils.validateName(newName);\n\n const newValue = `${FileUtils.getPath(renameItem.filename)}${newName}`;\n try {\n const fileInfo = await storage.info(newValue);\n throw new FileExistsError(fileInfo);\n } catch (e) {\n if (!(e instanceof FileNotFoundError)) {\n throw e;\n }\n // The file does not exist, fine to save at that path\n }\n },\n [storage]\n );\n\n const isDeleteConfirmationShown = itemsToDelete.length > 0;\n const deleteConfirmationMessage = useMemo(() => {\n if (itemsToDelete.length === 1) {\n return `Are you sure you want to delete \"${itemsToDelete[0].filename}\"?`;\n }\n return `Are you sure you want to delete the selected files?`;\n }, [itemsToDelete]);\n\n return (\n <div className=\"file-explorer\">\n {table && (\n <FileListContainer\n isMultiSelect={isMultiSelect}\n focusedPath={focusedPath}\n showContextMenu\n onMove={handleMove}\n onDelete={handleDelete}\n onRename={handleRename}\n onSelect={onSelect}\n onSelectionChange={onSelectionChange}\n rowHeight={rowHeight}\n table={table}\n validateRename={handleValidateRename}\n />\n )}\n <BasicModal\n isOpen={isDeleteConfirmationShown}\n headerText={deleteConfirmationMessage}\n bodyText=\"You cannot undo this action.\"\n onCancel={handleDeleteCancel}\n onConfirm={handleDeleteConfirm}\n confirmButtonText=\"Delete\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AAgC;MAC9B,mDAA2CnC,aAAa,CAAC,CAAD,CAAb,CAAiBwB,QAA5D;IACD;;IACD;EACD,CALwC,EAKtC,CAACxB,aAAD,CALsC,CAAzC;EAOA,oBACE;IAAK,SAAS,EAAC;EAAf,GACGE,KAAK,iBACJ,oBAAC,iBAAD;IACE,aAAa,EAAEV,aADjB;IAEE,WAAW,EAAEC,WAFf;IAGE,eAAe,MAHjB;IAIE,MAAM,EAAEiC,UAJV;IAKE,QAAQ,EAAET,YALZ;IAME,QAAQ,EAAEsB,YANZ;IAOE,QAAQ,EAAE1C,QAPZ;IAQE,iBAAiB,EAAEC,iBARrB;IASE,SAAS,EAAEC,SATb;IAUE,KAAK,EAAEG,KAVT;IAWE,cAAc,EAAE8C;EAXlB,EAFJ,eAgBE,oBAAC,UAAD;IACE,MAAM,EAAEQ,yBADV;IAEE,UAAU,EAAEC,yBAFd;IAGE,QAAQ,EAAC,8BAHX;IAIE,QAAQ,EAAEhC,kBAJZ;IAKE,SAAS,EAAEN,mBALb;IAME,iBAAiB,EAAC;EANpB,EAhBF,CADF;AA2BD,CAzKM;AA2KP9B,YAAY,CAACqE,WAAb,GAA2B,cAA3B;AAEA,eAAerE,YAAf"}
|
|
1
|
+
{"version":3,"file":"FileExplorer.js","names":["BasicModal","Log","PromiseUtils","React","useCallback","useEffect","useMemo","useState","DEFAULT_ROW_HEIGHT","isDirectory","FileListContainer","FileUtils","FileExistsError","FileNotFoundError","log","module","FileExplorer","props","storage","isMultiSelect","focusedPath","onDelete","undefined","onRename","onSelect","onSelectionChange","rowHeight","itemsToDelete","setItemsToDelete","table","setTable","initializeTable","tablePromise","initTable","debug","makeCancelable","getTable","t","close","e","isCanceled","error","cancel","handleError","handleDelete","files","handleDeleteConfirm","forEach","file","deleteFile","makePath","filename","handleDeleteCancel","handleMove","path","filesToMove","reducePaths","map","newFile","isPath","getBaseName","substring","length","moveFile","then","catch","handleRename","item","newName","name","isDir","endsWith","destination","getParent","debug2","handleValidateRename","renameItem","basename","validateName","newValue","getPath","fileInfo","info","isDeleteConfirmationShown","deleteConfirmationMessage","displayName"],"sources":["../src/FileExplorer.tsx"],"sourcesContent":["import { BasicModal } from '@deephaven/components';\nimport Log from '@deephaven/log';\nimport { CancelablePromise, PromiseUtils } from '@deephaven/utils';\nimport React, { useCallback, useEffect, useMemo, useState } from 'react';\nimport { DEFAULT_ROW_HEIGHT } from './FileList';\nimport FileStorage, {\n FileStorageItem,\n FileStorageTable,\n isDirectory,\n} from './FileStorage';\nimport './FileExplorer.scss';\nimport FileListContainer from './FileListContainer';\nimport FileUtils from './FileUtils';\nimport FileExistsError from './FileExistsError';\nimport FileNotFoundError from './FileNotFoundError';\n\nconst log = Log.module('FileExplorer');\n\nexport interface FileExplorerProps {\n storage: FileStorage;\n\n isMultiSelect?: boolean;\n focusedPath?: string;\n\n onDelete?: (files: FileStorageItem[]) => void;\n onRename?: (oldName: string, newName: string) => void;\n onSelect: (file: FileStorageItem, event: React.SyntheticEvent) => void;\n onSelectionChange?: (selectedItems: FileStorageItem[]) => void;\n\n /** Height of each item in the list */\n rowHeight?: number;\n}\n\n/**\n * Component that displays and allows interaction with the file system in the provided FileStorage.\n */\nexport function FileExplorer(props: FileExplorerProps): JSX.Element {\n const {\n storage,\n isMultiSelect = false,\n focusedPath,\n onDelete = () => undefined,\n onRename = () => undefined,\n onSelect,\n onSelectionChange,\n rowHeight = DEFAULT_ROW_HEIGHT,\n } = props;\n const [itemsToDelete, setItemsToDelete] = useState<FileStorageItem[]>([]);\n const [table, setTable] = useState<FileStorageTable>();\n\n useEffect(\n function initializeTable() {\n let tablePromise: CancelablePromise<FileStorageTable>;\n async function initTable() {\n log.debug('initTable');\n\n tablePromise = PromiseUtils.makeCancelable(storage.getTable(), t =>\n t.close()\n );\n\n try {\n setTable(await tablePromise);\n } catch (e) {\n if (!PromiseUtils.isCanceled(e)) {\n log.error('Unable to initialize table', e);\n }\n }\n }\n initTable();\n return () => {\n tablePromise.cancel();\n };\n },\n [storage]\n );\n\n const handleError = useCallback((e: Error) => {\n if (!PromiseUtils.isCanceled(e)) {\n log.error(e);\n }\n }, []);\n\n const handleDelete = useCallback((files: FileStorageItem[]) => {\n log.debug('handleDelete, pending confirmation', files);\n setItemsToDelete(files);\n }, []);\n\n const handleDeleteConfirm = useCallback(() => {\n log.debug('handleDeleteConfirm', itemsToDelete);\n itemsToDelete.forEach(file =>\n storage.deleteFile(\n isDirectory(file) ? FileUtils.makePath(file.filename) : file.filename\n )\n );\n onDelete(itemsToDelete);\n setItemsToDelete([]);\n }, [itemsToDelete, onDelete, storage]);\n\n const handleDeleteCancel = useCallback(() => {\n log.debug('handleDeleteCancel');\n setItemsToDelete([]);\n }, []);\n\n const handleMove = useCallback(\n (files: FileStorageItem[], path: string) => {\n const filesToMove = FileUtils.reducePaths(\n files.map(file =>\n isDirectory(file) ? FileUtils.makePath(file.filename) : file.filename\n )\n );\n\n filesToMove.forEach(file => {\n const newFile = FileUtils.isPath(file)\n ? `${path}${FileUtils.getBaseName(\n file.substring(0, file.length - 1)\n )}/`\n : `${path}${FileUtils.getBaseName(file)}`;\n storage\n .moveFile(file, newFile)\n .then(() => {\n // Each moved file triggers a rename so parent knows something has happened\n // We signal each individually if for some reason there's an error moving one of the files\n onRename(file, newFile);\n })\n .catch(handleError);\n });\n },\n [handleError, onRename, storage]\n );\n\n const handleRename = useCallback(\n (item: FileStorageItem, newName: string) => {\n let name = item.filename;\n const isDir = isDirectory(item);\n if (isDir && !name.endsWith('/')) {\n name = `${name}/`;\n }\n let destination = `${FileUtils.getParent(name)}${newName}`;\n if (isDir && !destination.endsWith('/')) {\n destination = `${destination}/`;\n }\n log.debug2('handleRename', name, destination);\n storage.moveFile(name, destination).catch(handleError);\n onRename(name, destination);\n },\n [handleError, onRename, storage]\n );\n\n const handleValidateRename = useCallback(\n async (renameItem: FileStorageItem, newName: string): Promise<void> => {\n if (newName === renameItem.basename) {\n // Same name is fine\n return undefined;\n }\n FileUtils.validateName(newName);\n\n const newValue = `${FileUtils.getPath(renameItem.filename)}${newName}`;\n try {\n const fileInfo = await storage.info(newValue);\n throw new FileExistsError(fileInfo);\n } catch (e) {\n if (!(e instanceof FileNotFoundError)) {\n throw e;\n }\n // The file does not exist, fine to save at that path\n }\n },\n [storage]\n );\n\n const isDeleteConfirmationShown = itemsToDelete.length > 0;\n const deleteConfirmationMessage = useMemo(() => {\n if (itemsToDelete.length === 1) {\n return `Are you sure you want to delete \"${itemsToDelete[0].filename}\"?`;\n }\n return `Are you sure you want to delete the selected files?`;\n }, [itemsToDelete]);\n\n return (\n <div className=\"file-explorer\">\n {table && (\n <FileListContainer\n isMultiSelect={isMultiSelect}\n focusedPath={focusedPath}\n showContextMenu\n onMove={handleMove}\n onDelete={handleDelete}\n onRename={handleRename}\n onSelect={onSelect}\n onSelectionChange={onSelectionChange}\n rowHeight={rowHeight}\n table={table}\n validateRename={handleValidateRename}\n />\n )}\n <BasicModal\n isOpen={isDeleteConfirmationShown}\n headerText={deleteConfirmationMessage}\n bodyText=\"You cannot undo this action.\"\n onCancel={handleDeleteCancel}\n onConfirm={handleDeleteConfirm}\n confirmButtonText=\"Delete\"\n />\n </div>\n );\n}\n\nFileExplorer.displayName = 'FileExplorer';\n\nexport default FileExplorer;\n"],"mappings":";;AAAA,SAASA,UAAU,QAAQ,uBAAuB;AAClD,OAAOC,GAAG,MAAM,gBAAgB;AAChC,SAA4BC,YAAY,QAAQ,kBAAkB;AAClE,OAAOC,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAAC,SAChEC,kBAAkB;AAAA,SAIzBC,WAAW;AAAA;AAAA,OAGNC,iBAAiB;AAAA,OACjBC,SAAS;AAAA,OACTC,eAAe;AAAA,OACfC,iBAAiB;AAExB,IAAMC,GAAG,GAAGb,GAAG,CAACc,MAAM,CAAC,cAAc,CAAC;AAiBtC;AACA;AACA;AACA,OAAO,SAASC,YAAY,CAACC,KAAwB,EAAe;EAClE,IAAM;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,MAAM,EAAEQ,yBAA0B;IAClC,UAAU,EAAEC,yBAA0B;IACtC,QAAQ,EAAC,8BAA8B;IACvC,QAAQ,EAAEhC,kBAAmB;IAC7B,SAAS,EAAEN,mBAAoB;IAC/B,iBAAiB,EAAC;EAAQ,EAC1B,CACE;AAEV;AAEA9B,YAAY,CAACqE,WAAW,GAAG,cAAc;AAEzC,eAAerE,YAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileExplorerShortcuts.js","names":["ShortcutRegistry","KEY","MODIFIER","FILE_EXPLORER","name","DELETE","createAndAdd","id","shortcut","macShortcut","CMD","BACKSPACE","RENAME","ENTER"],"sources":["../src/FileExplorerShortcuts.ts"],"sourcesContent":["import { ShortcutRegistry, KEY, MODIFIER } from '@deephaven/components';\n\nconst FILE_EXPLORER = {\n name: 'File Explorer',\n DELETE: ShortcutRegistry.createAndAdd({\n id: 'FILE_EXPLORER.DELETE',\n name: 'Delete',\n shortcut: [KEY.DELETE],\n macShortcut: [MODIFIER.CMD, KEY.BACKSPACE],\n }),\n RENAME: ShortcutRegistry.createAndAdd({\n id: 'FILE_EXPLORER.RENAME',\n name: 'Rename',\n shortcut: [KEY.ENTER],\n macShortcut: [KEY.ENTER],\n }),\n};\n\nexport default {\n FILE_EXPLORER,\n};\n"],"mappings":"AAAA,SAASA,
|
|
1
|
+
{"version":3,"file":"FileExplorerShortcuts.js","names":["ShortcutRegistry","KEY","MODIFIER","FILE_EXPLORER","name","DELETE","createAndAdd","id","shortcut","macShortcut","CMD","BACKSPACE","RENAME","ENTER"],"sources":["../src/FileExplorerShortcuts.ts"],"sourcesContent":["import { ShortcutRegistry, KEY, MODIFIER } from '@deephaven/components';\n\nconst FILE_EXPLORER = {\n name: 'File Explorer',\n DELETE: ShortcutRegistry.createAndAdd({\n id: 'FILE_EXPLORER.DELETE',\n name: 'Delete',\n shortcut: [KEY.DELETE],\n macShortcut: [MODIFIER.CMD, KEY.BACKSPACE],\n }),\n RENAME: ShortcutRegistry.createAndAdd({\n id: 'FILE_EXPLORER.RENAME',\n name: 'Rename',\n shortcut: [KEY.ENTER],\n macShortcut: [KEY.ENTER],\n }),\n};\n\nexport default {\n FILE_EXPLORER,\n};\n"],"mappings":"AAAA,SAASA,gBAAgB,EAAEC,GAAG,EAAEC,QAAQ,QAAQ,uBAAuB;AAEvE,IAAMC,aAAa,GAAG;EACpBC,IAAI,EAAE,eAAe;EACrBC,MAAM,EAAEL,gBAAgB,CAACM,YAAY,CAAC;IACpCC,EAAE,EAAE,sBAAsB;IAC1BH,IAAI,EAAE,QAAQ;IACdI,QAAQ,EAAE,CAACP,GAAG,CAACI,MAAM,CAAC;IACtBI,WAAW,EAAE,CAACP,QAAQ,CAACQ,GAAG,EAAET,GAAG,CAACU,SAAS;EAC3C,CAAC,CAAC;EACFC,MAAM,EAAEZ,gBAAgB,CAACM,YAAY,CAAC;IACpCC,EAAE,EAAE,sBAAsB;IAC1BH,IAAI,EAAE,QAAQ;IACdI,QAAQ,EAAE,CAACP,GAAG,CAACY,KAAK,CAAC;IACrBJ,WAAW,EAAE,CAACR,GAAG,CAACY,KAAK;EACzB,CAAC;AACH,CAAC;AAED,eAAe;EACbV;AACF,CAAC"}
|
|
@@ -6,6 +6,6 @@ declare type FileExplorerToolbarProps = {
|
|
|
6
6
|
onSearchChange?(text: string): void;
|
|
7
7
|
defaultSearchText?: string;
|
|
8
8
|
};
|
|
9
|
-
export declare
|
|
9
|
+
export declare function FileExplorerToolbar({ createFile, createFolder, onSearchChange, defaultSearchText, }: FileExplorerToolbarProps): JSX.Element;
|
|
10
10
|
export default FileExplorerToolbar;
|
|
11
11
|
//# sourceMappingURL=FileExplorerToolbar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileExplorerToolbar.d.ts","sourceRoot":"","sources":["../src/FileExplorerToolbar.tsx"],"names":[],"mappings":";AAGA,OAAO,4BAA4B,CAAC;AAEpC,aAAK,wBAAwB,GAAG;IAC9B,UAAU,IAAI,IAAI,CAAC;IACnB,YAAY,IAAI,IAAI,CAAC;IACrB,cAAc,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,
|
|
1
|
+
{"version":3,"file":"FileExplorerToolbar.d.ts","sourceRoot":"","sources":["../src/FileExplorerToolbar.tsx"],"names":[],"mappings":";AAGA,OAAO,4BAA4B,CAAC;AAEpC,aAAK,wBAAwB,GAAG;IAC9B,UAAU,IAAI,IAAI,CAAC;IACnB,YAAY,IAAI,IAAI,CAAC;IACrB,cAAc,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,EAClC,UAAU,EACV,YAAY,EACZ,cAAc,EACd,iBAAsB,GACvB,EAAE,wBAAwB,GAAG,GAAG,CAAC,OAAO,CA8BxC;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { Button, DebouncedSearchInput } from '@deephaven/components';
|
|
3
3
|
import { vsNewFile, vsNewFolder } from '@deephaven/icons';
|
|
4
4
|
import "./FileExplorerToolbar.css";
|
|
5
|
-
export
|
|
5
|
+
export function FileExplorerToolbar(_ref) {
|
|
6
6
|
var {
|
|
7
7
|
createFile,
|
|
8
8
|
createFolder,
|
|
@@ -32,6 +32,6 @@ export var FileExplorerToolbar = _ref => {
|
|
|
32
32
|
onChange: onSearchChange,
|
|
33
33
|
placeholder: "Search by name"
|
|
34
34
|
})));
|
|
35
|
-
}
|
|
35
|
+
}
|
|
36
36
|
export default FileExplorerToolbar;
|
|
37
37
|
//# sourceMappingURL=FileExplorerToolbar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileExplorerToolbar.js","names":["React","Button","DebouncedSearchInput","vsNewFile","vsNewFolder","FileExplorerToolbar","createFile","createFolder","onSearchChange","defaultSearchText"],"sources":["../src/FileExplorerToolbar.tsx"],"sourcesContent":["import React from 'react';\nimport { Button, DebouncedSearchInput } from '@deephaven/components';\nimport { vsNewFile, vsNewFolder } from '@deephaven/icons';\nimport './FileExplorerToolbar.scss';\n\ntype FileExplorerToolbarProps = {\n createFile(): void;\n createFolder(): void;\n onSearchChange?(text: string): void;\n defaultSearchText?: string;\n};\n\nexport
|
|
1
|
+
{"version":3,"file":"FileExplorerToolbar.js","names":["React","Button","DebouncedSearchInput","vsNewFile","vsNewFolder","FileExplorerToolbar","createFile","createFolder","onSearchChange","defaultSearchText"],"sources":["../src/FileExplorerToolbar.tsx"],"sourcesContent":["import React from 'react';\nimport { Button, DebouncedSearchInput } from '@deephaven/components';\nimport { vsNewFile, vsNewFolder } from '@deephaven/icons';\nimport './FileExplorerToolbar.scss';\n\ntype FileExplorerToolbarProps = {\n createFile(): void;\n createFolder(): void;\n onSearchChange?(text: string): void;\n defaultSearchText?: string;\n};\n\nexport function FileExplorerToolbar({\n createFile,\n createFolder,\n onSearchChange,\n defaultSearchText = '',\n}: FileExplorerToolbarProps): JSX.Element {\n return (\n <div className=\"file-explorer-toolbar\">\n <div className=\"file-explorer-toolbar-buttons\">\n <Button\n kind=\"ghost\"\n icon={vsNewFile}\n tooltip=\"New notebook\"\n onClick={createFile}\n aria-label=\"New notebook\"\n />\n <Button\n kind=\"ghost\"\n icon={vsNewFolder}\n tooltip=\"New folder\"\n onClick={createFolder}\n aria-label=\"New folder\"\n />\n </div>\n {onSearchChange && (\n <div className=\"file-explorer-toolbar-search\">\n <DebouncedSearchInput\n value={defaultSearchText}\n onChange={onSearchChange}\n placeholder=\"Search by name\"\n />\n </div>\n )}\n </div>\n );\n}\n\nexport default FileExplorerToolbar;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,MAAM,EAAEC,oBAAoB,QAAQ,uBAAuB;AACpE,SAASC,SAAS,EAAEC,WAAW,QAAQ,kBAAkB;AAAC;AAU1D,OAAO,SAASC,mBAAmB,OAKO;EAAA,IALN;IAClCC,UAAU;IACVC,YAAY;IACZC,cAAc;IACdC,iBAAiB,GAAG;EACI,CAAC;EACzB,oBACE;IAAK,SAAS,EAAC;EAAuB,gBACpC;IAAK,SAAS,EAAC;EAA+B,gBAC5C,oBAAC,MAAM;IACL,IAAI,EAAC,OAAO;IACZ,IAAI,EAAEN,SAAU;IAChB,OAAO,EAAC,cAAc;IACtB,OAAO,EAAEG,UAAW;IACpB,cAAW;EAAc,EACzB,eACF,oBAAC,MAAM;IACL,IAAI,EAAC,OAAO;IACZ,IAAI,EAAEF,WAAY;IAClB,OAAO,EAAC,YAAY;IACpB,OAAO,EAAEG,YAAa;IACtB,cAAW;EAAY,EACvB,CACE,EACLC,cAAc,iBACb;IAAK,SAAS,EAAC;EAA8B,gBAC3C,oBAAC,oBAAoB;IACnB,KAAK,EAAEC,iBAAkB;IACzB,QAAQ,EAAED,cAAe;IACzB,WAAW,EAAC;EAAgB,EAC5B,CAEL,CACG;AAEV;AAEA,eAAeH,mBAAmB"}
|
package/dist/FileList.d.ts
CHANGED
|
@@ -56,6 +56,6 @@ export declare function getMoveOperation(draggedItems: FileStorageItem[], target
|
|
|
56
56
|
/**
|
|
57
57
|
* Component that displays and allows interaction with the file system in the provided FileStorageTable.
|
|
58
58
|
*/
|
|
59
|
-
export declare
|
|
59
|
+
export declare function FileList(props: FileListProps): JSX.Element;
|
|
60
60
|
export default FileList;
|
|
61
61
|
//# sourceMappingURL=FileList.d.ts.map
|
package/dist/FileList.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileList.d.ts","sourceRoot":"","sources":["../src/FileList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,eAAe,EAEhB,MAAM,uBAAuB,CAAC;AAK/B,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAEnE,OAAO,KAMN,MAAM,O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IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,CAAC,cAAc,KAAK,IAAI,CAAC;IACvE,iBAAiB,CAAC,EAAE,CAAC,aAAa,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;IAE/D,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,GAAG,CAAC,OAAO,CAAC;IAE7D,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,eAAe,SAAU,eAAe,KAAG,MAGlB,CAAC;AAEvC,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAGrC,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAItC,eAAO,MAAM,kBAAkB,UACtB,uBAAuB,KAC7B,WA6EF,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,cAAc,CAWjE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,eAAe,EAAE,EAC/B,UAAU,EAAE,eAAe,GAC1B;IAAE,KAAK,EAAE,eAAe,EAAE,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAyBlD;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,GAAG,CAAC,OAAO,CAsY1D;AAED,eAAe,QAAQ,CAAC"}
|
package/dist/FileList.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
2
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
|
|
5
3
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
|
|
7
4
|
import { ItemList, Tooltip } from '@deephaven/components';
|
|
8
5
|
import { dhPython, vsCode, vsFolder, vsFolderOpened } from '@deephaven/icons';
|
|
9
6
|
import Log from '@deephaven/log';
|
|
@@ -16,13 +13,13 @@ import "./FileList.css";
|
|
|
16
13
|
import FileUtils, { MIME_TYPE } from "./FileUtils.js";
|
|
17
14
|
var log = Log.module('FileList');
|
|
18
15
|
export var getPathFromItem = file => isDirectory(file) ? FileUtils.makePath(file.filename) : FileUtils.getPath(file.filename);
|
|
19
|
-
export var DEFAULT_ROW_HEIGHT = 26;
|
|
16
|
+
export var DEFAULT_ROW_HEIGHT = 26;
|
|
20
17
|
|
|
18
|
+
// How long you need to hover over a directory before it expands
|
|
21
19
|
export var DRAG_HOVER_TIMEOUT = 500;
|
|
22
20
|
var ITEM_LIST_CLASS_NAME = 'item-list-scroll-pane';
|
|
23
21
|
export var renderFileListItem = props => {
|
|
24
22
|
var _draggedItems$some;
|
|
25
|
-
|
|
26
23
|
var {
|
|
27
24
|
children,
|
|
28
25
|
draggedItems,
|
|
@@ -64,44 +61,36 @@ export var renderFileListItem = props => {
|
|
|
64
61
|
function onDragStart(_x) {
|
|
65
62
|
return _onDragStart.apply(this, arguments);
|
|
66
63
|
}
|
|
67
|
-
|
|
68
64
|
onDragStart.toString = function () {
|
|
69
65
|
return _onDragStart.toString();
|
|
70
66
|
};
|
|
71
|
-
|
|
72
67
|
return onDragStart;
|
|
73
68
|
}(e => onDragStart(itemIndex, e)),
|
|
74
69
|
onDragOver: function (_onDragOver) {
|
|
75
70
|
function onDragOver(_x2) {
|
|
76
71
|
return _onDragOver.apply(this, arguments);
|
|
77
72
|
}
|
|
78
|
-
|
|
79
73
|
onDragOver.toString = function () {
|
|
80
74
|
return _onDragOver.toString();
|
|
81
75
|
};
|
|
82
|
-
|
|
83
76
|
return onDragOver;
|
|
84
77
|
}(e => onDragOver(itemIndex, e)),
|
|
85
78
|
onDragEnd: function (_onDragEnd) {
|
|
86
79
|
function onDragEnd(_x3) {
|
|
87
80
|
return _onDragEnd.apply(this, arguments);
|
|
88
81
|
}
|
|
89
|
-
|
|
90
82
|
onDragEnd.toString = function () {
|
|
91
83
|
return _onDragEnd.toString();
|
|
92
84
|
};
|
|
93
|
-
|
|
94
85
|
return onDragEnd;
|
|
95
86
|
}(e => onDragEnd(itemIndex, e)),
|
|
96
87
|
onDrop: function (_onDrop) {
|
|
97
88
|
function onDrop(_x4) {
|
|
98
89
|
return _onDrop.apply(this, arguments);
|
|
99
90
|
}
|
|
100
|
-
|
|
101
91
|
onDrop.toString = function () {
|
|
102
92
|
return _onDrop.toString();
|
|
103
93
|
};
|
|
104
|
-
|
|
105
94
|
return onDrop;
|
|
106
95
|
}(e => onDrop(itemIndex, e)),
|
|
107
96
|
draggable: true,
|
|
@@ -124,38 +113,33 @@ export var renderFileListItem = props => {
|
|
|
124
113
|
}
|
|
125
114
|
}, children !== null && children !== void 0 ? children : item.basename)));
|
|
126
115
|
};
|
|
116
|
+
|
|
127
117
|
/**
|
|
128
118
|
* Get the icon definition for a file or folder item
|
|
129
119
|
* @param item Item to get the icon for
|
|
130
120
|
* @returns Icon definition to pass in the FontAwesomeIcon icon prop
|
|
131
121
|
*/
|
|
132
|
-
|
|
133
122
|
export function getItemIcon(item) {
|
|
134
123
|
if (isDirectory(item)) {
|
|
135
124
|
return item.isExpanded ? vsFolderOpened : vsFolder;
|
|
136
125
|
}
|
|
137
|
-
|
|
138
126
|
var mimeType = FileUtils.getMimeType(item.basename);
|
|
139
|
-
|
|
140
127
|
switch (mimeType) {
|
|
141
128
|
case MIME_TYPE.PYTHON:
|
|
142
129
|
return dhPython;
|
|
143
|
-
|
|
144
130
|
default:
|
|
145
131
|
return vsCode;
|
|
146
132
|
}
|
|
147
133
|
}
|
|
134
|
+
|
|
148
135
|
/**
|
|
149
136
|
* Get the move operation for the current selection and the given target. Throws if the operation is invalid.
|
|
150
137
|
*/
|
|
151
|
-
|
|
152
138
|
export function getMoveOperation(draggedItems, targetItem) {
|
|
153
139
|
if (draggedItems.length === 0 || targetItem == null) {
|
|
154
140
|
throw new Error('No items to move');
|
|
155
141
|
}
|
|
156
|
-
|
|
157
142
|
var targetPath = getPathFromItem(targetItem);
|
|
158
|
-
|
|
159
143
|
if (draggedItems.some(_ref => {
|
|
160
144
|
var {
|
|
161
145
|
filename
|
|
@@ -165,22 +149,20 @@ export function getMoveOperation(draggedItems, targetItem) {
|
|
|
165
149
|
// Cannot drop if target is one of the dragged items is already in the target folder
|
|
166
150
|
throw new Error('File already in the destination folder');
|
|
167
151
|
}
|
|
168
|
-
|
|
169
152
|
if (draggedItems.some(item => isDirectory(item) && targetPath.startsWith(FileUtils.makePath(item.filename)))) {
|
|
170
153
|
// Cannot drop if target is a child of one of the directories being moved
|
|
171
154
|
throw new Error('Destination folder cannot be a child of a dragged folder');
|
|
172
155
|
}
|
|
173
|
-
|
|
174
156
|
return {
|
|
175
157
|
files: draggedItems,
|
|
176
158
|
targetPath
|
|
177
159
|
};
|
|
178
160
|
}
|
|
161
|
+
|
|
179
162
|
/**
|
|
180
163
|
* Component that displays and allows interaction with the file system in the provided FileStorageTable.
|
|
181
164
|
*/
|
|
182
|
-
|
|
183
|
-
export var FileList = props => {
|
|
165
|
+
export function FileList(props) {
|
|
184
166
|
var {
|
|
185
167
|
isMultiSelect = false,
|
|
186
168
|
table,
|
|
@@ -211,72 +193,59 @@ export var FileList = props => {
|
|
|
211
193
|
if (ranges.length === 0 || loadedViewport == null) {
|
|
212
194
|
return [];
|
|
213
195
|
}
|
|
214
|
-
|
|
215
196
|
var items = [];
|
|
216
|
-
|
|
217
197
|
for (var i = 0; i < ranges.length; i += 1) {
|
|
218
198
|
var range = ranges[i];
|
|
219
|
-
|
|
220
199
|
for (var j = range[0]; j <= range[1]; j += 1) {
|
|
221
200
|
if (j >= loadedViewport.offset && j < loadedViewport.offset + loadedViewport.items.length) {
|
|
222
201
|
items.push(loadedViewport.items[j - loadedViewport.offset]);
|
|
223
202
|
}
|
|
224
203
|
}
|
|
225
204
|
}
|
|
226
|
-
|
|
227
205
|
return items;
|
|
228
206
|
}, [loadedViewport]);
|
|
229
207
|
var getItem = useCallback(itemIndex => {
|
|
230
208
|
var items = getItems([[itemIndex, itemIndex]]);
|
|
231
|
-
|
|
232
209
|
if (items.length > 0) {
|
|
233
210
|
return items[0];
|
|
234
211
|
}
|
|
235
212
|
}, [getItems]);
|
|
213
|
+
|
|
236
214
|
/**
|
|
237
215
|
* Get the placeholder text to show when a drag operation is in progress
|
|
238
216
|
*/
|
|
239
|
-
|
|
240
217
|
var getDragPlaceholderText = useCallback(() => {
|
|
241
218
|
var count = RangeUtils.count(selectedRanges);
|
|
242
|
-
|
|
243
219
|
if (count === 0) {
|
|
244
220
|
return null;
|
|
245
221
|
}
|
|
246
|
-
|
|
247
222
|
if (count === 1) {
|
|
248
223
|
var _index = selectedRanges[0][0];
|
|
249
224
|
var item = getItem(_index);
|
|
250
|
-
|
|
251
225
|
if (item != null) {
|
|
252
226
|
return item.filename;
|
|
253
227
|
}
|
|
254
228
|
}
|
|
255
|
-
|
|
256
229
|
return "".concat(count, " items");
|
|
257
230
|
}, [getItem, selectedRanges]);
|
|
231
|
+
|
|
258
232
|
/**
|
|
259
233
|
* Drop the currently dragged items at the currently set drop target.
|
|
260
234
|
* If an itemIndex is provided, focus that index after the drop.
|
|
261
235
|
*/
|
|
262
|
-
|
|
263
236
|
var dropItems = useCallback(itemIndex => {
|
|
264
237
|
if (!draggedItems || !dropTargetItem) {
|
|
265
238
|
return;
|
|
266
239
|
}
|
|
267
|
-
|
|
268
240
|
log.debug('dropItems', draggedItems, 'to', itemIndex);
|
|
269
|
-
|
|
270
241
|
try {
|
|
271
242
|
var {
|
|
272
243
|
files: _files,
|
|
273
244
|
targetPath
|
|
274
245
|
} = getMoveOperation(draggedItems, dropTargetItem);
|
|
275
246
|
onMove(_files, targetPath);
|
|
276
|
-
|
|
277
247
|
if (itemIndex != null) {
|
|
278
248
|
var _itemList$current;
|
|
279
|
-
|
|
280
249
|
setSelectedRanges([[itemIndex, itemIndex]]);
|
|
281
250
|
(_itemList$current = itemList.current) === null || _itemList$current === void 0 ? void 0 : _itemList$current.focusItem(itemIndex);
|
|
282
251
|
}
|
|
@@ -286,11 +255,9 @@ export var FileList = props => {
|
|
|
286
255
|
}, [draggedItems, dropTargetItem, onMove]);
|
|
287
256
|
var handleSelect = useCallback((itemIndex, event) => {
|
|
288
257
|
var item = loadedViewport.items[itemIndex - loadedViewport.offset];
|
|
289
|
-
|
|
290
258
|
if (item !== undefined) {
|
|
291
259
|
log.debug('handleItemClick', item);
|
|
292
260
|
onSelect(item, event);
|
|
293
|
-
|
|
294
261
|
if (isDirectory(item)) {
|
|
295
262
|
table === null || table === void 0 ? void 0 : table.setExpanded(item.filename, !item.isExpanded);
|
|
296
263
|
}
|
|
@@ -298,17 +265,15 @@ export var FileList = props => {
|
|
|
298
265
|
}, [loadedViewport, onSelect, table]);
|
|
299
266
|
var handleItemDragStart = useCallback((itemIndex, e) => {
|
|
300
267
|
var _itemList$current2;
|
|
301
|
-
|
|
302
268
|
log.debug2('handleItemDragStart', itemIndex, selectedRanges);
|
|
303
269
|
var draggedRanges = selectedRanges;
|
|
304
|
-
|
|
305
270
|
if (!RangeUtils.isSelected(selectedRanges, itemIndex)) {
|
|
306
271
|
draggedRanges = [[itemIndex, itemIndex]];
|
|
307
272
|
setSelectedRanges(draggedRanges);
|
|
308
273
|
}
|
|
274
|
+
setDraggedItems(getItems(draggedRanges));
|
|
309
275
|
|
|
310
|
-
|
|
311
|
-
|
|
276
|
+
// We need to reset reset the mouse state since we steal the drag
|
|
312
277
|
(_itemList$current2 = itemList.current) === null || _itemList$current2 === void 0 ? void 0 : _itemList$current2.resetMouseState();
|
|
313
278
|
var newDragPlaceholder = document.createElement('div');
|
|
314
279
|
newDragPlaceholder.innerHTML = "<div class=\"dnd-placeholder-content\">".concat(getDragPlaceholderText(), "</div>");
|
|
@@ -325,9 +290,10 @@ export var FileList = props => {
|
|
|
325
290
|
}, [getItem]);
|
|
326
291
|
var handleItemDragEnd = useCallback((itemIndex, e) => {
|
|
327
292
|
log.debug('handleItemDragEnd', itemIndex);
|
|
328
|
-
dragPlaceholder === null || dragPlaceholder === void 0 ? void 0 : dragPlaceholder.remove();
|
|
329
|
-
// Also drop isn't triggered if drag end is outside of the list
|
|
293
|
+
dragPlaceholder === null || dragPlaceholder === void 0 ? void 0 : dragPlaceholder.remove();
|
|
330
294
|
|
|
295
|
+
// Drag end is triggered after drop
|
|
296
|
+
// Also drop isn't triggered if drag end is outside of the list
|
|
331
297
|
setDraggedItems(undefined);
|
|
332
298
|
setDropTargetItem(undefined);
|
|
333
299
|
setDragPlaceholder(undefined);
|
|
@@ -361,18 +327,14 @@ export var FileList = props => {
|
|
|
361
327
|
}, [dropItems]);
|
|
362
328
|
var handleSelectionChange = useCallback(newSelectedRanges => {
|
|
363
329
|
log.debug2('handleSelectionChange', newSelectedRanges);
|
|
364
|
-
|
|
365
330
|
if (newSelectedRanges !== selectedRanges) {
|
|
366
331
|
setSelectedRanges(newSelectedRanges);
|
|
367
|
-
|
|
368
332
|
var _selectedItems = getItems(newSelectedRanges);
|
|
369
|
-
|
|
370
333
|
onSelectionChange(_selectedItems);
|
|
371
334
|
}
|
|
372
335
|
}, [getItems, onSelectionChange, selectedRanges]);
|
|
373
336
|
var handleFocusChange = useCallback(focusIndex => {
|
|
374
337
|
log.debug2('handleFocusChange', focusIndex);
|
|
375
|
-
|
|
376
338
|
if (focusIndex != null) {
|
|
377
339
|
var [_focusedItem] = getItems([[focusIndex, focusIndex]]);
|
|
378
340
|
onFocusChange(_focusedItem);
|
|
@@ -382,7 +344,6 @@ export var FileList = props => {
|
|
|
382
344
|
}, [getItems, onFocusChange]);
|
|
383
345
|
var handleViewportChange = useCallback((top, bottom) => {
|
|
384
346
|
log.debug('handleViewportChange', top, bottom);
|
|
385
|
-
|
|
386
347
|
if (top !== viewport.top || bottom !== viewport.bottom) {
|
|
387
348
|
setViewport({
|
|
388
349
|
top,
|
|
@@ -394,7 +355,6 @@ export var FileList = props => {
|
|
|
394
355
|
if (!draggedItems || !dropTargetItem) {
|
|
395
356
|
return false;
|
|
396
357
|
}
|
|
397
|
-
|
|
398
358
|
try {
|
|
399
359
|
getMoveOperation(draggedItems, dropTargetItem);
|
|
400
360
|
log.debug('handleValidateDropTarget true');
|
|
@@ -423,8 +383,9 @@ export var FileList = props => {
|
|
|
423
383
|
top: Math.max(0, viewport.top - overscanCount),
|
|
424
384
|
bottom: viewport.bottom + overscanCount
|
|
425
385
|
});
|
|
426
|
-
}, [overscanCount, table, viewport]);
|
|
386
|
+
}, [overscanCount, table, viewport]);
|
|
427
387
|
|
|
388
|
+
// Listen for table updates
|
|
428
389
|
useEffect(function setLoadedViewportAndReturnCleanup() {
|
|
429
390
|
var listenerRemover = table.onUpdate(newViewport => {
|
|
430
391
|
setLoadedViewport({
|
|
@@ -438,8 +399,9 @@ export var FileList = props => {
|
|
|
438
399
|
return () => {
|
|
439
400
|
listenerRemover();
|
|
440
401
|
};
|
|
441
|
-
}, [table]);
|
|
402
|
+
}, [table]);
|
|
442
403
|
|
|
404
|
+
// Expand a folder if hovering over it
|
|
443
405
|
useEffect(function expandFolderOnHover() {
|
|
444
406
|
if (dropTargetItem != null && isDirectory(dropTargetItem) && dropTargetItem.filename !== '/') {
|
|
445
407
|
var timeout = setTimeout(() => {
|
|
@@ -484,6 +446,6 @@ export var FileList = props => {
|
|
|
484
446
|
isDragSelect: false,
|
|
485
447
|
isDeselectOnClick: false
|
|
486
448
|
}));
|
|
487
|
-
}
|
|
449
|
+
}
|
|
488
450
|
export default FileList;
|
|
489
451
|
//# sourceMappingURL=FileList.js.map
|