dsh-linked-workspace 0.13.0 → 0.14.0
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 +15 -0
- package/README.en.md +4 -3
- package/README.md +4 -3
- package/docs/API.md +5 -2
- package/docs/VERIFY.md +13 -5
- package/lib/client.js +614 -44
- package/lib/index.js +248 -50
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -2139,6 +2139,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
2139
2139
|
welcomePasswordWhere: '添加工作区时直接填 SSH 密码,只保存在本机',
|
|
2140
2140
|
welcomeStar: '★ 点个 Star',
|
|
2141
2141
|
welcomeDone: '知道了',
|
|
2142
|
+
welcomeReplay: '再次查看欢迎卡片',
|
|
2142
2143
|
intro: '把 SSH 连接变成工作区:联动工作区把本地目录与远端目录配对,远程工作区让会话直接运行在远端目录。会话都能读取、搜索和编辑远端文件。',
|
|
2143
2144
|
addWorkspace: '添加工作区',
|
|
2144
2145
|
addLinked: '添加联动工作区',
|
|
@@ -2248,6 +2249,14 @@ function attributeViolation(name, value, tagName) {
|
|
|
2248
2249
|
filterPlaceholder: '按名称过滤…',
|
|
2249
2250
|
filterEmpty: '没有匹配当前过滤条件的条目',
|
|
2250
2251
|
searchTruncated: '结果过多,仅显示前 200 条;请输入更精确的关键词',
|
|
2252
|
+
searchTruncatedFiles: '文件太多,搜索结果不完整;请缩小目录范围或换个关键词',
|
|
2253
|
+
searchTruncatedBytes: '读取的文件总量已达上限,搜索结果不完整;请缩小目录范围',
|
|
2254
|
+
searchTruncatedDeadline: '搜索超时,结果不完整;请缩小目录范围或换个关键词',
|
|
2255
|
+
searchCase: '区分大小写',
|
|
2256
|
+
searchRegex: '正则表达式',
|
|
2257
|
+
searchScopeAll: '整个工作区',
|
|
2258
|
+
searchScopeHere: '只搜当前目录',
|
|
2259
|
+
searchScopeLabel: '范围:{{scope}}',
|
|
2251
2260
|
findPlaceholder: '查找…',
|
|
2252
2261
|
replacePlaceholder: '替换为…',
|
|
2253
2262
|
findCounter: '第 {{index}} / {{total}} 个',
|
|
@@ -2329,6 +2338,24 @@ function attributeViolation(name, value, tagName) {
|
|
|
2329
2338
|
searchModeContent: '内容',
|
|
2330
2339
|
searchPlaceholderContent: '在文件内容中搜索…',
|
|
2331
2340
|
queueRetry: '重试',
|
|
2341
|
+
rowModifiedAt: '修改于 {{when}}',
|
|
2342
|
+
ctxRenameSelected: '批量重命名所选的 {{count}} 项…',
|
|
2343
|
+
renameManyTitle: '批量重命名 {{count}} 项',
|
|
2344
|
+
renameManyPattern: '按序号',
|
|
2345
|
+
renameManyReplace: '查找替换',
|
|
2346
|
+
renameManyPrefix: '前缀',
|
|
2347
|
+
renameManyStart: '起始序号',
|
|
2348
|
+
renameManyPad: '序号位数',
|
|
2349
|
+
renameManyFind: '查找',
|
|
2350
|
+
renameManyReplaceWith: '替换为',
|
|
2351
|
+
renameManyEmpty: '(名称不能为空)',
|
|
2352
|
+
renameManyConflict: '有重名,先调整规则再重命名',
|
|
2353
|
+
renameManyApply: '重命名 {{count}} 项',
|
|
2354
|
+
renameManyDone: '已重命名 {{count}} 项',
|
|
2355
|
+
queueCancel: '取消',
|
|
2356
|
+
queueProgress: '已传 {{files}} 个 · {{size}}',
|
|
2357
|
+
queueCancelling: '正在取消…',
|
|
2358
|
+
queueCancelled: '已取消(已传 {{files}} 个)',
|
|
2332
2359
|
shortcutWebNote: 'Web GUI 中 Ctrl+W、Ctrl+Tab 由浏览器占用,请在 DSH 桌面端使用这些快捷键。',
|
|
2333
2360
|
themeTitle: '编辑器主题',
|
|
2334
2361
|
themeHint: '远程文件编辑器的配色;主题只影响本插件的远程文件视图。',
|
|
@@ -2571,6 +2598,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
2571
2598
|
welcomePasswordWhere: 'Type the SSH password when adding a workspace; it stays on this machine',
|
|
2572
2599
|
welcomeStar: '★ Star the repo',
|
|
2573
2600
|
welcomeDone: 'Got it',
|
|
2601
|
+
welcomeReplay: 'Show the welcome card again',
|
|
2574
2602
|
intro: 'Turn an SSH connection into a workspace: a linked workspace pairs a local folder with a remote folder, and a remote workspace runs sessions directly inside the remote folder. Either way sessions can read, search and edit remote files.',
|
|
2575
2603
|
addWorkspace: 'Add workspace',
|
|
2576
2604
|
addRemoteDir: 'Add remote directory',
|
|
@@ -2681,6 +2709,14 @@ function attributeViolation(name, value, tagName) {
|
|
|
2681
2709
|
filterPlaceholder: 'Filter by name…',
|
|
2682
2710
|
filterEmpty: 'No entries match the current filter',
|
|
2683
2711
|
searchTruncated: 'Too many results; showing the first 200. Narrow the query.',
|
|
2712
|
+
searchTruncatedFiles: 'Too many files were scanned; results are incomplete. Narrow the folder or the query.',
|
|
2713
|
+
searchTruncatedBytes: 'The byte budget ran out; results are incomplete. Narrow the folder.',
|
|
2714
|
+
searchTruncatedDeadline: 'The search timed out; results are incomplete. Narrow the folder or the query.',
|
|
2715
|
+
searchCase: 'Match case',
|
|
2716
|
+
searchRegex: 'Regular expression',
|
|
2717
|
+
searchScopeAll: 'Whole workspace',
|
|
2718
|
+
searchScopeHere: 'Current folder only',
|
|
2719
|
+
searchScopeLabel: 'Scope: {{scope}}',
|
|
2684
2720
|
findPlaceholder: 'Find…',
|
|
2685
2721
|
replacePlaceholder: 'Replace with…',
|
|
2686
2722
|
findCounter: '{{index}} / {{total}}',
|
|
@@ -2762,6 +2798,24 @@ function attributeViolation(name, value, tagName) {
|
|
|
2762
2798
|
searchModeContent: 'Content',
|
|
2763
2799
|
searchPlaceholderContent: 'Search file contents…',
|
|
2764
2800
|
queueRetry: 'Retry',
|
|
2801
|
+
rowModifiedAt: 'Modified {{when}}',
|
|
2802
|
+
ctxRenameSelected: 'Rename the {{count}} selected…',
|
|
2803
|
+
renameManyTitle: 'Rename {{count}} entries',
|
|
2804
|
+
renameManyPattern: 'Numbering',
|
|
2805
|
+
renameManyReplace: 'Find and replace',
|
|
2806
|
+
renameManyPrefix: 'Prefix',
|
|
2807
|
+
renameManyStart: 'Start at',
|
|
2808
|
+
renameManyPad: 'Digits',
|
|
2809
|
+
renameManyFind: 'Find',
|
|
2810
|
+
renameManyReplaceWith: 'Replace with',
|
|
2811
|
+
renameManyEmpty: '(name cannot be empty)',
|
|
2812
|
+
renameManyConflict: 'Two entries would share a name — adjust the rule first',
|
|
2813
|
+
renameManyApply: 'Rename {{count}}',
|
|
2814
|
+
renameManyDone: 'Renamed {{count}} entries',
|
|
2815
|
+
queueCancel: 'Cancel',
|
|
2816
|
+
queueProgress: '{{files}} sent · {{size}}',
|
|
2817
|
+
queueCancelling: 'Cancelling…',
|
|
2818
|
+
queueCancelled: 'Cancelled ({{files}} sent)',
|
|
2765
2819
|
shortcutWebNote: 'In the Web GUI, Ctrl+W and Ctrl+Tab are reserved by the browser; use these shortcuts in the DSH desktop app.',
|
|
2766
2820
|
themeTitle: 'Editor theme',
|
|
2767
2821
|
themeHint: 'Colors of the remote file editor. Themes affect this plugin’s remote file views only.',
|
|
@@ -3402,6 +3456,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
3402
3456
|
'.rw-input{height:32px;padding:0 10px;border-radius:8px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;outline:none;min-width:0;box-sizing:border-box}',
|
|
3403
3457
|
'.rw-input:focus{border-color:var(--dsw-alias-brand-primary)}',
|
|
3404
3458
|
'.rw-input-mono{font-family:ui-monospace,"Cascadia Code",Consolas,monospace;font-size:12.5px}',
|
|
3459
|
+
// A long remote path must never push the "use this directory" button out of
|
|
3460
|
+
// the row; it ellipsizes inside its own flex item instead.
|
|
3461
|
+
'.rw-path-text{display:block;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
3405
3462
|
'.rw-input-row{display:flex;align-items:center;gap:8px;min-width:0}',
|
|
3406
3463
|
'.rw-input-row .rw-input{flex:1 1 auto}',
|
|
3407
3464
|
'.rw-host-list{display:flex;flex-direction:column;gap:2px;max-height:216px;overflow:auto;padding:4px;border:1px solid var(--dsw-alias-border-l2);border-radius:10px;background:var(--dsw-alias-bg-layer-1)}',
|
|
@@ -3530,6 +3587,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
3530
3587
|
'.rw-menu-backdrop{position:fixed;inset:0;z-index:40}',
|
|
3531
3588
|
'.rw-searchbar{display:flex;align-items:center;gap:6px;margin:6px 8px 0;padding:0 8px;height:30px;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;background:var(--dsw-alias-bg-layer-1);flex:none}',
|
|
3532
3589
|
'.rw-searchbar input{flex:1 1 auto;border:0;outline:0;background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:12px;min-width:0}',
|
|
3590
|
+
'.rw-search-flags{display:inline-flex;align-items:center;gap:2px;flex:none}',
|
|
3533
3591
|
'.rw-chips{display:flex;gap:4px;padding:6px 8px 0;overflow:auto;flex:none}',
|
|
3534
3592
|
'.rw-chip-btn{display:inline-flex;align-items:center;gap:4px;max-width:190px;padding:2px 8px;border-radius:999px;border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-secondary);font:inherit;font-size:11px;line-height:16px;cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:none}',
|
|
3535
3593
|
'.rw-chip-btn.is-on{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-label-primary);background:color-mix(in srgb,var(--dsw-alias-brand-primary) 10%,transparent)}',
|
|
@@ -3550,6 +3608,10 @@ function attributeViolation(name, value, tagName) {
|
|
|
3550
3608
|
'.rw-change-meta{flex:none;font-size:10.5px;color:var(--dsw-alias-label-tertiary)}',
|
|
3551
3609
|
'.rw-search-results{flex:1 1 auto;min-height:0;overflow:auto;padding:6px 8px}',
|
|
3552
3610
|
'.rw-result-row{display:flex;align-items:center;gap:6px;width:100%;padding:4px;border:0;border-radius:5px;background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:12px;cursor:pointer;text-align:left}',
|
|
3611
|
+
'.rw-result-row.is-content{flex-direction:column;align-items:stretch;gap:1px}',
|
|
3612
|
+
'.rw-result-head{display:flex;align-items:center;gap:6px;min-width:0}',
|
|
3613
|
+
'.rw-result-line{flex:none;font-size:11px;color:var(--dsw-alias-label-secondary)}',
|
|
3614
|
+
'.rw-result-preview{display:block;font-size:11px;line-height:15px;color:var(--dsw-alias-label-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
|
|
3553
3615
|
'.rw-result-row:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12))}',
|
|
3554
3616
|
'.rw-hint-row{padding:9px 6px;font-size:11.5px;line-height:17px;color:var(--dsw-alias-label-tertiary)}',
|
|
3555
3617
|
'.rw-linked-notice{margin:6px 8px 0}',
|
|
@@ -3644,13 +3706,15 @@ function attributeViolation(name, value, tagName) {
|
|
|
3644
3706
|
'.rw-ctx-arrow{display:inline-flex;color:var(--dsw-alias-label-tertiary)}',
|
|
3645
3707
|
'.rw-ctx-sub{display:none;position:absolute;left:100%;top:-5px;min-width:150px;padding:4px 0;border:1px solid var(--dsw-alias-border-l2);border-radius:7px;background:var(--dsw-alias-bg-overlay);box-shadow:0 12px 36px rgba(0,0,0,.3)}',
|
|
3646
3708
|
'.rw-ctx-item.has-sub:hover .rw-ctx-sub{display:block}',
|
|
3647
|
-
'.rw-dialog-backdrop{position:fixed;inset:0;z-index:80;background:rgba(0,0,0,.
|
|
3648
|
-
|
|
3649
|
-
|
|
3709
|
+
'.rw-dialog-backdrop{position:fixed;inset:0;z-index:80;padding:24px;background:rgba(0,0,0,.34);backdrop-filter:blur(2px);display:flex;align-items:center;justify-content:center}',
|
|
3710
|
+
// D4: dialogs share the add-workspace modal's frame so a confirm never
|
|
3711
|
+
// looks like a foreign panel next to it.
|
|
3712
|
+
'.rw-dialog{width:min(460px,calc(100vw - 48px));max-height:min(80vh,620px);overflow:auto;border:1px solid var(--dsw-alias-border-l2);border-radius:16px;background:var(--dsw-alias-bg-overlay);box-shadow:0 18px 60px rgba(0,0,0,.35);padding:18px 20px}',
|
|
3713
|
+
'.rw-dialog-title{font-size:15px;font-weight:600;line-height:22px;margin-bottom:10px}',
|
|
3650
3714
|
'.rw-dialog-label{display:block;margin:7px 0 4px;font-size:11.5px;color:var(--dsw-alias-label-tertiary)}',
|
|
3651
3715
|
'.rw-dialog-input{width:100%;box-sizing:border-box;padding:6px 9px;border:1px solid var(--dsw-alias-border-l2);border-radius:6px;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font:inherit;font-size:12px;outline:none}',
|
|
3652
|
-
'.rw-dialog-actions{display:flex;justify-content:flex-end;gap:
|
|
3653
|
-
'.rw-dialog-message{font-size:
|
|
3716
|
+
'.rw-dialog-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:14px}',
|
|
3717
|
+
'.rw-dialog-message{font-size:13px;line-height:19px;color:var(--dsw-alias-label-secondary)}',
|
|
3654
3718
|
// First-run welcome card: sits in shell.overlay, so the backdrop is its own.
|
|
3655
3719
|
'.rw-welcome-backdrop{position:fixed;inset:0;z-index:2000;display:flex;align-items:center;justify-content:center;padding:24px;background:rgba(0,0,0,.42)}',
|
|
3656
3720
|
'.rw-welcome{position:relative;width:min(470px,100%);max-height:min(86vh,700px);overflow:auto;box-sizing:border-box;padding:22px 22px 18px;border:1px solid var(--dsw-alias-border-l2);border-radius:18px;background:var(--dsw-alias-bg-layer-2);box-shadow:0 26px 70px rgba(0,0,0,.42);color:var(--dsw-alias-label-primary)}',
|
|
@@ -3687,6 +3751,12 @@ function attributeViolation(name, value, tagName) {
|
|
|
3687
3751
|
'.rw-csv-table tr:nth-child(even) td{background:color-mix(in srgb,var(--dsw-alias-bg-layer-1) 52%,transparent)}',
|
|
3688
3752
|
'.rw-csv-note{padding:5px 9px;font-size:10.5px;color:var(--dsw-alias-label-tertiary);border-top:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1)}',
|
|
3689
3753
|
'.rw-queue-row{display:flex;align-items:center;gap:8px;padding:5px 0;border-bottom:1px solid var(--dsw-alias-border-l1);font-size:12px}',
|
|
3754
|
+
'.rw-rename-preview{max-height:min(38vh,300px);overflow:auto;border:1px solid var(--dsw-alias-border-l1);border-radius:10px;padding:4px 8px;margin:2px 0 10px}',
|
|
3755
|
+
'.rw-rename-row{display:flex;align-items:center;gap:6px;padding:3px 0;font-size:12px;line-height:18px}',
|
|
3756
|
+
'.rw-rename-row.is-bad{color:var(--dsw-alias-state-error-primary)}',
|
|
3757
|
+
'.rw-rename-from{flex:1 1 0;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-secondary)}',
|
|
3758
|
+
'.rw-rename-arrow{flex:none;color:var(--dsw-alias-label-tertiary)}',
|
|
3759
|
+
'.rw-rename-to{flex:1 1 0;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500}',
|
|
3690
3760
|
'.rw-queue-label{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
3691
3761
|
'.rw-queue-state{flex:none;font-size:10.5px;color:var(--dsw-alias-label-tertiary)}',
|
|
3692
3762
|
].join('\n');
|
|
@@ -4424,7 +4494,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
4424
4494
|
placeholder: t('filterPlaceholder'),
|
|
4425
4495
|
'aria-label': t('filterPlaceholder'),
|
|
4426
4496
|
spellCheck: false,
|
|
4427
|
-
onChange: function (event) { setLocal(function (previous) { return Object.assign({}, previous, { filter:
|
|
4497
|
+
onChange: function (event) { var value = event.currentTarget.value; setLocal(function (previous) { return Object.assign({}, previous, { filter: value }); }); },
|
|
4428
4498
|
})),
|
|
4429
4499
|
h('div', { className: 'rw-browser-list', role: 'list' },
|
|
4430
4500
|
local.error
|
|
@@ -4448,10 +4518,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
4448
4518
|
className: 'rw-input rw-input-mono', style: { height: 28, fontSize: 11.5 },
|
|
4449
4519
|
value: local.input,
|
|
4450
4520
|
spellCheck: false,
|
|
4451
|
-
onChange: function (event) { setLocal(function (previous) { return Object.assign({}, previous, { input:
|
|
4521
|
+
onChange: function (event) { var value = event.currentTarget.value; setLocal(function (previous) { return Object.assign({}, previous, { input: value }); }); },
|
|
4452
4522
|
onKeyDown: function (event) { if (event.key === 'Enter') navigate(local.input); },
|
|
4453
4523
|
}),
|
|
4454
|
-
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: function () { navigate(local.input); } }, t('open')),
|
|
4455
4524
|
typeof window !== 'undefined' && typeof window.__DSH_DESKTOP_PICK_DIRECTORY__ === 'function'
|
|
4456
4525
|
? h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: nativePick, title: t('nativePicker') }, t('nativePicker'))
|
|
4457
4526
|
: null,
|
|
@@ -4470,7 +4539,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
4470
4539
|
h('input', {
|
|
4471
4540
|
className: 'rw-input', style: { height: 28, fontSize: 12 }, placeholder: t('folderName'),
|
|
4472
4541
|
value: local.folderName, autoFocus: true,
|
|
4473
|
-
onChange: function (event) { setLocal(function (previous) { return Object.assign({}, previous, { folderName:
|
|
4542
|
+
onChange: function (event) { var value = event.currentTarget.value; setLocal(function (previous) { return Object.assign({}, previous, { folderName: value }); }); },
|
|
4474
4543
|
onKeyDown: function (event) { if (event.key === 'Enter') createFolder(); },
|
|
4475
4544
|
}),
|
|
4476
4545
|
h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-primary', disabled: local.folderName.trim() === '', onClick: createFolder }, t('create')),
|
|
@@ -4485,7 +4554,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
4485
4554
|
var t = props.t;
|
|
4486
4555
|
var locale = props.locale;
|
|
4487
4556
|
var hostId = props.hostId;
|
|
4488
|
-
var state = useState({ loading: true, listing: null, error: '', input: props.initialPath || '', filter: '' });
|
|
4557
|
+
var state = useState({ loading: true, listing: null, error: '', input: props.initialPath || '', filter: '', creating: false, folderName: '', busy: false });
|
|
4489
4558
|
var remote = state[0];
|
|
4490
4559
|
var setRemote = state[1];
|
|
4491
4560
|
|
|
@@ -4511,6 +4580,20 @@ function attributeViolation(name, value, tagName) {
|
|
|
4511
4580
|
load(path);
|
|
4512
4581
|
}
|
|
4513
4582
|
|
|
4583
|
+
function createFolder() {
|
|
4584
|
+
var name = remote.folderName.trim();
|
|
4585
|
+
if (name === '' || !listing || remote.busy) return;
|
|
4586
|
+
setRemote(function (previous) { return Object.assign({}, previous, { busy: true, error: '' }); });
|
|
4587
|
+
apiCall('hosts.mkdir', { hostId: hostId, path: listing.path, name: name }).then(function (result) {
|
|
4588
|
+
setRemote(function (previous) { return Object.assign({}, previous, { busy: false, creating: false, folderName: '' }); });
|
|
4589
|
+
// Land inside the folder that was just made: it is almost always the
|
|
4590
|
+
// directory the user wants to pick.
|
|
4591
|
+
load(result && result.path ? result.path : listing.path);
|
|
4592
|
+
}).catch(function (error) {
|
|
4593
|
+
setRemote(function (previous) { return Object.assign({}, previous, { busy: false, error: messageOf(error, t, locale) }); });
|
|
4594
|
+
});
|
|
4595
|
+
}
|
|
4596
|
+
|
|
4514
4597
|
var listing = remote.listing;
|
|
4515
4598
|
var dirs = listing ? (listing.entries || []).filter(function (entry) { return entry.type === 'dir'; }) : [];
|
|
4516
4599
|
var PICKER_LIMIT = 500;
|
|
@@ -4553,7 +4636,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
4553
4636
|
placeholder: t('filterPlaceholder'),
|
|
4554
4637
|
'aria-label': t('filterPlaceholder'),
|
|
4555
4638
|
spellCheck: false,
|
|
4556
|
-
onChange: function (event) { setRemote(function (previous) { return Object.assign({}, previous, { filter:
|
|
4639
|
+
onChange: function (event) { var value = event.currentTarget.value; setRemote(function (previous) { return Object.assign({}, previous, { filter: value }); }); },
|
|
4557
4640
|
})),
|
|
4558
4641
|
h('div', { className: 'rw-browser-list', role: 'list' },
|
|
4559
4642
|
remote.error
|
|
@@ -4571,14 +4654,43 @@ function attributeViolation(name, value, tagName) {
|
|
|
4571
4654
|
pickerTruncated
|
|
4572
4655
|
? h('div', { className: 'rw-row-msg' }, t('pickerTruncated', { count: PICKER_LIMIT }))
|
|
4573
4656
|
: null),
|
|
4574
|
-
h('div', { className: 'rw-browser-actions', style: { padding: '8px' } },
|
|
4575
|
-
h('
|
|
4576
|
-
(
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4657
|
+
h('div', { className: 'rw-browser-actions', style: { padding: '8px', gap: 8 } },
|
|
4658
|
+
h('div', { className: 'rw-inline', style: { minWidth: 0, flex: '1 1 auto', flexWrap: 'nowrap' } },
|
|
4659
|
+
h('span', {
|
|
4660
|
+
className: 'rw-hint rw-input-mono rw-path-text',
|
|
4661
|
+
title: remote.input || (listing && listing.path) || '',
|
|
4662
|
+
}, (listing && listing.path) || (remote.input !== '' ? remote.input : t('home'))),
|
|
4663
|
+
h('button', {
|
|
4664
|
+
type: 'button', className: 'rw-btn rw-btn-sm',
|
|
4665
|
+
disabled: !listing || remote.loading,
|
|
4666
|
+
onClick: function () { setRemote(function (previous) { return Object.assign({}, previous, { creating: !previous.creating, folderName: '' }); }); },
|
|
4667
|
+
}, IconPlus(12), t('newFolder'))),
|
|
4668
|
+
h('div', { className: 'rw-actions', style: { flex: 'none' } },
|
|
4669
|
+
h('button', {
|
|
4670
|
+
type: 'button', className: 'rw-btn rw-btn-sm rw-btn-primary',
|
|
4671
|
+
disabled: !listing || remote.loading,
|
|
4672
|
+
onClick: function () { if (listing && props.onPick) props.onPick(listing.path); },
|
|
4673
|
+
}, IconCheck(12), t('useThisDir')))),
|
|
4674
|
+
remote.creating
|
|
4675
|
+
? h('div', { className: 'rw-browser-actions', style: { padding: '0 8px 8px', gap: 8 } },
|
|
4676
|
+
h('div', { className: 'rw-inline', style: { minWidth: 0, flex: '1 1 auto', flexWrap: 'nowrap' } },
|
|
4677
|
+
h('input', {
|
|
4678
|
+
className: 'rw-input', style: { height: 28, fontSize: 12 }, placeholder: t('folderName'),
|
|
4679
|
+
value: remote.folderName, autoFocus: true,
|
|
4680
|
+
onChange: function (event) { var value = event.currentTarget.value; setRemote(function (previous) { return Object.assign({}, previous, { folderName: value }); }); },
|
|
4681
|
+
onKeyDown: function (event) { if (event.key === 'Enter') createFolder(); },
|
|
4682
|
+
})),
|
|
4683
|
+
h('div', { className: 'rw-actions', style: { flex: 'none' } },
|
|
4684
|
+
h('button', {
|
|
4685
|
+
type: 'button', className: 'rw-btn rw-btn-sm rw-btn-primary',
|
|
4686
|
+
disabled: remote.busy || remote.folderName.trim() === '',
|
|
4687
|
+
onClick: createFolder,
|
|
4688
|
+
}, t('create')),
|
|
4689
|
+
h('button', {
|
|
4690
|
+
type: 'button', className: 'rw-btn rw-btn-sm',
|
|
4691
|
+
onClick: function () { setRemote(function (previous) { return Object.assign({}, previous, { creating: false, folderName: '' }); }); },
|
|
4692
|
+
}, t('cancel'))))
|
|
4693
|
+
: null);
|
|
4582
4694
|
}
|
|
4583
4695
|
|
|
4584
4696
|
function ScopePathPicker(props) {
|
|
@@ -4893,6 +5005,31 @@ function attributeViolation(name, value, tagName) {
|
|
|
4893
5005
|
return nodes;
|
|
4894
5006
|
}
|
|
4895
5007
|
|
|
5008
|
+
// Rows are plain buttons, so ↑/↓/Home/End only have to move focus; the
|
|
5009
|
+
// browser keeps the click and Enter behaviour for free.
|
|
5010
|
+
var LIST_KEY_STEP = { ArrowDown: 1, ArrowUp: -1 };
|
|
5011
|
+
|
|
5012
|
+
function handleListKeys(event, container, selector) {
|
|
5013
|
+
if (!container) return false;
|
|
5014
|
+
if (event.ctrlKey || event.metaKey || event.altKey) return false;
|
|
5015
|
+
var step = LIST_KEY_STEP[event.key];
|
|
5016
|
+
var isHome = event.key === 'Home';
|
|
5017
|
+
var isEnd = event.key === 'End';
|
|
5018
|
+
if (step === undefined && !isHome && !isEnd) return false;
|
|
5019
|
+
var rows = Array.prototype.slice.call(container.querySelectorAll(selector));
|
|
5020
|
+
if (rows.length === 0) return false;
|
|
5021
|
+
var index = rows.indexOf(document.activeElement);
|
|
5022
|
+
var next;
|
|
5023
|
+
if (isHome) next = 0;
|
|
5024
|
+
else if (isEnd) next = rows.length - 1;
|
|
5025
|
+
else if (index === -1) next = step > 0 ? 0 : rows.length - 1;
|
|
5026
|
+
else next = Math.min(rows.length - 1, Math.max(0, index + step));
|
|
5027
|
+
event.preventDefault();
|
|
5028
|
+
event.stopPropagation();
|
|
5029
|
+
rows[next].focus();
|
|
5030
|
+
return true;
|
|
5031
|
+
}
|
|
5032
|
+
|
|
4896
5033
|
function RemoteFileEditor(props) {
|
|
4897
5034
|
var ctx = props.ctx;
|
|
4898
5035
|
var t = props.t;
|
|
@@ -4952,6 +5089,45 @@ function attributeViolation(name, value, tagName) {
|
|
|
4952
5089
|
if (typeof props.onDirtyChange === 'function') props.onDirtyChange(dirty);
|
|
4953
5090
|
}, [dirty]);
|
|
4954
5091
|
|
|
5092
|
+
// A content-search hit opens the file at the matching line: place the
|
|
5093
|
+
// caret on it and centre the row, but only once per (file, line) pair so
|
|
5094
|
+
// typing and saving never yank the viewport back.
|
|
5095
|
+
var jumpedRef = useRef('');
|
|
5096
|
+
useEffect(function () {
|
|
5097
|
+
var target = Number(props.focusLine) || 0;
|
|
5098
|
+
if (target <= 0 || load.loading || load.error || content === '') return undefined;
|
|
5099
|
+
var stamp = filePath + '#' + target;
|
|
5100
|
+
if (jumpedRef.current === stamp) return undefined;
|
|
5101
|
+
// The textarea can mount one commit after the content arrives, so retry
|
|
5102
|
+
// for a few frames instead of giving up on the first pass.
|
|
5103
|
+
var tries = 0;
|
|
5104
|
+
var timers = [];
|
|
5105
|
+
function attempt() {
|
|
5106
|
+
if (jumpedRef.current === stamp) return;
|
|
5107
|
+
var area = textareaRef.current;
|
|
5108
|
+
if (!area) {
|
|
5109
|
+
if (tries < 12) { tries += 1; timers.push(setTimeout(attempt, 40)); }
|
|
5110
|
+
return;
|
|
5111
|
+
}
|
|
5112
|
+
jumpedRef.current = stamp;
|
|
5113
|
+
var lines = String(content).split('\n');
|
|
5114
|
+
var offset = 0;
|
|
5115
|
+
var last = Math.min(Math.max(target - 1, 0), Math.max(lines.length - 1, 0));
|
|
5116
|
+
for (var index = 0; index < last; index += 1) offset += lines[index].length + 1;
|
|
5117
|
+
var end = offset + (lines[last] ? lines[last].length : 0);
|
|
5118
|
+
try {
|
|
5119
|
+
area.focus();
|
|
5120
|
+
area.setSelectionRange(offset, end);
|
|
5121
|
+
} catch (error) { /* not focusable yet */ }
|
|
5122
|
+
var lineHeight = 18;
|
|
5123
|
+
area.scrollTop = Math.max(0, (last - 4) * lineHeight);
|
|
5124
|
+
if (highlightRef.current) highlightRef.current.scrollTop = area.scrollTop;
|
|
5125
|
+
if (gutterRef.current) gutterRef.current.scrollTop = area.scrollTop;
|
|
5126
|
+
}
|
|
5127
|
+
attempt();
|
|
5128
|
+
return function () { timers.forEach(function (timer) { clearTimeout(timer); }); };
|
|
5129
|
+
}, [filePath, props.focusLine, load.loading, load.error, content]);
|
|
5130
|
+
|
|
4955
5131
|
useEffect(function () {
|
|
4956
5132
|
if (!sidebar || typeof sidebar.updateTab !== 'function' || !props.tabId) return;
|
|
4957
5133
|
try {
|
|
@@ -5530,6 +5706,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
5530
5706
|
className: 'rw-tree',
|
|
5531
5707
|
role: 'tree',
|
|
5532
5708
|
'aria-label': t('allFiles'),
|
|
5709
|
+
onKeyDown: function (event) { handleListKeys(event, event.currentTarget, '[role="treeitem"]'); },
|
|
5533
5710
|
onDragOver: function (event) {
|
|
5534
5711
|
if (!props.onDropOnPath) return;
|
|
5535
5712
|
event.preventDefault();
|
|
@@ -5563,6 +5740,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
5563
5740
|
selectedPath: props.selectedPath || '',
|
|
5564
5741
|
selectedSet: props.selectedPaths && props.selectedPaths.length > 0 ? new Set(props.selectedPaths) : null,
|
|
5565
5742
|
siblings: rootSiblings,
|
|
5743
|
+
statSide: props.kind || 'remote',
|
|
5566
5744
|
}));
|
|
5567
5745
|
}
|
|
5568
5746
|
|
|
@@ -5692,6 +5870,8 @@ function attributeViolation(name, value, tagName) {
|
|
|
5692
5870
|
var t = props.t;
|
|
5693
5871
|
var locale = props.locale;
|
|
5694
5872
|
var state = props.state;
|
|
5873
|
+
var contentMode = props.mode === 'content';
|
|
5874
|
+
var resultsRef = useRef(null);
|
|
5695
5875
|
var groups = [
|
|
5696
5876
|
{ side: 'remote', label: t('remoteTree'), entries: state.remote || [] },
|
|
5697
5877
|
{ side: 'local', label: t('localTree'), entries: props.hasLocal ? state.local || [] : [] },
|
|
@@ -5709,26 +5889,46 @@ function attributeViolation(name, value, tagName) {
|
|
|
5709
5889
|
});
|
|
5710
5890
|
}
|
|
5711
5891
|
var total = groups.reduce(function (sum, group) { return sum + group.entries.length; }, 0);
|
|
5712
|
-
|
|
5892
|
+
// The Host reports *why* it stopped, because "too many results" and "the
|
|
5893
|
+
// search timed out" need different advice from the user.
|
|
5894
|
+
var reasonKey = state.truncatedReason === 'files' ? 'searchTruncatedFiles'
|
|
5895
|
+
: state.truncatedReason === 'bytes' ? 'searchTruncatedBytes'
|
|
5896
|
+
: state.truncatedReason === 'deadline' ? 'searchTruncatedDeadline'
|
|
5897
|
+
: 'searchTruncated';
|
|
5898
|
+
return h('div', {
|
|
5899
|
+
className: 'rw-search-results',
|
|
5900
|
+
ref: resultsRef,
|
|
5901
|
+
onKeyDown: function (event) { handleListKeys(event, resultsRef.current, '.rw-result-row'); },
|
|
5902
|
+
},
|
|
5713
5903
|
state.error ? h(Banner, { kind: 'error' }, state.error) : null,
|
|
5714
5904
|
state.loading ? h('div', { className: 'rw-hint-row' }, Spinner(12), t('loading')) : null,
|
|
5715
5905
|
!state.loading && total === 0 ? h('div', { className: 'rw-hint-row' }, t('searchEmpty')) : null,
|
|
5716
|
-
!state.loading && state.truncated ? h('div', { className: 'rw-hint-row' }, t(
|
|
5906
|
+
!state.loading && state.truncated ? h('div', { className: 'rw-hint-row' }, t(reasonKey)) : null,
|
|
5717
5907
|
groups.map(function (group) {
|
|
5718
5908
|
if (group.entries.length === 0) return null;
|
|
5719
5909
|
return h('div', { key: group.side, className: 'rw-change-group' },
|
|
5720
5910
|
h('div', { className: 'rw-change-group-title' }, group.label, h('span', { className: 'rw-change-meta' }, String(group.entries.length))),
|
|
5721
5911
|
group.entries.map(function (entry) {
|
|
5912
|
+
var line = Number(entry.line) || 0;
|
|
5722
5913
|
return h('button', {
|
|
5723
|
-
key: group.side + ':' + entry.path,
|
|
5914
|
+
key: group.side + ':' + entry.path + ':' + line,
|
|
5724
5915
|
type: 'button',
|
|
5725
|
-
className: 'rw-result-row',
|
|
5726
|
-
title: entry.path,
|
|
5916
|
+
className: 'rw-result-row' + (contentMode ? ' is-content' : ''),
|
|
5917
|
+
title: line > 0 ? entry.path + ':' + line : entry.path,
|
|
5727
5918
|
onClick: function () { props.onOpen(group.side, entry.path, entry); },
|
|
5728
5919
|
},
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
|
|
5920
|
+
contentMode
|
|
5921
|
+
? h('span', { className: 'rw-result-head' },
|
|
5922
|
+
h(FileGlyph, { name: entry.relative || entry.path, size: 13 }),
|
|
5923
|
+
h('span', { className: 'rw-change-path' }, entry.relative || entry.path),
|
|
5924
|
+
line > 0 ? h('span', { className: 'rw-result-line' }, ':' + line) : null,
|
|
5925
|
+
h('span', { className: 'rw-change-meta' }, group.side === 'remote' ? t('sideRemote') : t('sideLocal')))
|
|
5926
|
+
: [
|
|
5927
|
+
h(FileGlyph, { name: entry.relative || entry.path, size: 13 }),
|
|
5928
|
+
h('span', { className: 'rw-change-path' }, entry.relative || entry.path),
|
|
5929
|
+
h('span', { className: 'rw-change-meta' }, group.side === 'remote' ? t('sideRemote') : t('sideLocal')),
|
|
5930
|
+
],
|
|
5931
|
+
contentMode && entry.preview ? h('span', { className: 'rw-result-preview' }, entry.preview) : null);
|
|
5732
5932
|
}));
|
|
5733
5933
|
}));
|
|
5734
5934
|
}
|
|
@@ -5878,6 +6078,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
5878
6078
|
// Shown once per browser profile: the flag lives in localStorage so the
|
|
5879
6079
|
// dialog never reopens on refresh, and a fresh DSH install opens it again.
|
|
5880
6080
|
var WELCOME_KEY = 'dsh-linked-workspace:welcome';
|
|
6081
|
+
// F6: the settings page can replay the card, so the flag is cleared and an
|
|
6082
|
+
// event wakes the overlay instead of the user hunting for local storage.
|
|
6083
|
+
var WELCOME_EVENT = 'dsh-linked-workspace:welcome-open';
|
|
5881
6084
|
|
|
5882
6085
|
function welcomeSeen() {
|
|
5883
6086
|
try {
|
|
@@ -5907,6 +6110,11 @@ function attributeViolation(name, value, tagName) {
|
|
|
5907
6110
|
var open = state[0];
|
|
5908
6111
|
var setOpen = state[1];
|
|
5909
6112
|
function close() { welcomeRemember(); setOpen(false); }
|
|
6113
|
+
useEffect(function () {
|
|
6114
|
+
function onReplay() { setOpen(true); }
|
|
6115
|
+
window.addEventListener(WELCOME_EVENT, onReplay);
|
|
6116
|
+
return function () { window.removeEventListener(WELCOME_EVENT, onReplay); };
|
|
6117
|
+
}, []);
|
|
5910
6118
|
useEffect(function () {
|
|
5911
6119
|
if (!open) return undefined;
|
|
5912
6120
|
function onKey(event) {
|
|
@@ -6023,6 +6231,129 @@ function attributeViolation(name, value, tagName) {
|
|
|
6023
6231
|
h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-danger', onClick: props.onConfirm }, props.confirmLabel)));
|
|
6024
6232
|
}
|
|
6025
6233
|
|
|
6234
|
+
// F2: renaming a dozen files one by one is the slowest thing left in the
|
|
6235
|
+
// tree, so a multi-selection gets a single batch dialog with a live preview.
|
|
6236
|
+
function BatchRenameDialog(props) {
|
|
6237
|
+
var t = props.t;
|
|
6238
|
+
var entries = props.entries || [];
|
|
6239
|
+
var modeState = useState('pattern');
|
|
6240
|
+
var mode = modeState[0];
|
|
6241
|
+
var setMode = modeState[1];
|
|
6242
|
+
var prefixState = useState('');
|
|
6243
|
+
var prefix = prefixState[0];
|
|
6244
|
+
var setPrefix = prefixState[1];
|
|
6245
|
+
var startState = useState('1');
|
|
6246
|
+
var start = startState[0];
|
|
6247
|
+
var setStart = startState[1];
|
|
6248
|
+
var padState = useState('2');
|
|
6249
|
+
var pad = padState[0];
|
|
6250
|
+
var setPad = padState[1];
|
|
6251
|
+
var findState = useState('');
|
|
6252
|
+
var find = findState[0];
|
|
6253
|
+
var setFind = findState[1];
|
|
6254
|
+
var replaceState = useState('');
|
|
6255
|
+
var replaceWith = replaceState[0];
|
|
6256
|
+
var setReplaceWith = replaceState[1];
|
|
6257
|
+
var busyState = useState(false);
|
|
6258
|
+
var busy = busyState[0];
|
|
6259
|
+
var setBusy = busyState[1];
|
|
6260
|
+
|
|
6261
|
+
function splitName(name) {
|
|
6262
|
+
var dot = String(name).lastIndexOf('.');
|
|
6263
|
+
if (dot <= 0) return { base: String(name), ext: '' };
|
|
6264
|
+
return { base: String(name).slice(0, dot), ext: String(name).slice(dot) };
|
|
6265
|
+
}
|
|
6266
|
+
|
|
6267
|
+
var pairs = entries.map(function (entry, index) {
|
|
6268
|
+
var parts = splitName(entry.name);
|
|
6269
|
+
var next = '';
|
|
6270
|
+
if (mode === 'pattern') {
|
|
6271
|
+
var number = String(Number(start || 0) + index).padStart(Math.max(1, Number(pad) || 1), '0');
|
|
6272
|
+
next = prefix + number + (entry.isDir ? '' : parts.ext);
|
|
6273
|
+
} else {
|
|
6274
|
+
next = find === '' ? entry.name : String(entry.name).split(find).join(replaceWith);
|
|
6275
|
+
}
|
|
6276
|
+
return { entry: entry, from: entry.name, to: next };
|
|
6277
|
+
});
|
|
6278
|
+
var seen = {};
|
|
6279
|
+
var conflict = false;
|
|
6280
|
+
var invalid = false;
|
|
6281
|
+
pairs.forEach(function (pair) {
|
|
6282
|
+
if (pair.to === '') invalid = true;
|
|
6283
|
+
if (seen[pair.to]) conflict = true;
|
|
6284
|
+
seen[pair.to] = true;
|
|
6285
|
+
if (pair.to !== pair.from && pairs.some(function (other) { return other.entry.name === pair.to; })) conflict = true;
|
|
6286
|
+
});
|
|
6287
|
+
var changed = pairs.filter(function (pair) { return pair.to !== pair.from; }).length;
|
|
6288
|
+
|
|
6289
|
+
function apply() {
|
|
6290
|
+
if (busy || invalid || conflict || changed === 0) return;
|
|
6291
|
+
setBusy(true);
|
|
6292
|
+
props.onApply(pairs.filter(function (pair) { return pair.to !== pair.from; })).then(function () {
|
|
6293
|
+
setBusy(false);
|
|
6294
|
+
props.onClose();
|
|
6295
|
+
}).catch(function () { setBusy(false); });
|
|
6296
|
+
}
|
|
6297
|
+
|
|
6298
|
+
return h(DialogShell, { title: t('renameManyTitle', { count: entries.length }), onClose: props.onClose },
|
|
6299
|
+
h('div', { className: 'rw-inline', style: { gap: 6, marginBottom: 10 } },
|
|
6300
|
+
h('button', {
|
|
6301
|
+
type: 'button',
|
|
6302
|
+
className: 'rw-chip-btn' + (mode === 'pattern' ? ' is-on' : ''),
|
|
6303
|
+
'aria-pressed': mode === 'pattern',
|
|
6304
|
+
onClick: function () { setMode('pattern'); },
|
|
6305
|
+
}, t('renameManyPattern')),
|
|
6306
|
+
h('button', {
|
|
6307
|
+
type: 'button',
|
|
6308
|
+
className: 'rw-chip-btn' + (mode === 'replace' ? ' is-on' : ''),
|
|
6309
|
+
'aria-pressed': mode === 'replace',
|
|
6310
|
+
onClick: function () { setMode('replace'); },
|
|
6311
|
+
}, t('renameManyReplace'))),
|
|
6312
|
+
mode === 'pattern'
|
|
6313
|
+
? h('div', { className: 'rw-inline', style: { gap: 6, marginBottom: 10 } },
|
|
6314
|
+
h('input', {
|
|
6315
|
+
className: 'rw-input', style: { flex: '2 1 0', minWidth: 0 }, value: prefix,
|
|
6316
|
+
placeholder: t('renameManyPrefix'), 'aria-label': t('renameManyPrefix'),
|
|
6317
|
+
onChange: function (event) { var value = event.currentTarget.value; setPrefix(value); },
|
|
6318
|
+
}),
|
|
6319
|
+
h('input', {
|
|
6320
|
+
className: 'rw-input rw-input-mono', style: { flex: '1 1 0', minWidth: 0 }, value: start,
|
|
6321
|
+
placeholder: t('renameManyStart'), 'aria-label': t('renameManyStart'),
|
|
6322
|
+
onChange: function (event) { var value = event.currentTarget.value; setStart(value.replace(/[^0-9]/g, '')); },
|
|
6323
|
+
}),
|
|
6324
|
+
h('input', {
|
|
6325
|
+
className: 'rw-input rw-input-mono', style: { flex: '1 1 0', minWidth: 0 }, value: pad,
|
|
6326
|
+
placeholder: t('renameManyPad'), 'aria-label': t('renameManyPad'),
|
|
6327
|
+
onChange: function (event) { var value = event.currentTarget.value; setPad(value.replace(/[^0-9]/g, '')); },
|
|
6328
|
+
}))
|
|
6329
|
+
: h('div', { className: 'rw-inline', style: { gap: 6, marginBottom: 10 } },
|
|
6330
|
+
h('input', {
|
|
6331
|
+
className: 'rw-input', style: { flex: '1 1 0', minWidth: 0 }, value: find,
|
|
6332
|
+
placeholder: t('renameManyFind'), 'aria-label': t('renameManyFind'),
|
|
6333
|
+
onChange: function (event) { var value = event.currentTarget.value; setFind(value); },
|
|
6334
|
+
}),
|
|
6335
|
+
h('input', {
|
|
6336
|
+
className: 'rw-input', style: { flex: '1 1 0', minWidth: 0 }, value: replaceWith,
|
|
6337
|
+
placeholder: t('renameManyReplaceWith'), 'aria-label': t('renameManyReplaceWith'),
|
|
6338
|
+
onChange: function (event) { var value = event.currentTarget.value; setReplaceWith(value); },
|
|
6339
|
+
})),
|
|
6340
|
+
h('div', { className: 'rw-rename-preview' }, pairs.slice(0, 50).map(function (pair) {
|
|
6341
|
+
return h('div', { key: pair.entry.path, className: 'rw-rename-row' + (pair.to === '' || seen[pair.to] > 1 ? ' is-bad' : '') },
|
|
6342
|
+
h('span', { className: 'rw-rename-from', title: pair.entry.path }, pair.from),
|
|
6343
|
+
h('span', { className: 'rw-rename-arrow' }, '→'),
|
|
6344
|
+
h('span', { className: 'rw-rename-to' }, pair.to === '' ? t('renameManyEmpty') : pair.to));
|
|
6345
|
+
})),
|
|
6346
|
+
conflict ? h('div', { className: 'rw-dialog-message rw-dialog-error' }, t('renameManyConflict')) : null,
|
|
6347
|
+
h('div', { className: 'rw-dialog-actions' },
|
|
6348
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: props.onClose }, t('cancel')),
|
|
6349
|
+
h('button', {
|
|
6350
|
+
type: 'button',
|
|
6351
|
+
className: 'rw-btn rw-btn-sm rw-btn-primary',
|
|
6352
|
+
disabled: busy || invalid || conflict || changed === 0,
|
|
6353
|
+
onClick: apply,
|
|
6354
|
+
}, t(busy ? 'loading' : 'renameManyApply', { count: changed }))));
|
|
6355
|
+
}
|
|
6356
|
+
|
|
6026
6357
|
function PropertiesDialog(props) {
|
|
6027
6358
|
return h(DialogShell, { title: props.title, onClose: props.onClose },
|
|
6028
6359
|
h('div', { className: 'rw-props' }, props.rows.map(function (row) {
|
|
@@ -6122,6 +6453,14 @@ function attributeViolation(name, value, tagName) {
|
|
|
6122
6453
|
return h('div', { key: entry.id, className: 'rw-queue-row' },
|
|
6123
6454
|
h('span', { className: 'rw-queue-label', title: entry.path }, entry.label),
|
|
6124
6455
|
h('span', { className: 'rw-queue-state' }, entry.message || entry.state),
|
|
6456
|
+
entry.state === 'running' && props.onCancel
|
|
6457
|
+
? h('button', {
|
|
6458
|
+
type: 'button',
|
|
6459
|
+
className: 'rw-btn rw-btn-sm',
|
|
6460
|
+
disabled: Boolean(entry.cancelling),
|
|
6461
|
+
onClick: function () { props.onCancel(entry); },
|
|
6462
|
+
}, props.t('queueCancel'))
|
|
6463
|
+
: null,
|
|
6125
6464
|
entry.state === 'error' && props.onRetry
|
|
6126
6465
|
? h('button', {
|
|
6127
6466
|
type: 'button',
|
|
@@ -6539,7 +6878,16 @@ function attributeViolation(name, value, tagName) {
|
|
|
6539
6878
|
var searchModeState = useState('name');
|
|
6540
6879
|
var searchMode = searchModeState[0];
|
|
6541
6880
|
var setSearchMode = searchModeState[1];
|
|
6542
|
-
var
|
|
6881
|
+
var searchCaseState = useState(false);
|
|
6882
|
+
var searchCase = searchCaseState[0];
|
|
6883
|
+
var setSearchCase = searchCaseState[1];
|
|
6884
|
+
var searchRegexState = useState(false);
|
|
6885
|
+
var searchRegex = searchRegexState[0];
|
|
6886
|
+
var setSearchRegex = searchRegexState[1];
|
|
6887
|
+
var searchHereState = useState(false);
|
|
6888
|
+
var searchHere = searchHereState[0];
|
|
6889
|
+
var setSearchHere = searchHereState[1];
|
|
6890
|
+
var searchState = useState({ loading: false, remote: [], local: [], truncated: false, truncatedReason: '', error: null });
|
|
6543
6891
|
var search = searchState[0];
|
|
6544
6892
|
var setSearch = searchState[1];
|
|
6545
6893
|
var gitState = useState({ loading: false, remote: null, local: null, error: null });
|
|
@@ -6839,6 +7187,12 @@ function attributeViolation(name, value, tagName) {
|
|
|
6839
7187
|
setOpenFiles(function (previous) {
|
|
6840
7188
|
var existing = previous.filter(function (file) { return file.key === key; })[0];
|
|
6841
7189
|
if (existing) {
|
|
7190
|
+
var wanted = Number(opts.line) || 0;
|
|
7191
|
+
if (wanted > 0 && existing.line !== wanted) {
|
|
7192
|
+
// Re-opening the same file from another hit must move the caret,
|
|
7193
|
+
// so the line travels with the tab instead of being dropped.
|
|
7194
|
+
return previous.map(function (file) { return file.key === key ? Object.assign({}, file, { line: wanted, pinned: Boolean(opts.pinned) || file.pinned }) : file; });
|
|
7195
|
+
}
|
|
6842
7196
|
if (opts.pinned && !existing.pinned) {
|
|
6843
7197
|
return previous.map(function (file) { return file.key === key ? Object.assign({}, file, { pinned: true }) : file; });
|
|
6844
7198
|
}
|
|
@@ -6851,13 +7205,13 @@ function attributeViolation(name, value, tagName) {
|
|
|
6851
7205
|
var active = previous[activeIndex];
|
|
6852
7206
|
if (!active.pinned && !fileDirty[active.key]) {
|
|
6853
7207
|
var replaced = previous.slice();
|
|
6854
|
-
replaced[activeIndex] = { key: key, side: side, path: filePath, name: basename(filePath), pinned: false };
|
|
7208
|
+
replaced[activeIndex] = { key: key, side: side, path: filePath, name: basename(filePath), pinned: false, line: Number(opts.line) || 0 };
|
|
6855
7209
|
setFileDirty(function (dirtyMap) { var copy = Object.assign({}, dirtyMap); delete copy[active.key]; return copy; });
|
|
6856
7210
|
return replaced;
|
|
6857
7211
|
}
|
|
6858
7212
|
}
|
|
6859
7213
|
}
|
|
6860
|
-
return previous.concat([{ key: key, side: side, path: filePath, name: basename(filePath), pinned: Boolean(opts.pinned) }]);
|
|
7214
|
+
return previous.concat([{ key: key, side: side, path: filePath, name: basename(filePath), pinned: Boolean(opts.pinned), line: Number(opts.line) || 0 }]);
|
|
6861
7215
|
});
|
|
6862
7216
|
setActiveFileKey(key);
|
|
6863
7217
|
setDirectoryOpen(true);
|
|
@@ -7021,10 +7375,13 @@ function attributeViolation(name, value, tagName) {
|
|
|
7021
7375
|
function enqueueTransfer(side, filePath, name) {
|
|
7022
7376
|
var entry = {
|
|
7023
7377
|
id: String(Date.now()) + Math.random().toString(16).slice(2),
|
|
7378
|
+
jobId: 'job-' + String(Date.now()) + '-' + Math.random().toString(16).slice(2, 8),
|
|
7024
7379
|
side: side || 'remote',
|
|
7025
7380
|
path: filePath,
|
|
7026
7381
|
label: name,
|
|
7027
7382
|
state: 'queued',
|
|
7383
|
+
files: 0,
|
|
7384
|
+
bytes: 0,
|
|
7028
7385
|
message: t('queueQueued'),
|
|
7029
7386
|
};
|
|
7030
7387
|
queueRef.current = queueRef.current.concat([entry]);
|
|
@@ -7032,23 +7389,49 @@ function attributeViolation(name, value, tagName) {
|
|
|
7032
7389
|
pumpQueue();
|
|
7033
7390
|
}
|
|
7034
7391
|
|
|
7392
|
+
/** Ask the Host to stop a running transfer after the current file. */
|
|
7393
|
+
function cancelTransfer(entry) {
|
|
7394
|
+
if (!entry || !entry.jobId) return;
|
|
7395
|
+
entry.cancelling = true;
|
|
7396
|
+
entry.message = t('queueCancelling');
|
|
7397
|
+
setQueueList(queueRef.current.slice());
|
|
7398
|
+
apiCall('fs.transferCancel', { jobId: entry.jobId }).catch(function () { /* the transfer may be over */ });
|
|
7399
|
+
}
|
|
7400
|
+
|
|
7035
7401
|
function pumpQueue() {
|
|
7036
7402
|
if (queueRunning.current) return;
|
|
7037
7403
|
var next = queueRef.current.filter(function (entry) { return entry.state === 'queued'; })[0];
|
|
7038
7404
|
if (!next) return;
|
|
7039
7405
|
queueRunning.current = true;
|
|
7040
7406
|
next.state = 'running';
|
|
7407
|
+
next.files = 0;
|
|
7408
|
+
next.bytes = 0;
|
|
7041
7409
|
next.message = t('queueRunning');
|
|
7042
7410
|
setQueueList(queueRef.current.slice());
|
|
7043
|
-
|
|
7411
|
+
// Poll the Host while the transfer runs: a folder can take minutes and
|
|
7412
|
+
// the row otherwise sits on “running” with no evidence of progress.
|
|
7413
|
+
var poll = setInterval(function () {
|
|
7414
|
+
apiCall('fs.transferProgress', { jobId: next.jobId }).then(function (result) {
|
|
7415
|
+
var job = result && result.job;
|
|
7416
|
+
if (!job || next.state !== 'running') return;
|
|
7417
|
+
next.files = job.files;
|
|
7418
|
+
next.bytes = job.bytes;
|
|
7419
|
+
next.message = t('queueProgress', { files: job.files, size: formatBytes(job.bytes) });
|
|
7420
|
+
setQueueList(queueRef.current.slice());
|
|
7421
|
+
}).catch(function () { /* progress is best-effort */ });
|
|
7422
|
+
}, 700);
|
|
7423
|
+
apiCall('fs.transfer', Object.assign({ side: next.side || 'remote', path: next.path, jobId: next.jobId }, scopeParams(scopeRef))).then(function (result) {
|
|
7044
7424
|
next.state = 'done';
|
|
7045
7425
|
next.message = t('transferDone', { files: result.files, size: formatBytes(result.bytes) }) + (result.truncated ? t('transferTruncated') : '');
|
|
7046
7426
|
showNotice('success', next.message);
|
|
7047
7427
|
refreshTree();
|
|
7048
7428
|
}).catch(function (error) {
|
|
7049
|
-
|
|
7050
|
-
next.
|
|
7429
|
+
var cancelled = error && error.code === 'CANCELLED';
|
|
7430
|
+
next.state = cancelled ? 'cancelled' : 'error';
|
|
7431
|
+
next.message = cancelled ? t('queueCancelled', { files: next.files }) : messageOf(error, t, locale);
|
|
7051
7432
|
}).then(function () {
|
|
7433
|
+
clearInterval(poll);
|
|
7434
|
+
next.cancelling = false;
|
|
7052
7435
|
setQueueList(queueRef.current.slice());
|
|
7053
7436
|
queueRunning.current = false;
|
|
7054
7437
|
pumpQueue();
|
|
@@ -7372,6 +7755,32 @@ function attributeViolation(name, value, tagName) {
|
|
|
7372
7755
|
}).catch(noticeError);
|
|
7373
7756
|
}
|
|
7374
7757
|
|
|
7758
|
+
/**
|
|
7759
|
+
* F2: rename sequentially so one failure (a clash on disk) does not leave
|
|
7760
|
+
* the rest half-applied without a word.
|
|
7761
|
+
*/
|
|
7762
|
+
function renameManyEntries(side, pairs) {
|
|
7763
|
+
var method = side === 'remote' ? 'fs.rename' : 'local.rename';
|
|
7764
|
+
var done = 0;
|
|
7765
|
+
return pairs.reduce(function (chain, pair) {
|
|
7766
|
+
return chain.then(function () {
|
|
7767
|
+
var target = joinChildPath(parentPathOf(pair.entry.path, side), pair.to, side);
|
|
7768
|
+
var params = side === 'remote'
|
|
7769
|
+
? Object.assign({ from: pair.entry.path, to: target }, scopeParams(scopeRef))
|
|
7770
|
+
: { from: pair.entry.path, to: target };
|
|
7771
|
+
return apiCall(method, params).then(function () { done += 1; });
|
|
7772
|
+
});
|
|
7773
|
+
}, Promise.resolve()).then(function () {
|
|
7774
|
+
showNotice('success', t('renameManyDone', { count: done }));
|
|
7775
|
+
refreshTree();
|
|
7776
|
+
return done;
|
|
7777
|
+
}).catch(function (error) {
|
|
7778
|
+
if (done > 0) showNotice('success', t('renameManyDone', { count: done }));
|
|
7779
|
+
noticeError(error);
|
|
7780
|
+
throw error;
|
|
7781
|
+
});
|
|
7782
|
+
}
|
|
7783
|
+
|
|
7375
7784
|
function pathUnder(filePath, parentPath) {
|
|
7376
7785
|
if (!filePath || !parentPath) return false;
|
|
7377
7786
|
var normalized = String(filePath).replace(/\\/g, '/').replace(/\/+$/, '');
|
|
@@ -7434,6 +7843,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
7434
7843
|
initialPath: parentPathOf(menu.path, menu.side),
|
|
7435
7844
|
});
|
|
7436
7845
|
} });
|
|
7846
|
+
items.push({ label: t('ctxRenameSelected', { count: batch.length }), onSelect: function () {
|
|
7847
|
+
setDialog({ kind: 'renameMany', side: menu.side, entries: batch });
|
|
7848
|
+
} });
|
|
7437
7849
|
}
|
|
7438
7850
|
items.push({ separator: true });
|
|
7439
7851
|
}
|
|
@@ -7546,6 +7958,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
7546
7958
|
setQueueList(queueRef.current.slice());
|
|
7547
7959
|
},
|
|
7548
7960
|
onRetry: function (entry) { enqueueTransfer(entry.side, entry.path, entry.label); },
|
|
7961
|
+
onCancel: cancelTransfer,
|
|
7549
7962
|
});
|
|
7550
7963
|
}
|
|
7551
7964
|
if (dialog.kind === 'delete') {
|
|
@@ -7594,6 +8007,14 @@ function attributeViolation(name, value, tagName) {
|
|
|
7594
8007
|
onPick: function (targetDir) { moveEntries(dialog.side, moveTargets, targetDir); },
|
|
7595
8008
|
});
|
|
7596
8009
|
}
|
|
8010
|
+
if (dialog.kind === 'renameMany') {
|
|
8011
|
+
return h(BatchRenameDialog, {
|
|
8012
|
+
t: t,
|
|
8013
|
+
entries: dialog.entries,
|
|
8014
|
+
onClose: function () { setDialog(null); },
|
|
8015
|
+
onApply: function (pairs) { return renameManyEntries(dialog.side, pairs); },
|
|
8016
|
+
});
|
|
8017
|
+
}
|
|
7597
8018
|
if (dialog.kind === 'closeDirty') {
|
|
7598
8019
|
return h(ConfirmDialog, {
|
|
7599
8020
|
t: t,
|
|
@@ -7640,26 +8061,50 @@ function attributeViolation(name, value, tagName) {
|
|
|
7640
8061
|
return function () { alive = false; };
|
|
7641
8062
|
}, [mode, selectedKey, version]);
|
|
7642
8063
|
|
|
8064
|
+
// F3: when the user ticks “current folder only”, the sweep starts from the
|
|
8065
|
+
// row they have selected (its parent when the row is a file).
|
|
8066
|
+
var searchRootPath = '';
|
|
8067
|
+
if (selected && selected.kind !== 'workspace' && selectedEntry && selectedEntry.side === 'remote' && selected.remotePath) {
|
|
8068
|
+
var entryPath = String(selectedEntry.path || '');
|
|
8069
|
+
var rootPrefix = String(selected.remotePath).replace(/\/+$/, '');
|
|
8070
|
+
if (entryPath === rootPrefix) {
|
|
8071
|
+
searchRootPath = '';
|
|
8072
|
+
} else if (entryPath.indexOf(rootPrefix + '/') === 0) {
|
|
8073
|
+
var inside = entryPath.slice(rootPrefix.length + 1);
|
|
8074
|
+
searchRootPath = selectedEntry.isDir === false ? parentPathOf(inside, 'remote') : inside;
|
|
8075
|
+
}
|
|
8076
|
+
}
|
|
8077
|
+
|
|
7643
8078
|
useEffect(function () {
|
|
7644
8079
|
if (!searchOpen) {
|
|
7645
|
-
setSearch({ loading: false, remote: [], local: [], error: null });
|
|
8080
|
+
setSearch({ loading: false, remote: [], local: [], truncated: false, truncatedReason: '', error: null });
|
|
7646
8081
|
return undefined;
|
|
7647
8082
|
}
|
|
7648
8083
|
var query = searchQuery.trim();
|
|
7649
8084
|
if (query.length < 2 || !selected) {
|
|
7650
|
-
setSearch({ loading: false, remote: [], local: [], error: null });
|
|
8085
|
+
setSearch({ loading: false, remote: [], local: [], truncated: false, truncatedReason: '', error: null });
|
|
7651
8086
|
return undefined;
|
|
7652
8087
|
}
|
|
7653
8088
|
var alive = true;
|
|
7654
8089
|
var timer = setTimeout(function () {
|
|
7655
|
-
setSearch(function (previous) { return { loading: true, remote: previous.remote, local: previous.local, truncated: false, error: null }; });
|
|
8090
|
+
setSearch(function (previous) { return { loading: true, remote: previous.remote, local: previous.local, truncated: false, truncatedReason: '', error: null }; });
|
|
7656
8091
|
var scopeNow = sourceScopeOf(selected);
|
|
7657
|
-
var
|
|
7658
|
-
var
|
|
8092
|
+
var contentMode = searchMode === 'content';
|
|
8093
|
+
var method = contentMode ? 'fs.grep' : 'fs.search';
|
|
8094
|
+
var extra = { side: 'remote', query: query, maxResults: 200 };
|
|
8095
|
+
if (contentMode) {
|
|
8096
|
+
// F3: narrow the sweep to the folder the user is standing in.
|
|
8097
|
+
if (searchHere && searchRootPath !== '') extra.path = searchRootPath;
|
|
8098
|
+
extra.ignoreCase = !searchCase;
|
|
8099
|
+
extra.regex = searchRegex;
|
|
8100
|
+
}
|
|
8101
|
+
var jobs = [apiCall(method, Object.assign(extra, scopeParams(scopeNow))).catch(function (error) {
|
|
7659
8102
|
return { ok: false, entries: [], error: messageOf(error, t, locale) };
|
|
7660
8103
|
})];
|
|
7661
8104
|
if (selected.kind === 'linked') {
|
|
7662
|
-
|
|
8105
|
+
var localExtra = Object.assign({}, extra, { side: 'local' });
|
|
8106
|
+
if (contentMode) localExtra.ignoreCase = !searchCase;
|
|
8107
|
+
jobs.push(apiCall(method, Object.assign(localExtra, scopeParams(scopeNow))).catch(function (error) {
|
|
7663
8108
|
return { ok: false, entries: [], error: messageOf(error, t, locale) };
|
|
7664
8109
|
}));
|
|
7665
8110
|
} else {
|
|
@@ -7672,12 +8117,13 @@ function attributeViolation(name, value, tagName) {
|
|
|
7672
8117
|
remote: results[0] && results[0].entries ? results[0].entries : [],
|
|
7673
8118
|
local: results[1] && results[1].entries ? results[1].entries : [],
|
|
7674
8119
|
truncated: Boolean((results[0] && results[0].truncated) || (results[1] && results[1].truncated)),
|
|
8120
|
+
truncatedReason: (results[0] && results[0].truncatedReason) || (results[1] && results[1].truncatedReason) || '',
|
|
7675
8121
|
error: (results[0] && results[0].error) || (results[1] && results[1].error) || null,
|
|
7676
8122
|
});
|
|
7677
8123
|
});
|
|
7678
8124
|
}, 320);
|
|
7679
8125
|
return function () { alive = false; clearTimeout(timer); };
|
|
7680
|
-
}, [searchOpen, searchQuery, selectedKey, version, searchMode]);
|
|
8126
|
+
}, [searchOpen, searchQuery, selectedKey, version, searchMode, searchCase, searchRegex, searchHere]);
|
|
7681
8127
|
|
|
7682
8128
|
if (!selected) {
|
|
7683
8129
|
return h('div', { className: 'rw-workbench rw-workspace', ref: workbenchRef },
|
|
@@ -7697,9 +8143,13 @@ function attributeViolation(name, value, tagName) {
|
|
|
7697
8143
|
if (searchOpen && searchQuery.trim().length >= 2) {
|
|
7698
8144
|
body = h(SearchResults, {
|
|
7699
8145
|
t: t, locale: locale, state: search,
|
|
8146
|
+
mode: searchMode,
|
|
7700
8147
|
hasLocal: selected.kind === 'linked',
|
|
7701
8148
|
showHidden: showHidden,
|
|
7702
|
-
onOpen:
|
|
8149
|
+
onOpen: function (side, filePath, entry) {
|
|
8150
|
+
var line = entry && Number(entry.line) ? Number(entry.line) : 0;
|
|
8151
|
+
openByMode(side, filePath, line > 0 ? { pinned: true, line: line } : undefined);
|
|
8152
|
+
},
|
|
7703
8153
|
});
|
|
7704
8154
|
} else if (mode !== 'files') {
|
|
7705
8155
|
body = h(GitChangesView, {
|
|
@@ -7759,6 +8209,10 @@ function attributeViolation(name, value, tagName) {
|
|
|
7759
8209
|
|
|
7760
8210
|
var activeFile = openFiles.filter(function (file) { return file.key === activeFileKey; })[0] || null;
|
|
7761
8211
|
var activeDocKind = activeFile ? documentKindOf(activeFile.name) : '';
|
|
8212
|
+
// A hit that carries a line number needs the code view: the document pane
|
|
8213
|
+
// has no caret, so the jump would be lost on Markdown/HTML files.
|
|
8214
|
+
var activeForceCode = Boolean(activeFile && Number(activeFile.line) > 0);
|
|
8215
|
+
if (activeForceCode) activeDocKind = '';
|
|
7762
8216
|
var contentArea = activeFile
|
|
7763
8217
|
? (activeDocKind === 'image'
|
|
7764
8218
|
? h(ImagePreview, {
|
|
@@ -7801,6 +8255,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
7801
8255
|
local: activeFile.side === 'local',
|
|
7802
8256
|
readOnly: remoteOnly,
|
|
7803
8257
|
hideHeader: true,
|
|
8258
|
+
focusLine: activeFile.line || 0,
|
|
7804
8259
|
onSaveReady: function (handler) {
|
|
7805
8260
|
if (handler) saveHandlersRef.current[activeFile.key] = handler;
|
|
7806
8261
|
else delete saveHandlersRef.current[activeFile.key];
|
|
@@ -7867,7 +8322,42 @@ function attributeViolation(name, value, tagName) {
|
|
|
7867
8322
|
spellCheck: false,
|
|
7868
8323
|
autoFocus: true,
|
|
7869
8324
|
onChange: function (event) { setSearchQuery(event.currentTarget.value); },
|
|
8325
|
+
onKeyDown: function (event) {
|
|
8326
|
+
if (event.key !== 'ArrowDown') return;
|
|
8327
|
+
// Landing on the first hit without leaving the keyboard is the
|
|
8328
|
+
// whole point of the list shortcuts.
|
|
8329
|
+
var list = document.querySelector('.rw-search-results');
|
|
8330
|
+
var first = list && list.querySelector('.rw-result-row');
|
|
8331
|
+
if (!first) return;
|
|
8332
|
+
event.preventDefault();
|
|
8333
|
+
first.focus();
|
|
8334
|
+
},
|
|
7870
8335
|
}),
|
|
8336
|
+
searchMode === 'content'
|
|
8337
|
+
? h('span', { className: 'rw-search-flags' },
|
|
8338
|
+
h('button', {
|
|
8339
|
+
type: 'button',
|
|
8340
|
+
className: 'rw-chip-btn' + (searchCase ? ' is-on' : ''),
|
|
8341
|
+
title: t('searchCase'),
|
|
8342
|
+
'aria-pressed': searchCase ? 'true' : 'false',
|
|
8343
|
+
onClick: function () { setSearchCase(!searchCase); },
|
|
8344
|
+
}, 'Aa'),
|
|
8345
|
+
h('button', {
|
|
8346
|
+
type: 'button',
|
|
8347
|
+
className: 'rw-chip-btn' + (searchRegex ? ' is-on' : ''),
|
|
8348
|
+
title: t('searchRegex'),
|
|
8349
|
+
'aria-pressed': searchRegex ? 'true' : 'false',
|
|
8350
|
+
onClick: function () { setSearchRegex(!searchRegex); },
|
|
8351
|
+
}, '.*'),
|
|
8352
|
+
h('button', {
|
|
8353
|
+
type: 'button',
|
|
8354
|
+
className: 'rw-chip-btn' + (searchHere ? ' is-on' : ''),
|
|
8355
|
+
title: searchHere ? t('searchScopeHere') : t('searchScopeAll'),
|
|
8356
|
+
'aria-pressed': searchHere ? 'true' : 'false',
|
|
8357
|
+
disabled: searchRootPath === '',
|
|
8358
|
+
onClick: function () { setSearchHere(!searchHere); },
|
|
8359
|
+
}, IconFolderTree(11)))
|
|
8360
|
+
: null,
|
|
7871
8361
|
h('button', {
|
|
7872
8362
|
type: 'button', className: 'rw-icon-btn', title: t('cancel'),
|
|
7873
8363
|
onClick: function () { setSearchOpen(false); setSearchQuery(''); },
|
|
@@ -7953,6 +8443,39 @@ function attributeViolation(name, value, tagName) {
|
|
|
7953
8443
|
|
|
7954
8444
|
// ── tree ───────────────────────────────────────────────────────────────
|
|
7955
8445
|
|
|
8446
|
+
// F5: the row tooltip shows where a file lives, which is the one thing a
|
|
8447
|
+
// hover cannot tell you about time. One stat per row per 5 s is cheap and
|
|
8448
|
+
// keeps the tree quiet otherwise.
|
|
8449
|
+
var ROW_STAT_TTL_MS = 5000;
|
|
8450
|
+
var rowStatCache = new Map();
|
|
8451
|
+
|
|
8452
|
+
function rowStatKey(side, filePath) {
|
|
8453
|
+
return (side === 'remote' ? 'r:' : 'l:') + filePath;
|
|
8454
|
+
}
|
|
8455
|
+
|
|
8456
|
+
function decorateRowStat(row, side, filePath, scope, t, locale) {
|
|
8457
|
+
if (!row || !filePath) return;
|
|
8458
|
+
var key = rowStatKey(side, filePath);
|
|
8459
|
+
var cached = rowStatCache.get(key);
|
|
8460
|
+
if (cached && Date.now() - cached.at < ROW_STAT_TTL_MS) {
|
|
8461
|
+
row.title = cached.text;
|
|
8462
|
+
return;
|
|
8463
|
+
}
|
|
8464
|
+
row.title = filePath;
|
|
8465
|
+
var method = side === 'remote' ? 'fs.stat' : 'local.stat';
|
|
8466
|
+
var params = side === 'remote'
|
|
8467
|
+
? Object.assign({ path: filePath }, scopeParams(scope))
|
|
8468
|
+
: { path: filePath };
|
|
8469
|
+
apiCall(method, params).then(function (result) {
|
|
8470
|
+
var stamp = Number(result && result.mtime);
|
|
8471
|
+
var when = stamp > 0 ? new Date(stamp).toLocaleString() : '-';
|
|
8472
|
+
var text = filePath + '\n' + t('rowModifiedAt', { when: when })
|
|
8473
|
+
+ (result && result.type === 'dir' ? '' : ' · ' + formatBytes(result && result.size));
|
|
8474
|
+
rowStatCache.set(key, { at: Date.now(), text: text });
|
|
8475
|
+
if (row.isConnected) row.title = text;
|
|
8476
|
+
}).catch(function () { /* a tooltip is not worth a notice */ });
|
|
8477
|
+
}
|
|
8478
|
+
|
|
7956
8479
|
function TreeDirectory(props) {
|
|
7957
8480
|
var path = props.path;
|
|
7958
8481
|
var name = props.name;
|
|
@@ -8023,6 +8546,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
8023
8546
|
selectedPath: selectedPath,
|
|
8024
8547
|
selectedSet: props.selectedSet,
|
|
8025
8548
|
siblings: childSiblings,
|
|
8549
|
+
statSide: props.statSide || 'remote',
|
|
8026
8550
|
}));
|
|
8027
8551
|
} else if (child.type === 'file' || child.type === 'symlink') {
|
|
8028
8552
|
var active = selectedPath === child.path || Boolean(props.selectedSet && props.selectedSet.has(child.path));
|
|
@@ -8044,6 +8568,25 @@ function attributeViolation(name, value, tagName) {
|
|
|
8044
8568
|
if (event.detail !== 2) onSelect(child.path);
|
|
8045
8569
|
},
|
|
8046
8570
|
onDoubleClick: function () { if (onPin) onPin(child.path); },
|
|
8571
|
+
onMouseEnter: function (event) {
|
|
8572
|
+
decorateRowStat(event.currentTarget, props.statSide || 'remote', child.path, source, t, locale);
|
|
8573
|
+
},
|
|
8574
|
+
onKeyDown: function (event) {
|
|
8575
|
+
// ← on a file folds the focus back onto its parent folder,
|
|
8576
|
+
// which is what a file tree is expected to do.
|
|
8577
|
+
if (event.key !== 'ArrowLeft') return;
|
|
8578
|
+
var owner = event.currentTarget.closest('[data-dir-path]');
|
|
8579
|
+
// The folder header is the wrapper's previous sibling, not a
|
|
8580
|
+
// child of it, so look sideways first and fall back inside.
|
|
8581
|
+
var header = owner ? owner.previousElementSibling : null;
|
|
8582
|
+
if (!header || String(header.getAttribute('role')) !== 'treeitem') {
|
|
8583
|
+
header = owner ? owner.querySelector('[data-dir-path]') : null;
|
|
8584
|
+
}
|
|
8585
|
+
if (!header) return;
|
|
8586
|
+
event.preventDefault();
|
|
8587
|
+
event.stopPropagation();
|
|
8588
|
+
header.focus();
|
|
8589
|
+
},
|
|
8047
8590
|
onContextMenu: function (event) {
|
|
8048
8591
|
if (!onContextMenu) return;
|
|
8049
8592
|
event.preventDefault();
|
|
@@ -8079,6 +8622,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
8079
8622
|
role: 'treeitem',
|
|
8080
8623
|
'aria-level': depth + 1,
|
|
8081
8624
|
'aria-expanded': isOpen,
|
|
8625
|
+
'data-dir-path': path,
|
|
8082
8626
|
className: 'rw-row' + (selectedPath === path || (props.selectedSet && props.selectedSet.has(path)) ? ' is-active' : ''),
|
|
8083
8627
|
style: { paddingLeft: 6 + depth * 12 },
|
|
8084
8628
|
title: path,
|
|
@@ -8090,6 +8634,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
8090
8634
|
if (onSelectPath) onSelectPath({ path: path, name: name, isDir: true, siblings: props.siblings || [], event: event });
|
|
8091
8635
|
if (event.detail !== 2) toggle(path);
|
|
8092
8636
|
},
|
|
8637
|
+
onMouseEnter: function (event) {
|
|
8638
|
+
decorateRowStat(event.currentTarget, props.statSide || 'remote', path, source, t, locale);
|
|
8639
|
+
},
|
|
8093
8640
|
onKeyDown: function (event) {
|
|
8094
8641
|
if (event.key === 'ArrowRight' && !isOpen) { event.preventDefault(); toggle(path); }
|
|
8095
8642
|
else if (event.key === 'ArrowLeft' && isOpen) { event.preventDefault(); toggle(path); }
|
|
@@ -8132,7 +8679,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
8132
8679
|
h('span', { className: 'rw-chevron' + (isOpen ? ' is-open' : '') }, IconChevron(12)),
|
|
8133
8680
|
h(FileGlyph, { name: name, dir: true, open: isOpen, size: 13 }),
|
|
8134
8681
|
h('span', { className: 'rw-row-name' }, name)),
|
|
8135
|
-
|
|
8682
|
+
// The wrapper carries the folder path so a child row can walk back up
|
|
8683
|
+
// to the folder that owns it (← from a file focuses its folder).
|
|
8684
|
+
children.length > 0 ? h('div', { className: 'rw-tree-children', 'data-dir-path': path }, children) : null);
|
|
8136
8685
|
}
|
|
8137
8686
|
|
|
8138
8687
|
function WorkspaceTreeSource(props) {
|
|
@@ -8267,7 +8816,14 @@ function attributeViolation(name, value, tagName) {
|
|
|
8267
8816
|
+ (source.kind === 'linked' ? ' · ' + t('linkedChip') : source.kind === 'remote' ? ' · ' + t('remoteChip') : ''))),
|
|
8268
8817
|
h(StatusPill, { status: source.status, t: t })),
|
|
8269
8818
|
open
|
|
8270
|
-
? h('div', {
|
|
8819
|
+
? h('div', {
|
|
8820
|
+
className: 'rw-tree-body',
|
|
8821
|
+
role: 'tree',
|
|
8822
|
+
'aria-label': source.name,
|
|
8823
|
+
// D3: ↑/↓/Home/End walk the visible rows; ←/→ are handled per row
|
|
8824
|
+
// (expand/collapse a folder, fold back up from a file).
|
|
8825
|
+
onKeyDown: function (event) { handleListKeys(event, event.currentTarget, '[role="treeitem"]'); },
|
|
8826
|
+
},
|
|
8271
8827
|
h(TreeDirectory, {
|
|
8272
8828
|
path: source.remotePath,
|
|
8273
8829
|
name: '/',
|
|
@@ -8282,6 +8838,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
8282
8838
|
loadMore: loadMore,
|
|
8283
8839
|
onSelect: props.onSelect,
|
|
8284
8840
|
selectedPath: props.selectedPath,
|
|
8841
|
+
statSide: 'remote',
|
|
8285
8842
|
}))
|
|
8286
8843
|
: null);
|
|
8287
8844
|
}
|
|
@@ -9469,7 +10026,20 @@ function attributeViolation(name, value, tagName) {
|
|
|
9469
10026
|
h('button', {
|
|
9470
10027
|
type: 'button', className: 'rw-btn' + (adding === 'remote' ? '' : ' rw-btn-primary'),
|
|
9471
10028
|
onClick: function () { toggleAdding('remote'); },
|
|
9472
|
-
}, adding === 'remote' ? IconClose(13) : IconRemoteWorkspace(13), t('createRemote'))
|
|
10029
|
+
}, adding === 'remote' ? IconClose(13) : IconRemoteWorkspace(13), t('createRemote')),
|
|
10030
|
+
// F6: the welcome card only shows once, so offer a way back to it.
|
|
10031
|
+
h('button', {
|
|
10032
|
+
type: 'button', className: 'rw-btn rw-btn-sm',
|
|
10033
|
+
title: t('welcomeReplay'),
|
|
10034
|
+
onClick: function () {
|
|
10035
|
+
try { if (window.localStorage) window.localStorage.removeItem(WELCOME_KEY); } catch (error) { /* ignore */ }
|
|
10036
|
+
// The card sits under the settings overlay, so close it first.
|
|
10037
|
+
dismissSettingsOverlay();
|
|
10038
|
+
setTimeout(function () {
|
|
10039
|
+
try { window.dispatchEvent(new CustomEvent(WELCOME_EVENT)); } catch (error) { /* ignore */ }
|
|
10040
|
+
}, 60);
|
|
10041
|
+
},
|
|
10042
|
+
}, IconAlert(13), t('welcomeReplay')))),
|
|
9473
10043
|
!sidebarAvailable ? h(Banner, { kind: 'warn' }, t('needsSidebar')) : null,
|
|
9474
10044
|
h(ThemeGroup, { t: t, locale: locale }),
|
|
9475
10045
|
h(EditorSettingsGroup, { t: t, locale: locale }),
|