@lvce-editor/explorer-view 7.9.0 → 7.9.2
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/explorerViewWorkerMain.js +157 -71
- package/package.json +1 -1
|
@@ -856,7 +856,10 @@ const constructError = (message, type, name) => {
|
|
|
856
856
|
if (ErrorConstructor === Error) {
|
|
857
857
|
const error = new Error(message);
|
|
858
858
|
if (name && name !== 'VError') {
|
|
859
|
-
error
|
|
859
|
+
Object.defineProperty(error, 'name', {
|
|
860
|
+
configurable: true,
|
|
861
|
+
value: name
|
|
862
|
+
});
|
|
860
863
|
}
|
|
861
864
|
return error;
|
|
862
865
|
}
|
|
@@ -887,31 +890,45 @@ const getParentStack = error => {
|
|
|
887
890
|
};
|
|
888
891
|
const MethodNotFound = -32601;
|
|
889
892
|
const Custom = -32001;
|
|
893
|
+
const setStack = (error, stack) => {
|
|
894
|
+
const descriptor = Object.getOwnPropertyDescriptor(error, 'stack');
|
|
895
|
+
if (descriptor) {
|
|
896
|
+
if (!descriptor.configurable && !descriptor.writable) {
|
|
897
|
+
return;
|
|
898
|
+
}
|
|
899
|
+
if (!descriptor.configurable && descriptor.writable) {
|
|
900
|
+
error.stack = stack;
|
|
901
|
+
return;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
Object.defineProperty(error, 'stack', {
|
|
905
|
+
configurable: true,
|
|
906
|
+
value: stack,
|
|
907
|
+
writable: true
|
|
908
|
+
});
|
|
909
|
+
};
|
|
890
910
|
const restoreExistingError = (error, currentStack) => {
|
|
891
911
|
if (typeof error.stack === 'string') {
|
|
892
|
-
error
|
|
912
|
+
setStack(error, `${error.stack}${NewLine}${currentStack}`);
|
|
893
913
|
}
|
|
894
914
|
return error;
|
|
895
915
|
};
|
|
896
916
|
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
897
917
|
const restoredError = new JsonRpcError(error.message);
|
|
898
918
|
const parentStack = getParentStack(error);
|
|
899
|
-
restoredError
|
|
919
|
+
setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
|
|
900
920
|
return restoredError;
|
|
901
921
|
};
|
|
902
922
|
const restoreStackFromData = (restoredError, error, currentStack) => {
|
|
903
923
|
if (error.data.stack && error.data.type && error.message) {
|
|
904
|
-
restoredError
|
|
924
|
+
setStack(restoredError, `${error.data.type}: ${error.message}${NewLine}${error.data.stack}${NewLine}${currentStack}`);
|
|
905
925
|
return;
|
|
906
926
|
}
|
|
907
927
|
if (error.data.stack) {
|
|
908
|
-
restoredError
|
|
928
|
+
setStack(restoredError, error.data.stack);
|
|
909
929
|
}
|
|
910
930
|
};
|
|
911
931
|
const applyDataProperties = (restoredError, error) => {
|
|
912
|
-
if (!error.data) {
|
|
913
|
-
return;
|
|
914
|
-
}
|
|
915
932
|
restoreStackFromData(restoredError, error, getCurrentStack());
|
|
916
933
|
if (error.data.codeFrame) {
|
|
917
934
|
// @ts-ignore
|
|
@@ -932,7 +949,7 @@ const applyDirectProperties = (restoredError, error) => {
|
|
|
932
949
|
const indexNewLine = getNewLineIndex(lowerStack);
|
|
933
950
|
const parentStack = getParentStack(error);
|
|
934
951
|
// @ts-ignore
|
|
935
|
-
restoredError
|
|
952
|
+
setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
|
|
936
953
|
}
|
|
937
954
|
if (error.codeFrame) {
|
|
938
955
|
// @ts-ignore
|
|
@@ -2227,7 +2244,18 @@ const mergeTrees = (a, b) => {
|
|
|
2227
2244
|
};
|
|
2228
2245
|
};
|
|
2229
2246
|
|
|
2230
|
-
const openUri = async (uri, focus) => {
|
|
2247
|
+
const openUri = async (uri, focus, options) => {
|
|
2248
|
+
if (options) {
|
|
2249
|
+
await invoke$2('Main.openInput', {
|
|
2250
|
+
editorInput: {
|
|
2251
|
+
type: 'editor',
|
|
2252
|
+
uri
|
|
2253
|
+
},
|
|
2254
|
+
focu: focus,
|
|
2255
|
+
preview: options.preview ?? false
|
|
2256
|
+
});
|
|
2257
|
+
return;
|
|
2258
|
+
}
|
|
2231
2259
|
await openUri$1(uri, /* focus */focus);
|
|
2232
2260
|
};
|
|
2233
2261
|
|
|
@@ -2530,6 +2558,15 @@ const getFileOperationsRename = (oldAbsolutePath, newFileName) => {
|
|
|
2530
2558
|
return operations;
|
|
2531
2559
|
};
|
|
2532
2560
|
|
|
2561
|
+
const getRenameSiblingFileNames = (items, editingIndex, pathSeparator) => {
|
|
2562
|
+
const editingItem = items[editingIndex];
|
|
2563
|
+
if (!editingItem) {
|
|
2564
|
+
return [];
|
|
2565
|
+
}
|
|
2566
|
+
const parentPath = dirname(pathSeparator, editingItem.path);
|
|
2567
|
+
return items.filter((item, index) => index !== editingIndex && dirname(pathSeparator, item.path) === parentPath).map(item => item.name);
|
|
2568
|
+
};
|
|
2569
|
+
|
|
2533
2570
|
const updateTree2 = (tree, update) => {
|
|
2534
2571
|
const updatedTree = {
|
|
2535
2572
|
...tree,
|
|
@@ -2547,7 +2584,8 @@ const acceptRename = async state => {
|
|
|
2547
2584
|
pathSeparator,
|
|
2548
2585
|
root
|
|
2549
2586
|
} = state;
|
|
2550
|
-
const
|
|
2587
|
+
const siblingFileNames = getRenameSiblingFileNames(items, editingIndex, pathSeparator);
|
|
2588
|
+
const editingErrorMessage = validateFileName2(editingValue, siblingFileNames);
|
|
2551
2589
|
if (editingErrorMessage) {
|
|
2552
2590
|
return {
|
|
2553
2591
|
...state,
|
|
@@ -2555,6 +2593,9 @@ const acceptRename = async state => {
|
|
|
2555
2593
|
};
|
|
2556
2594
|
}
|
|
2557
2595
|
const renamedDirent = items[editingIndex];
|
|
2596
|
+
const oldUri = renamedDirent.path;
|
|
2597
|
+
const dirname = dirname2(oldUri);
|
|
2598
|
+
const newUri = join2(dirname, editingValue);
|
|
2558
2599
|
const operations = getFileOperationsRename(renamedDirent.path, editingValue);
|
|
2559
2600
|
const renameErrorMessage = await applyFileOperations(operations);
|
|
2560
2601
|
if (renameErrorMessage) {
|
|
@@ -2563,9 +2604,7 @@ const acceptRename = async state => {
|
|
|
2563
2604
|
editingErrorMessage: renameErrorMessage
|
|
2564
2605
|
};
|
|
2565
2606
|
}
|
|
2566
|
-
|
|
2567
|
-
const dirname = dirname2(oldUri);
|
|
2568
|
-
const newUri = join2(dirname, editingValue);
|
|
2607
|
+
await invoke$2('Main.handleUriChange', oldUri, newUri);
|
|
2569
2608
|
const children = await getChildDirents(pathSeparator, dirname, renamedDirent.depth - 1, excluded, root);
|
|
2570
2609
|
const tree = createTree(items, root);
|
|
2571
2610
|
const update = computeExplorerRenamedDirentUpdate(root, dirname, oldUri, children, tree, newUri);
|
|
@@ -2588,6 +2627,9 @@ const acceptRename = async state => {
|
|
|
2588
2627
|
};
|
|
2589
2628
|
|
|
2590
2629
|
const acceptEdit = async state => {
|
|
2630
|
+
if (state.isReadonly) {
|
|
2631
|
+
return state;
|
|
2632
|
+
}
|
|
2591
2633
|
const {
|
|
2592
2634
|
editingType
|
|
2593
2635
|
} = state;
|
|
@@ -4266,16 +4308,24 @@ const menuEntryRename = {
|
|
|
4266
4308
|
id: 'rename',
|
|
4267
4309
|
label: rename()
|
|
4268
4310
|
};
|
|
4269
|
-
const menuEntryRenameDisabled = {
|
|
4270
|
-
...menuEntryRename,
|
|
4271
|
-
flags: Disabled
|
|
4272
|
-
};
|
|
4273
4311
|
const menuEntryDelete = {
|
|
4274
4312
|
command: 'Explorer.removeDirent',
|
|
4275
4313
|
flags: None$2,
|
|
4276
4314
|
id: 'delete',
|
|
4277
4315
|
label: deleteItem()
|
|
4278
4316
|
};
|
|
4317
|
+
const disable = entry => {
|
|
4318
|
+
return {
|
|
4319
|
+
...entry,
|
|
4320
|
+
flags: Disabled
|
|
4321
|
+
};
|
|
4322
|
+
};
|
|
4323
|
+
const getWritableEntry = (state, entry) => {
|
|
4324
|
+
if (state.isReadonly) {
|
|
4325
|
+
return disable(entry);
|
|
4326
|
+
}
|
|
4327
|
+
return entry;
|
|
4328
|
+
};
|
|
4279
4329
|
const menuEntryRemoveFolderFromWorkspace = {
|
|
4280
4330
|
command: 'Workspace.close',
|
|
4281
4331
|
flags: None$2,
|
|
@@ -4292,26 +4342,23 @@ const getFocusedDirent = explorerState => {
|
|
|
4292
4342
|
}
|
|
4293
4343
|
return explorerState.items[explorerState.focusedIndex];
|
|
4294
4344
|
};
|
|
4295
|
-
const getMenuEntryRename = state => {
|
|
4296
|
-
if (state.isReadonly) {
|
|
4297
|
-
return menuEntryRenameDisabled;
|
|
4298
|
-
}
|
|
4299
|
-
return menuEntryRename;
|
|
4300
|
-
};
|
|
4301
4345
|
const getMenuEntriesDirectory = state => {
|
|
4302
|
-
return [menuEntryNewFile, menuEntryNewFolder, menuEntryOpenContainingFolder, menuEntryOpenInIntegratedTerminal, menuEntrySeparator, menuEntryCut, menuEntryCopy, menuEntryPaste, menuEntrySeparator, menuEntryCopyPath, menuEntryCopyRelativePath, menuEntrySeparator,
|
|
4346
|
+
return [getWritableEntry(state, menuEntryNewFile), getWritableEntry(state, menuEntryNewFolder), menuEntryOpenContainingFolder, menuEntryOpenInIntegratedTerminal, menuEntrySeparator, getWritableEntry(state, menuEntryCut), menuEntryCopy, getWritableEntry(state, menuEntryPaste), menuEntrySeparator, menuEntryCopyPath, menuEntryCopyRelativePath, menuEntrySeparator, getWritableEntry(state, menuEntryRename), getWritableEntry(state, menuEntryDelete)];
|
|
4303
4347
|
};
|
|
4304
4348
|
const getMenuEntriesFile = state => {
|
|
4305
|
-
return [menuEntryOpenContainingFolder, menuEntryOpenInIntegratedTerminal, menuEntrySeparator, menuEntryCut, menuEntryCopy, menuEntryPaste, menuEntrySeparator, menuEntryCopyPath, menuEntryCopyRelativePath, menuEntrySeparator, menuEntrySelectForCompare, menuEntrySeparator,
|
|
4349
|
+
return [menuEntryOpenContainingFolder, menuEntryOpenInIntegratedTerminal, menuEntrySeparator, getWritableEntry(state, menuEntryCut), menuEntryCopy, getWritableEntry(state, menuEntryPaste), menuEntrySeparator, menuEntryCopyPath, menuEntryCopyRelativePath, menuEntrySeparator, menuEntrySelectForCompare, menuEntrySeparator, getWritableEntry(state, menuEntryRename), getWritableEntry(state, menuEntryDelete)];
|
|
4306
4350
|
};
|
|
4307
4351
|
const getMenuEntriesFileCompareWithSelected = state => {
|
|
4308
|
-
return [menuEntryOpenContainingFolder, menuEntryOpenInIntegratedTerminal, menuEntrySeparator, menuEntryCut, menuEntryCopy, menuEntryPaste, menuEntrySeparator, menuEntryCopyPath, menuEntryCopyRelativePath, menuEntrySeparator, menuEntryCompareWithSelected, menuEntrySeparator,
|
|
4352
|
+
return [menuEntryOpenContainingFolder, menuEntryOpenInIntegratedTerminal, menuEntrySeparator, getWritableEntry(state, menuEntryCut), menuEntryCopy, getWritableEntry(state, menuEntryPaste), menuEntrySeparator, menuEntryCopyPath, menuEntryCopyRelativePath, menuEntrySeparator, menuEntryCompareWithSelected, menuEntrySeparator, getWritableEntry(state, menuEntryRename), getWritableEntry(state, menuEntryDelete)];
|
|
4309
4353
|
};
|
|
4310
4354
|
const getMenuEntriesDefault = state => {
|
|
4311
4355
|
return getMenuEntriesDirectory(state);
|
|
4312
4356
|
};
|
|
4313
|
-
const getMenuEntriesRoot =
|
|
4314
|
-
const
|
|
4357
|
+
const getMenuEntriesRoot = state => {
|
|
4358
|
+
const {
|
|
4359
|
+
root
|
|
4360
|
+
} = state;
|
|
4361
|
+
const entries = [getWritableEntry(state, menuEntryNewFile), getWritableEntry(state, menuEntryNewFolder), menuEntryOpenContainingFolder, menuEntryOpenInIntegratedTerminal, menuEntrySeparator, getWritableEntry(state, menuEntryPaste), menuEntrySeparator, menuEntryCopyPath, menuEntryCopyRelativePath];
|
|
4315
4362
|
if (root) {
|
|
4316
4363
|
entries.push(menuEntrySeparator, menuEntryRemoveFolderFromWorkspace);
|
|
4317
4364
|
}
|
|
@@ -4320,7 +4367,7 @@ const getMenuEntriesRoot = root => {
|
|
|
4320
4367
|
const getMenuEntries = state => {
|
|
4321
4368
|
const focusedDirent = getFocusedDirent(state);
|
|
4322
4369
|
if (!focusedDirent) {
|
|
4323
|
-
return getMenuEntriesRoot(state
|
|
4370
|
+
return getMenuEntriesRoot(state);
|
|
4324
4371
|
}
|
|
4325
4372
|
switch (focusedDirent.type) {
|
|
4326
4373
|
case Directory:
|
|
@@ -4507,7 +4554,9 @@ const handleClickDirectory = async (state, dirent, index, keepFocus) => {
|
|
|
4507
4554
|
};
|
|
4508
4555
|
|
|
4509
4556
|
const handleClickFile = async (state, dirent, index, keepFocus = false) => {
|
|
4510
|
-
await openUri(dirent.path, !keepFocus
|
|
4557
|
+
await openUri(dirent.path, !keepFocus, {
|
|
4558
|
+
preview: true
|
|
4559
|
+
});
|
|
4511
4560
|
return {
|
|
4512
4561
|
...state,
|
|
4513
4562
|
focused: keepFocus,
|
|
@@ -4712,6 +4761,9 @@ const newDirent = async (state, editingType, editingIcon = '') => {
|
|
|
4712
4761
|
|
|
4713
4762
|
// TODO much shared logic with newFolder
|
|
4714
4763
|
const newFile = state => {
|
|
4764
|
+
if (state.isReadonly) {
|
|
4765
|
+
return Promise.resolve(state);
|
|
4766
|
+
}
|
|
4715
4767
|
return newDirent(state, CreateFile);
|
|
4716
4768
|
};
|
|
4717
4769
|
|
|
@@ -4742,7 +4794,7 @@ const getEditingIcon = async (editingType, value, direntType) => {
|
|
|
4742
4794
|
};
|
|
4743
4795
|
|
|
4744
4796
|
const newFolder = async state => {
|
|
4745
|
-
if (state.editingIndex !== -1) {
|
|
4797
|
+
if (state.isReadonly || state.editingIndex !== -1) {
|
|
4746
4798
|
return state;
|
|
4747
4799
|
}
|
|
4748
4800
|
const editingIcon = await getEditingIcon(CreateFolder, '');
|
|
@@ -5194,6 +5246,9 @@ const getSelectedItems = (items, focusedIndex) => {
|
|
|
5194
5246
|
};
|
|
5195
5247
|
|
|
5196
5248
|
const handleCut = async state => {
|
|
5249
|
+
if (state.isReadonly) {
|
|
5250
|
+
return state;
|
|
5251
|
+
}
|
|
5197
5252
|
// TODO handle multiple files
|
|
5198
5253
|
// TODO if not file is selected, what happens?
|
|
5199
5254
|
const {
|
|
@@ -5292,6 +5347,9 @@ const isEqual = (a, b) => {
|
|
|
5292
5347
|
};
|
|
5293
5348
|
|
|
5294
5349
|
const handleDragOverIndex = (state, index) => {
|
|
5350
|
+
if (state.isReadonly) {
|
|
5351
|
+
return state;
|
|
5352
|
+
}
|
|
5295
5353
|
const {
|
|
5296
5354
|
dropTargets
|
|
5297
5355
|
} = state;
|
|
@@ -5308,6 +5366,9 @@ const handleDragOverIndex = (state, index) => {
|
|
|
5308
5366
|
const handleDragOver = (state, x, y) => {
|
|
5309
5367
|
number(x);
|
|
5310
5368
|
number(y);
|
|
5369
|
+
if (state.isReadonly) {
|
|
5370
|
+
return state;
|
|
5371
|
+
}
|
|
5311
5372
|
const index = getIndexFromPosition(state, x, y);
|
|
5312
5373
|
return handleDragOverIndex(state, index);
|
|
5313
5374
|
};
|
|
@@ -5427,7 +5488,7 @@ const getSettings = async () => {
|
|
|
5427
5488
|
const useChevronsRaw = await invoke$2('Preferences.get', 'explorer.useChevrons');
|
|
5428
5489
|
const useChevrons = useChevronsRaw === false ? false : true;
|
|
5429
5490
|
const confirmDeleteRaw = await invoke$2('Preferences.get', 'explorer.confirmdelete');
|
|
5430
|
-
const confirmDelete = confirmDeleteRaw === false ? false :
|
|
5491
|
+
const confirmDelete = confirmDeleteRaw === false ? false : true;
|
|
5431
5492
|
const confirmPasteRaw = await invoke$2('Preferences.get', 'explorer.confirmpaste');
|
|
5432
5493
|
const confirmPaste = confirmPasteRaw === false ? false : false;
|
|
5433
5494
|
const excludedRaw = await invoke$2('Preferences.get', 'files.exclude');
|
|
@@ -5859,6 +5920,9 @@ const getModule = isElectron => {
|
|
|
5859
5920
|
return handleDrop$2;
|
|
5860
5921
|
};
|
|
5861
5922
|
const handleDropRoot = async (state, fileHandles, files, paths) => {
|
|
5923
|
+
if (state.isReadonly) {
|
|
5924
|
+
return state;
|
|
5925
|
+
}
|
|
5862
5926
|
const isElectron = state.platform === Electron;
|
|
5863
5927
|
const fn = getModule(isElectron);
|
|
5864
5928
|
return fn(state, fileHandles, files, paths);
|
|
@@ -5909,6 +5973,9 @@ const handleDropIntoFile = (state, dirent, index, fileHandles, files, paths) =>
|
|
|
5909
5973
|
return handleDropIndex(state, fileHandles, files, paths, parentIndex);
|
|
5910
5974
|
};
|
|
5911
5975
|
const handleDropIndex = async (state, fileHandles, files, paths, index) => {
|
|
5976
|
+
if (state.isReadonly) {
|
|
5977
|
+
return state;
|
|
5978
|
+
}
|
|
5912
5979
|
const {
|
|
5913
5980
|
items
|
|
5914
5981
|
} = state;
|
|
@@ -5967,6 +6034,9 @@ const getFilePaths = async (files, platform) => {
|
|
|
5967
6034
|
};
|
|
5968
6035
|
|
|
5969
6036
|
const handleDrop = async (state, x, y, fileIds, fileList) => {
|
|
6037
|
+
if (state.isReadonly) {
|
|
6038
|
+
return state;
|
|
6039
|
+
}
|
|
5970
6040
|
try {
|
|
5971
6041
|
const {
|
|
5972
6042
|
platform
|
|
@@ -6194,26 +6264,19 @@ const generateUniqueName = (baseName, existingPaths, root) => {
|
|
|
6194
6264
|
}
|
|
6195
6265
|
};
|
|
6196
6266
|
|
|
6197
|
-
const getFileOperationsCopy = (
|
|
6267
|
+
const getFileOperationsCopy = (targetUri, existingUris, files) => {
|
|
6198
6268
|
const operations = [];
|
|
6269
|
+
const reservedUris = [...existingUris];
|
|
6199
6270
|
for (const file of files) {
|
|
6200
6271
|
const baseName = getBaseName('/', file);
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
}
|
|
6208
|
-
|
|
6209
|
-
const newUri = join2(root, uniqueName);
|
|
6210
|
-
operations.push({
|
|
6211
|
-
from: file,
|
|
6212
|
-
// TODO ensure file is uri
|
|
6213
|
-
path: newUri,
|
|
6214
|
-
type: Copy$1
|
|
6215
|
-
});
|
|
6216
|
-
}
|
|
6272
|
+
const uniqueName = generateUniqueName(baseName, reservedUris, targetUri);
|
|
6273
|
+
const newUri = join2(targetUri, uniqueName);
|
|
6274
|
+
operations.push({
|
|
6275
|
+
from: file,
|
|
6276
|
+
path: newUri,
|
|
6277
|
+
type: Copy$1
|
|
6278
|
+
});
|
|
6279
|
+
reservedUris.push(newUri);
|
|
6217
6280
|
}
|
|
6218
6281
|
return operations;
|
|
6219
6282
|
};
|
|
@@ -6229,11 +6292,13 @@ const handlePasteCopy = async (state, nativeFiles) => {
|
|
|
6229
6292
|
const {
|
|
6230
6293
|
focusedIndex,
|
|
6231
6294
|
items,
|
|
6295
|
+
pathSeparator,
|
|
6232
6296
|
root
|
|
6233
6297
|
} = state;
|
|
6234
|
-
const
|
|
6235
|
-
const
|
|
6236
|
-
const
|
|
6298
|
+
const targetUri = getParentFolder(items, focusedIndex, root, pathSeparator);
|
|
6299
|
+
const targetDirents = await readDirWithFileTypes(targetUri);
|
|
6300
|
+
const existingUris = targetDirents.map(dirent => join2(targetUri, dirent.name));
|
|
6301
|
+
const operations = getFileOperationsCopy(targetUri, existingUris, nativeFiles.files);
|
|
6237
6302
|
// TODO handle error?
|
|
6238
6303
|
await applyFileOperations(operations);
|
|
6239
6304
|
|
|
@@ -6326,6 +6391,9 @@ const handlePasteCut = async (state, nativeFiles) => {
|
|
|
6326
6391
|
const None$1 = 'none';
|
|
6327
6392
|
|
|
6328
6393
|
const handlePaste = async state => {
|
|
6394
|
+
if (state.isReadonly) {
|
|
6395
|
+
return state;
|
|
6396
|
+
}
|
|
6329
6397
|
const nativeFiles = await readNativeFiles();
|
|
6330
6398
|
if (!nativeFiles) {
|
|
6331
6399
|
return state;
|
|
@@ -6411,6 +6479,9 @@ const handleResize = (state, dimensions) => {
|
|
|
6411
6479
|
};
|
|
6412
6480
|
|
|
6413
6481
|
const handleUpload = async (state, dirents) => {
|
|
6482
|
+
if (state.isReadonly) {
|
|
6483
|
+
return state;
|
|
6484
|
+
}
|
|
6414
6485
|
const {
|
|
6415
6486
|
pathSeparator,
|
|
6416
6487
|
root
|
|
@@ -6517,6 +6588,9 @@ const showErrorAlert = async errorMessage => {
|
|
|
6517
6588
|
};
|
|
6518
6589
|
|
|
6519
6590
|
const removeDirent = async state => {
|
|
6591
|
+
if (state.isReadonly) {
|
|
6592
|
+
return state;
|
|
6593
|
+
}
|
|
6520
6594
|
const {
|
|
6521
6595
|
confirmDelete: confirmDelete$1,
|
|
6522
6596
|
focusedIndex,
|
|
@@ -6587,6 +6661,9 @@ const User = 1;
|
|
|
6587
6661
|
const Script = 2;
|
|
6588
6662
|
|
|
6589
6663
|
const renameDirent = async state => {
|
|
6664
|
+
if (state.isReadonly) {
|
|
6665
|
+
return state;
|
|
6666
|
+
}
|
|
6590
6667
|
const {
|
|
6591
6668
|
focusedIndex,
|
|
6592
6669
|
icons,
|
|
@@ -7193,11 +7270,12 @@ const applyRender = (oldState, newState, diffResult) => {
|
|
|
7193
7270
|
return commands;
|
|
7194
7271
|
};
|
|
7195
7272
|
|
|
7196
|
-
const render2 = (uid,
|
|
7273
|
+
const render2 = (uid, _diffResult) => {
|
|
7197
7274
|
const {
|
|
7198
7275
|
oldState,
|
|
7199
7276
|
scheduledState
|
|
7200
7277
|
} = get(uid);
|
|
7278
|
+
const diffResult = diff(oldState, scheduledState);
|
|
7201
7279
|
set(uid, scheduledState, scheduledState);
|
|
7202
7280
|
const commands = applyRender(oldState, scheduledState, diffResult);
|
|
7203
7281
|
return commands;
|
|
@@ -7210,23 +7288,27 @@ const NewFile = 'NewFile';
|
|
|
7210
7288
|
const NewFolder = 'NewFolder';
|
|
7211
7289
|
const Refresh = 'Refresh';
|
|
7212
7290
|
|
|
7213
|
-
const getActions = root => {
|
|
7291
|
+
const getActions = (root, isReadonly) => {
|
|
7214
7292
|
if (!root) {
|
|
7215
7293
|
return [];
|
|
7216
7294
|
}
|
|
7217
|
-
|
|
7218
|
-
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
|
|
7227
|
-
|
|
7228
|
-
|
|
7229
|
-
|
|
7295
|
+
const actions = [];
|
|
7296
|
+
if (!isReadonly) {
|
|
7297
|
+
actions.push({
|
|
7298
|
+
command: 'newFile',
|
|
7299
|
+
icon: NewFile,
|
|
7300
|
+
id: newFile$1(),
|
|
7301
|
+
name: NewFile$1,
|
|
7302
|
+
type: Button
|
|
7303
|
+
}, {
|
|
7304
|
+
command: 'newFolder',
|
|
7305
|
+
icon: NewFolder,
|
|
7306
|
+
id: newFolder$1(),
|
|
7307
|
+
name: NewFolder$1,
|
|
7308
|
+
type: Button
|
|
7309
|
+
});
|
|
7310
|
+
}
|
|
7311
|
+
actions.push({
|
|
7230
7312
|
command: 'refresh',
|
|
7231
7313
|
icon: Refresh,
|
|
7232
7314
|
id: refresh$1(),
|
|
@@ -7238,7 +7320,8 @@ const getActions = root => {
|
|
|
7238
7320
|
id: collapseAll$1(),
|
|
7239
7321
|
name: CollapseAll$1,
|
|
7240
7322
|
type: Button
|
|
7241
|
-
}
|
|
7323
|
+
});
|
|
7324
|
+
return actions;
|
|
7242
7325
|
};
|
|
7243
7326
|
|
|
7244
7327
|
const getIconVirtualDom = (icon, type = Div) => {
|
|
@@ -7288,7 +7371,7 @@ const renderActions = uid => {
|
|
|
7288
7371
|
const {
|
|
7289
7372
|
newState
|
|
7290
7373
|
} = get(uid);
|
|
7291
|
-
const actions = getActions(newState.root);
|
|
7374
|
+
const actions = getActions(newState.root, newState.isReadonly);
|
|
7292
7375
|
const dom = getActionsVirtualDom(actions);
|
|
7293
7376
|
return dom;
|
|
7294
7377
|
};
|
|
@@ -7644,13 +7727,16 @@ const updateEditingValue = async (state, value, inputSource = User) => {
|
|
|
7644
7727
|
editingIndex,
|
|
7645
7728
|
editingType,
|
|
7646
7729
|
focusedIndex,
|
|
7647
|
-
items
|
|
7730
|
+
items,
|
|
7731
|
+
pathSeparator} = state;
|
|
7648
7732
|
const editingIcon = await getEditingIcon(editingType, value, items[editingIndex]?.type);
|
|
7649
7733
|
|
|
7650
7734
|
// Get sibling file names for validation during file/folder creation
|
|
7651
7735
|
let siblingFileNames = [];
|
|
7652
7736
|
if (editingType === CreateFile || editingType === CreateFolder) {
|
|
7653
7737
|
siblingFileNames = getSiblingFileNames(items, focusedIndex);
|
|
7738
|
+
} else if (editingType === Rename$1) {
|
|
7739
|
+
siblingFileNames = getRenameSiblingFileNames(items, editingIndex, pathSeparator);
|
|
7654
7740
|
}
|
|
7655
7741
|
const editingErrorMessage = validateFileName2(value, siblingFileNames);
|
|
7656
7742
|
return {
|