dsh-linked-workspace 0.15.0 → 0.16.1
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/CHANGELOG.md +50 -0
- package/README.en.md +7 -2
- package/README.md +6 -2
- package/docs/API.md +3 -1
- package/docs/VERIFY.md +28 -3
- package/lib/client.js +474 -37
- package/lib/index.js +119 -33
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -1958,6 +1958,15 @@ function attributeViolation(name, value, tagName) {
|
|
|
1958
1958
|
// but a full remote listing on a huge folder is expensive; 15 s keeps the
|
|
1959
1959
|
// tree fresh without hammering the SSH channel.
|
|
1960
1960
|
var REFRESH_MIN_INTERVAL_MS = 15000;
|
|
1961
|
+
// HTML previews read the whole document (a plotly/figure page is one big
|
|
1962
|
+
// inlined script), so they ask the Host for the 8 MB read cap instead of
|
|
1963
|
+
// the editor's 2 MB one.
|
|
1964
|
+
var PREVIEW_MAX_BYTES = 8 * 1024 * 1024;
|
|
1965
|
+
// Connection state is a live fact, not a property of the workspace: the
|
|
1966
|
+
// sidebar rows and the hover card poll the Host so a dropped socket turns
|
|
1967
|
+
// red within a few seconds and a recovered one turns back. The call reads
|
|
1968
|
+
// memory only (it never dials), so a short interval is cheap.
|
|
1969
|
+
var STATUS_POLL_MS = 6000;
|
|
1961
1970
|
var linkedLocalKeys = new Set();
|
|
1962
1971
|
var linkedWorkspaceKeys = new Set();
|
|
1963
1972
|
// Remote workspaces run inside a placeholder directory, so they are matched
|
|
@@ -2201,7 +2210,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
2201
2210
|
imageFit: '适应窗口',
|
|
2202
2211
|
imageActualSize: '原始大小',
|
|
2203
2212
|
htmlLoadError: '无法预览网页',
|
|
2204
|
-
|
|
2213
|
+
htmlPreviewTooLarge: '文件 {{size}} 超过预览上限 {{limit}},请右键「下载到默认文件夹」后用浏览器打开。',
|
|
2214
|
+
htmlPreviewBinary: '这是二进制文件,无法按网页预览。',
|
|
2215
|
+
htmlSandboxed: '沙箱预览(脚本可运行,无法访问 DSH 界面)',
|
|
2205
2216
|
previewOnly: '图片预览',
|
|
2206
2217
|
csvTable: '表格',
|
|
2207
2218
|
csvSource: '源码',
|
|
@@ -2515,7 +2526,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
2515
2526
|
ctxDownload: '下载到默认文件夹',
|
|
2516
2527
|
ctxQueue: '队列',
|
|
2517
2528
|
ctxOpen: '打开',
|
|
2518
|
-
ctxNotepad: '
|
|
2529
|
+
ctxNotepad: '用记事本打开副本(不回写)',
|
|
2519
2530
|
ctxCopy: '复制',
|
|
2520
2531
|
ctxPaste: '粘贴',
|
|
2521
2532
|
ctxCopyPath: '复制路径',
|
|
@@ -2535,6 +2546,20 @@ function attributeViolation(name, value, tagName) {
|
|
|
2535
2546
|
transferDone: '已传输 {{files}} 个文件({{size}})',
|
|
2536
2547
|
transferTruncated: '(达到上限,未全部传输)',
|
|
2537
2548
|
downloadDone: '已下载到 {{path}}',
|
|
2549
|
+
downloadCount: '{{files}} 个文件({{size}})',
|
|
2550
|
+
downloadTruncated: '达到上限,未全部下载',
|
|
2551
|
+
downloadSkipped: '跳过 {{count}} 个(超过 20 MB)',
|
|
2552
|
+
downloadManyDone: '已下载 {{count}} 项,共 {{files}} 个文件({{size}})',
|
|
2553
|
+
downloadFailed: '{{count}} 项失败',
|
|
2554
|
+
ctxDownloadSelected: '下载所选的 {{count}} 项',
|
|
2555
|
+
ctxCopySsh: '复制 ssh 命令',
|
|
2556
|
+
sshCopied: '已复制 ssh 命令',
|
|
2557
|
+
searchRecent: '最近搜索',
|
|
2558
|
+
editorNextHit: '下一个命中(Ctrl+↓)',
|
|
2559
|
+
transferHistoryTitle: '最近的传输',
|
|
2560
|
+
transferHistoryEmpty: '还没有传输记录。',
|
|
2561
|
+
diskFree: '可用 {{free}}(已用 {{percent}}%)',
|
|
2562
|
+
diskUnavailable: '磁盘信息不可用',
|
|
2538
2563
|
renameTitle: '重命名',
|
|
2539
2564
|
renameLabel: '新名称',
|
|
2540
2565
|
deleteTitle: '确认删除',
|
|
@@ -2545,6 +2570,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
2545
2570
|
nameLabel: '名称',
|
|
2546
2571
|
chmodTitle: '更改权限',
|
|
2547
2572
|
chmodLabel: '八进制权限(如 644 / 0755)',
|
|
2573
|
+
chmodLabelDir: '目录权限(需要含 7 才有进入权限,如 755)',
|
|
2548
2574
|
propsTitle: '属性',
|
|
2549
2575
|
propsName: '名称',
|
|
2550
2576
|
propsPath: '路径',
|
|
@@ -2561,6 +2587,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
2561
2587
|
deleteDone: '已删除',
|
|
2562
2588
|
chmodDone: '权限已更新',
|
|
2563
2589
|
actionFailed: '操作失败',
|
|
2590
|
+
permissionHint: '(目录可能缺少执行位:用「更改权限」改回 755 即可恢复)',
|
|
2564
2591
|
close: '关闭',
|
|
2565
2592
|
confirm: '确定',
|
|
2566
2593
|
queueClear: '清空已完成',
|
|
@@ -2568,8 +2595,8 @@ function attributeViolation(name, value, tagName) {
|
|
|
2568
2595
|
transferSelected: '传输所选文件/文件夹',
|
|
2569
2596
|
transferNeedsLinked: '传输只在联动工作区可用(远端 → 本地)',
|
|
2570
2597
|
selectFirst: '先在目录树中选择一个远端文件或文件夹。',
|
|
2571
|
-
showHidden: '
|
|
2572
|
-
hideHidden: '
|
|
2598
|
+
showHidden: '显示以 . 开头的文件',
|
|
2599
|
+
hideHidden: '不显示以 . 开头的文件',
|
|
2573
2600
|
syncStarting: '正在启动同步…',
|
|
2574
2601
|
syncRunning: '同步中:{{files}} 个文件 / {{size}}',
|
|
2575
2602
|
syncDone2: '同步完成:{{files}} 个文件({{size}})',
|
|
@@ -2662,7 +2689,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
2662
2689
|
imageFit: 'Fit to window',
|
|
2663
2690
|
imageActualSize: 'Actual size',
|
|
2664
2691
|
htmlLoadError: 'Cannot preview this page',
|
|
2665
|
-
|
|
2692
|
+
htmlPreviewTooLarge: 'This file is {{size}}, above the {{limit}} preview limit. Download it to the default folder and open it in a browser.',
|
|
2693
|
+
htmlPreviewBinary: 'This is a binary file, so it cannot be previewed as a page.',
|
|
2694
|
+
htmlSandboxed: 'Sandboxed preview (scripts run, no access to the DSH UI)',
|
|
2666
2695
|
previewOnly: 'Image preview',
|
|
2667
2696
|
csvTable: 'Table',
|
|
2668
2697
|
csvSource: 'Source',
|
|
@@ -2976,7 +3005,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
2976
3005
|
ctxDownload: 'Download to default folder',
|
|
2977
3006
|
ctxQueue: 'Queue',
|
|
2978
3007
|
ctxOpen: 'Open',
|
|
2979
|
-
ctxNotepad: '
|
|
3008
|
+
ctxNotepad: 'Open a copy in Notepad (edits are not written back)',
|
|
2980
3009
|
ctxCopy: 'Copy',
|
|
2981
3010
|
ctxPaste: 'Paste',
|
|
2982
3011
|
ctxCopyPath: 'Copy path',
|
|
@@ -2996,6 +3025,20 @@ function attributeViolation(name, value, tagName) {
|
|
|
2996
3025
|
transferDone: 'Transferred {{files}} files ({{size}})',
|
|
2997
3026
|
transferTruncated: ' (limit reached; not everything was transferred)',
|
|
2998
3027
|
downloadDone: 'Downloaded to {{path}}',
|
|
3028
|
+
downloadCount: '{{files}} files ({{size}})',
|
|
3029
|
+
downloadTruncated: 'hit the cap, not everything was downloaded',
|
|
3030
|
+
downloadSkipped: 'skipped {{count}} (over 20 MB)',
|
|
3031
|
+
downloadManyDone: 'Downloaded {{count}} items, {{files}} files ({{size}})',
|
|
3032
|
+
downloadFailed: '{{count}} failed',
|
|
3033
|
+
ctxDownloadSelected: 'Download {{count}} selected',
|
|
3034
|
+
ctxCopySsh: 'Copy ssh command',
|
|
3035
|
+
sshCopied: 'ssh command copied',
|
|
3036
|
+
searchRecent: 'Recent searches',
|
|
3037
|
+
editorNextHit: 'Next hit (Ctrl+Down)',
|
|
3038
|
+
transferHistoryTitle: 'Recent transfers',
|
|
3039
|
+
transferHistoryEmpty: 'No transfers yet.',
|
|
3040
|
+
diskFree: '{{free}} free ({{percent}}% used)',
|
|
3041
|
+
diskUnavailable: 'Disk usage unavailable',
|
|
2999
3042
|
renameTitle: 'Rename',
|
|
3000
3043
|
renameLabel: 'New name',
|
|
3001
3044
|
deleteTitle: 'Confirm delete',
|
|
@@ -3006,6 +3049,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
3006
3049
|
nameLabel: 'Name',
|
|
3007
3050
|
chmodTitle: 'Change permissions',
|
|
3008
3051
|
chmodLabel: 'Octal permissions (e.g. 644 / 0755)',
|
|
3052
|
+
chmodLabelDir: 'Directory permissions (needs a 7 to stay enterable, e.g. 755)',
|
|
3009
3053
|
propsTitle: 'Properties',
|
|
3010
3054
|
propsName: 'Name',
|
|
3011
3055
|
propsPath: 'Path',
|
|
@@ -3022,6 +3066,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
3022
3066
|
deleteDone: 'Deleted',
|
|
3023
3067
|
chmodDone: 'Permissions updated',
|
|
3024
3068
|
actionFailed: 'Action failed',
|
|
3069
|
+
permissionHint: ' (a folder without the execute bit — use “Change permissions” and set 755 again)',
|
|
3025
3070
|
close: 'Close',
|
|
3026
3071
|
confirm: 'OK',
|
|
3027
3072
|
queueClear: 'Clear finished',
|
|
@@ -3029,8 +3074,8 @@ function attributeViolation(name, value, tagName) {
|
|
|
3029
3074
|
transferSelected: 'Transfer the selected file/folder',
|
|
3030
3075
|
transferNeedsLinked: 'Transfer needs a linked workspace (remote → local)',
|
|
3031
3076
|
selectFirst: 'Select a remote file or folder in the tree first.',
|
|
3032
|
-
showHidden: 'Show
|
|
3033
|
-
hideHidden: 'Hide
|
|
3077
|
+
showHidden: 'Show dotfiles (names starting with .)',
|
|
3078
|
+
hideHidden: 'Hide dotfiles (names starting with .)',
|
|
3034
3079
|
syncStarting: 'Starting sync…',
|
|
3035
3080
|
syncRunning: 'Syncing: {{files}} files / {{size}}',
|
|
3036
3081
|
syncDone2: 'Sync finished: {{files}} files ({{size}})',
|
|
@@ -3182,8 +3227,11 @@ function attributeViolation(name, value, tagName) {
|
|
|
3182
3227
|
// Keep the server's own wording: "All configured authentication methods
|
|
3183
3228
|
// failed" tells the user far more than the generic code text alone.
|
|
3184
3229
|
var detail = typeof error.message === 'string' ? error.message.trim() : '';
|
|
3185
|
-
|
|
3186
|
-
|
|
3230
|
+
// A folder without the execute bit looks empty instead of failing loudly,
|
|
3231
|
+
// so name the usual cause and the way back whenever this code shows up.
|
|
3232
|
+
var hint = error.code === 'FS_PERMISSION' ? t('permissionHint') : '';
|
|
3233
|
+
if (!detail || detail === known) return known + hint;
|
|
3234
|
+
return known + (locale === 'zh' ? ':' : ': ') + detail + hint;
|
|
3187
3235
|
}
|
|
3188
3236
|
|
|
3189
3237
|
function documentKindOf(path) {
|
|
@@ -3638,6 +3686,14 @@ function attributeViolation(name, value, tagName) {
|
|
|
3638
3686
|
'.rw-result-row:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12))}',
|
|
3639
3687
|
'.rw-hint-row{padding:9px 6px;font-size:11.5px;line-height:17px;color:var(--dsw-alias-label-tertiary)}',
|
|
3640
3688
|
'.rw-linked-notice{margin:6px 8px 0}',
|
|
3689
|
+
'.rw-disk{flex:none;font-size:11px;color:var(--dsw-alias-label-secondary,#8b949e);font-variant-numeric:tabular-nums}',
|
|
3690
|
+
'.rw-search-history{display:flex;align-items:center;gap:6px;flex-wrap:wrap;padding:4px 8px 6px}',
|
|
3691
|
+
'.rw-search-history-label{font-size:11px;color:var(--dsw-alias-label-secondary,#8b949e);flex:none}',
|
|
3692
|
+
'.rw-queue-history{margin-top:12px;border-top:1px solid var(--dsw-alias-border-l1,rgba(127,127,127,.28));padding-top:8px}',
|
|
3693
|
+
'.rw-queue-history-title{font-size:11px;color:var(--dsw-alias-label-secondary,#8b949e);margin-bottom:4px}',
|
|
3694
|
+
'.rw-queue-row.is-history .rw-queue-state{opacity:.75}',
|
|
3695
|
+
'.rw-notice-body{display:flex;align-items:flex-start;gap:8px}',
|
|
3696
|
+
'.rw-notice-text{flex:1 1 auto;min-width:0;white-space:pre-wrap;word-break:break-word}',
|
|
3641
3697
|
'.rw-ctx-backdrop{position:fixed;inset:0;z-index:70}',
|
|
3642
3698
|
'.rw-workspace-body{display:flex;flex:1 1 auto;min-height:0;min-width:0}',
|
|
3643
3699
|
'.rw-content-pane{display:flex;flex-direction:column;flex:1 1 auto;min-width:0;min-height:0}',
|
|
@@ -3938,17 +3994,37 @@ function attributeViolation(name, value, tagName) {
|
|
|
3938
3994
|
}
|
|
3939
3995
|
}
|
|
3940
3996
|
|
|
3997
|
+
/** Repaint the "host · state" line of an already decorated card. */
|
|
3998
|
+
function refreshHoverStatus(card, scopeKey) {
|
|
3999
|
+
var line = card.querySelector('.rw-hover-host');
|
|
4000
|
+
if (!line) return;
|
|
4001
|
+
var record = workspaceHoverRecords[scopeKey];
|
|
4002
|
+
if (!record || !record.remotePath) return;
|
|
4003
|
+
var nextText = record.host ? record.host + ' · ' + record.status : record.status;
|
|
4004
|
+
var nextClass = 'rw-hover-host' + (record.disconnected ? ' is-off' : record.connected ? ' is-on' : '');
|
|
4005
|
+
if (line.textContent === nextText && line.className === nextClass) return;
|
|
4006
|
+
line.textContent = nextText;
|
|
4007
|
+
line.className = nextClass;
|
|
4008
|
+
}
|
|
4009
|
+
|
|
3941
4010
|
function decorateHoverCard(card) {
|
|
3942
4011
|
if (!card || !hoverCardState || !card.querySelector) return;
|
|
3943
4012
|
var pathEl = card.querySelector('[class*="hoverPath"]');
|
|
3944
4013
|
if (!pathEl) return;
|
|
3945
4014
|
var known = hoverCardState.get(card);
|
|
3946
4015
|
var current = (pathEl.textContent || '').trim();
|
|
3947
|
-
// Already decorated for this very content:
|
|
3948
|
-
|
|
4016
|
+
// Already decorated for this very content: the paths stay, but the status
|
|
4017
|
+
// may have moved on (the connection drops or comes back while the card is
|
|
4018
|
+
// open), so refresh that one line instead of giving up. The key has to be
|
|
4019
|
+
// remembered, because the path text has been rewritten by now.
|
|
4020
|
+
if (known && known.rendered === current) {
|
|
4021
|
+
refreshHoverStatus(card, known.key || linkedScopeKey(current));
|
|
4022
|
+
return;
|
|
4023
|
+
}
|
|
3949
4024
|
// The host re-rendered the card for another workspace: drop our lines.
|
|
3950
4025
|
if (known) clearHoverLines(card);
|
|
3951
|
-
var
|
|
4026
|
+
var key = linkedScopeKey(current);
|
|
4027
|
+
var record = workspaceHoverRecords[key];
|
|
3952
4028
|
if (!record || !record.remotePath) return;
|
|
3953
4029
|
var t = makeT(readLocale());
|
|
3954
4030
|
var remote = record.remotePath;
|
|
@@ -3983,7 +4059,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
3983
4059
|
host.setAttribute('aria-label', label.split(current).join(remote));
|
|
3984
4060
|
}
|
|
3985
4061
|
|
|
3986
|
-
hoverCardState.set(card, { rendered: (pathEl.textContent || '').trim() });
|
|
4062
|
+
hoverCardState.set(card, { rendered: (pathEl.textContent || '').trim(), key: key });
|
|
3987
4063
|
}
|
|
3988
4064
|
|
|
3989
4065
|
function applyHoverCards() {
|
|
@@ -4340,6 +4416,46 @@ function attributeViolation(name, value, tagName) {
|
|
|
4340
4416
|
};
|
|
4341
4417
|
}, [load]);
|
|
4342
4418
|
|
|
4419
|
+
// Keep the connection state in step with reality. Only the status field is
|
|
4420
|
+
// patched, and only when it actually changed, so polling never re-renders
|
|
4421
|
+
// the whole page or re-fetches the trees.
|
|
4422
|
+
var dataRef = useRef(data);
|
|
4423
|
+
dataRef.current = data;
|
|
4424
|
+
useEffect(function () {
|
|
4425
|
+
var stopped = false;
|
|
4426
|
+
var tick = function () {
|
|
4427
|
+
apiCall('hosts.status', {}).then(function (result) {
|
|
4428
|
+
if (stopped) return;
|
|
4429
|
+
var statuses = (result && result.statuses) || {};
|
|
4430
|
+
var previous = dataRef.current;
|
|
4431
|
+
var changed = false;
|
|
4432
|
+
var apply = function (list) {
|
|
4433
|
+
return (list || []).map(function (item) {
|
|
4434
|
+
var status = item && item.hostId ? statuses[item.hostId] : null;
|
|
4435
|
+
if (!status) return item;
|
|
4436
|
+
if (JSON.stringify(item.status || null) === JSON.stringify(status)) return item;
|
|
4437
|
+
changed = true;
|
|
4438
|
+
return Object.assign({}, item, { status: status });
|
|
4439
|
+
});
|
|
4440
|
+
};
|
|
4441
|
+
var links = apply(previous.links);
|
|
4442
|
+
var remotes = apply(previous.remotes);
|
|
4443
|
+
if (!changed) return;
|
|
4444
|
+
setData(function (current) {
|
|
4445
|
+
return Object.assign({}, current, { links: links, remotes: remotes });
|
|
4446
|
+
});
|
|
4447
|
+
publishWorkspaceIcons(links, remotes);
|
|
4448
|
+
}).catch(function () {});
|
|
4449
|
+
};
|
|
4450
|
+
var timer = setInterval(tick, STATUS_POLL_MS);
|
|
4451
|
+
if (timer && typeof timer.unref === 'function') timer.unref();
|
|
4452
|
+
tick();
|
|
4453
|
+
return function () {
|
|
4454
|
+
stopped = true;
|
|
4455
|
+
clearInterval(timer);
|
|
4456
|
+
};
|
|
4457
|
+
}, []);
|
|
4458
|
+
|
|
4343
4459
|
return { data: data, reload: load };
|
|
4344
4460
|
}
|
|
4345
4461
|
|
|
@@ -4939,10 +5055,18 @@ function attributeViolation(name, value, tagName) {
|
|
|
4939
5055
|
return;
|
|
4940
5056
|
}
|
|
4941
5057
|
setView({ loading: true, error: null, data: null });
|
|
4942
|
-
var request = local ? { path: filePath } : Object.assign({ path: filePath }, params);
|
|
5058
|
+
var request = local ? { path: filePath, preview: true } : Object.assign({ path: filePath, preview: true }, params);
|
|
4943
5059
|
apiCall(local ? 'local.read' : 'fs.read', request).then(function (result) {
|
|
4944
|
-
if (result.
|
|
4945
|
-
setView({
|
|
5060
|
+
if (result.tooLarge || result.truncated) {
|
|
5061
|
+
setView({
|
|
5062
|
+
loading: false,
|
|
5063
|
+
error: new Error(t('htmlPreviewTooLarge', { size: formatBytes(result.size), limit: formatBytes(PREVIEW_MAX_BYTES) })),
|
|
5064
|
+
data: null,
|
|
5065
|
+
});
|
|
5066
|
+
return;
|
|
5067
|
+
}
|
|
5068
|
+
if (result.binary) {
|
|
5069
|
+
setView({ loading: false, error: new Error(t('htmlPreviewBinary')), data: null });
|
|
4946
5070
|
return;
|
|
4947
5071
|
}
|
|
4948
5072
|
setView({ loading: false, error: null, data: result });
|
|
@@ -4979,14 +5103,16 @@ function attributeViolation(name, value, tagName) {
|
|
|
4979
5103
|
h('iframe', {
|
|
4980
5104
|
className: 'rw-html-frame',
|
|
4981
5105
|
title: name,
|
|
4982
|
-
|
|
5106
|
+
// allow-scripts runs the page's own JS (charts need it) inside an
|
|
5107
|
+
// opaque origin: no access to the DSH UI, its storage or the tree.
|
|
5108
|
+
sandbox: 'allow-scripts',
|
|
4983
5109
|
srcDoc: data.content || '',
|
|
4984
5110
|
})),
|
|
4985
5111
|
h('div', { className: 'rw-editor-status' },
|
|
4986
5112
|
h('span', { className: 'rw-status-chip' }, 'HTML'),
|
|
4987
5113
|
h('span', { className: 'rw-status-chip' }, formatBytes(data.size || 0)),
|
|
4988
5114
|
h('span', { className: 'rw-fill', style: { flex: '1 1 auto' } }),
|
|
4989
|
-
h('span', { className: 'rw-status-chip' }, t('
|
|
5115
|
+
h('span', { className: 'rw-status-chip' }, t('htmlSandboxed'))));
|
|
4990
5116
|
}
|
|
4991
5117
|
|
|
4992
5118
|
// ── editor ─────────────────────────────────────────────────────────────
|
|
@@ -5150,6 +5276,38 @@ function attributeViolation(name, value, tagName) {
|
|
|
5150
5276
|
return function () { timers.forEach(function (timer) { clearTimeout(timer); }); };
|
|
5151
5277
|
}, [filePath, props.focusLine, load.loading, load.error, content]);
|
|
5152
5278
|
|
|
5279
|
+
// F5: hop between the hits of the current search without leaving the
|
|
5280
|
+
// keyboard — Ctrl+Down / Ctrl+Up move to the next / previous occurrence.
|
|
5281
|
+
useEffect(function () {
|
|
5282
|
+
var query = String(props.hitQuery || '');
|
|
5283
|
+
if (query === '') return undefined;
|
|
5284
|
+
function move(direction) {
|
|
5285
|
+
var area = textareaRef.current;
|
|
5286
|
+
if (!area) return;
|
|
5287
|
+
var haystack = String(content).toLowerCase();
|
|
5288
|
+
var needle = query.toLowerCase();
|
|
5289
|
+
var from = area.selectionStart;
|
|
5290
|
+
var at = direction > 0
|
|
5291
|
+
? haystack.indexOf(needle, Math.min(from + 1, haystack.length))
|
|
5292
|
+
: haystack.lastIndexOf(needle, Math.max(from - 1, 0));
|
|
5293
|
+
if (at < 0) at = direction > 0 ? haystack.indexOf(needle) : haystack.lastIndexOf(needle);
|
|
5294
|
+
if (at < 0) return;
|
|
5295
|
+
area.focus();
|
|
5296
|
+
try { area.setSelectionRange(at, at + needle.length); } catch (error) { /* not focusable yet */ }
|
|
5297
|
+
var lineIndex = haystack.slice(0, at).split('\n').length - 1;
|
|
5298
|
+
area.scrollTop = Math.max(0, (lineIndex - 4) * 18);
|
|
5299
|
+
if (highlightRef.current) highlightRef.current.scrollTop = area.scrollTop;
|
|
5300
|
+
if (gutterRef.current) gutterRef.current.scrollTop = area.scrollTop;
|
|
5301
|
+
}
|
|
5302
|
+
function onKey(event) {
|
|
5303
|
+
if (!event.ctrlKey && !event.metaKey) return;
|
|
5304
|
+
if (event.key === 'ArrowDown') { event.preventDefault(); move(1); }
|
|
5305
|
+
else if (event.key === 'ArrowUp') { event.preventDefault(); move(-1); }
|
|
5306
|
+
}
|
|
5307
|
+
window.addEventListener('keydown', onKey, true);
|
|
5308
|
+
return function () { window.removeEventListener('keydown', onKey, true); };
|
|
5309
|
+
}, [props.hitQuery, content]);
|
|
5310
|
+
|
|
5153
5311
|
useEffect(function () {
|
|
5154
5312
|
if (!sidebar || typeof sidebar.updateTab !== 'function' || !props.tabId) return;
|
|
5155
5313
|
try {
|
|
@@ -6101,6 +6259,26 @@ function attributeViolation(name, value, tagName) {
|
|
|
6101
6259
|
// F6: the settings page can replay the card, so the flag is cleared and an
|
|
6102
6260
|
// event wakes the overlay instead of the user hunting for local storage.
|
|
6103
6261
|
var WELCOME_EVENT = 'dsh-linked-workspace:welcome-open';
|
|
6262
|
+
var SHOW_HIDDEN_KEY = 'dsh-linked-workspace:show-hidden';
|
|
6263
|
+
|
|
6264
|
+
function readShowHidden() {
|
|
6265
|
+
try {
|
|
6266
|
+
var stored = window.localStorage.getItem(SHOW_HIDDEN_KEY);
|
|
6267
|
+
if (stored === '0') return false;
|
|
6268
|
+
if (stored === '1') return true;
|
|
6269
|
+
} catch (error) {
|
|
6270
|
+
/* private mode: fall through to the default */
|
|
6271
|
+
}
|
|
6272
|
+
return true;
|
|
6273
|
+
}
|
|
6274
|
+
|
|
6275
|
+
function rememberShowHidden(value) {
|
|
6276
|
+
try {
|
|
6277
|
+
window.localStorage.setItem(SHOW_HIDDEN_KEY, value ? '1' : '0');
|
|
6278
|
+
} catch (error) {
|
|
6279
|
+
/* ignore quota / private mode */
|
|
6280
|
+
}
|
|
6281
|
+
}
|
|
6104
6282
|
|
|
6105
6283
|
function welcomeSeen() {
|
|
6106
6284
|
try {
|
|
@@ -6117,6 +6295,35 @@ function attributeViolation(name, value, tagName) {
|
|
|
6117
6295
|
} catch (error) { /* storage unavailable: the card simply shows again */ }
|
|
6118
6296
|
}
|
|
6119
6297
|
|
|
6298
|
+
// F4: keep the last few content searches so the bar is not blank every time.
|
|
6299
|
+
var SEARCH_HISTORY_KEY = 'dsh-linked-workspace:search-history';
|
|
6300
|
+
var SEARCH_HISTORY_MAX = 8;
|
|
6301
|
+
|
|
6302
|
+
function readSearchHistory() {
|
|
6303
|
+
try {
|
|
6304
|
+
if (typeof window === 'undefined' || !window.localStorage) return [];
|
|
6305
|
+
var raw = window.localStorage.getItem(SEARCH_HISTORY_KEY);
|
|
6306
|
+
if (!raw) return [];
|
|
6307
|
+
var list = JSON.parse(raw);
|
|
6308
|
+
if (!Array.isArray(list)) return [];
|
|
6309
|
+
return list.filter(function (item) { return typeof item === 'string' && item !== ''; }).slice(0, SEARCH_HISTORY_MAX);
|
|
6310
|
+
} catch (error) {
|
|
6311
|
+
return [];
|
|
6312
|
+
}
|
|
6313
|
+
}
|
|
6314
|
+
|
|
6315
|
+
function rememberSearch(term) {
|
|
6316
|
+
var text = String(term || '').trim();
|
|
6317
|
+
if (text === '') return readSearchHistory();
|
|
6318
|
+
var list = readSearchHistory().filter(function (item) { return item !== text; });
|
|
6319
|
+
list.unshift(text);
|
|
6320
|
+
list = list.slice(0, SEARCH_HISTORY_MAX);
|
|
6321
|
+
try {
|
|
6322
|
+
if (typeof window !== 'undefined' && window.localStorage) window.localStorage.setItem(SEARCH_HISTORY_KEY, JSON.stringify(list));
|
|
6323
|
+
} catch (error) { /* storage unavailable: history stays in memory */ }
|
|
6324
|
+
return list;
|
|
6325
|
+
}
|
|
6326
|
+
|
|
6120
6327
|
function WelcomeRow(props) {
|
|
6121
6328
|
return h('div', { className: 'rw-welcome-row' },
|
|
6122
6329
|
h('div', { className: 'rw-welcome-row-main' }, props.main),
|
|
@@ -6186,10 +6393,57 @@ function attributeViolation(name, value, tagName) {
|
|
|
6186
6393
|
}
|
|
6187
6394
|
|
|
6188
6395
|
function DialogShell(props) {
|
|
6396
|
+
var boxRef = useRef(null);
|
|
6397
|
+
var restoreRef = useRef(null);
|
|
6398
|
+
useEffect(function () {
|
|
6399
|
+
restoreRef.current = typeof document === 'undefined' ? null : document.activeElement;
|
|
6400
|
+
var box = boxRef.current;
|
|
6401
|
+
if (box) {
|
|
6402
|
+
var target = box.querySelector('input:not([disabled]), textarea:not([disabled]), select:not([disabled])')
|
|
6403
|
+
|| box.querySelector('button:not([disabled])')
|
|
6404
|
+
|| box;
|
|
6405
|
+
try { target.focus(); } catch (error) { /* focus is cosmetic */ }
|
|
6406
|
+
}
|
|
6407
|
+
return function () {
|
|
6408
|
+
var previous = restoreRef.current;
|
|
6409
|
+
if (previous && typeof previous.focus === 'function') {
|
|
6410
|
+
try { previous.focus(); } catch (error) { /* the row may be gone */ }
|
|
6411
|
+
}
|
|
6412
|
+
};
|
|
6413
|
+
}, []);
|
|
6414
|
+
useEffect(function () {
|
|
6415
|
+
function onKey(event) {
|
|
6416
|
+
if (event.key === 'Escape') {
|
|
6417
|
+
event.preventDefault();
|
|
6418
|
+
event.stopPropagation();
|
|
6419
|
+
props.onClose();
|
|
6420
|
+
return;
|
|
6421
|
+
}
|
|
6422
|
+
if (event.key !== 'Tab') return;
|
|
6423
|
+
var box = boxRef.current;
|
|
6424
|
+
if (!box) return;
|
|
6425
|
+
var nodes = box.querySelectorAll('input:not([disabled]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex="-1"])');
|
|
6426
|
+
var focusable = [].slice.call(nodes).filter(function (node) { return node.offsetParent !== null; });
|
|
6427
|
+
if (focusable.length === 0) return;
|
|
6428
|
+
var first = focusable[0];
|
|
6429
|
+
var last = focusable[focusable.length - 1];
|
|
6430
|
+
if (event.shiftKey && document.activeElement === first) { event.preventDefault(); last.focus(); }
|
|
6431
|
+
else if (!event.shiftKey && document.activeElement === last) { event.preventDefault(); first.focus(); }
|
|
6432
|
+
}
|
|
6433
|
+
window.addEventListener('keydown', onKey, true);
|
|
6434
|
+
return function () { window.removeEventListener('keydown', onKey, true); };
|
|
6435
|
+
}, [props.onClose]);
|
|
6189
6436
|
return h('div', {
|
|
6190
6437
|
className: 'rw-dialog-backdrop',
|
|
6191
6438
|
onMouseDown: function (event) { if (event.target === event.currentTarget) props.onClose(); },
|
|
6192
|
-
}, h('div', {
|
|
6439
|
+
}, h('div', {
|
|
6440
|
+
className: 'rw-dialog',
|
|
6441
|
+
ref: boxRef,
|
|
6442
|
+
role: 'dialog',
|
|
6443
|
+
'aria-modal': 'true',
|
|
6444
|
+
'aria-label': typeof props.title === 'string' ? props.title : undefined,
|
|
6445
|
+
tabIndex: -1,
|
|
6446
|
+
},
|
|
6193
6447
|
h('div', { className: 'rw-dialog-title' }, props.title),
|
|
6194
6448
|
props.children));
|
|
6195
6449
|
}
|
|
@@ -6466,6 +6720,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
6466
6720
|
}
|
|
6467
6721
|
|
|
6468
6722
|
function QueueDialog(props) {
|
|
6723
|
+
var history = props.history && props.history.length > 0 ? props.history : null;
|
|
6469
6724
|
return h(DialogShell, { title: props.title, onClose: props.onClose },
|
|
6470
6725
|
props.queue.length === 0
|
|
6471
6726
|
? h('div', { className: 'rw-dialog-message' }, props.t('queueEmpty'))
|
|
@@ -6489,6 +6744,15 @@ function attributeViolation(name, value, tagName) {
|
|
|
6489
6744
|
}, props.t('queueRetry'))
|
|
6490
6745
|
: null);
|
|
6491
6746
|
}),
|
|
6747
|
+
history
|
|
6748
|
+
? h('div', { className: 'rw-queue-history' },
|
|
6749
|
+
h('div', { className: 'rw-queue-history-title' }, props.t('transferHistoryTitle')),
|
|
6750
|
+
history.slice().reverse().map(function (item) {
|
|
6751
|
+
return h('div', { key: item.id, className: 'rw-queue-row is-history' },
|
|
6752
|
+
h('span', { className: 'rw-queue-label' }, item.label),
|
|
6753
|
+
h('span', { className: 'rw-queue-state' }, item.message || item.state));
|
|
6754
|
+
}))
|
|
6755
|
+
: null,
|
|
6492
6756
|
h('div', { className: 'rw-dialog-actions' },
|
|
6493
6757
|
props.queue.some(function (entry) { return entry.state === 'done' || entry.state === 'error'; })
|
|
6494
6758
|
? h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: props.onClear }, props.t('queueClear'))
|
|
@@ -6932,6 +7196,28 @@ function attributeViolation(name, value, tagName) {
|
|
|
6932
7196
|
var queueState = useState([]);
|
|
6933
7197
|
var queueList = queueState[0];
|
|
6934
7198
|
var setQueueList = queueState[1];
|
|
7199
|
+
// F6: keep the last finished transfers so closing the queue dialog does
|
|
7200
|
+
// not lose the record of what actually went through.
|
|
7201
|
+
var transferHistoryState = useState([]);
|
|
7202
|
+
var transferHistory = transferHistoryState[0];
|
|
7203
|
+
var setTransferHistory = transferHistoryState[1];
|
|
7204
|
+
useEffect(function () {
|
|
7205
|
+
var finished = queueList.filter(function (entry) {
|
|
7206
|
+
return entry.state === 'done' || entry.state === 'error' || entry.state === 'cancelled';
|
|
7207
|
+
});
|
|
7208
|
+
if (finished.length === 0) return;
|
|
7209
|
+
setTransferHistory(function (previous) {
|
|
7210
|
+
var seen = {};
|
|
7211
|
+
previous.forEach(function (item) { seen[item.id] = true; });
|
|
7212
|
+
var next = previous.slice();
|
|
7213
|
+
finished.forEach(function (entry) {
|
|
7214
|
+
if (seen[entry.id]) return;
|
|
7215
|
+
seen[entry.id] = true;
|
|
7216
|
+
next.push({ id: entry.id, label: entry.label, state: entry.state, message: entry.message || entry.state });
|
|
7217
|
+
});
|
|
7218
|
+
return next.slice(-20);
|
|
7219
|
+
});
|
|
7220
|
+
}, [queueList]);
|
|
6935
7221
|
var queueRef = useRef([]);
|
|
6936
7222
|
var queueRunning = useRef(false);
|
|
6937
7223
|
var selectedEntryState = useState(null);
|
|
@@ -6942,14 +7228,16 @@ function attributeViolation(name, value, tagName) {
|
|
|
6942
7228
|
var setMulti = multiState[1];
|
|
6943
7229
|
// Anchor for Shift+click range selection (a ref: it must not re-render).
|
|
6944
7230
|
var selectionAnchorRef = useRef(null);
|
|
6945
|
-
var showHiddenState = useState(
|
|
7231
|
+
var showHiddenState = useState(readShowHidden);
|
|
6946
7232
|
var showHidden = showHiddenState[0];
|
|
6947
7233
|
var setShowHidden = showHiddenState[1];
|
|
6948
7234
|
// A refresh only reloads this bundle, so the running Host may be older.
|
|
6949
7235
|
var hostStaleState = useState(false);
|
|
6950
7236
|
var hostStale = hostStaleState[0];
|
|
6951
7237
|
var setHostStale = hostStaleState[1];
|
|
6952
|
-
|
|
7238
|
+
var searchHistoryState = useState(readSearchHistory);
|
|
7239
|
+
var searchHistory = searchHistoryState[0];
|
|
7240
|
+
var setSearchHistory = searchHistoryState[1]; useEffect(function () {
|
|
6953
7241
|
var alive = true;
|
|
6954
7242
|
probeHostInfo().then(function (result) {
|
|
6955
7243
|
if (alive && result && result.stale) setHostStale(true);
|
|
@@ -6988,6 +7276,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
6988
7276
|
localPath: null,
|
|
6989
7277
|
placeholderPath: item.placeholderPath,
|
|
6990
7278
|
remotePath: item.remotePath,
|
|
7279
|
+
hostId: item.hostId,
|
|
6991
7280
|
host: item.host,
|
|
6992
7281
|
username: item.username,
|
|
6993
7282
|
hostName: item.hostName,
|
|
@@ -7002,6 +7291,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
7002
7291
|
name: item.name,
|
|
7003
7292
|
localPath: item.localPath,
|
|
7004
7293
|
remotePath: item.remotePath,
|
|
7294
|
+
hostId: item.hostId,
|
|
7005
7295
|
host: item.host,
|
|
7006
7296
|
username: item.username,
|
|
7007
7297
|
hostName: item.hostName,
|
|
@@ -7034,6 +7324,22 @@ function attributeViolation(name, value, tagName) {
|
|
|
7034
7324
|
|
|
7035
7325
|
var scopeRef = selected ? sourceScopeOf(selected) : null;
|
|
7036
7326
|
|
|
7327
|
+
// Free space on the remote volume (F2): fetched once per workspace and
|
|
7328
|
+
// refreshed when the tree is refreshed. Cheap enough to keep on screen.
|
|
7329
|
+
var diskState = useState(null);
|
|
7330
|
+
var disk = diskState[0];
|
|
7331
|
+
var setDisk = diskState[1];
|
|
7332
|
+
var diskHostId = selected && selected.hostId ? selected.hostId : '';
|
|
7333
|
+
var diskPath = selected && selected.remotePath ? selected.remotePath : '';
|
|
7334
|
+
useEffect(function () {
|
|
7335
|
+
if (!diskHostId) { setDisk(null); return; }
|
|
7336
|
+
var alive = true;
|
|
7337
|
+
apiCall('hosts.df', { hostId: diskHostId, path: diskPath || undefined }).then(function (result) {
|
|
7338
|
+
if (alive) setDisk(result && result.disk ? result.disk : null);
|
|
7339
|
+
}).catch(function () { if (alive) setDisk(null); });
|
|
7340
|
+
return function () { alive = false; };
|
|
7341
|
+
}, [diskHostId, diskPath]);
|
|
7342
|
+
|
|
7037
7343
|
var openFilesState = useState([]);
|
|
7038
7344
|
var openFiles = openFilesState[0];
|
|
7039
7345
|
var setOpenFiles = openFilesState[1];
|
|
@@ -7134,6 +7440,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
7134
7440
|
function showNotice(kind, text) {
|
|
7135
7441
|
if (noticeTimer.current) clearTimeout(noticeTimer.current);
|
|
7136
7442
|
setNotice({ kind: kind, text: text });
|
|
7443
|
+
// Errors stay until dismissed: they can carry a whole SSH message and
|
|
7444
|
+
// the user may want to read or copy it.
|
|
7445
|
+
if (kind === 'error') return;
|
|
7137
7446
|
noticeTimer.current = setTimeout(function () { setNotice(null); }, 4200);
|
|
7138
7447
|
}
|
|
7139
7448
|
|
|
@@ -7143,6 +7452,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
7143
7452
|
}
|
|
7144
7453
|
|
|
7145
7454
|
function refreshTree() {
|
|
7455
|
+
clearStaleError();
|
|
7146
7456
|
bumpVersion(function (value) { return value + 1; });
|
|
7147
7457
|
data.reload();
|
|
7148
7458
|
}
|
|
@@ -7192,6 +7502,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
7192
7502
|
|
|
7193
7503
|
function openByMode(side, filePath, options) {
|
|
7194
7504
|
if (!selected || !filePath) return;
|
|
7505
|
+
clearStaleError();
|
|
7195
7506
|
var openMode = settings.fileOpenMode || 'editor';
|
|
7196
7507
|
if (openMode === 'copy') {
|
|
7197
7508
|
try {
|
|
@@ -7330,6 +7641,14 @@ function attributeViolation(name, value, tagName) {
|
|
|
7330
7641
|
showNotice('error', t('actionFailed') + ':' + messageOf(error, t, locale));
|
|
7331
7642
|
}
|
|
7332
7643
|
|
|
7644
|
+
// Errors stay on screen until the user closes them, so anything that
|
|
7645
|
+
// navigates or starts a new job drops the old one first.
|
|
7646
|
+
function clearStaleError() {
|
|
7647
|
+
setNotice(function (previous) {
|
|
7648
|
+
return previous && previous.kind === 'error' ? null : previous;
|
|
7649
|
+
});
|
|
7650
|
+
}
|
|
7651
|
+
|
|
7333
7652
|
// Ctrl/Cmd-click toggles an entry in the multi-selection; a plain click
|
|
7334
7653
|
// collapses the selection to that entry (Shift extends it).
|
|
7335
7654
|
function updateSelection(side, info) {
|
|
@@ -7403,6 +7722,22 @@ function attributeViolation(name, value, tagName) {
|
|
|
7403
7722
|
} catch (error) { /* clipboard unavailable */ }
|
|
7404
7723
|
}
|
|
7405
7724
|
|
|
7725
|
+
/** Copy a ready-made ssh command that lands in the given remote directory. */
|
|
7726
|
+
function copySshCommand(dirPath) {
|
|
7727
|
+
var source = selected || {};
|
|
7728
|
+
var target = source.hostName
|
|
7729
|
+
? source.hostName
|
|
7730
|
+
: (source.username ? source.username + '@' : '') + (source.host || '');
|
|
7731
|
+
if (!target) return;
|
|
7732
|
+
var command = 'ssh ' + target + " -t 'cd " + String(dirPath).replace(/'/g, "'\\''") + " && exec $SHELL -l'";
|
|
7733
|
+
try {
|
|
7734
|
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
7735
|
+
navigator.clipboard.writeText(command).then(function () { showNotice('success', t('sshCopied')); }).catch(function () {});
|
|
7736
|
+
return;
|
|
7737
|
+
}
|
|
7738
|
+
} catch (error) { /* clipboard unavailable */ }
|
|
7739
|
+
}
|
|
7740
|
+
|
|
7406
7741
|
function enqueueTransfer(side, filePath, name) {
|
|
7407
7742
|
var entry = {
|
|
7408
7743
|
id: String(Date.now()) + Math.random().toString(16).slice(2),
|
|
@@ -7438,6 +7773,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
7438
7773
|
next.files = 0;
|
|
7439
7774
|
next.bytes = 0;
|
|
7440
7775
|
next.message = t('queueRunning');
|
|
7776
|
+
next.startedAt = Date.now();
|
|
7441
7777
|
setQueueList(queueRef.current.slice());
|
|
7442
7778
|
// Poll the Host while the transfer runs: a folder can take minutes and
|
|
7443
7779
|
// the row otherwise sits on “running” with no evidence of progress.
|
|
@@ -7447,7 +7783,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
7447
7783
|
if (!job || next.state !== 'running') return;
|
|
7448
7784
|
next.files = job.files;
|
|
7449
7785
|
next.bytes = job.bytes;
|
|
7450
|
-
|
|
7786
|
+
var span = (Date.now() - (next.startedAt || Date.now())) / 1000;
|
|
7787
|
+
next.message = t('queueProgress', { files: job.files, size: formatBytes(job.bytes) })
|
|
7788
|
+
+ (span >= 1 && job.bytes > 0 ? ' · ' + formatBytes(job.bytes / span) + '/s' : '');
|
|
7451
7789
|
setQueueList(queueRef.current.slice());
|
|
7452
7790
|
}).catch(function () { /* progress is best-effort */ });
|
|
7453
7791
|
}, 700);
|
|
@@ -7469,12 +7807,55 @@ function attributeViolation(name, value, tagName) {
|
|
|
7469
7807
|
});
|
|
7470
7808
|
}
|
|
7471
7809
|
|
|
7810
|
+
function downloadSuffix(result) {
|
|
7811
|
+
var text = '';
|
|
7812
|
+
if (result.truncated) text += ' · ' + t('downloadTruncated');
|
|
7813
|
+
if (result.skipped) text += ' · ' + t('downloadSkipped', { count: result.skipped });
|
|
7814
|
+
return text;
|
|
7815
|
+
}
|
|
7816
|
+
|
|
7472
7817
|
function downloadEntry(entry) {
|
|
7473
|
-
apiCall('fs.download', Object.assign({ path: entry.path }, scopeParams(scopeRef))).then(function (result) {
|
|
7474
|
-
|
|
7818
|
+
return apiCall('fs.download', Object.assign({ path: entry.path }, scopeParams(scopeRef))).then(function (result) {
|
|
7819
|
+
var files = typeof result.files === 'number' ? result.files : 1;
|
|
7820
|
+
var bytes = typeof result.bytes === 'number' ? result.bytes : 0;
|
|
7821
|
+
var summary = result.files === 1 && !result.truncated
|
|
7822
|
+
? t('downloadDone', { path: result.path })
|
|
7823
|
+
: t('downloadManyDone', { count: 1, files: files, size: formatBytes(bytes) }) + ' · ' + t('downloadDone', { path: result.path });
|
|
7824
|
+
var kind = result.truncated || result.skipped ? 'warn' : 'success';
|
|
7825
|
+
showNotice(kind, summary + downloadSuffix(result));
|
|
7826
|
+
return result;
|
|
7475
7827
|
}).catch(noticeError);
|
|
7476
7828
|
}
|
|
7477
7829
|
|
|
7830
|
+
/** Download several selected remote entries one after another. */
|
|
7831
|
+
function downloadSelected(entries) {
|
|
7832
|
+
var batch = (entries || []).filter(function (item) { return item.side === 'remote'; });
|
|
7833
|
+
if (batch.length === 0) return;
|
|
7834
|
+
var files = 0;
|
|
7835
|
+
var bytes = 0;
|
|
7836
|
+
var skipped = 0;
|
|
7837
|
+
var truncated = 0;
|
|
7838
|
+
var failed = 0;
|
|
7839
|
+
var chain = Promise.resolve();
|
|
7840
|
+
batch.forEach(function (item) {
|
|
7841
|
+
chain = chain.then(function () {
|
|
7842
|
+
return apiCall('fs.download', Object.assign({ path: item.path }, scopeParams(scopeRef))).then(function (result) {
|
|
7843
|
+
files += typeof result.files === 'number' ? result.files : 1;
|
|
7844
|
+
bytes += typeof result.bytes === 'number' ? result.bytes : 0;
|
|
7845
|
+
skipped += result.skipped || 0;
|
|
7846
|
+
if (result.truncated) truncated += 1;
|
|
7847
|
+
}).catch(function () { failed += 1; });
|
|
7848
|
+
});
|
|
7849
|
+
});
|
|
7850
|
+
chain.then(function () {
|
|
7851
|
+
var text = t('downloadManyDone', { count: batch.length, files: files, size: formatBytes(bytes) });
|
|
7852
|
+
if (truncated) text += ' · ' + t('downloadTruncated');
|
|
7853
|
+
if (skipped) text += ' · ' + t('downloadSkipped', { count: skipped });
|
|
7854
|
+
if (failed) text += ' · ' + t('downloadFailed', { count: failed });
|
|
7855
|
+
showNotice(truncated || skipped || failed ? 'warn' : 'success', text);
|
|
7856
|
+
});
|
|
7857
|
+
}
|
|
7858
|
+
|
|
7478
7859
|
function editNotepad(side, filePath) {
|
|
7479
7860
|
var method = side === 'remote' ? 'fs.edit' : 'local.edit';
|
|
7480
7861
|
var params = side === 'remote'
|
|
@@ -7863,6 +8244,10 @@ function attributeViolation(name, value, tagName) {
|
|
|
7863
8244
|
} });
|
|
7864
8245
|
}
|
|
7865
8246
|
items.push({ label: t('ctxDeleteSelected', { count: batch.length }), onSelect: deleteSelection });
|
|
8247
|
+
var downloadable = batch.filter(function (item) { return item.side === 'remote'; });
|
|
8248
|
+
if (downloadable.length > 0) {
|
|
8249
|
+
items.push({ label: t('ctxDownloadSelected', { count: downloadable.length }), onSelect: function () { downloadSelected(downloadable); } });
|
|
8250
|
+
}
|
|
7866
8251
|
if (batch.some(function (item) { return item.path === menu.path; })) {
|
|
7867
8252
|
items.push({ label: t('ctxMoveSelected', { count: batch.length }), onSelect: function () {
|
|
7868
8253
|
setDialog({
|
|
@@ -7902,6 +8287,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
7902
8287
|
items.push({ label: t('ctxPaste'), disabled: !canPaste, onSelect: function () { pasteEntry(menu); } });
|
|
7903
8288
|
items.push({ separator: true });
|
|
7904
8289
|
items.push({ label: t('ctxCopyPath'), onSelect: function () { copyPathToClipboard(menu.path); } });
|
|
8290
|
+
if (menu.side === 'remote' && menu.isDir) {
|
|
8291
|
+
items.push({ label: t('ctxCopySsh'), onSelect: function () { copySshCommand(menu.path); } });
|
|
8292
|
+
}
|
|
7905
8293
|
items.push({ separator: true });
|
|
7906
8294
|
var rootPath = menu.side === 'remote' ? selected.remotePath : selected.localPath;
|
|
7907
8295
|
if (menu.path !== rootPath) {
|
|
@@ -7912,15 +8300,23 @@ function attributeViolation(name, value, tagName) {
|
|
|
7912
8300
|
});
|
|
7913
8301
|
} });
|
|
7914
8302
|
}
|
|
7915
|
-
|
|
7916
|
-
|
|
7917
|
-
|
|
7918
|
-
|
|
7919
|
-
|
|
7920
|
-
|
|
7921
|
-
|
|
7922
|
-
|
|
7923
|
-
|
|
8303
|
+
if (menu.path !== rootPath) {
|
|
8304
|
+
items.push({ label: t('ctxRename'), onSelect: function () {
|
|
8305
|
+
setDialog({ kind: 'rename', side: menu.side, path: menu.path, value: menu.name, title: t('renameTitle'), label: t('renameLabel') });
|
|
8306
|
+
} });
|
|
8307
|
+
items.push({ label: t('ctxDelete'), onSelect: function () {
|
|
8308
|
+
setDialog({ kind: 'delete', side: menu.side, path: menu.path, name: menu.name, isDir: menu.isDir });
|
|
8309
|
+
} });
|
|
8310
|
+
// The Host refuses chmod on the workspace root: a stray 644 there makes
|
|
8311
|
+
// the whole tree look empty, so the entry is not offered at all.
|
|
8312
|
+
items.push({ label: t('ctxChmod'), onSelect: function () {
|
|
8313
|
+
setDialog({
|
|
8314
|
+
kind: 'chmod', side: menu.side, path: menu.path, title: t('chmodTitle'),
|
|
8315
|
+
label: menu.isDir ? t('chmodLabelDir') : t('chmodLabel'),
|
|
8316
|
+
value: menu.isDir ? '755' : '644',
|
|
8317
|
+
});
|
|
8318
|
+
} });
|
|
8319
|
+
}
|
|
7924
8320
|
if (menu.isDir) {
|
|
7925
8321
|
items.push({ separator: true });
|
|
7926
8322
|
items.push({ label: t('ctxTerminalHere'), onSelect: function () { openTerminal(menu.side, menu.path); } });
|
|
@@ -7983,6 +8379,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
7983
8379
|
t: t,
|
|
7984
8380
|
title: t('queueTitle'),
|
|
7985
8381
|
queue: queueList,
|
|
8382
|
+
history: transferHistory,
|
|
7986
8383
|
onClose: function () { setDialog(null); },
|
|
7987
8384
|
onClear: function () {
|
|
7988
8385
|
queueRef.current = queueRef.current.filter(function (entry) { return entry.state !== 'done' && entry.state !== 'error'; });
|
|
@@ -8118,6 +8515,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
8118
8515
|
}
|
|
8119
8516
|
var alive = true;
|
|
8120
8517
|
var timer = setTimeout(function () {
|
|
8518
|
+
clearStaleError();
|
|
8121
8519
|
setSearch(function (previous) { return { loading: true, remote: previous.remote, local: previous.local, truncated: false, truncatedReason: '', error: null }; });
|
|
8122
8520
|
var scopeNow = sourceScopeOf(selected);
|
|
8123
8521
|
var contentMode = searchMode === 'content';
|
|
@@ -8167,8 +8565,18 @@ function attributeViolation(name, value, tagName) {
|
|
|
8167
8565
|
}
|
|
8168
8566
|
|
|
8169
8567
|
var info = null;
|
|
8170
|
-
if (notice)
|
|
8171
|
-
|
|
8568
|
+
if (notice) {
|
|
8569
|
+
info = h('div', { className: 'rw-linked-notice', role: 'status', 'aria-live': 'polite' },
|
|
8570
|
+
h(Banner, { kind: notice.kind },
|
|
8571
|
+
h('div', { className: 'rw-notice-body' },
|
|
8572
|
+
h('span', { className: 'rw-notice-text' }, notice.text),
|
|
8573
|
+
h('button', {
|
|
8574
|
+
type: 'button',
|
|
8575
|
+
className: 'rw-icon-btn',
|
|
8576
|
+
title: t('close'),
|
|
8577
|
+
onClick: function () { setNotice(null); },
|
|
8578
|
+
}, IconClose(12)))));
|
|
8579
|
+
} else if (data.data.error) info = h('div', { className: 'rw-linked-notice' }, h(Banner, { kind: 'error' }, t('workspacesFailed') + ':' + messageOf(data.data.error, t, locale)));
|
|
8172
8580
|
if (hostStale) {
|
|
8173
8581
|
var staleNotice = h('div', { className: 'rw-linked-notice' }, h(Banner, { kind: 'warn' }, t('staleHost')));
|
|
8174
8582
|
info = info ? h('div', null, staleNotice, info) : staleNotice;
|
|
@@ -8290,6 +8698,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
8290
8698
|
local: activeFile.side === 'local',
|
|
8291
8699
|
hideHeader: true,
|
|
8292
8700
|
focusLine: activeFile.line || 0,
|
|
8701
|
+
hitQuery: searchQuery,
|
|
8293
8702
|
onSaveReady: function (handler) {
|
|
8294
8703
|
if (handler) saveHandlersRef.current[activeFile.key] = handler;
|
|
8295
8704
|
else delete saveHandlersRef.current[activeFile.key];
|
|
@@ -8320,7 +8729,11 @@ function attributeViolation(name, value, tagName) {
|
|
|
8320
8729
|
onOpenTerminal: openTerminal,
|
|
8321
8730
|
localEnabled: !remoteOnly && selected.kind === 'linked',
|
|
8322
8731
|
showHidden: showHidden,
|
|
8323
|
-
onToggleHidden: function () {
|
|
8732
|
+
onToggleHidden: function () {
|
|
8733
|
+
var next = !showHidden;
|
|
8734
|
+
rememberShowHidden(next);
|
|
8735
|
+
setShowHidden(next);
|
|
8736
|
+
},
|
|
8324
8737
|
transferEnabled: selected.kind === 'linked' && (multi.length > 0 || Boolean(selectedEntry)),
|
|
8325
8738
|
transferTitle: selected.kind === 'linked' ? undefined : t('transferNeedsLinked'),
|
|
8326
8739
|
transferSelected: function () {
|
|
@@ -8358,6 +8771,11 @@ function attributeViolation(name, value, tagName) {
|
|
|
8358
8771
|
autoFocus: true,
|
|
8359
8772
|
onChange: function (event) { setSearchQuery(event.currentTarget.value); },
|
|
8360
8773
|
onKeyDown: function (event) {
|
|
8774
|
+
if (event.key === 'Enter') {
|
|
8775
|
+
var remembered = rememberSearch(searchQuery);
|
|
8776
|
+
setSearchHistory(remembered);
|
|
8777
|
+
return;
|
|
8778
|
+
}
|
|
8361
8779
|
if (event.key !== 'ArrowDown') return;
|
|
8362
8780
|
// Landing on the first hit without leaving the keyboard is the
|
|
8363
8781
|
// whole point of the list shortcuts.
|
|
@@ -8398,6 +8816,19 @@ function attributeViolation(name, value, tagName) {
|
|
|
8398
8816
|
onClick: function () { setSearchOpen(false); setSearchQuery(''); },
|
|
8399
8817
|
}, IconClose(12)))
|
|
8400
8818
|
: null,
|
|
8819
|
+
searchOpen && searchMode === 'content' && searchQuery === '' && searchHistory.length > 0
|
|
8820
|
+
? h('div', { className: 'rw-search-history' },
|
|
8821
|
+
h('span', { className: 'rw-search-history-label' }, t('searchRecent')),
|
|
8822
|
+
searchHistory.map(function (term) {
|
|
8823
|
+
return h('button', {
|
|
8824
|
+
key: term,
|
|
8825
|
+
type: 'button',
|
|
8826
|
+
className: 'rw-chip-btn',
|
|
8827
|
+
title: term,
|
|
8828
|
+
onClick: function () { setSearchQuery(term); },
|
|
8829
|
+
}, h('span', { style: { overflow: 'hidden', textOverflow: 'ellipsis', maxWidth: '160px' } }, term));
|
|
8830
|
+
}))
|
|
8831
|
+
: null,
|
|
8401
8832
|
sources.length > 1
|
|
8402
8833
|
? h('div', { className: 'rw-chips' },
|
|
8403
8834
|
sources.map(function (source) {
|
|
@@ -8446,6 +8877,12 @@ function attributeViolation(name, value, tagName) {
|
|
|
8446
8877
|
h('div', { className: 'rw-directory-head' },
|
|
8447
8878
|
IconFolder(11, false),
|
|
8448
8879
|
h('span', { style: { flex: '1 1 auto', minWidth: 0 } }, remoteOnly ? t('remoteTabTitle') : t('tabTitle')),
|
|
8880
|
+
disk
|
|
8881
|
+
? h('span', {
|
|
8882
|
+
className: 'rw-disk',
|
|
8883
|
+
title: (disk.path ? disk.path + ' · ' : '') + t('diskFree', { free: formatBytes(disk.avail), percent: disk.percent }) + (disk.used ? ' · ' + formatBytes(disk.used) + ' / ' + formatBytes(disk.size) : ''),
|
|
8884
|
+
}, formatBytes(disk.avail))
|
|
8885
|
+
: null,
|
|
8449
8886
|
h('button', { type: 'button', className: 'rw-icon-btn', title: t('toggleDirectory'), onClick: function () { setDirectoryOpen(false); } }, IconClose(11))),
|
|
8450
8887
|
h('div', { className: 'rw-directory-body' }, body))
|
|
8451
8888
|
: null),
|