dsh-linked-workspace 0.9.0 → 0.11.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 +37 -0
- package/README.en.md +166 -151
- package/README.md +148 -160
- package/docs/API.md +48 -36
- package/docs/VERIFY.md +67 -17
- package/lib/client.js +1307 -380
- package/lib/index.js +633 -266
- package/lib/ssh.js +20 -4
- package/locale/en.json +2 -2
- package/locale/zh.json +2 -2
- package/package.json +3 -4
package/lib/client.js
CHANGED
|
@@ -1947,7 +1947,10 @@ function attributeViolation(name, value, tagName) {
|
|
|
1947
1947
|
}
|
|
1948
1948
|
|
|
1949
1949
|
var TREE_TAB_TYPE = 'dsh-linked-workspace';
|
|
1950
|
-
|
|
1950
|
+
// Remote workspaces get their own page kind: the two modes show different
|
|
1951
|
+
// trees (local ⇄ remote pair vs. a plain remote root), so a session must be
|
|
1952
|
+
// able to hold both, and each one filters its own workspace list.
|
|
1953
|
+
var REMOTE_TREE_TAB_TYPE = 'dsh-remote-workspace';
|
|
1951
1954
|
// One tree page; a folder with 20k entries must not render 20k rows.
|
|
1952
1955
|
var TREE_PAGE_SIZE = 500;
|
|
1953
1956
|
var TREE_PAGE_MAX = 5000;
|
|
@@ -1957,10 +1960,16 @@ function attributeViolation(name, value, tagName) {
|
|
|
1957
1960
|
var REFRESH_MIN_INTERVAL_MS = 15000;
|
|
1958
1961
|
var linkedLocalKeys = new Set();
|
|
1959
1962
|
var linkedWorkspaceKeys = new Set();
|
|
1960
|
-
|
|
1963
|
+
// Remote workspaces run inside a placeholder directory, so they are matched
|
|
1964
|
+
// by that path (and by their DSH workspace id) instead of a local directory.
|
|
1965
|
+
var remotePlaceholderKeys = new Set();
|
|
1966
|
+
var remoteWorkspaceKeys = new Set();
|
|
1961
1967
|
var linkedTabDisposer = null;
|
|
1962
1968
|
var remoteTabDisposer = null;
|
|
1963
1969
|
var syncDirectoryTabsRef = null;
|
|
1970
|
+
// Set by the sidebar registration block so the availability refresh can ask
|
|
1971
|
+
// the sidebar to rebuild its "+" entries after the workspace lists change.
|
|
1972
|
+
var refreshTabVisibilityRef = null;
|
|
1964
1973
|
|
|
1965
1974
|
function linkedScopeKey(cwd) {
|
|
1966
1975
|
return String(cwd || '').replace(/\\/g, '/').replace(/\/+$/, '').toLowerCase();
|
|
@@ -1988,13 +1997,47 @@ function attributeViolation(name, value, tagName) {
|
|
|
1988
1997
|
return found;
|
|
1989
1998
|
}
|
|
1990
1999
|
|
|
2000
|
+
function isRemoteWorkspaceId(workspaceId) {
|
|
2001
|
+
return Boolean(workspaceId) && remoteWorkspaceKeys.has(String(workspaceId));
|
|
2002
|
+
}
|
|
2003
|
+
|
|
2004
|
+
function isRemoteScope(scope) {
|
|
2005
|
+
var key = linkedScopeKey(scope && scope.cwd);
|
|
2006
|
+
if (!key) return false;
|
|
2007
|
+
var found = false;
|
|
2008
|
+
remotePlaceholderKeys.forEach(function (placeholderKey) {
|
|
2009
|
+
if (found) return;
|
|
2010
|
+
if (key === placeholderKey || key.indexOf(placeholderKey + '/') === 0) found = true;
|
|
2011
|
+
});
|
|
2012
|
+
return found;
|
|
2013
|
+
}
|
|
2014
|
+
|
|
1991
2015
|
function dismissSettingsOverlay() {
|
|
2016
|
+
// 设置面板以 Escape 关闭;事件必须落在当前焦点元素上,直接派发到 window 不会触发它。
|
|
2017
|
+
function fire(target) {
|
|
2018
|
+
if (!target || typeof target.dispatchEvent !== 'function') return;
|
|
2019
|
+
target.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', code: 'Escape', keyCode: 27, which: 27, bubbles: true, cancelable: true }));
|
|
2020
|
+
}
|
|
1992
2021
|
try {
|
|
1993
|
-
|
|
2022
|
+
fire((typeof document !== 'undefined' && (document.activeElement || document.body)) || null);
|
|
2023
|
+
fire(typeof window !== 'undefined' ? window : null);
|
|
1994
2024
|
} catch (error) { /* keyboard unavailable */ }
|
|
1995
2025
|
}
|
|
1996
2026
|
|
|
1997
|
-
|
|
2027
|
+
// `dsh-better-sidebar` is an optional companion: everything that touches
|
|
2028
|
+
// its service goes through here, so a deployment without it keeps the
|
|
2029
|
+
// settings page, the directory flows and the agent tools working instead of
|
|
2030
|
+
// failing on a missing service lookup.
|
|
2031
|
+
function sidebarService(ctx) {
|
|
2032
|
+
if (!ctx || typeof ctx.get !== 'function') return undefined;
|
|
2033
|
+
try {
|
|
2034
|
+
return ctx.get('betterSidebar') || undefined;
|
|
2035
|
+
} catch (error) {
|
|
2036
|
+
return undefined;
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
|
|
2040
|
+
function rememberDirectoryAvailability(links, remotes) {
|
|
1998
2041
|
var next = new Set();
|
|
1999
2042
|
var workspaceKeys = new Set();
|
|
2000
2043
|
(links || []).forEach(function (link) {
|
|
@@ -2004,18 +2047,32 @@ function attributeViolation(name, value, tagName) {
|
|
|
2004
2047
|
});
|
|
2005
2048
|
linkedLocalKeys = next;
|
|
2006
2049
|
linkedWorkspaceKeys = workspaceKeys;
|
|
2007
|
-
|
|
2050
|
+
|
|
2051
|
+
var placeholderKeys = new Set();
|
|
2052
|
+
var remoteKeys = new Set();
|
|
2053
|
+
(remotes || []).forEach(function (workspace) {
|
|
2054
|
+
var key = linkedScopeKey(workspace.placeholderPath);
|
|
2055
|
+
if (key) placeholderKeys.add(key);
|
|
2056
|
+
if (workspace.workspaceId) remoteKeys.add(String(workspace.workspaceId));
|
|
2057
|
+
});
|
|
2058
|
+
remotePlaceholderKeys = placeholderKeys;
|
|
2059
|
+
remoteWorkspaceKeys = remoteKeys;
|
|
2008
2060
|
}
|
|
2009
2061
|
|
|
2010
2062
|
function refreshDirectoryAvailability() {
|
|
2011
2063
|
return Promise.all([
|
|
2012
2064
|
apiCall('linked.list').catch(function () { return { links: [] }; }),
|
|
2013
|
-
apiCall('
|
|
2065
|
+
apiCall('remote_workspaces.list').catch(function () { return { workspaces: [] }; }),
|
|
2014
2066
|
]).then(function (results) {
|
|
2015
|
-
var links = results[0] && results[0].links
|
|
2016
|
-
var
|
|
2017
|
-
rememberDirectoryAvailability(links,
|
|
2018
|
-
|
|
2067
|
+
var links = (results[0] && results[0].links) || [];
|
|
2068
|
+
var remotes = (results[1] && results[1].workspaces) || [];
|
|
2069
|
+
rememberDirectoryAvailability(links, remotes);
|
|
2070
|
+
publishWorkspaceIcons(links, remotes);
|
|
2071
|
+
// The "+" menu decides visibility from this availability data, and the
|
|
2072
|
+
// sidebar only rebuilds its entries when something notifies it.
|
|
2073
|
+
if (refreshTabVisibilityRef !== null) {
|
|
2074
|
+
try { refreshTabVisibilityRef(); } catch (error) { /* ignore */ }
|
|
2075
|
+
}
|
|
2019
2076
|
});
|
|
2020
2077
|
}
|
|
2021
2078
|
function releaseRemoteFileSlot(kind) {
|
|
@@ -2067,14 +2124,12 @@ function attributeViolation(name, value, tagName) {
|
|
|
2067
2124
|
// ── i18n ────────────────────────────────────────────────────────────────
|
|
2068
2125
|
|
|
2069
2126
|
var ZH = {
|
|
2070
|
-
settingsNav: '
|
|
2071
|
-
title: '
|
|
2072
|
-
intro: '
|
|
2127
|
+
settingsNav: '联动工作区',
|
|
2128
|
+
title: '联动&远程工作区',
|
|
2129
|
+
intro: '把 SSH 连接变成工作区:联动工作区把本地目录与远端目录配对,远程工作区让会话直接运行在远端目录。会话都能读取、搜索和编辑远端文件。',
|
|
2073
2130
|
addWorkspace: '添加工作区',
|
|
2074
|
-
addRemoteDir: '添加远程目录',
|
|
2075
2131
|
addLinked: '添加联动工作区',
|
|
2076
2132
|
createLinked: '创建联动工作区',
|
|
2077
|
-
addAction: '添加',
|
|
2078
2133
|
addShort: '添加',
|
|
2079
2134
|
refresh: '刷新',
|
|
2080
2135
|
open: '打开',
|
|
@@ -2083,15 +2138,17 @@ function attributeViolation(name, value, tagName) {
|
|
|
2083
2138
|
remove: '移除',
|
|
2084
2139
|
confirmRemove: '确认移除',
|
|
2085
2140
|
removeHint: '只移除记录,不会删除远端文件。',
|
|
2086
|
-
emptyTitle: '
|
|
2087
|
-
emptyBody: '
|
|
2141
|
+
emptyTitle: '还没有可浏览的工作区',
|
|
2142
|
+
emptyBody: '先在「设置 → 连接」里创建联动工作区或远程工作区,左侧「添加工作区」里也能创建。',
|
|
2088
2143
|
emptyHint: '没有找到可用的 SSH 连接。请先在右侧栏的 SSH Tunnel 面板里添加主机。',
|
|
2089
2144
|
stepHost: '1. 选择 SSH 连接',
|
|
2090
2145
|
stepPath: '2. 远程目录',
|
|
2091
2146
|
stepLocalPath: '3. 本地目录',
|
|
2092
2147
|
stepName: '4. 工作区名称',
|
|
2148
|
+
remoteStepName: '3. 工作区名称',
|
|
2093
2149
|
pathPlaceholder: '/shared_data_ssd1/huangjh/project',
|
|
2094
2150
|
localPathPlaceholder: 'C:\\Users\\you\\projects\\demo',
|
|
2151
|
+
localPathRequired: '先选择或填写一个本地目录',
|
|
2095
2152
|
namePlaceholder: '留空则使用目录名',
|
|
2096
2153
|
browse: '浏览…',
|
|
2097
2154
|
browsing: '正在浏览…',
|
|
@@ -2107,6 +2164,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
2107
2164
|
connected: '已连接',
|
|
2108
2165
|
idle: '未连接',
|
|
2109
2166
|
errorState: '连接异常',
|
|
2167
|
+
disconnected: '连接已断开',
|
|
2110
2168
|
testOk: '连接正常',
|
|
2111
2169
|
testFail: '连接失败',
|
|
2112
2170
|
testRunning: '正在测试…',
|
|
@@ -2143,7 +2201,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
2143
2201
|
moveHint: '进入目标文件夹后点击「使用此目录」',
|
|
2144
2202
|
ctxMove: '移动到…',
|
|
2145
2203
|
noWorkspace: '远程工作区不存在,请重新添加。',
|
|
2146
|
-
noTarget: '
|
|
2204
|
+
noTarget: '没有可浏览的工作区。先在设置 → 连接中创建,或点击左侧「添加工作区」。',
|
|
2147
2205
|
treeEmpty: '空目录',
|
|
2148
2206
|
sourceManager: 'SSH 管理器',
|
|
2149
2207
|
sourceConfig: '~/.ssh/config',
|
|
@@ -2199,11 +2257,11 @@ function attributeViolation(name, value, tagName) {
|
|
|
2199
2257
|
dropImported: '已导入 {{count}} 个文件',
|
|
2200
2258
|
dropSkipped: '{{count}} 个文件被跳过(过大或不是普通文件)',
|
|
2201
2259
|
dropDirUnsupported: '暂不支持把远程目录拖拽到本地,请使用右键「传输」',
|
|
2260
|
+
dropLocalDirUnsupported: '暂不支持把本地目录拖拽到远端,请使用右键「传输」',
|
|
2202
2261
|
sheetTruncated: '仅显示前 {{rows}} 行 × {{cols}} 列',
|
|
2203
2262
|
sheetMore: '工作表较多,仅显示前 20 个',
|
|
2204
2263
|
noCredential: '缺少凭据',
|
|
2205
2264
|
sourceManagerShort: 'SSH',
|
|
2206
|
-
remoteGroup: '远程目录',
|
|
2207
2265
|
linkedGroup: '联动工作区',
|
|
2208
2266
|
linkedEmpty: '还没有联动工作区。联动工作区会把本地目录与远端目录配对,会话可直接编辑远端文件。',
|
|
2209
2267
|
linkedName: '联动工作区',
|
|
@@ -2225,6 +2283,25 @@ function attributeViolation(name, value, tagName) {
|
|
|
2225
2283
|
removeWorkspaceHint: '「同时移除工作区」会把该本地目录从 DSH 工作区列表移除(会话保留,显示在未分组下)。',
|
|
2226
2284
|
openWorkspace: '打开工作区',
|
|
2227
2285
|
workspaceMissing: '工作区未注册',
|
|
2286
|
+
workspaceRegister: '注册为工作区',
|
|
2287
|
+
workspaceRegistered: '已注册为工作区',
|
|
2288
|
+
conflictDropTitle: '目标已存在',
|
|
2289
|
+
conflictOverwrite: '覆盖',
|
|
2290
|
+
conflictKeepBoth: '保留两者',
|
|
2291
|
+
conflictCancel: '取消',
|
|
2292
|
+
compareLocalMissing: '本地没有对应目录,远端独有的文件无法对比',
|
|
2293
|
+
compareTruncatedRemote: '远端条目过多,对比只覆盖前 4000 项',
|
|
2294
|
+
compareTruncatedLocal: '本地条目过多,对比只覆盖前 4000 项',
|
|
2295
|
+
comparePush: '推送到远端',
|
|
2296
|
+
comparePull: '拉取到本地',
|
|
2297
|
+
comparePushed: '已推送 {{name}}',
|
|
2298
|
+
comparePulled: '已拉取 {{name}}',
|
|
2299
|
+
dropSameSide: '同一工作区内请使用「移动到…」;拖拽只用于本地与远端之间',
|
|
2300
|
+
searchModeName: '文件名',
|
|
2301
|
+
searchModeContent: '内容',
|
|
2302
|
+
searchPlaceholderContent: '在文件内容中搜索…',
|
|
2303
|
+
queueRetry: '重试',
|
|
2304
|
+
shortcutWebNote: 'Web GUI 中 Ctrl+W、Ctrl+Tab 由浏览器占用,请在 DSH 桌面端使用这些快捷键。',
|
|
2228
2305
|
themeTitle: '编辑器主题',
|
|
2229
2306
|
themeHint: '远程文件编辑器的配色;主题只影响本插件的远程文件视图。',
|
|
2230
2307
|
themeDark: '深色',
|
|
@@ -2261,10 +2338,6 @@ function attributeViolation(name, value, tagName) {
|
|
|
2261
2338
|
docPageOf: '第 {page} / {total} 页',
|
|
2262
2339
|
docExportDone: '已导出 PDF:{path}',
|
|
2263
2340
|
docPreviewFailed: '预览失败',
|
|
2264
|
-
remoteTabTitle: '远程目录',
|
|
2265
|
-
remoteTabDesc: '只读查看已添加的远程目录及其文件,不允许编辑。',
|
|
2266
|
-
remoteDirsTitle: '远程目录',
|
|
2267
|
-
remoteDirsHint: '直接浏览远端目录(只读)。',
|
|
2268
2341
|
linkedTitle: '联动工作区',
|
|
2269
2342
|
linkedHint: '本地目录与远端目录成对出现:DSH 会话在该本地目录中工作,并通过 linked_workspace 工具直接编辑远端文件。',
|
|
2270
2343
|
localFlow: '本地目录',
|
|
@@ -2287,6 +2360,32 @@ function attributeViolation(name, value, tagName) {
|
|
|
2287
2360
|
openInTab: '在标签中打开',
|
|
2288
2361
|
linkedBadge: '本地 ⇄ 远端',
|
|
2289
2362
|
linkedChip: '联动',
|
|
2363
|
+
remoteChip: '远程',
|
|
2364
|
+
remoteGroup: '远程工作区',
|
|
2365
|
+
remoteEmpty: '还没有远程工作区。远程工作区会让会话直接运行在 SSH 主机的目录里,本地不落任何项目文件。',
|
|
2366
|
+
remoteTitle: '远程工作区',
|
|
2367
|
+
remoteHint: '会话运行在远端目录:DSH 不在本地创建项目文件,模型通过 remote_workspace 与 linked_workspace 工具读写远端。',
|
|
2368
|
+
addRemote: '添加远程工作区',
|
|
2369
|
+
createRemote: '创建远程工作区',
|
|
2370
|
+
remoteTabTitle: '远程工作区目录',
|
|
2371
|
+
remoteTabDesc: '远程工作区的远端目录;点击文件在新标签页打开。',
|
|
2372
|
+
remotePlaceholderLabel: '本地占位目录',
|
|
2373
|
+
remotePlaceholderHint: '占位目录只用于把工作区注册进 DSH,不会同步任何远端文件;请不要在里面存放项目文件。',
|
|
2374
|
+
remoteCreateFailed: '创建远程工作区失败',
|
|
2375
|
+
remoteUpdateFailed: '重命名远程工作区失败',
|
|
2376
|
+
remoteRemoveFailed: '移除远程工作区失败',
|
|
2377
|
+
remoteRemoved: '已移除远程工作区',
|
|
2378
|
+
removeRemote: '移除远程工作区',
|
|
2379
|
+
remoteRemoveHint: '只移除记录与占位目录,不会删除远端文件。',
|
|
2380
|
+
remoteSessionHint: '在该工作区下新建会话即可直接使用远端目录。',
|
|
2381
|
+
flowRemote: '远程工作区',
|
|
2382
|
+
flowRemoteDesc: '会话运行在远端目录,本地只保留一个占位目录',
|
|
2383
|
+
localSideMissing: '该工作区没有本地目录',
|
|
2384
|
+
remoteWorkspacesFailed: '读取远程工作区失败',
|
|
2385
|
+
openTree: '打开目录树',
|
|
2386
|
+
testConnection: '测试连接',
|
|
2387
|
+
testFailed: '连接失败',
|
|
2388
|
+
rename: '重命名',
|
|
2290
2389
|
pathLocalShort: '本地',
|
|
2291
2390
|
pathRemoteShort: '远端',
|
|
2292
2391
|
flowTitle: '添加工作区',
|
|
@@ -2429,14 +2528,13 @@ function attributeViolation(name, value, tagName) {
|
|
|
2429
2528
|
};
|
|
2430
2529
|
|
|
2431
2530
|
var EN = {
|
|
2432
|
-
settingsNav: '
|
|
2433
|
-
title: '
|
|
2434
|
-
intro: 'Turn an
|
|
2531
|
+
settingsNav: 'Linked workspaces',
|
|
2532
|
+
title: 'Linked & remote workspaces',
|
|
2533
|
+
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.',
|
|
2435
2534
|
addWorkspace: 'Add workspace',
|
|
2436
2535
|
addRemoteDir: 'Add remote directory',
|
|
2437
2536
|
addLinked: 'Add linked workspace',
|
|
2438
2537
|
createLinked: 'Create linked workspace',
|
|
2439
|
-
addAction: 'Add',
|
|
2440
2538
|
addShort: 'Add',
|
|
2441
2539
|
refresh: 'Refresh',
|
|
2442
2540
|
open: 'Open',
|
|
@@ -2445,15 +2543,17 @@ function attributeViolation(name, value, tagName) {
|
|
|
2445
2543
|
remove: 'Remove',
|
|
2446
2544
|
confirmRemove: 'Confirm remove',
|
|
2447
2545
|
removeHint: 'Removes the record only; remote files stay untouched.',
|
|
2448
|
-
emptyTitle: 'No
|
|
2449
|
-
emptyBody: '
|
|
2546
|
+
emptyTitle: 'No workspace to browse yet',
|
|
2547
|
+
emptyBody: 'Create a linked or remote workspace in Settings → Connections, or from “Add workspace” on the left.',
|
|
2450
2548
|
emptyHint: 'No SSH connections found. Add a host in the Side card’s SSH Tunnel panel first.',
|
|
2451
2549
|
stepHost: '1. Choose an SSH connection',
|
|
2452
2550
|
stepPath: '2. Remote directory',
|
|
2453
2551
|
stepLocalPath: '3. Local directory',
|
|
2454
2552
|
stepName: '4. Workspace name',
|
|
2553
|
+
remoteStepName: '3. Workspace name',
|
|
2455
2554
|
pathPlaceholder: '/home/you/project',
|
|
2456
2555
|
localPathPlaceholder: 'C:\\Users\\you\\projects\\demo',
|
|
2556
|
+
localPathRequired: 'Choose or enter a local directory first',
|
|
2457
2557
|
namePlaceholder: 'Defaults to the directory name',
|
|
2458
2558
|
browse: 'Browse…',
|
|
2459
2559
|
browsing: 'Browsing…',
|
|
@@ -2469,6 +2569,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
2469
2569
|
connected: 'Connected',
|
|
2470
2570
|
idle: 'Not connected',
|
|
2471
2571
|
errorState: 'Connection error',
|
|
2572
|
+
disconnected: 'Connection lost',
|
|
2472
2573
|
testOk: 'Connection OK',
|
|
2473
2574
|
testFail: 'Connection failed',
|
|
2474
2575
|
testRunning: 'Testing…',
|
|
@@ -2505,7 +2606,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
2505
2606
|
moveHint: 'Open the destination folder, then click “Use this directory”',
|
|
2506
2607
|
ctxMove: 'Move to…',
|
|
2507
2608
|
noWorkspace: 'This remote workspace no longer exists. Add it again.',
|
|
2508
|
-
noTarget: 'No
|
|
2609
|
+
noTarget: 'No workspace to browse. Create one in Settings → Connections, or click “Add workspace” on the left.',
|
|
2509
2610
|
treeEmpty: 'Empty directory',
|
|
2510
2611
|
sourceManager: 'SSH Manager',
|
|
2511
2612
|
sourceConfig: '~/.ssh/config',
|
|
@@ -2561,11 +2662,11 @@ function attributeViolation(name, value, tagName) {
|
|
|
2561
2662
|
dropImported: 'Imported {{count}} file(s)',
|
|
2562
2663
|
dropSkipped: '{{count}} file(s) skipped (too large or not a regular file)',
|
|
2563
2664
|
dropDirUnsupported: 'Dropping a remote folder onto local is not supported yet; use Transfer instead',
|
|
2665
|
+
dropLocalDirUnsupported: 'Dropping a local folder onto remote is not supported yet; use Transfer instead',
|
|
2564
2666
|
sheetTruncated: 'Showing the first {{rows}} rows × {{cols}} columns',
|
|
2565
2667
|
sheetMore: 'Showing the first 20 worksheets only',
|
|
2566
2668
|
noCredential: 'No credentials',
|
|
2567
2669
|
sourceManagerShort: 'SSH',
|
|
2568
|
-
remoteGroup: 'Remote directories',
|
|
2569
2670
|
linkedGroup: 'Linked workspaces',
|
|
2570
2671
|
linkedEmpty: 'No linked workspaces yet. A linked workspace pairs a local folder with a remote folder so sessions can edit remote files directly.',
|
|
2571
2672
|
linkedName: 'Linked workspace',
|
|
@@ -2587,6 +2688,25 @@ function attributeViolation(name, value, tagName) {
|
|
|
2587
2688
|
removeWorkspaceHint: '“Remove workspace too” also removes the local folder from the DSH workspace list (sessions stay, shown under ungrouped).',
|
|
2588
2689
|
openWorkspace: 'Open workspace',
|
|
2589
2690
|
workspaceMissing: 'Workspace not registered',
|
|
2691
|
+
workspaceRegister: 'Register as workspace',
|
|
2692
|
+
workspaceRegistered: 'Registered as workspace',
|
|
2693
|
+
conflictDropTitle: 'Target already exists',
|
|
2694
|
+
conflictOverwrite: 'Overwrite',
|
|
2695
|
+
conflictKeepBoth: 'Keep both',
|
|
2696
|
+
conflictCancel: 'Cancel',
|
|
2697
|
+
compareLocalMissing: 'The local folder has no counterpart here; remote-only entries cannot be compared',
|
|
2698
|
+
compareTruncatedRemote: 'Too many remote entries; the comparison covers the first 4000',
|
|
2699
|
+
compareTruncatedLocal: 'Too many local entries; the comparison covers the first 4000',
|
|
2700
|
+
comparePush: 'Push to remote',
|
|
2701
|
+
comparePull: 'Pull to local',
|
|
2702
|
+
comparePushed: 'Pushed {{name}}',
|
|
2703
|
+
comparePulled: 'Pulled {{name}}',
|
|
2704
|
+
dropSameSide: 'Within one side, use “Move to…”; dragging is for local ↔ remote only',
|
|
2705
|
+
searchModeName: 'Name',
|
|
2706
|
+
searchModeContent: 'Content',
|
|
2707
|
+
searchPlaceholderContent: 'Search file contents…',
|
|
2708
|
+
queueRetry: 'Retry',
|
|
2709
|
+
shortcutWebNote: 'In the Web GUI, Ctrl+W and Ctrl+Tab are reserved by the browser; use these shortcuts in the DSH desktop app.',
|
|
2590
2710
|
themeTitle: 'Editor theme',
|
|
2591
2711
|
themeHint: 'Colors of the remote file editor. Themes affect this plugin’s remote file views only.',
|
|
2592
2712
|
themeDark: 'Dark',
|
|
@@ -2623,10 +2743,6 @@ function attributeViolation(name, value, tagName) {
|
|
|
2623
2743
|
docPageOf: 'Page {page} / {total}',
|
|
2624
2744
|
docExportDone: 'Exported PDF: {path}',
|
|
2625
2745
|
docPreviewFailed: 'Preview failed',
|
|
2626
|
-
remoteTabTitle: 'Remote directories',
|
|
2627
|
-
remoteTabDesc: 'Read-only view of configured remote directories and files; editing is disabled.',
|
|
2628
|
-
remoteDirsTitle: 'Remote directories',
|
|
2629
|
-
remoteDirsHint: 'Browse remote directories read-only (no local copy).',
|
|
2630
2746
|
linkedTitle: 'Linked workspaces',
|
|
2631
2747
|
linkedHint: 'A local folder paired with a remote folder: DSH sessions work in the local folder and edit remote files through the linked_workspace tool.',
|
|
2632
2748
|
localFlow: 'Local folder',
|
|
@@ -2649,6 +2765,32 @@ function attributeViolation(name, value, tagName) {
|
|
|
2649
2765
|
openInTab: 'Open in tab',
|
|
2650
2766
|
linkedBadge: 'Local ⇄ remote',
|
|
2651
2767
|
linkedChip: 'Linked',
|
|
2768
|
+
remoteChip: 'Remote',
|
|
2769
|
+
remoteGroup: 'Remote workspaces',
|
|
2770
|
+
remoteEmpty: 'No remote workspace yet. A remote workspace runs sessions directly inside an SSH host folder, so nothing is written to your machine.',
|
|
2771
|
+
remoteTitle: 'Remote workspaces',
|
|
2772
|
+
remoteHint: 'Sessions run in the remote folder: DSH creates no local project files, and the model reads and writes the remote side through the remote_workspace and linked_workspace tools.',
|
|
2773
|
+
addRemote: 'Add remote workspace',
|
|
2774
|
+
createRemote: 'Create remote workspace',
|
|
2775
|
+
remoteTabTitle: 'Remote workspace tree',
|
|
2776
|
+
remoteTabDesc: 'The remote folder of this remote workspace; click a file to open it in a new tab.',
|
|
2777
|
+
remotePlaceholderLabel: 'Local placeholder',
|
|
2778
|
+
remotePlaceholderHint: 'The placeholder only registers the workspace in DSH and never mirrors remote files; do not keep project files in it.',
|
|
2779
|
+
remoteCreateFailed: 'Could not create the remote workspace',
|
|
2780
|
+
remoteUpdateFailed: 'Could not rename the remote workspace',
|
|
2781
|
+
remoteRemoveFailed: 'Could not remove the remote workspace',
|
|
2782
|
+
remoteRemoved: 'Remote workspace removed',
|
|
2783
|
+
removeRemote: 'Remove remote workspace',
|
|
2784
|
+
remoteRemoveHint: 'Only the record and the placeholder are removed; remote files are untouched.',
|
|
2785
|
+
remoteSessionHint: 'Start a session in this workspace to work directly in the remote folder.',
|
|
2786
|
+
flowRemote: 'Remote workspace',
|
|
2787
|
+
flowRemoteDesc: 'Sessions run in the remote folder; only a placeholder stays local',
|
|
2788
|
+
localSideMissing: 'This workspace has no local folder',
|
|
2789
|
+
remoteWorkspacesFailed: 'Could not read remote workspaces',
|
|
2790
|
+
openTree: 'Open tree',
|
|
2791
|
+
testConnection: 'Test connection',
|
|
2792
|
+
testFailed: 'Connection failed',
|
|
2793
|
+
rename: 'Rename',
|
|
2652
2794
|
pathLocalShort: 'Local',
|
|
2653
2795
|
pathRemoteShort: 'Remote',
|
|
2654
2796
|
flowTitle: 'Add workspace',
|
|
@@ -3016,6 +3158,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
3016
3158
|
function scopeParams(scope) {
|
|
3017
3159
|
if (!scope) return {};
|
|
3018
3160
|
if (scope.kind === 'linked') return { linkedId: scope.id };
|
|
3161
|
+
if (scope.kind === 'remote') return { remoteId: scope.id };
|
|
3019
3162
|
return { workspaceId: scope.id };
|
|
3020
3163
|
}
|
|
3021
3164
|
|
|
@@ -3144,8 +3287,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
3144
3287
|
'.rw-btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;height:30px;padding:0 12px;border-radius:8px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;cursor:pointer;white-space:nowrap;transition:background .12s ease,border-color .12s ease,opacity .12s ease}',
|
|
3145
3288
|
'.rw-btn:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12))}',
|
|
3146
3289
|
'.rw-btn:disabled{opacity:.5;cursor:not-allowed}',
|
|
3147
|
-
'.rw-btn-primary{background:var(--dsw-alias-brand-primary);border-color:transparent;color
|
|
3290
|
+
'.rw-btn-primary{background:var(--dsw-alias-brand-primary);border-color:transparent;color:var(--dsw-alias-bg-base)}',
|
|
3148
3291
|
'.rw-btn-primary:hover{filter:brightness(1.06)}',
|
|
3292
|
+
'body[data-ds-dark-theme] .rw-btn-primary{color:#000}',
|
|
3149
3293
|
'.rw-btn-ghost{background:transparent;border-color:transparent;color:var(--dsw-alias-label-secondary)}',
|
|
3150
3294
|
'.rw-btn-ghost:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12))}',
|
|
3151
3295
|
'.rw-btn-danger{color:var(--dsw-alias-state-error-primary);border-color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 40%,transparent)}',
|
|
@@ -3164,6 +3308,11 @@ function attributeViolation(name, value, tagName) {
|
|
|
3164
3308
|
'.rw-chip{display:inline-flex;align-items:center;gap:4px;padding:1px 8px;border-radius:999px;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);font-size:11px;line-height:16px;white-space:nowrap}',
|
|
3165
3309
|
'.rw-chip-link{color:var(--dsw-alias-state-success-primary);border-color:color-mix(in srgb,var(--dsw-alias-state-success-primary) 45%,transparent)}',
|
|
3166
3310
|
'.rw-path{font-family:ui-monospace,"Cascadia Code",Consolas,monospace;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary);word-break:break-all}',
|
|
3311
|
+
// Injected into the host's workspace hover preview, which always paints on
|
|
3312
|
+
// a fixed dark card, so these colours cannot follow the theme tokens.
|
|
3313
|
+
'.rw-hover-status{margin:1px 0 0;font-size:12px;line-height:18px;color:rgb(207,211,214)}',
|
|
3314
|
+
'.rw-hover-status.is-on{color:#3fb950}',
|
|
3315
|
+
'.rw-hover-status.is-off{color:#f85149}',
|
|
3167
3316
|
'.rw-meta{display:flex;align-items:center;gap:8px;flex-wrap:wrap;min-width:0}',
|
|
3168
3317
|
'.rw-meta-text{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
3169
3318
|
'.rw-pair{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:8px}',
|
|
@@ -3278,7 +3427,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
3278
3427
|
'.rw-switch-track{position:relative;flex:none;width:30px;height:18px;border-radius:999px;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l2);transition:background .12s ease,border-color .12s ease}',
|
|
3279
3428
|
'.rw-switch-thumb{position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;background:var(--dsw-alias-label-tertiary);transition:transform .12s ease,background .12s ease}',
|
|
3280
3429
|
'.rw-switch input:checked + .rw-switch-track{background:color-mix(in srgb,var(--dsw-alias-brand-primary) 55%,transparent);border-color:transparent}',
|
|
3281
|
-
'.rw-switch input:checked + .rw-switch-track .rw-switch-thumb{transform:translateX(12px);background
|
|
3430
|
+
'.rw-switch input:checked + .rw-switch-track .rw-switch-thumb{transform:translateX(12px);background:var(--dsw-alias-bg-base)}',
|
|
3282
3431
|
'.rw-theme-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(168px,1fr));gap:10px}',
|
|
3283
3432
|
'.rw-theme-card{display:flex;flex-direction:column;gap:6px;padding:8px;border:1px solid var(--dsw-alias-border-l2);border-radius:10px;background:var(--dsw-alias-bg-layer-1);cursor:pointer;font:inherit;color:inherit;text-align:left}',
|
|
3284
3433
|
'.rw-theme-card.is-on{border-color:var(--dsw-alias-brand-primary);box-shadow:0 0 0 1px color-mix(in srgb,var(--dsw-alias-brand-primary) 45%,transparent)}',
|
|
@@ -3382,6 +3531,13 @@ function attributeViolation(name, value, tagName) {
|
|
|
3382
3531
|
'.rw-compare-row:hover{background:var(--dsw-alias-interactive-bg-hover)}',
|
|
3383
3532
|
'.rw-compare-path{flex:1 1 auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
3384
3533
|
'.rw-compare-size{flex:0 0 auto;color:var(--dsw-alias-label-tertiary)}',
|
|
3534
|
+
'.rw-compare-item{display:flex;align-items:center;gap:4px}',
|
|
3535
|
+
'.rw-compare-item .rw-compare-row{flex:1 1 auto;min-width:0}',
|
|
3536
|
+
'.rw-compare-actions{display:flex;gap:4px;flex:0 0 auto;padding-right:4px}',
|
|
3537
|
+
'.rw-compare-act{border:1px solid var(--dsw-alias-border-l2);background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:10.5px;padding:1px 6px;border-radius:4px;cursor:pointer;white-space:nowrap}',
|
|
3538
|
+
'.rw-compare-act:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}',
|
|
3539
|
+
'.rw-search-mode{display:flex;gap:2px;flex:0 0 auto}',
|
|
3540
|
+
'.rw-doc-find{flex:0 0 auto}',
|
|
3385
3541
|
'.rw-dialog-note{font-size:11px;color:var(--dsw-alias-label-tertiary);padding:2px 0}',
|
|
3386
3542
|
'.rw-dialog-error{color:var(--dsw-alias-state-error-primary)}',
|
|
3387
3543
|
'.rw-row.is-drop-target{outline:1px dashed var(--dsw-alias-brand-primary);outline-offset:-1px}',
|
|
@@ -3469,19 +3625,41 @@ function attributeViolation(name, value, tagName) {
|
|
|
3469
3625
|
};
|
|
3470
3626
|
}
|
|
3471
3627
|
|
|
3472
|
-
// ──
|
|
3628
|
+
// ── workspace row icons ────────────────────────────────────────────────
|
|
3473
3629
|
// DSH renders a fixed folder glyph for every workspace row; the sidebar
|
|
3474
3630
|
// gives plugins no per-row icon slot. This stylesheet swaps that glyph for
|
|
3475
|
-
//
|
|
3631
|
+
// the icon of the workspace kind (identified by the documented
|
|
3476
3632
|
// data-row-key attribute). If the host markup ever changes the selector
|
|
3477
3633
|
// simply stops matching and the folder glyph stays — a safe degradation.
|
|
3478
3634
|
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3635
|
+
// Filled 1024-unit shapes, shared by the row masks and the JSX icons so a
|
|
3636
|
+
// workspace looks the same in the sidebar, the settings cards, the dialogs
|
|
3637
|
+
// and the sidebar "+" menu.
|
|
3638
|
+
// Linked workspace: two interlocking chain links (local ⇄ remote).
|
|
3639
|
+
var LINKED_ICON_PATHS = [
|
|
3640
|
+
'M861.866667 164.266667c-87.466667-87.466667-230.4-89.6-320-2.133334l-68.266667 68.266667c-12.8 12.8-12.8 32 0 44.8s32 12.8 44.8 0l68.266667-68.266667c64-61.866667 166.4-61.866667 230.4 2.133334 64 64 64 168.533333 2.133333 232.533333l-117.333333 119.466667c-34.133333 34.133333-81.066667 51.2-128 49.066666-46.933333-4.266667-91.733333-27.733333-119.466667-66.133333-10.666667-14.933333-29.866667-17.066667-44.8-6.4-14.933333 10.666667-17.066667 29.866667-6.4 44.8 40.533333 53.333333 100.266667 87.466667 166.4 91.733333h17.066667c59.733333 0 119.466667-23.466667 162.133333-68.266666l117.333333-119.466667c83.2-89.6 83.2-234.666667-4.266666-322.133333z',
|
|
3641
|
+
'M505.6 750.933333l-66.133333 68.266667c-64 61.866667-166.4 61.866667-230.4-2.133333-64-64-64-168.533333-2.133334-232.533334l117.333334-119.466666c34.133333-34.133333 81.066667-51.2 128-49.066667 46.933333 4.266667 91.733333 27.733333 119.466666 66.133333 10.666667 14.933333 29.866667 17.066667 44.8 6.4 14.933333-10.666667 17.066667-29.866667 6.4-44.8-40.533333-53.333333-100.266667-87.466667-166.4-91.733333-66.133333-4.266667-130.133333 19.2-177.066666 66.133333l-117.333334 119.466667c-85.333333 89.6-85.333333 234.666667 2.133334 322.133333 44.8 44.8 102.4 66.133333 162.133333 66.133334 57.6 0 115.2-21.333333 160-64l66.133333-68.266667c12.8-12.8 12.8-32 0-44.8-14.933333-10.666667-34.133333-10.666667-46.933333 2.133333z',
|
|
3642
|
+
];
|
|
3643
|
+
// Remote workspace: a display with an outbound arrow — the session itself
|
|
3644
|
+
// runs on the far side of the connection.
|
|
3645
|
+
var REMOTE_ICON_PATHS = [
|
|
3646
|
+
'M896 64a64 64 0 0 1 64 64v608a64 64 0 0 1-64 64H128a64 64 0 0 1-64-64V128a64 64 0 0 1 64-64h768z m-12.8 76.8H140.8v582.4h742.4V140.8z',
|
|
3647
|
+
'M320 883.2m38.4 0l307.2 0q38.4 0 38.4 38.4l0 0q0 38.4-38.4 38.4l-307.2 0q-38.4 0-38.4-38.4l0 0q0-38.4 38.4-38.4Z',
|
|
3648
|
+
'M262.4 224h243.2a38.4 38.4 0 1 1 0 76.8H351.808L586.24 535.168a38.4 38.4 0 0 1 4.032 49.536l-4.032 4.736-4.736 4.032a38.4 38.4 0 0 1-49.6-4.032L300.8 358.272 300.8 505.6a38.4 38.4 0 0 1-76.8 0V262.4a38.4 38.4 0 0 1 38.4-38.4z',
|
|
3649
|
+
];
|
|
3650
|
+
|
|
3651
|
+
var ICON_DISCONNECTED_COLOR = '#f85149';
|
|
3652
|
+
var ICON_BUSY_COLOR = '#2f81f7';
|
|
3653
|
+
|
|
3654
|
+
function iconMaskUrl(paths) {
|
|
3655
|
+
var markup = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" fill="black">'
|
|
3656
|
+
+ paths.map(function (path) { return '<path d="' + path + '"/>'; }).join('')
|
|
3657
|
+
+ '</svg>';
|
|
3658
|
+
return 'url("data:image/svg+xml,' + encodeURIComponent(markup) + '")';
|
|
3659
|
+
}
|
|
3660
|
+
|
|
3661
|
+
var LINKED_ICON_MASK = iconMaskUrl(LINKED_ICON_PATHS);
|
|
3662
|
+
var REMOTE_ICON_MASK = iconMaskUrl(REMOTE_ICON_PATHS);
|
|
3485
3663
|
|
|
3486
3664
|
function workspaceIconStyleTag() {
|
|
3487
3665
|
if (typeof document === 'undefined' || !document.head) return null;
|
|
@@ -3495,22 +3673,216 @@ function attributeViolation(name, value, tagName) {
|
|
|
3495
3673
|
return tag;
|
|
3496
3674
|
}
|
|
3497
3675
|
|
|
3498
|
-
function
|
|
3676
|
+
function stateOf(item) {
|
|
3677
|
+
var status = item && item.status;
|
|
3678
|
+
var state = status && status.state;
|
|
3679
|
+
return typeof state === 'string' && state !== '' ? state : 'idle';
|
|
3680
|
+
}
|
|
3681
|
+
|
|
3682
|
+
function isDisconnected(item) {
|
|
3683
|
+
return stateOf(item) === 'error';
|
|
3684
|
+
}
|
|
3685
|
+
|
|
3686
|
+
// Rows are React-rendered and get recreated on every sidebar update, so the
|
|
3687
|
+
// decorations have to be re-applied. A debounced observer handles that.
|
|
3688
|
+
var workspaceRowTips = [];
|
|
3689
|
+
var workspaceRowObserver = null;
|
|
3690
|
+
var workspaceRowTimer = null;
|
|
3691
|
+
var workspaceHoverRecords = {};
|
|
3692
|
+
|
|
3693
|
+
function applyWorkspaceRowTips() {
|
|
3694
|
+
if (typeof document === 'undefined') return;
|
|
3695
|
+
for (var index = 0; index < workspaceRowTips.length; index += 1) {
|
|
3696
|
+
var tip = workspaceRowTips[index];
|
|
3697
|
+
var rows = document.querySelectorAll('[data-row-key="workspace:' + tip.id + '"]');
|
|
3698
|
+
for (var rowIndex = 0; rowIndex < rows.length; rowIndex += 1) {
|
|
3699
|
+
var row = rows[rowIndex];
|
|
3700
|
+
if (tip.disconnected) row.setAttribute('data-lw-disconnected', 'true');
|
|
3701
|
+
else row.removeAttribute('data-lw-disconnected');
|
|
3702
|
+
// The native tooltip would pop up next to the hover preview card, so
|
|
3703
|
+
// the connection state is written into that card instead.
|
|
3704
|
+
if (row.hasAttribute('title')) row.removeAttribute('title');
|
|
3705
|
+
}
|
|
3706
|
+
}
|
|
3707
|
+
}
|
|
3708
|
+
|
|
3709
|
+
function queueWorkspaceRowTips() {
|
|
3710
|
+
if (typeof window === 'undefined' || workspaceRowTimer !== null) return;
|
|
3711
|
+
workspaceRowTimer = window.setTimeout(function () {
|
|
3712
|
+
workspaceRowTimer = null;
|
|
3713
|
+
applyWorkspaceRowTips();
|
|
3714
|
+
applyHoverCards();
|
|
3715
|
+
}, 200);
|
|
3716
|
+
if (workspaceRowTimer && typeof workspaceRowTimer.unref === 'function') workspaceRowTimer.unref();
|
|
3717
|
+
}
|
|
3718
|
+
|
|
3719
|
+
function watchWorkspaceRows() {
|
|
3720
|
+
if (workspaceRowObserver !== null) return;
|
|
3721
|
+
if (typeof MutationObserver === 'undefined' || typeof document === 'undefined' || !document.body) return;
|
|
3722
|
+
try {
|
|
3723
|
+
workspaceRowObserver = new MutationObserver(function () { queueWorkspaceRowTips(); });
|
|
3724
|
+
// Only structural changes: our own attribute writes must not retrigger it.
|
|
3725
|
+
workspaceRowObserver.observe(document.body, { childList: true, subtree: true });
|
|
3726
|
+
} catch (error) {
|
|
3727
|
+
workspaceRowObserver = null;
|
|
3728
|
+
}
|
|
3729
|
+
}
|
|
3730
|
+
|
|
3731
|
+
function statusLabel(t, item) {
|
|
3732
|
+
var state = stateOf(item);
|
|
3733
|
+
if (state === 'error') return item && item.status && item.status.reason === 'lost' ? t('disconnected') : t('errorState');
|
|
3734
|
+
return state === 'connected' ? t('connected') : t('idle');
|
|
3735
|
+
}
|
|
3736
|
+
|
|
3737
|
+
// ── workspace hover preview ────────────────────────────────────────────
|
|
3738
|
+
// The host renders the hover card itself (name / directory / created at)
|
|
3739
|
+
// inside a portal that lives outside our row, so it can only be enriched by
|
|
3740
|
+
// decorating it after it appears. Class names are hashed, hence the
|
|
3741
|
+
// substring selectors.
|
|
3742
|
+
var HOVER_CARD_QUERY = '[class*="hoverContent"]';
|
|
3743
|
+
var HOVER_LINE_ATTR = 'data-lw-hover-line';
|
|
3744
|
+
var hoverCardObserver = null;
|
|
3745
|
+
var hoverCardState = typeof WeakMap === 'function' ? new WeakMap() : null;
|
|
3746
|
+
|
|
3747
|
+
function clearHoverLines(card) {
|
|
3748
|
+
var injected = card.querySelectorAll('[' + HOVER_LINE_ATTR + ']');
|
|
3749
|
+
for (var index = 0; index < injected.length; index += 1) {
|
|
3750
|
+
var node = injected[index];
|
|
3751
|
+
if (node.parentNode) node.parentNode.removeChild(node);
|
|
3752
|
+
}
|
|
3753
|
+
}
|
|
3754
|
+
|
|
3755
|
+
function decorateHoverCard(card) {
|
|
3756
|
+
if (!card || !hoverCardState || !card.querySelector) return;
|
|
3757
|
+
var pathEl = card.querySelector('[class*="hoverPath"]');
|
|
3758
|
+
if (!pathEl) return;
|
|
3759
|
+
var known = hoverCardState.get(card);
|
|
3760
|
+
var current = (pathEl.textContent || '').trim();
|
|
3761
|
+
// Already decorated for this very content: nothing to do.
|
|
3762
|
+
if (known && known.rendered === current) return;
|
|
3763
|
+
// The host re-rendered the card for another workspace: drop our lines.
|
|
3764
|
+
if (known) clearHoverLines(card);
|
|
3765
|
+
var record = workspaceHoverRecords[linkedScopeKey(current)];
|
|
3766
|
+
if (!record || !record.remotePath) return;
|
|
3767
|
+
var t = makeT(readLocale());
|
|
3768
|
+
var remote = record.remotePath;
|
|
3769
|
+
var local = record.localPath || '';
|
|
3770
|
+
|
|
3771
|
+
var status = document.createElement('div');
|
|
3772
|
+
status.className = 'rw-hover-status' + (record.disconnected ? ' is-off' : record.connected ? ' is-on' : '');
|
|
3773
|
+
status.setAttribute(HOVER_LINE_ATTR, '1');
|
|
3774
|
+
status.textContent = record.status;
|
|
3775
|
+
var titleEl = card.querySelector('[class*="hoverTitle"]');
|
|
3776
|
+
var anchor = titleEl || pathEl;
|
|
3777
|
+
anchor.parentNode.insertBefore(status, anchor.nextSibling);
|
|
3778
|
+
|
|
3779
|
+
if (record.kind === 'linked' && local !== '') {
|
|
3780
|
+
pathEl.textContent = t('pathRemoteShort') + ' ' + remote;
|
|
3781
|
+
var localEl = pathEl.cloneNode(false);
|
|
3782
|
+
localEl.setAttribute(HOVER_LINE_ATTR, '1');
|
|
3783
|
+
localEl.textContent = t('pathLocalShort') + ' ' + local;
|
|
3784
|
+
pathEl.parentNode.insertBefore(localEl, pathEl.nextSibling);
|
|
3785
|
+
} else {
|
|
3786
|
+
pathEl.textContent = remote;
|
|
3787
|
+
}
|
|
3788
|
+
|
|
3789
|
+
// The card doubles as a "copy this path" button; keep its label in sync so
|
|
3790
|
+
// a remote workspace copies the remote directory, not the placeholder.
|
|
3791
|
+
var host = card.parentElement;
|
|
3792
|
+
var label = host && host.getAttribute ? host.getAttribute('aria-label') : null;
|
|
3793
|
+
if (label && current !== '' && label.indexOf(current) !== -1) {
|
|
3794
|
+
host.setAttribute('aria-label', label.split(current).join(remote));
|
|
3795
|
+
}
|
|
3796
|
+
|
|
3797
|
+
hoverCardState.set(card, { rendered: (pathEl.textContent || '').trim() });
|
|
3798
|
+
}
|
|
3799
|
+
|
|
3800
|
+
function applyHoverCards() {
|
|
3801
|
+
if (typeof document === 'undefined') return;
|
|
3802
|
+
var cards = document.querySelectorAll(HOVER_CARD_QUERY);
|
|
3803
|
+
for (var index = 0; index < cards.length; index += 1) decorateHoverCard(cards[index]);
|
|
3804
|
+
}
|
|
3805
|
+
|
|
3806
|
+
function watchHoverCards() {
|
|
3807
|
+
if (hoverCardObserver !== null) return;
|
|
3808
|
+
if (typeof MutationObserver === 'undefined' || typeof document === 'undefined' || !document.body) return;
|
|
3809
|
+
try {
|
|
3810
|
+
hoverCardObserver = new MutationObserver(function (records) {
|
|
3811
|
+
for (var index = 0; index < records.length; index += 1) {
|
|
3812
|
+
var added = records[index].addedNodes;
|
|
3813
|
+
for (var nodeIndex = 0; nodeIndex < added.length; nodeIndex += 1) {
|
|
3814
|
+
var node = added[nodeIndex];
|
|
3815
|
+
if (!node || node.nodeType !== 1) continue;
|
|
3816
|
+
if (node.closest) {
|
|
3817
|
+
var outer = node.closest(HOVER_CARD_QUERY);
|
|
3818
|
+
if (outer) decorateHoverCard(outer);
|
|
3819
|
+
}
|
|
3820
|
+
if (node.querySelectorAll) {
|
|
3821
|
+
var inner = node.querySelectorAll(HOVER_CARD_QUERY);
|
|
3822
|
+
for (var innerIndex = 0; innerIndex < inner.length; innerIndex += 1) decorateHoverCard(inner[innerIndex]);
|
|
3823
|
+
}
|
|
3824
|
+
}
|
|
3825
|
+
}
|
|
3826
|
+
});
|
|
3827
|
+
hoverCardObserver.observe(document.body, { childList: true, subtree: true });
|
|
3828
|
+
} catch (error) {
|
|
3829
|
+
hoverCardObserver = null;
|
|
3830
|
+
}
|
|
3831
|
+
}
|
|
3832
|
+
|
|
3833
|
+
function publishRowTips(entries) {
|
|
3834
|
+
var t = makeT(readLocale());
|
|
3835
|
+
var records = {};
|
|
3836
|
+
workspaceRowTips = entries.map(function (entry) {
|
|
3837
|
+
var item = entry.item || {};
|
|
3838
|
+
var linked = entry.kind === 'linked';
|
|
3839
|
+
var key = linkedScopeKey(linked ? item.localPath : item.placeholderPath);
|
|
3840
|
+
if (key !== '') {
|
|
3841
|
+
records[key] = {
|
|
3842
|
+
kind: entry.kind,
|
|
3843
|
+
name: item.name,
|
|
3844
|
+
remotePath: item.remotePath || '',
|
|
3845
|
+
localPath: linked ? (item.localPath || '') : '',
|
|
3846
|
+
status: statusLabel(t, item),
|
|
3847
|
+
connected: stateOf(item) === 'connected',
|
|
3848
|
+
disconnected: isDisconnected(item),
|
|
3849
|
+
};
|
|
3850
|
+
}
|
|
3851
|
+
return { id: entry.id, disconnected: isDisconnected(item) };
|
|
3852
|
+
});
|
|
3853
|
+
workspaceHoverRecords = records;
|
|
3854
|
+
applyWorkspaceRowTips();
|
|
3855
|
+
watchWorkspaceRows();
|
|
3856
|
+
watchHoverCards();
|
|
3857
|
+
applyHoverCards();
|
|
3858
|
+
}
|
|
3859
|
+
|
|
3860
|
+
function publishWorkspaceIcons(links, remotes) {
|
|
3499
3861
|
var tag = workspaceIconStyleTag();
|
|
3500
3862
|
if (!tag) return;
|
|
3501
|
-
var
|
|
3502
|
-
|
|
3503
|
-
|
|
3863
|
+
var entries = [];
|
|
3864
|
+
(links || []).forEach(function (link) {
|
|
3865
|
+
entries.push({ item: link, id: link && link.workspaceId, mask: LINKED_ICON_MASK, running: Boolean(link.running), kind: 'linked' });
|
|
3866
|
+
});
|
|
3867
|
+
(remotes || []).forEach(function (workspace) {
|
|
3868
|
+
entries.push({ item: workspace, id: workspace && workspace.workspaceId, mask: REMOTE_ICON_MASK, running: false, kind: 'remote' });
|
|
3869
|
+
});
|
|
3870
|
+
var rules = entries.map(function (entry) {
|
|
3871
|
+
var id = entry.id ? String(entry.id).replace(/[^0-9a-zA-Z-]/g, '') : '';
|
|
3504
3872
|
if (id === '') return '';
|
|
3505
3873
|
var row = '[data-row-key="workspace:' + id + '"] > span:first-child';
|
|
3506
3874
|
var rule = row + '{display:inline-flex;align-items:center;justify-content:center;flex:none;}'
|
|
3507
3875
|
+ row + ' svg{display:none!important;}'
|
|
3508
3876
|
+ row + '::before{content:"";display:block;width:14px;height:14px;background:currentColor;'
|
|
3509
|
-
+ '-webkit-mask:' + mask + ' center/contain no-repeat;mask:' + mask + ' center/contain no-repeat;}';
|
|
3510
|
-
|
|
3877
|
+
+ '-webkit-mask:' + entry.mask + ' center/contain no-repeat;mask:' + entry.mask + ' center/contain no-repeat;}';
|
|
3878
|
+
// A dropped SSH connection turns the row icon red; a running mirror
|
|
3879
|
+
// sync keeps the existing accent highlight.
|
|
3880
|
+
if (isDisconnected(entry.item)) rule += row + '::before{background:' + ICON_DISCONNECTED_COLOR + '!important}';
|
|
3881
|
+
else if (entry.running) rule += row + '::before{background:' + ICON_BUSY_COLOR + '!important}';
|
|
3511
3882
|
return rule;
|
|
3512
3883
|
}).filter(function (rule) { return rule !== ''; });
|
|
3513
3884
|
tag.textContent = rules.join('\n');
|
|
3885
|
+
publishRowTips(entries);
|
|
3514
3886
|
}
|
|
3515
3887
|
|
|
3516
3888
|
// ── icons (16px outline set, currentColor) ─────────────────────────────
|
|
@@ -3529,6 +3901,28 @@ function attributeViolation(name, value, tagName) {
|
|
|
3529
3901
|
return h('svg', props, children);
|
|
3530
3902
|
}
|
|
3531
3903
|
|
|
3904
|
+
// Filled workspace-kind icons. The supplied shapes are drawn on a 1024 grid
|
|
3905
|
+
// and carry no stroke, so they are rendered apart from the outline set.
|
|
3906
|
+
function solidIcon(size, paths) {
|
|
3907
|
+
return h('svg', {
|
|
3908
|
+
width: size,
|
|
3909
|
+
height: size,
|
|
3910
|
+
viewBox: '0 0 1024 1024',
|
|
3911
|
+
fill: 'currentColor',
|
|
3912
|
+
xmlns: 'http://www.w3.org/2000/svg',
|
|
3913
|
+
'aria-hidden': 'true',
|
|
3914
|
+
focusable: 'false',
|
|
3915
|
+
}, paths.map(function (path, index) { return h('path', { key: index, d: path }); }));
|
|
3916
|
+
}
|
|
3917
|
+
|
|
3918
|
+
function IconLinkedWorkspace(size) {
|
|
3919
|
+
return solidIcon(size || 14, LINKED_ICON_PATHS);
|
|
3920
|
+
}
|
|
3921
|
+
|
|
3922
|
+
function IconRemoteWorkspace(size) {
|
|
3923
|
+
return solidIcon(size || 14, REMOTE_ICON_PATHS);
|
|
3924
|
+
}
|
|
3925
|
+
|
|
3532
3926
|
function IconChevron(size) {
|
|
3533
3927
|
return svg(size || 14, h('path', {
|
|
3534
3928
|
d: 'm6 3 5 5-5 5', stroke: 'currentColor', strokeWidth: 1.6,
|
|
@@ -3708,14 +4102,14 @@ function attributeViolation(name, value, tagName) {
|
|
|
3708
4102
|
// ── data hooks ─────────────────────────────────────────────────────────
|
|
3709
4103
|
|
|
3710
4104
|
function useRemoteData(ctx) {
|
|
3711
|
-
var dataState = useState({ loading: true, hosts: [],
|
|
4105
|
+
var dataState = useState({ loading: true, hosts: [], remotes: [], links: [], error: null, hostError: null, linkError: null });
|
|
3712
4106
|
var data = dataState[0];
|
|
3713
4107
|
var setData = dataState[1];
|
|
3714
4108
|
var alive = useRef(true);
|
|
3715
4109
|
|
|
3716
4110
|
var load = useCallback(function () {
|
|
3717
4111
|
var jobs = [
|
|
3718
|
-
apiCall('
|
|
4112
|
+
apiCall('remote_workspaces.list').then(function (result) { return { remotes: result.workspaces || [] }; }),
|
|
3719
4113
|
apiCall('hosts.list').then(function (result) { return { hosts: result.hosts || [] }; }),
|
|
3720
4114
|
apiCall('linked.list').then(function (result) { return { links: result.links || [] }; }),
|
|
3721
4115
|
];
|
|
@@ -3723,22 +4117,22 @@ function attributeViolation(name, value, tagName) {
|
|
|
3723
4117
|
return promise.then(function (value) { return { ok: true, value: value }; }, function (error) { return { ok: false, error: error }; });
|
|
3724
4118
|
})).then(function (results) {
|
|
3725
4119
|
if (!alive.current) return;
|
|
3726
|
-
var
|
|
4120
|
+
var remotesResult = results[0];
|
|
3727
4121
|
var hostsResult = results[1];
|
|
3728
4122
|
var linksResult = results[2];
|
|
3729
4123
|
setData(function (previous) {
|
|
3730
4124
|
return {
|
|
3731
4125
|
loading: false,
|
|
3732
|
-
|
|
4126
|
+
remotes: remotesResult.ok ? remotesResult.value.remotes : previous.remotes,
|
|
3733
4127
|
hosts: hostsResult.ok ? hostsResult.value.hosts : previous.hosts,
|
|
3734
4128
|
links: linksResult.ok ? linksResult.value.links : previous.links,
|
|
3735
|
-
error:
|
|
4129
|
+
error: remotesResult.ok ? null : remotesResult.error,
|
|
3736
4130
|
hostError: hostsResult.ok ? null : hostsResult.error,
|
|
3737
4131
|
linkError: linksResult.ok ? null : linksResult.error,
|
|
3738
4132
|
};
|
|
3739
4133
|
});
|
|
3740
|
-
rememberDirectoryAvailability(linksResult.ok ? linksResult.value.links : [],
|
|
3741
|
-
|
|
4134
|
+
rememberDirectoryAvailability(linksResult.ok ? linksResult.value.links : [], remotesResult.ok ? remotesResult.value.remotes : []);
|
|
4135
|
+
publishWorkspaceIcons(linksResult.ok ? linksResult.value.links : [], remotesResult.ok ? remotesResult.value.remotes : []);
|
|
3742
4136
|
});
|
|
3743
4137
|
}, []);
|
|
3744
4138
|
|
|
@@ -3757,13 +4151,28 @@ function attributeViolation(name, value, tagName) {
|
|
|
3757
4151
|
|
|
3758
4152
|
// ── small building blocks ───────────────────────────────────────────────
|
|
3759
4153
|
|
|
4154
|
+
function statusTitle(t, item) {
|
|
4155
|
+
var status = (item && item.status) || {};
|
|
4156
|
+
if (status.state === 'connected') {
|
|
4157
|
+
return typeof status.latencyMs === 'number' ? t('connected') + ' · ' + status.latencyMs + ' ms' : t('connected');
|
|
4158
|
+
}
|
|
4159
|
+
if (status.state === 'error') {
|
|
4160
|
+
if (status.reason === 'lost') return t('disconnected');
|
|
4161
|
+
return status.message ? t('errorState') + ' · ' + status.message : t('errorState');
|
|
4162
|
+
}
|
|
4163
|
+
return t('idle');
|
|
4164
|
+
}
|
|
4165
|
+
|
|
3760
4166
|
function StatusPill(props) {
|
|
3761
4167
|
var t = props.t;
|
|
3762
4168
|
var status = props.status || { state: 'idle' };
|
|
3763
4169
|
var cls = status.state === 'connected' ? 'rw-dot-ok' : status.state === 'error' ? 'rw-dot-error' : '';
|
|
3764
|
-
var label = status.state === 'connected'
|
|
3765
|
-
|
|
3766
|
-
|
|
4170
|
+
var label = status.state === 'connected'
|
|
4171
|
+
? t('connected')
|
|
4172
|
+
: status.state === 'error'
|
|
4173
|
+
? (status.reason === 'lost' ? t('disconnected') : t('errorState'))
|
|
4174
|
+
: t('idle');
|
|
4175
|
+
return h('span', { className: 'rw-chip', title: statusTitle(t, props) || label },
|
|
3767
4176
|
h('span', { className: 'rw-dot ' + cls }),
|
|
3768
4177
|
label);
|
|
3769
4178
|
}
|
|
@@ -4391,7 +4800,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
4391
4800
|
var local = props.local === true;
|
|
4392
4801
|
var readOnly = props.readOnly === true;
|
|
4393
4802
|
var filePath = props.path;
|
|
4394
|
-
var sidebar = ctx
|
|
4803
|
+
var sidebar = sidebarService(ctx);
|
|
4395
4804
|
var settings = useRuntimeSettings();
|
|
4396
4805
|
var theme = getTheme(resolveEditorTheme(settings));
|
|
4397
4806
|
var language = languageOf(filePath);
|
|
@@ -4621,7 +5030,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
4621
5030
|
if (event.key === 'Escape') { event.preventDefault(); closeFind(); }
|
|
4622
5031
|
},
|
|
4623
5032
|
}),
|
|
4624
|
-
h('span', { className: 'rw-find-counter' }, counter),
|
|
5033
|
+
h('span', { className: 'rw-find-counter', 'aria-live': 'polite' }, counter),
|
|
4625
5034
|
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', title: t('findNext'), disabled: findMatches.length === 0, onClick: function () { stepMatch(1); } }, IconChevron(12)),
|
|
4626
5035
|
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', title: t('findPrev'), disabled: findMatches.length === 0, onClick: function () { stepMatch(-1); } }, h('span', { style: { display: 'inline-flex', transform: 'rotate(180deg)' } }, IconChevron(12))),
|
|
4627
5036
|
h('input', {
|
|
@@ -4635,7 +5044,10 @@ function attributeViolation(name, value, tagName) {
|
|
|
4635
5044
|
var value = event.currentTarget.value;
|
|
4636
5045
|
setFind(function (previous) { return Object.assign({}, previous, { replace: value }); });
|
|
4637
5046
|
},
|
|
4638
|
-
onKeyDown: function (event) {
|
|
5047
|
+
onKeyDown: function (event) {
|
|
5048
|
+
if (event.key === 'Enter') { event.preventDefault(); replaceCurrent(); }
|
|
5049
|
+
if (event.key === 'Escape') { event.preventDefault(); closeFind(); }
|
|
5050
|
+
},
|
|
4639
5051
|
}),
|
|
4640
5052
|
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', disabled: !editable || findMatches.length === 0, onClick: replaceCurrent }, t('replaceOne')),
|
|
4641
5053
|
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', disabled: !editable || findMatches.length === 0, onClick: replaceAll }, t('replaceAll')),
|
|
@@ -4818,8 +5230,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
4818
5230
|
: file.tooLarge || file.truncated || file.binary
|
|
4819
5231
|
? h('span', { className: 'rw-status-chip rw-status-error' }, t('readOnly'))
|
|
4820
5232
|
: h('span', { className: 'rw-status-chip rw-status-ok' }, theme.label ? (locale === 'zh' ? theme.label.zh : theme.label.en) : theme.id),
|
|
4821
|
-
h('span', { className: 'rw-fill', style: { flex: '1 1 auto' } })
|
|
4822
|
-
h('span', { className: 'rw-status-chip' }, h('span', { className: 'rw-kbd' }, 'Ctrl'), h('span', { className: 'rw-kbd' }, 'S'))));
|
|
5233
|
+
h('span', { className: 'rw-fill', style: { flex: '1 1 auto' } })));
|
|
4823
5234
|
}
|
|
4824
5235
|
|
|
4825
5236
|
// ── linked workspace directory workbench ──────────────────────────────
|
|
@@ -4841,13 +5252,14 @@ function attributeViolation(name, value, tagName) {
|
|
|
4841
5252
|
|
|
4842
5253
|
function sourceScopeOf(source) {
|
|
4843
5254
|
if (source && source.kind === 'linked') return { kind: 'linked', id: source.id };
|
|
5255
|
+
if (source && source.kind === 'remote') return { kind: 'remote', id: source.id };
|
|
4844
5256
|
return { kind: 'workspace', id: source ? source.id : '' };
|
|
4845
5257
|
}
|
|
4846
5258
|
|
|
4847
5259
|
function sourceMetaOf(source) {
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
5260
|
+
if (source && source.kind === 'linked') return { linkedId: source.id, linkedName: source.name };
|
|
5261
|
+
if (source && source.kind === 'remote') return { remoteId: source.id, remoteName: source.name };
|
|
5262
|
+
return { workspaceId: source ? source.id : undefined, workspaceName: source ? source.name : undefined };
|
|
4851
5263
|
}
|
|
4852
5264
|
|
|
4853
5265
|
function workspaceRelativePath(rootPath, filePath) {
|
|
@@ -5009,6 +5421,10 @@ function attributeViolation(name, value, tagName) {
|
|
|
5009
5421
|
});
|
|
5010
5422
|
}
|
|
5011
5423
|
|
|
5424
|
+
var rootRecord = cache.entries.get(rootPath);
|
|
5425
|
+
var rootSiblings = rootRecord && rootRecord.entries ? rootRecord.entries.map(function (item) {
|
|
5426
|
+
return { path: item.path, name: item.name, isDir: item.type === 'dir' };
|
|
5427
|
+
}) : [];
|
|
5012
5428
|
return h('div', {
|
|
5013
5429
|
className: 'rw-tree',
|
|
5014
5430
|
role: 'tree',
|
|
@@ -5045,6 +5461,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
5045
5461
|
: null,
|
|
5046
5462
|
selectedPath: props.selectedPath || '',
|
|
5047
5463
|
selectedSet: props.selectedPaths && props.selectedPaths.length > 0 ? new Set(props.selectedPaths) : null,
|
|
5464
|
+
siblings: rootSiblings,
|
|
5048
5465
|
}));
|
|
5049
5466
|
}
|
|
5050
5467
|
|
|
@@ -5432,32 +5849,64 @@ function attributeViolation(name, value, tagName) {
|
|
|
5432
5849
|
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: props.onClose }, props.t('close'))));
|
|
5433
5850
|
}
|
|
5434
5851
|
|
|
5852
|
+
function joinRelativePath(parent, relative, side) {
|
|
5853
|
+
var sep = side === 'remote' ? '/' : (String(parent || '').indexOf('\\') >= 0 ? '\\' : '/');
|
|
5854
|
+
var base = String(parent || '').replace(/[\\/]+$/, '');
|
|
5855
|
+
var tail = String(relative || '').split('/').filter(function (part) { return part !== ''; }).join(sep);
|
|
5856
|
+
if (base === '') return sep + tail;
|
|
5857
|
+
if (base === '/') return '/' + tail;
|
|
5858
|
+
return base + sep + tail;
|
|
5859
|
+
}
|
|
5860
|
+
|
|
5435
5861
|
function CompareDialog(props) {
|
|
5436
5862
|
var t = props.t;
|
|
5437
5863
|
var data = props.data;
|
|
5438
|
-
function
|
|
5864
|
+
function rowAction(side, row, kind) {
|
|
5865
|
+
var label = kind === 'push' ? t('comparePush') : t('comparePull');
|
|
5866
|
+
var title = label + ' · ' + row.path;
|
|
5867
|
+
return h('button', {
|
|
5868
|
+
key: kind,
|
|
5869
|
+
type: 'button',
|
|
5870
|
+
className: 'rw-btn rw-btn-sm rw-compare-act',
|
|
5871
|
+
title: title,
|
|
5872
|
+
onClick: function () {
|
|
5873
|
+
if (kind === 'push') props.onPush(row.path);
|
|
5874
|
+
else props.onPull(row.path);
|
|
5875
|
+
},
|
|
5876
|
+
}, label);
|
|
5877
|
+
}
|
|
5878
|
+
function section(key, title, rows, count, side, actions) {
|
|
5439
5879
|
return h('div', { key: key, className: 'rw-compare-section' },
|
|
5440
5880
|
h('div', { className: 'rw-compare-title' }, title + ' (' + count + ')'),
|
|
5441
5881
|
count === 0
|
|
5442
5882
|
? h('div', { className: 'rw-compare-empty' }, t('compareNone'))
|
|
5443
5883
|
: rows.map(function (row) {
|
|
5444
5884
|
var size = row.size != null ? row.size : row.localSize;
|
|
5445
|
-
return h('
|
|
5446
|
-
|
|
5447
|
-
|
|
5448
|
-
|
|
5449
|
-
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5885
|
+
return h('div', { key: row.path, className: 'rw-compare-item' },
|
|
5886
|
+
h('button', {
|
|
5887
|
+
type: 'button',
|
|
5888
|
+
className: 'rw-compare-row',
|
|
5889
|
+
title: row.path,
|
|
5890
|
+
onClick: function () { props.onOpen(side, row.path); },
|
|
5891
|
+
},
|
|
5892
|
+
h('span', { className: 'rw-compare-path' }, row.path),
|
|
5893
|
+
h('span', { className: 'rw-compare-size' }, typeof size === 'number' ? formatBytes(size) : '')),
|
|
5894
|
+
actions && actions.length > 0 ? h('span', { className: 'rw-compare-actions' }, actions.map(function (kind) { return rowAction(side, row, kind); })) : null);
|
|
5454
5895
|
}));
|
|
5455
5896
|
}
|
|
5897
|
+
var notes = [];
|
|
5898
|
+
if (data.localMissing) notes.push(t('compareLocalMissing'));
|
|
5899
|
+
if (data.remoteTruncated) notes.push(t('compareTruncatedRemote'));
|
|
5900
|
+
if (data.localTruncated) notes.push(t('compareTruncatedLocal'));
|
|
5901
|
+
var note = notes.length > 0
|
|
5902
|
+
? h('div', { className: 'rw-dialog-note' }, notes.join(' '))
|
|
5903
|
+
: null;
|
|
5456
5904
|
return h(DialogShell, { title: props.title, onClose: props.onClose },
|
|
5457
5905
|
h('div', { className: 'rw-dialog-message rw-compare-root', title: data.localPath }, data.localPath),
|
|
5458
|
-
|
|
5459
|
-
section('
|
|
5460
|
-
section('
|
|
5906
|
+
note,
|
|
5907
|
+
section('onlyLocal', t('compareOnlyLocal'), data.onlyLocal || [], data.counts.onlyLocal, 'local', ['push']),
|
|
5908
|
+
section('onlyRemote', t('compareOnlyRemote'), data.onlyRemote || [], data.counts.onlyRemote, 'remote', ['pull']),
|
|
5909
|
+
section('changed', t('compareChanged'), data.changed || [], data.counts.changed, 'remote', ['push', 'pull']),
|
|
5461
5910
|
data.truncated ? h('div', { className: 'rw-dialog-note' }, t('compareTruncated')) : null,
|
|
5462
5911
|
h('div', { className: 'rw-dialog-actions' },
|
|
5463
5912
|
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: props.onClose }, t('close'))));
|
|
@@ -5487,7 +5936,14 @@ function attributeViolation(name, value, tagName) {
|
|
|
5487
5936
|
: props.queue.map(function (entry) {
|
|
5488
5937
|
return h('div', { key: entry.id, className: 'rw-queue-row' },
|
|
5489
5938
|
h('span', { className: 'rw-queue-label', title: entry.path }, entry.label),
|
|
5490
|
-
h('span', { className: 'rw-queue-state' }, entry.message || entry.state)
|
|
5939
|
+
h('span', { className: 'rw-queue-state' }, entry.message || entry.state),
|
|
5940
|
+
entry.state === 'error' && props.onRetry
|
|
5941
|
+
? h('button', {
|
|
5942
|
+
type: 'button',
|
|
5943
|
+
className: 'rw-btn rw-btn-sm',
|
|
5944
|
+
onClick: function () { props.onRetry(entry); },
|
|
5945
|
+
}, props.t('queueRetry'))
|
|
5946
|
+
: null);
|
|
5491
5947
|
}),
|
|
5492
5948
|
h('div', { className: 'rw-dialog-actions' },
|
|
5493
5949
|
props.queue.some(function (entry) { return entry.state === 'done' || entry.state === 'error'; })
|
|
@@ -5510,9 +5966,11 @@ function attributeViolation(name, value, tagName) {
|
|
|
5510
5966
|
loading: true, error: '', data: null, text: '', dirty: false, saving: false,
|
|
5511
5967
|
preview: false, html: '', previewLoading: false, page: 0, sheet: 0, slide: 0,
|
|
5512
5968
|
updates: {}, pptxUpdates: {}, rotations: {}, deleted: {}, pdfLoading: false, notice: '',
|
|
5969
|
+
findOpen: false, findQuery: '', findIndex: 0,
|
|
5513
5970
|
});
|
|
5514
5971
|
var state = stateRef[0];
|
|
5515
5972
|
var setState = stateRef[1];
|
|
5973
|
+
var docTextareaRef = useRef(null);
|
|
5516
5974
|
|
|
5517
5975
|
function patch(next) {
|
|
5518
5976
|
setState(function (previous) { return Object.assign({}, previous, next); });
|
|
@@ -5587,13 +6045,57 @@ function attributeViolation(name, value, tagName) {
|
|
|
5587
6045
|
if (props.visible === false) return undefined;
|
|
5588
6046
|
function onKey(event) {
|
|
5589
6047
|
var mod = event.ctrlKey || event.metaKey;
|
|
5590
|
-
if (!mod
|
|
5591
|
-
event.
|
|
5592
|
-
|
|
6048
|
+
if (!mod) return;
|
|
6049
|
+
var key = String(event.key || '').toLowerCase();
|
|
6050
|
+
if (key === 's') {
|
|
6051
|
+
event.preventDefault();
|
|
6052
|
+
saveRef.current();
|
|
6053
|
+
return;
|
|
6054
|
+
}
|
|
6055
|
+
// Read-only find inside the document editor (no replace).
|
|
6056
|
+
if (key === 'f' && kind === 'markdown' && !state.preview) {
|
|
6057
|
+
event.preventDefault();
|
|
6058
|
+
patch({ findOpen: true });
|
|
6059
|
+
}
|
|
5593
6060
|
}
|
|
5594
6061
|
window.addEventListener('keydown', onKey, true);
|
|
5595
6062
|
return function () { window.removeEventListener('keydown', onKey, true); };
|
|
5596
|
-
}, [props.visible]);
|
|
6063
|
+
}, [props.visible, kind, state.preview]);
|
|
6064
|
+
|
|
6065
|
+
function docMatches() {
|
|
6066
|
+
var query = state.findQuery;
|
|
6067
|
+
if (!query) return [];
|
|
6068
|
+
var haystack = state.text;
|
|
6069
|
+
var needle = query.toLowerCase();
|
|
6070
|
+
var lower = haystack.toLowerCase();
|
|
6071
|
+
var found = [];
|
|
6072
|
+
var from = 0;
|
|
6073
|
+
while (found.length < 2000) {
|
|
6074
|
+
var at = lower.indexOf(needle, from);
|
|
6075
|
+
if (at < 0) break;
|
|
6076
|
+
found.push(at);
|
|
6077
|
+
from = at + Math.max(needle.length, 1);
|
|
6078
|
+
}
|
|
6079
|
+
return found;
|
|
6080
|
+
}
|
|
6081
|
+
|
|
6082
|
+
function stepDocMatch(delta) {
|
|
6083
|
+
var matches = docMatches();
|
|
6084
|
+
if (matches.length === 0) return;
|
|
6085
|
+
var next = ((state.findIndex + delta) % matches.length + matches.length) % matches.length;
|
|
6086
|
+
patch({ findIndex: next });
|
|
6087
|
+
var area = docTextareaRef.current;
|
|
6088
|
+
if (!area) return;
|
|
6089
|
+
area.focus();
|
|
6090
|
+
area.setSelectionRange(matches[next], matches[next] + state.findQuery.length);
|
|
6091
|
+
var ratio = matches[next] / Math.max(area.value.length, 1);
|
|
6092
|
+
area.scrollTop = Math.max(0, ratio * area.scrollHeight - area.clientHeight / 2);
|
|
6093
|
+
}
|
|
6094
|
+
|
|
6095
|
+
function closeDocFind() {
|
|
6096
|
+
patch({ findOpen: false });
|
|
6097
|
+
if (docTextareaRef.current) docTextareaRef.current.focus();
|
|
6098
|
+
}
|
|
5597
6099
|
|
|
5598
6100
|
useEffect(function () {
|
|
5599
6101
|
if (!settings.autoSave || !state.dirty || state.saving) return undefined;
|
|
@@ -5704,7 +6206,32 @@ function attributeViolation(name, value, tagName) {
|
|
|
5704
6206
|
state.previewLoading ? h('div', { className: 'rw-editor-message' }, Spinner(14), t('loading')) : null,
|
|
5705
6207
|
state.html ? h('div', { className: 'rw-doc-preview', dangerouslySetInnerHTML: { __html: state.html } }) : null)
|
|
5706
6208
|
: h('div', { className: 'rw-doc-body' },
|
|
6209
|
+
state.findOpen ? h('div', { className: 'rw-find-bar rw-doc-find' },
|
|
6210
|
+
h('input', {
|
|
6211
|
+
className: 'rw-input',
|
|
6212
|
+
value: state.findQuery,
|
|
6213
|
+
placeholder: t('findPlaceholder'),
|
|
6214
|
+
'aria-label': t('findPlaceholder'),
|
|
6215
|
+
spellCheck: false,
|
|
6216
|
+
autoFocus: true,
|
|
6217
|
+
onChange: function (event) { patch({ findQuery: event.currentTarget.value, findIndex: 0 }); },
|
|
6218
|
+
onKeyDown: function (event) {
|
|
6219
|
+
if (event.key === 'Enter') { event.preventDefault(); stepDocMatch(event.shiftKey ? -1 : 1); }
|
|
6220
|
+
if (event.key === 'Escape') { event.preventDefault(); closeDocFind(); }
|
|
6221
|
+
},
|
|
6222
|
+
}),
|
|
6223
|
+
h('span', { className: 'rw-find-counter', 'aria-live': 'polite' },
|
|
6224
|
+
(function () {
|
|
6225
|
+
var total = docMatches().length;
|
|
6226
|
+
if (state.findQuery === '') return '';
|
|
6227
|
+
return total === 0 ? t('findNoMatch') : t('findCounter', { index: state.findIndex + 1, total: total });
|
|
6228
|
+
})()),
|
|
6229
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', title: t('findPrev'), onClick: function () { stepDocMatch(-1); } }, h('span', { style: { display: 'inline-flex', transform: 'rotate(180deg)' } }, IconChevron(12))),
|
|
6230
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', title: t('findNext'), onClick: function () { stepDocMatch(1); } }, IconChevron(12)),
|
|
6231
|
+
h('button', { type: 'button', className: 'rw-icon-btn', title: t('close'), onClick: closeDocFind }, IconClose(12)))
|
|
6232
|
+
: null,
|
|
5707
6233
|
h('textarea', {
|
|
6234
|
+
ref: docTextareaRef,
|
|
5708
6235
|
className: 'rw-doc-textarea', value: state.text, spellCheck: false,
|
|
5709
6236
|
onChange: function (event) { patch({ text: event.currentTarget.value, dirty: true, html: '' }); },
|
|
5710
6237
|
}));
|
|
@@ -5811,7 +6338,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
5811
6338
|
var remoteOnly = props.variant === 'remote';
|
|
5812
6339
|
var data = useRemoteData(ctx);
|
|
5813
6340
|
var settings = useRuntimeSettings();
|
|
5814
|
-
var sidebar = ctx
|
|
6341
|
+
var sidebar = sidebarService(ctx);
|
|
5815
6342
|
var selectedState = useState('');
|
|
5816
6343
|
var selectedKey = selectedState[0];
|
|
5817
6344
|
var setSelectedKey = selectedState[1];
|
|
@@ -5824,6 +6351,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
5824
6351
|
var searchQueryState = useState('');
|
|
5825
6352
|
var searchQuery = searchQueryState[0];
|
|
5826
6353
|
var setSearchQuery = searchQueryState[1];
|
|
6354
|
+
var searchModeState = useState('name');
|
|
6355
|
+
var searchMode = searchModeState[0];
|
|
6356
|
+
var setSearchMode = searchModeState[1];
|
|
5827
6357
|
var searchState = useState({ loading: false, remote: [], local: [], error: null });
|
|
5828
6358
|
var search = searchState[0];
|
|
5829
6359
|
var setSearch = searchState[1];
|
|
@@ -5857,6 +6387,8 @@ function attributeViolation(name, value, tagName) {
|
|
|
5857
6387
|
var multiState = useState([]);
|
|
5858
6388
|
var multi = multiState[0];
|
|
5859
6389
|
var setMulti = multiState[1];
|
|
6390
|
+
// Anchor for Shift+click range selection (a ref: it must not re-render).
|
|
6391
|
+
var selectionAnchorRef = useRef(null);
|
|
5860
6392
|
var showHiddenState = useState(true);
|
|
5861
6393
|
var showHidden = showHiddenState[0];
|
|
5862
6394
|
var setShowHidden = showHiddenState[1];
|
|
@@ -5876,46 +6408,52 @@ function attributeViolation(name, value, tagName) {
|
|
|
5876
6408
|
var pinnedLinkedId = tabMeta.linkedId ? String(tabMeta.linkedId) : '';
|
|
5877
6409
|
var pinnedRemoteId = tabMeta.remoteId ? String(tabMeta.remoteId) : '';
|
|
5878
6410
|
var sources = useMemo(function () {
|
|
5879
|
-
var
|
|
6411
|
+
var pinned = remoteOnly ? pinnedRemoteId : pinnedLinkedId;
|
|
5880
6412
|
var scopeKey = linkedScopeKey(scope && scope.cwd);
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
|
|
5884
|
-
|
|
5885
|
-
|
|
5886
|
-
|
|
5887
|
-
|
|
5888
|
-
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
host: link.host,
|
|
5893
|
-
username: link.username,
|
|
5894
|
-
hostName: link.hostName,
|
|
5895
|
-
mirror: link.mirror,
|
|
5896
|
-
status: link.status,
|
|
5897
|
-
});
|
|
5898
|
-
});
|
|
5899
|
-
} else {
|
|
5900
|
-
(data.data.workspaces || []).forEach(function (workspace) {
|
|
5901
|
-
if (pinnedRemoteId && String(workspace.id) !== pinnedRemoteId) return;
|
|
5902
|
-
list.push({
|
|
5903
|
-
key: 'workspace:' + workspace.id,
|
|
5904
|
-
kind: 'workspace',
|
|
5905
|
-
id: workspace.id,
|
|
5906
|
-
name: workspace.name,
|
|
6413
|
+
var all = (remoteOnly ? (data.data.remotes || []) : (data.data.links || []));
|
|
6414
|
+
function pathOf(item) {
|
|
6415
|
+
return remoteOnly ? item.placeholderPath : item.localPath;
|
|
6416
|
+
}
|
|
6417
|
+
function toSource(item) {
|
|
6418
|
+
if (remoteOnly) {
|
|
6419
|
+
return {
|
|
6420
|
+
key: 'remote:' + item.id,
|
|
6421
|
+
kind: 'remote',
|
|
6422
|
+
id: item.id,
|
|
6423
|
+
name: item.name,
|
|
5907
6424
|
localPath: null,
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
|
|
5911
|
-
|
|
6425
|
+
placeholderPath: item.placeholderPath,
|
|
6426
|
+
remotePath: item.remotePath,
|
|
6427
|
+
host: item.host,
|
|
6428
|
+
username: item.username,
|
|
6429
|
+
hostName: item.hostName,
|
|
5912
6430
|
mirror: false,
|
|
5913
|
-
status:
|
|
5914
|
-
}
|
|
5915
|
-
}
|
|
6431
|
+
status: item.status,
|
|
6432
|
+
};
|
|
6433
|
+
}
|
|
6434
|
+
return {
|
|
6435
|
+
key: 'linked:' + item.id,
|
|
6436
|
+
kind: 'linked',
|
|
6437
|
+
id: item.id,
|
|
6438
|
+
name: item.name,
|
|
6439
|
+
localPath: item.localPath,
|
|
6440
|
+
remotePath: item.remotePath,
|
|
6441
|
+
host: item.host,
|
|
6442
|
+
username: item.username,
|
|
6443
|
+
hostName: item.hostName,
|
|
6444
|
+
mirror: item.mirror,
|
|
6445
|
+
status: item.status,
|
|
6446
|
+
};
|
|
5916
6447
|
}
|
|
5917
|
-
|
|
5918
|
-
|
|
6448
|
+
var matched = all.filter(function (item) {
|
|
6449
|
+
if (pinned) return String(item.id) === pinned;
|
|
6450
|
+
if (!scopeKey) return true;
|
|
6451
|
+
return linkedScopeKey(pathOf(item)) === scopeKey;
|
|
6452
|
+
});
|
|
6453
|
+
// 标签页也可能从起始页或设置页直接打开:当前会话不属于任何联动/远程工作区时,
|
|
6454
|
+
// 列出全部,而不是让标签页空着。
|
|
6455
|
+
return (matched.length === 0 && !pinned ? all : matched).map(toSource);
|
|
6456
|
+
}, [data.data.links, data.data.remotes, remoteOnly, scope && scope.cwd, pinnedLinkedId, pinnedRemoteId]);
|
|
5919
6457
|
|
|
5920
6458
|
var selected = useMemo(function () {
|
|
5921
6459
|
return sources.filter(function (source) { return source.key === selectedKey; })[0] || sources[0] || null;
|
|
@@ -6069,10 +6607,12 @@ function attributeViolation(name, value, tagName) {
|
|
|
6069
6607
|
|
|
6070
6608
|
function openTerminal(side, atPath) {
|
|
6071
6609
|
if (!selected) return;
|
|
6072
|
-
|
|
6610
|
+
if (side === 'local' && selected.kind !== 'linked') {
|
|
6611
|
+
showNotice('info', t('localSideMissing'));
|
|
6612
|
+
return;
|
|
6613
|
+
}
|
|
6614
|
+
var request = Object.assign({ side: side }, scopeParams(selected));
|
|
6073
6615
|
if (typeof atPath === 'string' && atPath !== '') request.path = atPath;
|
|
6074
|
-
if (selected.kind === 'linked') request.linkedId = selected.id;
|
|
6075
|
-
else request.workspaceId = selected.id;
|
|
6076
6616
|
apiCall('terminal.open', request).then(function () {
|
|
6077
6617
|
showNotice('success', t('terminalOpened'));
|
|
6078
6618
|
}).catch(function (error) {
|
|
@@ -6229,6 +6769,26 @@ function attributeViolation(name, value, tagName) {
|
|
|
6229
6769
|
setSelectedEntry(entry);
|
|
6230
6770
|
var toggle = Boolean(event && (event.ctrlKey || event.metaKey));
|
|
6231
6771
|
var extend = Boolean(event && event.shiftKey);
|
|
6772
|
+
if (extend) {
|
|
6773
|
+
var anchor = selectionAnchorRef.current;
|
|
6774
|
+
var siblings = Array.isArray(info.siblings) ? info.siblings : [];
|
|
6775
|
+
if (anchor && anchor.side === side && siblings.length > 0) {
|
|
6776
|
+
var anchorIndex = -1;
|
|
6777
|
+
var targetIndex = -1;
|
|
6778
|
+
siblings.forEach(function (item, index) {
|
|
6779
|
+
if (item.path === anchor.path) anchorIndex = index;
|
|
6780
|
+
if (item.path === info.path) targetIndex = index;
|
|
6781
|
+
});
|
|
6782
|
+
if (anchorIndex >= 0 && targetIndex >= 0) {
|
|
6783
|
+
var start = Math.min(anchorIndex, targetIndex);
|
|
6784
|
+
var end = Math.max(anchorIndex, targetIndex);
|
|
6785
|
+
setMulti(siblings.slice(start, end + 1).map(function (item) {
|
|
6786
|
+
return { side: side, path: item.path, name: item.name, isDir: Boolean(item.isDir) };
|
|
6787
|
+
}));
|
|
6788
|
+
return;
|
|
6789
|
+
}
|
|
6790
|
+
}
|
|
6791
|
+
}
|
|
6232
6792
|
setMulti(function (previous) {
|
|
6233
6793
|
var exists = previous.some(function (item) { return item.side === side && item.path === entry.path; });
|
|
6234
6794
|
if (extend) return exists ? previous : previous.concat([entry]);
|
|
@@ -6239,6 +6799,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
6239
6799
|
}
|
|
6240
6800
|
return [entry];
|
|
6241
6801
|
});
|
|
6802
|
+
if (!extend) selectionAnchorRef.current = toggle ? selectionAnchorRef.current : { side: side, path: info.path };
|
|
6242
6803
|
}
|
|
6243
6804
|
|
|
6244
6805
|
function selectedOn(side) {
|
|
@@ -6408,6 +6969,28 @@ function attributeViolation(name, value, tagName) {
|
|
|
6408
6969
|
} catch (error) { /* drag payload unsupported */ }
|
|
6409
6970
|
}
|
|
6410
6971
|
|
|
6972
|
+
// A drop that would replace an existing file asks first: file transfer is
|
|
6973
|
+
// destructive and previously overwrote the target silently.
|
|
6974
|
+
function openConflict(error, method, params) {
|
|
6975
|
+
if (!error || String(error.code || '') !== 'FS_EXISTS') return false;
|
|
6976
|
+
setDialog({ kind: 'conflict', message: messageOf(error, t, locale), method: method, params: params });
|
|
6977
|
+
return true;
|
|
6978
|
+
}
|
|
6979
|
+
|
|
6980
|
+
function resolveConflict(choice) {
|
|
6981
|
+
var current = dialog;
|
|
6982
|
+
setDialog(null);
|
|
6983
|
+
if (!current || current.kind !== 'conflict' || choice === 'cancel') return;
|
|
6984
|
+
var params = Object.assign({}, current.params, { conflict: choice === 'overwrite' ? 'overwrite' : 'unique' });
|
|
6985
|
+
apiCall(current.method, params).then(function (result) {
|
|
6986
|
+
var skipped = Number(result && result.skipped) || 0;
|
|
6987
|
+
var count = current.method === 'fs.upload' ? Number(result && result.files) || 0 : 1;
|
|
6988
|
+
if (count > 0) showNotice('success', t('dropImported', { count: count }));
|
|
6989
|
+
if (skipped > 0) showNotice('warn', t('dropSkipped', { count: skipped }));
|
|
6990
|
+
refreshTree();
|
|
6991
|
+
}).catch(noticeError);
|
|
6992
|
+
}
|
|
6993
|
+
|
|
6411
6994
|
// Drop target handling for both trees: OS files are imported into the
|
|
6412
6995
|
// target directory, while an entry dragged from the other tree is pushed
|
|
6413
6996
|
// across the boundary (remote→local or local→remote).
|
|
@@ -6428,12 +7011,16 @@ function attributeViolation(name, value, tagName) {
|
|
|
6428
7011
|
var payload = side === 'remote'
|
|
6429
7012
|
? Object.assign({ path: targetDir, paths: osPaths }, scopeParams(scopeRef))
|
|
6430
7013
|
: { dir: targetDir, paths: osPaths };
|
|
6431
|
-
|
|
7014
|
+
var method = side === 'remote' ? 'fs.upload' : 'local.import';
|
|
7015
|
+
apiCall(method, payload).then(function (result) {
|
|
6432
7016
|
var count = side === 'remote' ? Number(result.files) || 0 : Number(result.copied) || 0;
|
|
6433
7017
|
showNotice('success', t('dropImported', { count: count }));
|
|
6434
7018
|
if (Number(result.skipped) > 0) showNotice('warn', t('dropSkipped', { count: result.skipped }));
|
|
6435
7019
|
refreshTree();
|
|
6436
|
-
}).catch(
|
|
7020
|
+
}).catch(function (error) {
|
|
7021
|
+
if (openConflict(error, method, payload)) return;
|
|
7022
|
+
noticeError(error);
|
|
7023
|
+
});
|
|
6437
7024
|
return;
|
|
6438
7025
|
}
|
|
6439
7026
|
var raw = '';
|
|
@@ -6441,23 +7028,39 @@ function attributeViolation(name, value, tagName) {
|
|
|
6441
7028
|
if (!raw) return;
|
|
6442
7029
|
var entry;
|
|
6443
7030
|
try { entry = JSON.parse(raw); } catch (error) { return; }
|
|
6444
|
-
if (!entry || typeof entry.path !== 'string'
|
|
7031
|
+
if (!entry || typeof entry.path !== 'string') return;
|
|
7032
|
+
if (entry.side === side) {
|
|
7033
|
+
showNotice('error', t('dropSameSide'));
|
|
7034
|
+
return;
|
|
7035
|
+
}
|
|
6445
7036
|
if (entry.side === 'remote') {
|
|
6446
7037
|
if (entry.isDir) {
|
|
6447
7038
|
showNotice('error', t('dropDirUnsupported'));
|
|
6448
7039
|
return;
|
|
6449
7040
|
}
|
|
6450
|
-
|
|
7041
|
+
var pullParams = Object.assign({ path: entry.path, targetDir: targetDir }, scopeParams(scopeRef));
|
|
7042
|
+
apiCall('fs.pullToLocal', pullParams).then(function () {
|
|
6451
7043
|
showNotice('success', t('dropImported', { count: 1 }));
|
|
6452
7044
|
refreshTree();
|
|
6453
|
-
}).catch(
|
|
7045
|
+
}).catch(function (error) {
|
|
7046
|
+
if (openConflict(error, 'fs.pullToLocal', pullParams)) return;
|
|
7047
|
+
noticeError(error);
|
|
7048
|
+
});
|
|
7049
|
+
return;
|
|
7050
|
+
}
|
|
7051
|
+
if (entry.isDir) {
|
|
7052
|
+
showNotice('error', t('dropLocalDirUnsupported'));
|
|
6454
7053
|
return;
|
|
6455
7054
|
}
|
|
6456
|
-
|
|
7055
|
+
var pushParams = Object.assign({ path: targetDir, paths: [entry.path] }, scopeParams(scopeRef));
|
|
7056
|
+
apiCall('fs.upload', pushParams).then(function (result) {
|
|
6457
7057
|
if (Number(result.skipped) > 0) showNotice('warn', t('dropSkipped', { count: result.skipped }));
|
|
6458
7058
|
else showNotice('success', t('dropImported', { count: Number(result.files) || 1 }));
|
|
6459
7059
|
refreshTree();
|
|
6460
|
-
}).catch(
|
|
7060
|
+
}).catch(function (error) {
|
|
7061
|
+
if (openConflict(error, 'fs.upload', pushParams)) return;
|
|
7062
|
+
noticeError(error);
|
|
7063
|
+
});
|
|
6461
7064
|
}
|
|
6462
7065
|
|
|
6463
7066
|
function submitRenamed(side, oldPath, name) {
|
|
@@ -6644,9 +7247,27 @@ function attributeViolation(name, value, tagName) {
|
|
|
6644
7247
|
data: dialog.data,
|
|
6645
7248
|
onClose: function () { setDialog(null); },
|
|
6646
7249
|
onOpen: function (side, relative) {
|
|
6647
|
-
|
|
6648
|
-
var target = side === 'local' ? dialog.localPath : root;
|
|
6649
|
-
openInternalFile(side === 'local' ? 'local' : 'remote',
|
|
7250
|
+
setDialog(null);
|
|
7251
|
+
var target = side === 'local' ? dialog.localPath : dialog.root;
|
|
7252
|
+
openInternalFile(side === 'local' ? 'local' : 'remote', joinRelativePath(target, relative, side === 'local' ? 'local' : 'remote'));
|
|
7253
|
+
},
|
|
7254
|
+
onPush: function (relative) {
|
|
7255
|
+
var source = joinRelativePath(dialog.localPath, relative, 'local');
|
|
7256
|
+
var remoteDir = parentPathOf(joinRelativePath(dialog.root, relative, 'remote'), 'remote');
|
|
7257
|
+
apiCall('fs.upload', Object.assign({ path: remoteDir, paths: [source], conflict: 'overwrite' }, scopeParams(scopeRef))).then(function () {
|
|
7258
|
+
showNotice('success', t('comparePushed', { name: relative.split('/').pop() }));
|
|
7259
|
+
setDialog(null);
|
|
7260
|
+
refreshTree();
|
|
7261
|
+
}).catch(noticeError);
|
|
7262
|
+
},
|
|
7263
|
+
onPull: function (relative) {
|
|
7264
|
+
var remoteFile = joinRelativePath(dialog.root, relative, 'remote');
|
|
7265
|
+
var localDir = parentPathOf(joinRelativePath(dialog.localPath, relative, 'local'), 'local');
|
|
7266
|
+
apiCall('fs.pullToLocal', Object.assign({ path: remoteFile, targetDir: localDir, conflict: 'overwrite' }, scopeParams(scopeRef))).then(function () {
|
|
7267
|
+
showNotice('success', t('comparePulled', { name: relative.split('/').pop() }));
|
|
7268
|
+
setDialog(null);
|
|
7269
|
+
refreshTree();
|
|
7270
|
+
}).catch(noticeError);
|
|
6650
7271
|
},
|
|
6651
7272
|
});
|
|
6652
7273
|
}
|
|
@@ -6663,6 +7284,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
6663
7284
|
queueRef.current = queueRef.current.filter(function (entry) { return entry.state !== 'done' && entry.state !== 'error'; });
|
|
6664
7285
|
setQueueList(queueRef.current.slice());
|
|
6665
7286
|
},
|
|
7287
|
+
onRetry: function (entry) { enqueueTransfer(entry.side, entry.path, entry.label); },
|
|
6666
7288
|
});
|
|
6667
7289
|
}
|
|
6668
7290
|
if (dialog.kind === 'delete') {
|
|
@@ -6685,6 +7307,14 @@ function attributeViolation(name, value, tagName) {
|
|
|
6685
7307
|
onConfirm: function () { setDialog(null); confirmDeleteMany(dialog.entries); },
|
|
6686
7308
|
});
|
|
6687
7309
|
}
|
|
7310
|
+
if (dialog.kind === 'conflict') {
|
|
7311
|
+
return h(DialogShell, { title: t('conflictDropTitle'), onClose: function () { resolveConflict('cancel'); } },
|
|
7312
|
+
h('div', { className: 'rw-dialog-message' }, dialog.message),
|
|
7313
|
+
h('div', { className: 'rw-dialog-actions' },
|
|
7314
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: function () { resolveConflict('cancel'); } }, t('conflictCancel')),
|
|
7315
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: function () { resolveConflict('unique'); } }, t('conflictKeepBoth')),
|
|
7316
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-danger', onClick: function () { resolveConflict('overwrite'); } }, t('conflictOverwrite'))));
|
|
7317
|
+
}
|
|
6688
7318
|
if (dialog.kind === 'move') {
|
|
6689
7319
|
return h(MoveDialog, {
|
|
6690
7320
|
t: t, locale: locale,
|
|
@@ -6758,11 +7388,12 @@ function attributeViolation(name, value, tagName) {
|
|
|
6758
7388
|
var timer = setTimeout(function () {
|
|
6759
7389
|
setSearch(function (previous) { return { loading: true, remote: previous.remote, local: previous.local, truncated: false, error: null }; });
|
|
6760
7390
|
var scopeNow = sourceScopeOf(selected);
|
|
6761
|
-
var
|
|
7391
|
+
var method = searchMode === 'content' ? 'fs.grep' : 'fs.search';
|
|
7392
|
+
var jobs = [apiCall(method, Object.assign({ side: 'remote', query: query, maxResults: 200 }, scopeParams(scopeNow))).catch(function (error) {
|
|
6762
7393
|
return { ok: false, entries: [], error: messageOf(error, t, locale) };
|
|
6763
7394
|
})];
|
|
6764
7395
|
if (selected.kind === 'linked') {
|
|
6765
|
-
jobs.push(apiCall(
|
|
7396
|
+
jobs.push(apiCall(method, Object.assign({ side: 'local', query: query, maxResults: 200 }, scopeParams(scopeNow))).catch(function (error) {
|
|
6766
7397
|
return { ok: false, entries: [], error: messageOf(error, t, locale) };
|
|
6767
7398
|
}));
|
|
6768
7399
|
} else {
|
|
@@ -6780,7 +7411,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
6780
7411
|
});
|
|
6781
7412
|
}, 320);
|
|
6782
7413
|
return function () { alive = false; clearTimeout(timer); };
|
|
6783
|
-
}, [searchOpen, searchQuery, selectedKey, version]);
|
|
7414
|
+
}, [searchOpen, searchQuery, selectedKey, version, searchMode]);
|
|
6784
7415
|
|
|
6785
7416
|
if (!selected) {
|
|
6786
7417
|
return h('div', { className: 'rw-workbench rw-workspace', ref: workbenchRef },
|
|
@@ -6813,7 +7444,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
6813
7444
|
h(TreeSection, {
|
|
6814
7445
|
key: 'remote:' + selected.key + ':' + version + ':' + (showHidden ? 'h' : 's'),
|
|
6815
7446
|
title: t('remoteTree'),
|
|
6816
|
-
icon:
|
|
7447
|
+
icon: IconRemoteWorkspace(11),
|
|
6817
7448
|
}, h(TreePanel, {
|
|
6818
7449
|
key: 'remote:' + selected.key + ':' + version + ':' + (showHidden ? 'h' : 's'),
|
|
6819
7450
|
kind: 'remote',
|
|
@@ -6951,9 +7582,22 @@ function attributeViolation(name, value, tagName) {
|
|
|
6951
7582
|
searchOpen
|
|
6952
7583
|
? h('div', { className: 'rw-searchbar' },
|
|
6953
7584
|
IconSearch(13),
|
|
7585
|
+
h('span', { className: 'rw-search-mode' },
|
|
7586
|
+
h('button', {
|
|
7587
|
+
type: 'button',
|
|
7588
|
+
className: 'rw-chip-btn' + (searchMode === 'name' ? ' is-on' : ''),
|
|
7589
|
+
title: t('searchModeName'),
|
|
7590
|
+
onClick: function () { setSearchMode('name'); },
|
|
7591
|
+
}, t('searchModeName')),
|
|
7592
|
+
h('button', {
|
|
7593
|
+
type: 'button',
|
|
7594
|
+
className: 'rw-chip-btn' + (searchMode === 'content' ? ' is-on' : ''),
|
|
7595
|
+
title: t('searchModeContent'),
|
|
7596
|
+
onClick: function () { setSearchMode('content'); },
|
|
7597
|
+
}, t('searchModeContent'))),
|
|
6954
7598
|
h('input', {
|
|
6955
7599
|
value: searchQuery,
|
|
6956
|
-
placeholder: t('searchPlaceholder'),
|
|
7600
|
+
placeholder: searchMode === 'content' ? t('searchPlaceholderContent') : t('searchPlaceholder'),
|
|
6957
7601
|
spellCheck: false,
|
|
6958
7602
|
autoFocus: true,
|
|
6959
7603
|
onChange: function (event) { setSearchQuery(event.currentTarget.value); },
|
|
@@ -6970,9 +7614,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
6970
7614
|
key: source.key,
|
|
6971
7615
|
type: 'button',
|
|
6972
7616
|
className: 'rw-chip-btn' + (selected.key === source.key ? ' is-on' : ''),
|
|
6973
|
-
title: source.name + ' · ' + source.remotePath,
|
|
7617
|
+
title: source.name + ' · ' + source.remotePath + ' · ' + statusTitle(t, source),
|
|
6974
7618
|
onClick: function () { setSelectedKey(source.key); },
|
|
6975
|
-
}, source.kind === 'linked' ?
|
|
7619
|
+
}, source.kind === 'linked' ? IconLinkedWorkspace(11) : source.kind === 'remote' ? IconRemoteWorkspace(11) : IconFolderTree(11), h('span', { style: { overflow: 'hidden', textOverflow: 'ellipsis' } }, source.name));
|
|
6976
7620
|
}))
|
|
6977
7621
|
: null,
|
|
6978
7622
|
info,
|
|
@@ -7026,7 +7670,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
7026
7670
|
var meta = tab && tab.meta ? tab.meta : {};
|
|
7027
7671
|
var scope = meta.linkedId
|
|
7028
7672
|
? { kind: 'linked', id: meta.linkedId }
|
|
7029
|
-
:
|
|
7673
|
+
: meta.remoteId
|
|
7674
|
+
? { kind: 'remote', id: meta.remoteId }
|
|
7675
|
+
: { kind: 'workspace', id: meta.workspaceId };
|
|
7030
7676
|
var filePath = tab && tab.path ? tab.path : '';
|
|
7031
7677
|
return h('div', { className: 'rw-editor-pane' },
|
|
7032
7678
|
h(RemoteFileEditor, {
|
|
@@ -7058,6 +7704,18 @@ function attributeViolation(name, value, tagName) {
|
|
|
7058
7704
|
var selectedPath = props.selectedPath;
|
|
7059
7705
|
var isOpen = expanded.has(path);
|
|
7060
7706
|
var entry = state.entries.get(path) || { loading: false, error: null, entries: [] };
|
|
7707
|
+
var childSiblings = entry.entries.map(function (item) {
|
|
7708
|
+
return { path: item.path, name: item.name, isDir: item.type === 'dir' };
|
|
7709
|
+
});
|
|
7710
|
+
// Hovering over a collapsed folder during a drag expands it after a short
|
|
7711
|
+
// delay, so dropping into a nested folder does not require two passes.
|
|
7712
|
+
var dragOpenTimer = useRef(null);
|
|
7713
|
+
|
|
7714
|
+
useEffect(function () {
|
|
7715
|
+
return function () {
|
|
7716
|
+
if (dragOpenTimer.current) clearTimeout(dragOpenTimer.current);
|
|
7717
|
+
};
|
|
7718
|
+
}, []);
|
|
7061
7719
|
|
|
7062
7720
|
useEffect(function () {
|
|
7063
7721
|
if (isOpen && !entry.loading && !entry.loaded && !entry.error) props.load(path);
|
|
@@ -7098,6 +7756,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
7098
7756
|
onDropOnPath: props.onDropOnPath,
|
|
7099
7757
|
selectedPath: selectedPath,
|
|
7100
7758
|
selectedSet: props.selectedSet,
|
|
7759
|
+
siblings: childSiblings,
|
|
7101
7760
|
}));
|
|
7102
7761
|
} else if (child.type === 'file' || child.type === 'symlink') {
|
|
7103
7762
|
var active = selectedPath === child.path || Boolean(props.selectedSet && props.selectedSet.has(child.path));
|
|
@@ -7115,7 +7774,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
7115
7774
|
if (props.onDragStart) props.onDragStart(event, { path: child.path, name: child.name, isDir: false });
|
|
7116
7775
|
},
|
|
7117
7776
|
onClick: function (event) {
|
|
7118
|
-
if (onSelectPath) onSelectPath({ path: child.path, name: child.name, isDir: false, event: event });
|
|
7777
|
+
if (onSelectPath) onSelectPath({ path: child.path, name: child.name, isDir: false, siblings: childSiblings, event: event });
|
|
7119
7778
|
if (event.detail !== 2) onSelect(child.path);
|
|
7120
7779
|
},
|
|
7121
7780
|
onDoubleClick: function () { if (onPin) onPin(child.path); },
|
|
@@ -7162,7 +7821,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
7162
7821
|
if (props.onDragStart) props.onDragStart(event, { path: path, name: name, isDir: true });
|
|
7163
7822
|
},
|
|
7164
7823
|
onClick: function (event) {
|
|
7165
|
-
if (onSelectPath) onSelectPath({ path: path, name: name, isDir: true, event: event });
|
|
7824
|
+
if (onSelectPath) onSelectPath({ path: path, name: name, isDir: true, siblings: props.siblings || [], event: event });
|
|
7166
7825
|
if (event.detail !== 2) toggle(path);
|
|
7167
7826
|
},
|
|
7168
7827
|
onKeyDown: function (event) {
|
|
@@ -7175,10 +7834,26 @@ function attributeViolation(name, value, tagName) {
|
|
|
7175
7834
|
event.stopPropagation();
|
|
7176
7835
|
try { event.dataTransfer.dropEffect = 'copy'; } catch (error) { /* ignore */ }
|
|
7177
7836
|
event.currentTarget.classList.add('is-drop-target');
|
|
7837
|
+
if (!isOpen && !dragOpenTimer.current) {
|
|
7838
|
+
dragOpenTimer.current = setTimeout(function () {
|
|
7839
|
+
dragOpenTimer.current = null;
|
|
7840
|
+
toggle(path);
|
|
7841
|
+
}, 700);
|
|
7842
|
+
}
|
|
7843
|
+
},
|
|
7844
|
+
onDragLeave: function (event) {
|
|
7845
|
+
event.currentTarget.classList.remove('is-drop-target');
|
|
7846
|
+
if (dragOpenTimer.current) {
|
|
7847
|
+
clearTimeout(dragOpenTimer.current);
|
|
7848
|
+
dragOpenTimer.current = null;
|
|
7849
|
+
}
|
|
7178
7850
|
},
|
|
7179
|
-
onDragLeave: function (event) { event.currentTarget.classList.remove('is-drop-target'); },
|
|
7180
7851
|
onDrop: function (event) {
|
|
7181
7852
|
event.currentTarget.classList.remove('is-drop-target');
|
|
7853
|
+
if (dragOpenTimer.current) {
|
|
7854
|
+
clearTimeout(dragOpenTimer.current);
|
|
7855
|
+
dragOpenTimer.current = null;
|
|
7856
|
+
}
|
|
7182
7857
|
if (props.onDropOnPath) props.onDropOnPath(path, event);
|
|
7183
7858
|
},
|
|
7184
7859
|
onContextMenu: function (event) {
|
|
@@ -7218,8 +7893,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
7218
7893
|
}
|
|
7219
7894
|
|
|
7220
7895
|
function listRequest(path, offset) {
|
|
7221
|
-
return Object.assign({ path: path, limit: TREE_PAGE_SIZE, offset: offset },
|
|
7222
|
-
source.kind === 'linked' ? { linkedId: source.id } : { workspaceId: source.id });
|
|
7896
|
+
return Object.assign({ path: path, limit: TREE_PAGE_SIZE, offset: offset }, scopeParams(source));
|
|
7223
7897
|
}
|
|
7224
7898
|
|
|
7225
7899
|
function load(path) {
|
|
@@ -7316,13 +7990,15 @@ function attributeViolation(name, value, tagName) {
|
|
|
7316
7990
|
className: 'rw-tree-ws-head',
|
|
7317
7991
|
onClick: function () { setOpen(function (value) { return !value; }); },
|
|
7318
7992
|
'aria-expanded': open,
|
|
7993
|
+
title: source.name + ' · ' + statusTitle(t, source),
|
|
7319
7994
|
},
|
|
7320
7995
|
h('span', { className: 'rw-chevron' + (open ? ' is-open' : '') }, IconChevron(12)),
|
|
7321
7996
|
h('span', { className: 'rw-icon-chip' + (source.kind === 'linked' ? ' rw-icon-chip-link' : ''), style: { width: 24, height: 24, borderRadius: 7 } },
|
|
7322
|
-
source.kind === 'linked' ?
|
|
7997
|
+
source.kind === 'linked' ? IconLinkedWorkspace(13) : source.kind === 'remote' ? IconRemoteWorkspace(13) : IconFolderTree(13)),
|
|
7323
7998
|
h('span', { className: 'rw-tree-ws-title' },
|
|
7324
7999
|
h('span', { className: 'rw-tree-ws-name' }, source.name),
|
|
7325
|
-
h('span', { className: 'rw-tree-ws-sub' }, source.username + '@' + source.host
|
|
8000
|
+
h('span', { className: 'rw-tree-ws-sub' }, source.username + '@' + source.host
|
|
8001
|
+
+ (source.kind === 'linked' ? ' · ' + t('linkedChip') : source.kind === 'remote' ? ' · ' + t('remoteChip') : ''))),
|
|
7326
8002
|
h(StatusPill, { status: source.status, t: t })),
|
|
7327
8003
|
open
|
|
7328
8004
|
? h('div', { className: 'rw-tree-body', role: 'tree', 'aria-label': source.name },
|
|
@@ -7381,10 +8057,6 @@ function attributeViolation(name, value, tagName) {
|
|
|
7381
8057
|
var locale = props.locale;
|
|
7382
8058
|
var onDone = props.onDone;
|
|
7383
8059
|
var onCancel = props.onCancel;
|
|
7384
|
-
var lockedMode = props.lockedMode === 'linked' ? 'linked' : props.lockedMode === 'remote' ? 'remote' : '';
|
|
7385
|
-
var modeState = useState(lockedMode || (props.initialMode === 'linked' ? 'linked' : 'remote'));
|
|
7386
|
-
var mode = lockedMode || modeState[0];
|
|
7387
|
-
var setMode = modeState[1];
|
|
7388
8060
|
|
|
7389
8061
|
var hostState = useState({ loading: true, hosts: [], error: null });
|
|
7390
8062
|
var hostData = hostState[0];
|
|
@@ -7448,25 +8120,10 @@ function attributeViolation(name, value, tagName) {
|
|
|
7448
8120
|
if (!selectedHostId) { setError(t('stepHost')); return; }
|
|
7449
8121
|
var trimmedRemote = remotePath.trim();
|
|
7450
8122
|
if (trimmedRemote === '') { setError(t('stepPath')); return; }
|
|
7451
|
-
setBusy(true);
|
|
7452
|
-
setError('');
|
|
7453
|
-
if (mode === 'remote') {
|
|
7454
|
-
apiCall('workspaces.add', {
|
|
7455
|
-
hostId: selectedHostId,
|
|
7456
|
-
remotePath: trimmedRemote,
|
|
7457
|
-
name: name.trim(),
|
|
7458
|
-
}).then(function () {
|
|
7459
|
-
setBusy(false);
|
|
7460
|
-
bus.emit();
|
|
7461
|
-
if (onDone) onDone();
|
|
7462
|
-
}).catch(function (err) {
|
|
7463
|
-
setBusy(false);
|
|
7464
|
-
setError(t('addFailed') + ':' + messageOf(err, t, locale));
|
|
7465
|
-
});
|
|
7466
|
-
return;
|
|
7467
|
-
}
|
|
7468
8123
|
var trimmedLocal = localPath.trim();
|
|
7469
8124
|
if (trimmedLocal === '') { setBusy(false); setError(t('stepLocalPath')); return; }
|
|
8125
|
+
setBusy(true);
|
|
8126
|
+
setError('');
|
|
7470
8127
|
apiCall('linked.create', {
|
|
7471
8128
|
hostId: selectedHostId,
|
|
7472
8129
|
remotePath: trimmedRemote,
|
|
@@ -7483,16 +8140,11 @@ function attributeViolation(name, value, tagName) {
|
|
|
7483
8140
|
});
|
|
7484
8141
|
}
|
|
7485
8142
|
|
|
7486
|
-
if (props.submitRef) props.submitRef.current = { submit: submit, busy: busy
|
|
8143
|
+
if (props.submitRef) props.submitRef.current = { submit: submit, busy: busy };
|
|
7487
8144
|
|
|
7488
8145
|
return h('div', { className: 'rw-add' },
|
|
7489
8146
|
h('div', { className: 'rw-inline', style: { justifyContent: 'space-between' } },
|
|
7490
|
-
h('div', { className: 'rw-add-title' },
|
|
7491
|
-
lockedMode === ''
|
|
7492
|
-
? h('div', { className: 'rw-tabs' },
|
|
7493
|
-
h('button', { type: 'button', className: 'rw-tab' + (mode === 'remote' ? ' is-on' : ''), onClick: function () { setMode('remote'); } }, IconServer(13), t('remoteGroup')),
|
|
7494
|
-
h('button', { type: 'button', className: 'rw-tab' + (mode === 'linked' ? ' is-on' : ''), onClick: function () { setMode('linked'); } }, IconLink(13), t('linkedName')))
|
|
7495
|
-
: null),
|
|
8147
|
+
h('div', { className: 'rw-add-title' }, t('createLinked'))),
|
|
7496
8148
|
h('div', { className: 'rw-field' },
|
|
7497
8149
|
h('div', { className: 'rw-label' }, t('stepHost')),
|
|
7498
8150
|
h(HostList, { t: t, hosts: hostData.hosts, loading: hostData.loading, selectedId: selectedHostId, onSelect: chooseHost }),
|
|
@@ -7522,8 +8174,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
7522
8174
|
})
|
|
7523
8175
|
: null,
|
|
7524
8176
|
h('div', { className: 'rw-hint' }, t('diskHint'))),
|
|
7525
|
-
|
|
7526
|
-
? h('div', { className: 'rw-field' },
|
|
8177
|
+
h('div', { className: 'rw-field' },
|
|
7527
8178
|
h('div', { className: 'rw-label' }, t('stepLocalPath')),
|
|
7528
8179
|
h('div', { className: 'rw-input-row' },
|
|
7529
8180
|
h('input', {
|
|
@@ -7549,28 +8200,158 @@ function attributeViolation(name, value, tagName) {
|
|
|
7549
8200
|
checked: mirror, onChange: setMirror, label: t('mirrorLabel'),
|
|
7550
8201
|
text: t('mirrorLabel'),
|
|
7551
8202
|
})),
|
|
7552
|
-
h('div', { className: 'rw-hint' }, t('mirrorHint')))
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
8203
|
+
h('div', { className: 'rw-hint' }, t('mirrorHint'))),
|
|
8204
|
+
h('div', { className: 'rw-field' },
|
|
8205
|
+
h('div', { className: 'rw-label' }, t('stepName')),
|
|
8206
|
+
h('input', {
|
|
8207
|
+
className: 'rw-input',
|
|
8208
|
+
value: name,
|
|
8209
|
+
placeholder: basename(localPath) || t('namePlaceholder'),
|
|
8210
|
+
maxLength: 120,
|
|
8211
|
+
onChange: function (event) { setName(event.currentTarget.value); },
|
|
8212
|
+
onKeyDown: function (event) { if (event.key === 'Enter') submit(); },
|
|
8213
|
+
})),
|
|
8214
|
+
error ? h(Banner, { kind: 'error' }, error) : null,
|
|
8215
|
+
props.compact ? null : h('div', { className: 'rw-actions' },
|
|
8216
|
+
h('button', { type: 'button', className: 'rw-btn', disabled: busy, onClick: onCancel }, t('cancel')),
|
|
8217
|
+
h('button', {
|
|
8218
|
+
type: 'button', className: 'rw-btn rw-btn-primary',
|
|
8219
|
+
disabled: busy || !selectedHostId || remotePath.trim() === '' || localPath.trim() === '',
|
|
8220
|
+
onClick: submit,
|
|
8221
|
+
}, busy ? Spinner(13) : IconLinkedWorkspace(13), busy ? t('creating') : t('create'))));
|
|
8222
|
+
}
|
|
8223
|
+
|
|
8224
|
+
// ── remote workspace flow (sessions run inside the remote folder) ──────
|
|
8225
|
+
|
|
8226
|
+
function AddRemoteWorkspaceFlow(props) {
|
|
8227
|
+
var t = props.t;
|
|
8228
|
+
var locale = props.locale;
|
|
8229
|
+
var onDone = props.onDone;
|
|
8230
|
+
var onCancel = props.onCancel;
|
|
8231
|
+
|
|
8232
|
+
var hostState = useState({ loading: true, hosts: [], error: null });
|
|
8233
|
+
var hostData = hostState[0];
|
|
8234
|
+
var setHostData = hostState[1];
|
|
8235
|
+
var selectedState = useState('');
|
|
8236
|
+
var selectedHostId = selectedState[0];
|
|
8237
|
+
var setSelectedHostId = selectedState[1];
|
|
8238
|
+
var pathState = useState('');
|
|
8239
|
+
var remotePath = pathState[0];
|
|
8240
|
+
var setRemotePath = pathState[1];
|
|
8241
|
+
var nameState = useState('');
|
|
8242
|
+
var name = nameState[0];
|
|
8243
|
+
var setName = nameState[1];
|
|
8244
|
+
var busyState = useState(false);
|
|
8245
|
+
var busy = busyState[0];
|
|
8246
|
+
var setBusy = busyState[1];
|
|
8247
|
+
var errorState = useState('');
|
|
8248
|
+
var error = errorState[0];
|
|
8249
|
+
var setError = errorState[1];
|
|
8250
|
+
var remoteOpenState = useState(false);
|
|
8251
|
+
var remoteOpen = remoteOpenState[0];
|
|
8252
|
+
var setRemoteOpen = remoteOpenState[1];
|
|
8253
|
+
|
|
8254
|
+
var loadHosts = useCallback(function () {
|
|
8255
|
+
setHostData(function (previous) { return { loading: previous.hosts.length === 0, hosts: previous.hosts, error: null }; });
|
|
8256
|
+
apiCall('hosts.list', {}).then(function (result) {
|
|
8257
|
+
setHostData({ loading: false, hosts: result.hosts || [], error: null });
|
|
8258
|
+
setSelectedHostId(function (current) {
|
|
8259
|
+
if (current) return current;
|
|
8260
|
+
return result.hosts && result.hosts.length > 0 ? result.hosts[0].id : '';
|
|
8261
|
+
});
|
|
8262
|
+
}).catch(function (err) {
|
|
8263
|
+
setHostData({ loading: false, hosts: [], error: err });
|
|
8264
|
+
});
|
|
8265
|
+
}, []);
|
|
8266
|
+
|
|
8267
|
+
useEffect(function () { loadHosts(); }, [loadHosts]);
|
|
8268
|
+
|
|
8269
|
+
function chooseHost(host) {
|
|
8270
|
+
setSelectedHostId(host.id);
|
|
8271
|
+
setError('');
|
|
8272
|
+
setRemoteOpen(false);
|
|
8273
|
+
if (remotePath.trim() === '' && host && host.hasCredential !== false) {
|
|
8274
|
+
apiCall('hosts.browse', { hostId: host.id }).then(function (result) {
|
|
8275
|
+
setRemotePath(function (current) { return current.trim() === '' ? result.home : current; });
|
|
8276
|
+
}).catch(function () { /* silent prefill */ });
|
|
8277
|
+
}
|
|
8278
|
+
}
|
|
8279
|
+
|
|
8280
|
+
function submit() {
|
|
8281
|
+
if (busy) return;
|
|
8282
|
+
if (!selectedHostId) { setError(t('stepHost')); return; }
|
|
8283
|
+
var trimmedRemote = remotePath.trim();
|
|
8284
|
+
if (trimmedRemote === '') { setError(t('stepPath')); return; }
|
|
8285
|
+
setBusy(true);
|
|
8286
|
+
setError('');
|
|
8287
|
+
apiCall('remote_workspaces.create', {
|
|
8288
|
+
hostId: selectedHostId,
|
|
8289
|
+
remotePath: trimmedRemote,
|
|
8290
|
+
name: name.trim(),
|
|
8291
|
+
}).then(function () {
|
|
8292
|
+
setBusy(false);
|
|
8293
|
+
bus.emit();
|
|
8294
|
+
if (onDone) onDone();
|
|
8295
|
+
}).catch(function (err) {
|
|
8296
|
+
setBusy(false);
|
|
8297
|
+
setError(t('remoteCreateFailed') + ':' + messageOf(err, t, locale));
|
|
8298
|
+
});
|
|
8299
|
+
}
|
|
8300
|
+
|
|
8301
|
+
if (props.submitRef) props.submitRef.current = { submit: submit, busy: busy };
|
|
8302
|
+
|
|
8303
|
+
return h('div', { className: 'rw-add' },
|
|
8304
|
+
h('div', { className: 'rw-inline', style: { justifyContent: 'space-between' } },
|
|
8305
|
+
h('div', { className: 'rw-add-title' }, t('createRemote'))),
|
|
8306
|
+
h('div', { className: 'rw-hint' }, t('flowRemoteDesc')),
|
|
8307
|
+
h('div', { className: 'rw-field' },
|
|
8308
|
+
h('div', { className: 'rw-label' }, t('stepHost')),
|
|
8309
|
+
h(HostList, { t: t, hosts: hostData.hosts, loading: hostData.loading, selectedId: selectedHostId, onSelect: chooseHost }),
|
|
8310
|
+
hostData.error ? h(Banner, { kind: 'error' }, t('hostsFailed') + ':' + messageOf(hostData.error, t, locale)) : null),
|
|
8311
|
+
h('div', { className: 'rw-field' },
|
|
8312
|
+
h('div', { className: 'rw-label' }, t('stepPath')),
|
|
8313
|
+
h('div', { className: 'rw-input-row' },
|
|
7557
8314
|
h('input', {
|
|
7558
|
-
className: 'rw-input',
|
|
7559
|
-
value:
|
|
7560
|
-
placeholder:
|
|
7561
|
-
|
|
7562
|
-
|
|
8315
|
+
className: 'rw-input rw-input-mono',
|
|
8316
|
+
value: remotePath,
|
|
8317
|
+
placeholder: t('pathPlaceholder'),
|
|
8318
|
+
spellCheck: false,
|
|
8319
|
+
autoComplete: 'off',
|
|
8320
|
+
onChange: function (event) { setRemotePath(event.currentTarget.value); },
|
|
7563
8321
|
onKeyDown: function (event) { if (event.key === 'Enter') submit(); },
|
|
7564
|
-
})
|
|
7565
|
-
|
|
8322
|
+
}),
|
|
8323
|
+
h('button', {
|
|
8324
|
+
type: 'button', className: 'rw-btn',
|
|
8325
|
+
onClick: function () { setRemoteOpen(function (value) { return !value; }); },
|
|
8326
|
+
disabled: !selectedHostId,
|
|
8327
|
+
}, IconFolder(13), remoteOpen ? t('cancel') : t('browse'))),
|
|
8328
|
+
remoteOpen
|
|
8329
|
+
? h(RemotePathPicker, {
|
|
8330
|
+
t: t, locale: locale, hostId: selectedHostId,
|
|
8331
|
+
initialPath: remotePath,
|
|
8332
|
+
onPick: function (picked) { setRemotePath(picked); setRemoteOpen(false); },
|
|
8333
|
+
})
|
|
8334
|
+
: null,
|
|
8335
|
+
h('div', { className: 'rw-hint' }, t('diskHint'))),
|
|
8336
|
+
h('div', { className: 'rw-field' },
|
|
8337
|
+
h('div', { className: 'rw-label' }, t('remoteStepName')),
|
|
8338
|
+
h('input', {
|
|
8339
|
+
className: 'rw-input',
|
|
8340
|
+
value: name,
|
|
8341
|
+
placeholder: basename(remotePath) || t('namePlaceholder'),
|
|
8342
|
+
maxLength: 120,
|
|
8343
|
+
onChange: function (event) { setName(event.currentTarget.value); },
|
|
8344
|
+
onKeyDown: function (event) { if (event.key === 'Enter') submit(); },
|
|
8345
|
+
})),
|
|
8346
|
+
h('div', { className: 'rw-hint' }, t('remotePlaceholderHint')),
|
|
7566
8347
|
error ? h(Banner, { kind: 'error' }, error) : null,
|
|
7567
8348
|
props.compact ? null : h('div', { className: 'rw-actions' },
|
|
7568
8349
|
h('button', { type: 'button', className: 'rw-btn', disabled: busy, onClick: onCancel }, t('cancel')),
|
|
7569
8350
|
h('button', {
|
|
7570
8351
|
type: 'button', className: 'rw-btn rw-btn-primary',
|
|
7571
|
-
disabled: busy || !selectedHostId || remotePath.trim() === ''
|
|
8352
|
+
disabled: busy || !selectedHostId || remotePath.trim() === '',
|
|
7572
8353
|
onClick: submit,
|
|
7573
|
-
}, busy ? Spinner(13) : (
|
|
8354
|
+
}, busy ? Spinner(13) : IconRemoteWorkspace(13), busy ? t('creating') : t('create'))));
|
|
7574
8355
|
}
|
|
7575
8356
|
|
|
7576
8357
|
// ── directory flow (sidebar / hero "add workspace" hole) ───────────────
|
|
@@ -7601,7 +8382,10 @@ function attributeViolation(name, value, tagName) {
|
|
|
7601
8382
|
|
|
7602
8383
|
function createLocal() {
|
|
7603
8384
|
var target = localPath.trim();
|
|
7604
|
-
if (
|
|
8385
|
+
if (localBusy) return;
|
|
8386
|
+
// Keep the button looking the same as the linked/remote ones and report
|
|
8387
|
+
// the missing folder instead of silently ignoring the click.
|
|
8388
|
+
if (target === '') { setLocalError(t('localPathRequired')); return; }
|
|
7605
8389
|
setLocalBusy(true);
|
|
7606
8390
|
setLocalError('');
|
|
7607
8391
|
apiCall('localWorkspace.create', { path: target, name: localName.trim() }).then(function () {
|
|
@@ -7667,14 +8451,15 @@ function attributeViolation(name, value, tagName) {
|
|
|
7667
8451
|
onKeyDown: onModalKeyDown,
|
|
7668
8452
|
},
|
|
7669
8453
|
h('div', { className: 'rw-modal-head' },
|
|
7670
|
-
h('span', { className: 'rw-icon-chip' },
|
|
8454
|
+
h('span', { className: 'rw-icon-chip' }, IconFolderTree(16)),
|
|
7671
8455
|
h('span', { className: 'rw-modal-title' }, t('flowTitle')),
|
|
7672
8456
|
h('button', { type: 'button', className: 'rw-icon-btn', title: t('cancel'), onClick: function () { if (props.onCancel) props.onCancel(); } }, IconClose(14))),
|
|
7673
8457
|
h('div', { className: 'rw-modal-body' },
|
|
7674
8458
|
h('div', { className: 'rw-tabs' },
|
|
7675
8459
|
h('button', { type: 'button', className: 'rw-tab' + (flow === 'local' ? ' is-on' : ''), onClick: function () { setFlow('local'); } }, IconFolder(13), t('flowLocal')),
|
|
7676
|
-
h('button', { type: 'button', className: 'rw-tab' + (flow === 'linked' ? ' is-on' : ''), onClick: function () { setFlow('linked'); } },
|
|
7677
|
-
|
|
8460
|
+
h('button', { type: 'button', className: 'rw-tab' + (flow === 'linked' ? ' is-on' : ''), onClick: function () { setFlow('linked'); } }, IconLinkedWorkspace(13), t('flowLinked')),
|
|
8461
|
+
h('button', { type: 'button', className: 'rw-tab' + (flow === 'remote' ? ' is-on' : ''), onClick: function () { setFlow('remote'); } }, IconRemoteWorkspace(13), t('flowRemote'))),
|
|
8462
|
+
h('div', { className: 'rw-hint' }, flow === 'local' ? t('localFlowHint') : flow === 'remote' ? t('flowRemoteDesc') : t('linkedFlowHint')),
|
|
7678
8463
|
flow === 'local'
|
|
7679
8464
|
? h('div', { className: 'rw-add' },
|
|
7680
8465
|
h('div', { className: 'rw-field' },
|
|
@@ -7685,7 +8470,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
7685
8470
|
value: localPath,
|
|
7686
8471
|
placeholder: t('localPathPlaceholder'),
|
|
7687
8472
|
spellCheck: false,
|
|
7688
|
-
onChange: function (event) { setLocalPath(event.currentTarget.value); },
|
|
8473
|
+
onChange: function (event) { setLocalPath(event.currentTarget.value); if (localError) setLocalError(''); },
|
|
7689
8474
|
}),
|
|
7690
8475
|
h('button', {
|
|
7691
8476
|
type: 'button', className: 'rw-btn',
|
|
@@ -7708,13 +8493,19 @@ function attributeViolation(name, value, tagName) {
|
|
|
7708
8493
|
onKeyDown: function (event) { if (event.key === 'Enter') createLocal(); },
|
|
7709
8494
|
})),
|
|
7710
8495
|
localError ? h(Banner, { kind: 'error' }, localError) : null)
|
|
7711
|
-
:
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7715
|
-
|
|
8496
|
+
: flow === 'remote'
|
|
8497
|
+
? h(AddRemoteWorkspaceFlow, {
|
|
8498
|
+
ctx: ctx, t: t, locale: locale, compact: true, submitRef: flowSubmitRef,
|
|
8499
|
+
onDone: function () { if (props.onCancel) props.onCancel(); },
|
|
8500
|
+
onCancel: function () { if (props.onCancel) props.onCancel(); },
|
|
8501
|
+
})
|
|
8502
|
+
: h(AddWorkspaceFlow, {
|
|
8503
|
+
ctx: ctx, t: t, locale: locale, compact: true, submitRef: flowSubmitRef,
|
|
8504
|
+
onDone: function () { if (props.onCancel) props.onCancel(); },
|
|
8505
|
+
onCancel: function () { if (props.onCancel) props.onCancel(); },
|
|
8506
|
+
})),
|
|
7716
8507
|
h('div', { className: 'rw-modal-foot' },
|
|
7717
|
-
h('span', { className: 'rw-hint', style: { flex: '1 1 auto' } }, props.busy ? t('wsFlowBusy') : flow === 'linked' ? t('linkedFlowHint') : t('useLocalDirHint')),
|
|
8508
|
+
h('span', { className: 'rw-hint', style: { flex: '1 1 auto' } }, props.busy ? t('wsFlowBusy') : flow === 'linked' ? t('linkedFlowHint') : flow === 'remote' ? t('flowRemoteDesc') : t('useLocalDirHint')),
|
|
7718
8509
|
h('button', {
|
|
7719
8510
|
type: 'button', className: 'rw-btn', disabled: Boolean(props.busy) || localBusy,
|
|
7720
8511
|
onClick: function () { if (props.onCancel) props.onCancel(); },
|
|
@@ -7722,7 +8513,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
7722
8513
|
flow === 'local'
|
|
7723
8514
|
? h('button', {
|
|
7724
8515
|
type: 'button', className: 'rw-btn rw-btn-primary',
|
|
7725
|
-
disabled:
|
|
8516
|
+
disabled: Boolean(props.busy) || localBusy,
|
|
7726
8517
|
onClick: createLocal,
|
|
7727
8518
|
}, localBusy ? Spinner(13) : IconPlus(13), localBusy ? t('creating') : t('create'))
|
|
7728
8519
|
: h('button', {
|
|
@@ -7737,89 +8528,6 @@ function attributeViolation(name, value, tagName) {
|
|
|
7737
8528
|
|
|
7738
8529
|
// ── settings section ───────────────────────────────────────────────────
|
|
7739
8530
|
|
|
7740
|
-
function RemoteWorkspaceCard(props) {
|
|
7741
|
-
var workspace = props.workspace;
|
|
7742
|
-
var t = props.t;
|
|
7743
|
-
var ctx = props.ctx;
|
|
7744
|
-
var locale = props.locale;
|
|
7745
|
-
var refresh = props.refresh;
|
|
7746
|
-
var state = useState({ testing: false, removing: false, message: null });
|
|
7747
|
-
var local = state[0];
|
|
7748
|
-
var setLocal = state[1];
|
|
7749
|
-
|
|
7750
|
-
function open() {
|
|
7751
|
-
var sidebar = ctx.get && ctx.get('betterSidebar');
|
|
7752
|
-
if (!sidebar || typeof sidebar.openTab !== 'function') return;
|
|
7753
|
-
sidebar.openTab({
|
|
7754
|
-
type: REMOTE_TAB_TYPE,
|
|
7755
|
-
id: REMOTE_TAB_TYPE,
|
|
7756
|
-
title: t('remoteTabTitle'),
|
|
7757
|
-
path: '/',
|
|
7758
|
-
meta: { remoteId: workspace.id },
|
|
7759
|
-
});
|
|
7760
|
-
dismissSettingsOverlay();
|
|
7761
|
-
}
|
|
7762
|
-
|
|
7763
|
-
function test() {
|
|
7764
|
-
setLocal({ testing: true, removing: false, message: null });
|
|
7765
|
-
apiCall('workspaces.test', { id: workspace.id }).then(function (result) {
|
|
7766
|
-
setLocal({
|
|
7767
|
-
testing: false,
|
|
7768
|
-
removing: false,
|
|
7769
|
-
message: result.ok
|
|
7770
|
-
? { kind: 'success', text: t('testOk') + (result.latencyMs ? ' · ' + result.latencyMs + ' ms' : '') }
|
|
7771
|
-
: { kind: 'error', text: t('testFail') + ':' + (result.error || '') },
|
|
7772
|
-
});
|
|
7773
|
-
refresh();
|
|
7774
|
-
}).catch(function (error) {
|
|
7775
|
-
setLocal({ testing: false, removing: false, message: { kind: 'error', text: t('testFail') + ':' + messageOf(error, t, locale) } });
|
|
7776
|
-
});
|
|
7777
|
-
}
|
|
7778
|
-
|
|
7779
|
-
function remove() {
|
|
7780
|
-
if (!local.removing) {
|
|
7781
|
-
setLocal({ testing: false, removing: true, message: null });
|
|
7782
|
-
return;
|
|
7783
|
-
}
|
|
7784
|
-
setLocal({ testing: false, removing: true, message: { kind: 'info', text: t('loading') } });
|
|
7785
|
-
apiCall('workspaces.remove', { id: workspace.id }).then(function () {
|
|
7786
|
-
bus.emit();
|
|
7787
|
-
}).catch(function (error) {
|
|
7788
|
-
setLocal({ testing: false, removing: false, message: { kind: 'error', text: messageOf(error, t, locale) } });
|
|
7789
|
-
});
|
|
7790
|
-
}
|
|
7791
|
-
|
|
7792
|
-
var title = workspace.name || basename(workspace.remotePath) || workspace.hostName;
|
|
7793
|
-
var hostLabel = workspace.username + '@' + workspace.host + ':' + workspace.port;
|
|
7794
|
-
|
|
7795
|
-
return h('div', { className: 'rw-card' },
|
|
7796
|
-
h('div', { className: 'rw-card-head' },
|
|
7797
|
-
h('span', { className: 'rw-icon-chip' }, IconServer(16)),
|
|
7798
|
-
h('div', { className: 'rw-fill', style: { flex: '1 1 auto', minWidth: 0 } },
|
|
7799
|
-
h('div', { className: 'rw-card-title' },
|
|
7800
|
-
h('span', { className: 'rw-name', title: title }, title),
|
|
7801
|
-
h(StatusPill, { status: workspace.status, t: t })),
|
|
7802
|
-
h('div', { className: 'rw-path', title: workspace.remotePath }, workspace.remotePath)),
|
|
7803
|
-
h('div', { className: 'rw-actions' },
|
|
7804
|
-
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: open, disabled: !(ctx.get && ctx.get('betterSidebar')) }, IconExternal(12), t('open')),
|
|
7805
|
-
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: test, disabled: local.testing }, local.testing ? Spinner(12) : IconRefresh(12), local.testing ? t('testRunning') : t('test')),
|
|
7806
|
-
h('button', {
|
|
7807
|
-
type: 'button',
|
|
7808
|
-
className: 'rw-btn rw-btn-sm' + (local.removing ? ' rw-btn-danger' : ' rw-btn-ghost'),
|
|
7809
|
-
onClick: remove,
|
|
7810
|
-
title: local.removing ? t('removeHint') : t('remove'),
|
|
7811
|
-
}, IconTrash(12), local.removing ? t('confirmRemove') : t('remove')))),
|
|
7812
|
-
h('div', { className: 'rw-meta' },
|
|
7813
|
-
h('span', { className: 'rw-chip' }, IconServer(11), workspace.hostName),
|
|
7814
|
-
h('span', { className: 'rw-meta-text rw-input-mono', title: hostLabel }, hostLabel)),
|
|
7815
|
-
local.message
|
|
7816
|
-
? h(Banner, {
|
|
7817
|
-
kind: local.message.kind === 'success' ? 'success' : local.message.kind === 'error' ? 'error' : undefined,
|
|
7818
|
-
onClose: function () { setLocal({ testing: false, removing: false, message: null }); },
|
|
7819
|
-
}, local.message.text)
|
|
7820
|
-
: null);
|
|
7821
|
-
}
|
|
7822
|
-
|
|
7823
8531
|
function LinkedWorkspaceCard(props) {
|
|
7824
8532
|
var link = props.link;
|
|
7825
8533
|
var t = props.t;
|
|
@@ -7851,6 +8559,20 @@ function attributeViolation(name, value, tagName) {
|
|
|
7851
8559
|
dismissSettingsOverlay();
|
|
7852
8560
|
}
|
|
7853
8561
|
|
|
8562
|
+
function registerWorkspace() {
|
|
8563
|
+
setLocal(function (previous) { return Object.assign({}, previous, { busy: 'register', message: null }); });
|
|
8564
|
+
apiCall('linked.update', { id: link.id, ensureWorkspace: true }).then(function () {
|
|
8565
|
+
setLocal(function (previous) {
|
|
8566
|
+
return Object.assign({}, previous, { busy: '', message: { kind: 'success', text: t('workspaceRegistered') } });
|
|
8567
|
+
});
|
|
8568
|
+
refresh();
|
|
8569
|
+
}).catch(function (error) {
|
|
8570
|
+
setLocal(function (previous) {
|
|
8571
|
+
return Object.assign({}, previous, { busy: '', message: { kind: 'error', text: messageOf(error, t, locale) } });
|
|
8572
|
+
});
|
|
8573
|
+
});
|
|
8574
|
+
}
|
|
8575
|
+
|
|
7854
8576
|
function pollSync(job) {
|
|
7855
8577
|
if (!job) {
|
|
7856
8578
|
setLocal(function (previous) { return Object.assign({}, previous, { busy: '', message: null }); });
|
|
@@ -7931,9 +8653,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
7931
8653
|
});
|
|
7932
8654
|
}
|
|
7933
8655
|
|
|
7934
|
-
return h('div', { className: 'rw-card' },
|
|
8656
|
+
return h('div', { className: 'rw-card', title: link.name + ' · ' + statusTitle(t, link) },
|
|
7935
8657
|
h('div', { className: 'rw-card-head' },
|
|
7936
|
-
h('span', { className: 'rw-icon-chip rw-icon-chip-link' },
|
|
8658
|
+
h('span', { className: 'rw-icon-chip rw-icon-chip-link' }, IconLinkedWorkspace(16)),
|
|
7937
8659
|
h('div', { className: 'rw-fill', style: { flex: '1 1 auto', minWidth: 0 } },
|
|
7938
8660
|
h('div', { className: 'rw-card-title' },
|
|
7939
8661
|
h('span', { className: 'rw-name', title: link.name }, link.name),
|
|
@@ -7949,7 +8671,12 @@ function attributeViolation(name, value, tagName) {
|
|
|
7949
8671
|
h('div', { className: 'rw-actions' },
|
|
7950
8672
|
link.workspaceId
|
|
7951
8673
|
? h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: openWorkspace }, IconExternal(12), t('openWorkspace'))
|
|
7952
|
-
: h('
|
|
8674
|
+
: h('button', {
|
|
8675
|
+
type: 'button', className: 'rw-btn rw-btn-sm',
|
|
8676
|
+
onClick: registerWorkspace,
|
|
8677
|
+
disabled: local.busy === 'register',
|
|
8678
|
+
title: t('workspaceMissing'),
|
|
8679
|
+
}, local.busy === 'register' ? Spinner(12) : IconPlus(12), t('workspaceRegister')),
|
|
7953
8680
|
h('button', {
|
|
7954
8681
|
type: 'button', className: 'rw-btn rw-btn-sm',
|
|
7955
8682
|
onClick: sync, disabled: local.busy !== '' || !link.mirror, title: link.mirror ? t('sync') : t('mirrorHint'),
|
|
@@ -7993,6 +8720,157 @@ function attributeViolation(name, value, tagName) {
|
|
|
7993
8720
|
: null);
|
|
7994
8721
|
}
|
|
7995
8722
|
|
|
8723
|
+
function RemoteWorkspaceCard(props) {
|
|
8724
|
+
var workspace = props.workspace;
|
|
8725
|
+
var t = props.t;
|
|
8726
|
+
var ctx = props.ctx;
|
|
8727
|
+
var locale = props.locale;
|
|
8728
|
+
var refresh = props.refresh;
|
|
8729
|
+
var state = useState({ busy: '', message: null, removing: false, renaming: false, draft: workspace.name });
|
|
8730
|
+
var local = state[0];
|
|
8731
|
+
var setLocal = state[1];
|
|
8732
|
+
|
|
8733
|
+
function openWorkspace() {
|
|
8734
|
+
if (!workspace.workspaceId) return;
|
|
8735
|
+
var uiWorkspace = null;
|
|
8736
|
+
try { uiWorkspace = ctx.get('uiWorkspace'); } catch (error) { uiWorkspace = null; }
|
|
8737
|
+
if (!uiWorkspace && ctx.root && typeof ctx.root.get === 'function') {
|
|
8738
|
+
try { uiWorkspace = ctx.root.get('uiWorkspace'); } catch (error) { uiWorkspace = null; }
|
|
8739
|
+
}
|
|
8740
|
+
if (uiWorkspace && typeof uiWorkspace.openWorkspace === 'function') {
|
|
8741
|
+
try {
|
|
8742
|
+
var navigation = uiWorkspace.openWorkspace(workspace.workspaceId);
|
|
8743
|
+
if (navigation && typeof navigation.catch === 'function') navigation.catch(function () { /* navigation aborted */ });
|
|
8744
|
+
} catch (error) { /* ignore */ }
|
|
8745
|
+
}
|
|
8746
|
+
dismissSettingsOverlay();
|
|
8747
|
+
}
|
|
8748
|
+
|
|
8749
|
+
function openTree() {
|
|
8750
|
+
var sidebar = sidebarService(ctx);
|
|
8751
|
+
if (!sidebar || typeof sidebar.openTab !== 'function') return;
|
|
8752
|
+
sidebar.openTab({
|
|
8753
|
+
type: REMOTE_TREE_TAB_TYPE,
|
|
8754
|
+
id: REMOTE_TREE_TAB_TYPE,
|
|
8755
|
+
title: workspace.name,
|
|
8756
|
+
path: '/',
|
|
8757
|
+
meta: { remoteId: workspace.id },
|
|
8758
|
+
});
|
|
8759
|
+
dismissSettingsOverlay();
|
|
8760
|
+
}
|
|
8761
|
+
|
|
8762
|
+
function startRename() {
|
|
8763
|
+
setLocal(function (previous) { return Object.assign({}, previous, { renaming: true, draft: workspace.name, message: null }); });
|
|
8764
|
+
}
|
|
8765
|
+
|
|
8766
|
+
function submitRename() {
|
|
8767
|
+
var next = String(local.draft == null ? '' : local.draft).trim();
|
|
8768
|
+
if (next === '' || next === workspace.name) {
|
|
8769
|
+
setLocal(function (previous) { return Object.assign({}, previous, { renaming: false }); });
|
|
8770
|
+
return;
|
|
8771
|
+
}
|
|
8772
|
+
setLocal(function (previous) { return Object.assign({}, previous, { busy: 'rename', message: null }); });
|
|
8773
|
+
apiCall('remote_workspaces.update', { id: workspace.id, name: next }).then(function () {
|
|
8774
|
+
setLocal(function (previous) { return Object.assign({}, previous, { busy: '', renaming: false }); });
|
|
8775
|
+
refresh();
|
|
8776
|
+
}).catch(function (error) {
|
|
8777
|
+
setLocal(function (previous) {
|
|
8778
|
+
return Object.assign({}, previous, { busy: '', message: { kind: 'error', text: t('remoteUpdateFailed') + ':' + messageOf(error, t, locale) } });
|
|
8779
|
+
});
|
|
8780
|
+
});
|
|
8781
|
+
}
|
|
8782
|
+
|
|
8783
|
+
function testConnection() {
|
|
8784
|
+
setLocal(function (previous) { return Object.assign({}, previous, { busy: 'test', message: null }); });
|
|
8785
|
+
apiCall('remote_workspaces.test', { id: workspace.id }).then(function (result) {
|
|
8786
|
+
var ok = result && result.ok;
|
|
8787
|
+
var text = ok
|
|
8788
|
+
? t('testOk', { ms: result.latencyMs == null ? '' : result.latencyMs })
|
|
8789
|
+
: (t('testFailed') + ':' + (result && result.error ? result.error : t('testFailed')));
|
|
8790
|
+
setLocal(function (previous) { return Object.assign({}, previous, { busy: '', message: { kind: ok ? 'success' : 'error', text: text } }); });
|
|
8791
|
+
}).catch(function (error) {
|
|
8792
|
+
setLocal(function (previous) {
|
|
8793
|
+
return Object.assign({}, previous, { busy: '', message: { kind: 'error', text: t('testFailed') + ':' + messageOf(error, t, locale) } });
|
|
8794
|
+
});
|
|
8795
|
+
});
|
|
8796
|
+
}
|
|
8797
|
+
|
|
8798
|
+
function remove() {
|
|
8799
|
+
if (!local.removing) {
|
|
8800
|
+
setLocal(function (previous) { return Object.assign({}, previous, { removing: true, message: null }); });
|
|
8801
|
+
return;
|
|
8802
|
+
}
|
|
8803
|
+
setLocal(function (previous) { return Object.assign({}, previous, { busy: 'remove' }); });
|
|
8804
|
+
apiCall('remote_workspaces.remove', { id: workspace.id }).then(function () {
|
|
8805
|
+
setLocal(function (previous) { return Object.assign({}, previous, { busy: '', removing: false, message: { kind: 'success', text: t('remoteRemoved') } }); });
|
|
8806
|
+
bus.emit();
|
|
8807
|
+
refresh();
|
|
8808
|
+
}).catch(function (error) {
|
|
8809
|
+
setLocal(function (previous) {
|
|
8810
|
+
return Object.assign({}, previous, { busy: '', message: { kind: 'error', text: t('remoteRemoveFailed') + ':' + messageOf(error, t, locale) } });
|
|
8811
|
+
});
|
|
8812
|
+
});
|
|
8813
|
+
}
|
|
8814
|
+
|
|
8815
|
+
var hostLabel = (workspace.username ? workspace.username + '@' : '') + (workspace.host || workspace.hostName || '');
|
|
8816
|
+
|
|
8817
|
+
return h('div', { className: 'rw-card', title: workspace.name + ' · ' + statusTitle(t, workspace) },
|
|
8818
|
+
h('div', { className: 'rw-card-head' },
|
|
8819
|
+
h('span', { className: 'rw-icon-chip' }, IconRemoteWorkspace(16)),
|
|
8820
|
+
h('div', { className: 'rw-fill', style: { flex: '1 1 auto', minWidth: 0 } },
|
|
8821
|
+
h('div', { className: 'rw-card-title' },
|
|
8822
|
+
local.renaming
|
|
8823
|
+
? h('input', {
|
|
8824
|
+
className: 'rw-input',
|
|
8825
|
+
value: local.draft,
|
|
8826
|
+
autoFocus: true,
|
|
8827
|
+
onChange: function (event) { setLocal(function (previous) { return Object.assign({}, previous, { draft: event.target.value }); }); },
|
|
8828
|
+
onKeyDown: function (event) {
|
|
8829
|
+
if (event.key === 'Enter') { event.preventDefault(); submitRename(); }
|
|
8830
|
+
if (event.key === 'Escape') { event.preventDefault(); setLocal(function (previous) { return Object.assign({}, previous, { renaming: false }); }); }
|
|
8831
|
+
},
|
|
8832
|
+
})
|
|
8833
|
+
: h('span', { className: 'rw-name', title: workspace.name }, workspace.name),
|
|
8834
|
+
h('span', { className: 'rw-chip' }, t('remoteChip')),
|
|
8835
|
+
h(StatusPill, { status: workspace.status, t: t })),
|
|
8836
|
+
local.renaming
|
|
8837
|
+
? null
|
|
8838
|
+
: h('div', { className: 'rw-pair' },
|
|
8839
|
+
h('div', { className: 'rw-pair-item' },
|
|
8840
|
+
h('span', { className: 'rw-pair-label' }, t('pathRemoteShort') + (hostLabel ? ' · ' + hostLabel : '')),
|
|
8841
|
+
h('span', { className: 'rw-path', title: workspace.remotePath }, workspace.remotePath)),
|
|
8842
|
+
h('div', { className: 'rw-pair-item' },
|
|
8843
|
+
h('span', { className: 'rw-pair-label' }, t('remotePlaceholderLabel')),
|
|
8844
|
+
h('span', { className: 'rw-path', title: workspace.placeholderPath }, workspace.placeholderPath)))),
|
|
8845
|
+
h('div', { className: 'rw-actions' },
|
|
8846
|
+
local.renaming
|
|
8847
|
+
? h('span', null,
|
|
8848
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-ghost', onClick: function () { setLocal(function (previous) { return Object.assign({}, previous, { renaming: false }); }); } }, t('cancel')),
|
|
8849
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-primary', onClick: submitRename, disabled: local.busy === 'rename' }, local.busy === 'rename' ? Spinner(12) : null, t('save')))
|
|
8850
|
+
: h('span', null,
|
|
8851
|
+
workspace.workspaceId
|
|
8852
|
+
? h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: openWorkspace }, IconExternal(12), t('openWorkspace'))
|
|
8853
|
+
: null,
|
|
8854
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: openTree }, IconFolderTree(12), t('openTree')),
|
|
8855
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-ghost', onClick: testConnection, disabled: local.busy !== '' }, local.busy === 'test' ? Spinner(12) : IconRefresh(12), t('testConnection')),
|
|
8856
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-ghost', onClick: startRename, disabled: local.busy !== '' }, t('rename')),
|
|
8857
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-ghost', onClick: remove, disabled: local.busy === 'remove' }, IconTrash(12), t('removeRemote'))))),
|
|
8858
|
+
h('div', { className: 'rw-hint' }, t('remoteSessionHint')),
|
|
8859
|
+
local.removing
|
|
8860
|
+
? h('div', { className: 'rw-warn-box' },
|
|
8861
|
+
h('div', null, t('remoteRemoveHint')),
|
|
8862
|
+
h('div', { className: 'rw-actions', style: { marginTop: 8 } },
|
|
8863
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm', onClick: function () { setLocal(function (previous) { return Object.assign({}, previous, { removing: false }); }); } }, t('cancel')),
|
|
8864
|
+
h('button', { type: 'button', className: 'rw-btn rw-btn-sm rw-btn-danger', onClick: remove, disabled: local.busy === 'remove' }, IconTrash(12), t('confirmRemove'))))
|
|
8865
|
+
: null,
|
|
8866
|
+
local.message
|
|
8867
|
+
? h(Banner, {
|
|
8868
|
+
kind: local.message.kind === 'success' ? 'success' : local.message.kind === 'error' ? 'error' : undefined,
|
|
8869
|
+
onClose: function () { setLocal(function (previous) { return Object.assign({}, previous, { message: null }); }); },
|
|
8870
|
+
}, local.message.text)
|
|
8871
|
+
: null);
|
|
8872
|
+
}
|
|
8873
|
+
|
|
7996
8874
|
function ThemeGroup(props) {
|
|
7997
8875
|
var t = props.t;
|
|
7998
8876
|
var locale = props.locale;
|
|
@@ -8118,6 +8996,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
8118
8996
|
h('kbd', { className: 'rw-kbd' }, item[0]),
|
|
8119
8997
|
h('span', null, item[1]));
|
|
8120
8998
|
})),
|
|
8999
|
+
h('div', { className: 'rw-group-hint', style: { marginTop: 8 } }, t('shortcutWebNote')),
|
|
8121
9000
|
local.message
|
|
8122
9001
|
? h(Banner, {
|
|
8123
9002
|
kind: local.message.kind === 'success' ? 'success' : 'error',
|
|
@@ -8134,13 +9013,13 @@ function attributeViolation(name, value, tagName) {
|
|
|
8134
9013
|
var addingState = useState('');
|
|
8135
9014
|
var adding = addingState[0];
|
|
8136
9015
|
var setAdding = addingState[1];
|
|
8137
|
-
var sidebarAvailable = Boolean(ctx
|
|
9016
|
+
var sidebarAvailable = Boolean(sidebarService(ctx));
|
|
8138
9017
|
var links = remote.data.links || [];
|
|
8139
|
-
var
|
|
9018
|
+
var remotes = remote.data.remotes || [];
|
|
8140
9019
|
var hosts = remote.data.hosts || [];
|
|
8141
9020
|
|
|
8142
9021
|
function openTree() {
|
|
8143
|
-
var sidebar = ctx
|
|
9022
|
+
var sidebar = sidebarService(ctx);
|
|
8144
9023
|
if (!sidebar || typeof sidebar.openTab !== 'function') return;
|
|
8145
9024
|
sidebar.openTab({
|
|
8146
9025
|
type: TREE_TAB_TYPE,
|
|
@@ -8149,6 +9028,11 @@ function attributeViolation(name, value, tagName) {
|
|
|
8149
9028
|
path: '/',
|
|
8150
9029
|
meta: {},
|
|
8151
9030
|
});
|
|
9031
|
+
dismissSettingsOverlay();
|
|
9032
|
+
}
|
|
9033
|
+
|
|
9034
|
+
function toggleAdding(mode) {
|
|
9035
|
+
setAdding(adding === mode ? '' : mode);
|
|
8152
9036
|
}
|
|
8153
9037
|
|
|
8154
9038
|
return h('div', { className: 'rw-root' },
|
|
@@ -8159,23 +9043,30 @@ function attributeViolation(name, value, tagName) {
|
|
|
8159
9043
|
h('div', { className: 'rw-actions' },
|
|
8160
9044
|
h('button', {
|
|
8161
9045
|
type: 'button', className: 'rw-btn' + (adding === 'linked' ? '' : ' rw-btn-primary'),
|
|
8162
|
-
onClick: function () {
|
|
8163
|
-
}, adding === 'linked' ? IconClose(13) :
|
|
9046
|
+
onClick: function () { toggleAdding('linked'); },
|
|
9047
|
+
}, adding === 'linked' ? IconClose(13) : IconLinkedWorkspace(13), t('createLinked')),
|
|
8164
9048
|
h('button', {
|
|
8165
9049
|
type: 'button', className: 'rw-btn' + (adding === 'remote' ? '' : ' rw-btn-primary'),
|
|
8166
|
-
onClick: function () {
|
|
8167
|
-
}, adding === 'remote' ? IconClose(13) :
|
|
9050
|
+
onClick: function () { toggleAdding('remote'); },
|
|
9051
|
+
}, adding === 'remote' ? IconClose(13) : IconRemoteWorkspace(13), t('createRemote')))),
|
|
8168
9052
|
!sidebarAvailable ? h(Banner, { kind: 'warn' }, t('needsSidebar')) : null,
|
|
8169
9053
|
h(ThemeGroup, { t: t, locale: locale }),
|
|
8170
9054
|
h(EditorSettingsGroup, { t: t, locale: locale }),
|
|
8171
|
-
adding
|
|
9055
|
+
adding === 'linked'
|
|
8172
9056
|
? h(AddWorkspaceFlow, {
|
|
8173
|
-
ctx: ctx, t: t, locale: locale,
|
|
9057
|
+
ctx: ctx, t: t, locale: locale,
|
|
9058
|
+
onDone: function () { setAdding(''); remote.reload(); },
|
|
9059
|
+
onCancel: function () { setAdding(''); },
|
|
9060
|
+
})
|
|
9061
|
+
: null,
|
|
9062
|
+
adding === 'remote'
|
|
9063
|
+
? h(AddRemoteWorkspaceFlow, {
|
|
9064
|
+
ctx: ctx, t: t, locale: locale,
|
|
8174
9065
|
onDone: function () { setAdding(''); remote.reload(); },
|
|
8175
9066
|
onCancel: function () { setAdding(''); },
|
|
8176
9067
|
})
|
|
8177
9068
|
: null,
|
|
8178
|
-
remote.data.error ? h(Banner, { kind: 'error' }, t('
|
|
9069
|
+
remote.data.error ? h(Banner, { kind: 'error' }, t('remoteWorkspacesFailed') + ':' + messageOf(remote.data.error, t, locale)) : null,
|
|
8179
9070
|
remote.data.hostError ? h(Banner, { kind: 'error' }, t('hostsFailed') + ':' + messageOf(remote.data.hostError, t, locale)) : null,
|
|
8180
9071
|
remote.data.linkError ? h(Banner, { kind: 'error' }, t('linksFailed') + ':' + messageOf(remote.data.linkError, t, locale)) : null,
|
|
8181
9072
|
h('div', { className: 'rw-group' },
|
|
@@ -8198,15 +9089,13 @@ function attributeViolation(name, value, tagName) {
|
|
|
8198
9089
|
}))),
|
|
8199
9090
|
h('div', { className: 'rw-group' },
|
|
8200
9091
|
h('div', { className: 'rw-group-head' },
|
|
8201
|
-
h('span', { className: 'rw-group-title' }, t('
|
|
8202
|
-
h('span', { className: 'rw-chip' }, String(
|
|
8203
|
-
h('span', { className: 'rw-group-hint' }, t('
|
|
8204
|
-
|
|
8205
|
-
? h('div', { className: 'rw-
|
|
8206
|
-
h('div', { className: 'rw-empty-title' }, t('emptyTitle')),
|
|
8207
|
-
h('div', { className: 'rw-empty-body' }, hosts.length === 0 ? t('emptyHint') : t('emptyBody')))
|
|
9092
|
+
h('span', { className: 'rw-group-title' }, t('remoteGroup')),
|
|
9093
|
+
h('span', { className: 'rw-chip' }, String(remotes.length)),
|
|
9094
|
+
h('span', { className: 'rw-group-hint' }, t('remoteHint'))),
|
|
9095
|
+
remotes.length === 0
|
|
9096
|
+
? h('div', { className: 'rw-hint' }, t('remoteEmpty'))
|
|
8208
9097
|
: h('div', { className: 'rw-list' },
|
|
8209
|
-
|
|
9098
|
+
remotes.map(function (workspace) {
|
|
8210
9099
|
return h(RemoteWorkspaceCard, {
|
|
8211
9100
|
key: workspace.id,
|
|
8212
9101
|
workspace: workspace,
|
|
@@ -8216,14 +9105,16 @@ function attributeViolation(name, value, tagName) {
|
|
|
8216
9105
|
refresh: remote.reload,
|
|
8217
9106
|
});
|
|
8218
9107
|
}))),
|
|
8219
|
-
h('div', { className: 'rw-inline', style: { justifyContent: '
|
|
8220
|
-
h('span', { className: 'rw-hint' }, workspaces.length + ' ' + t('remoteGroup') + ' · ' + links.length + ' ' + t('linkedGroup')),
|
|
9108
|
+
h('div', { className: 'rw-inline', style: { justifyContent: 'flex-end' } },
|
|
8221
9109
|
h('button', { type: 'button', className: 'rw-btn rw-btn-ghost rw-btn-sm', onClick: remote.reload }, IconRefresh(12), t('refresh'))));
|
|
8222
9110
|
}
|
|
8223
9111
|
|
|
8224
9112
|
// ── apply ──────────────────────────────────────────────────────────────
|
|
8225
9113
|
|
|
8226
|
-
|
|
9114
|
+
// `sessions` is a core client service (the sidebar shell injects it too):
|
|
9115
|
+
// the directory entries need the focused session's cwd/workspaceId to
|
|
9116
|
+
// decide whether they belong in the "+" menu.
|
|
9117
|
+
var inject = ['slots', 'locale', 'sessions'];
|
|
8227
9118
|
|
|
8228
9119
|
function apply(ctx) {
|
|
8229
9120
|
ctx.effect(installStyles, 'dsh-linked-workspace: styles');
|
|
@@ -8303,12 +9194,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
8303
9194
|
|
|
8304
9195
|
function registerSidebarTabs() {
|
|
8305
9196
|
if (sidebarRegistered) return;
|
|
8306
|
-
var sidebar =
|
|
8307
|
-
try {
|
|
8308
|
-
sidebar = ctx.get('betterSidebar');
|
|
8309
|
-
} catch (error) {
|
|
8310
|
-
sidebar = undefined;
|
|
8311
|
-
}
|
|
9197
|
+
var sidebar = sidebarService(ctx);
|
|
8312
9198
|
if (!sidebar || typeof sidebar.registerTab !== 'function') return;
|
|
8313
9199
|
sidebarRegistered = true;
|
|
8314
9200
|
if (tabPollTimer !== null) {
|
|
@@ -8317,22 +9203,97 @@ function attributeViolation(name, value, tagName) {
|
|
|
8317
9203
|
}
|
|
8318
9204
|
var syncDirectoryTabsInFlight = false;
|
|
8319
9205
|
|
|
8320
|
-
|
|
9206
|
+
// The "+" menu filters on `descriptor.hidden` and only maps `available`
|
|
9207
|
+
// to a disabled flag, so a per-session entry has to be hidden rather
|
|
9208
|
+
// than marked unavailable. These two helpers resolve the session on
|
|
9209
|
+
// screen right when the menu asks, which keeps the entries in sync with
|
|
9210
|
+
// the workspace kind without unregistering anything (an unregistered
|
|
9211
|
+
// kind would orphan its open pages and break "Open directory tree").
|
|
9212
|
+
var activeScopeCache = { cwd: '', workspaceId: '' };
|
|
9213
|
+
|
|
9214
|
+
function readActiveScope() {
|
|
9215
|
+
var info = { cwd: '', workspaceId: '' };
|
|
9216
|
+
try {
|
|
9217
|
+
var snapshot = typeof sidebar.getSnapshot === 'function' ? sidebar.getSnapshot() : null;
|
|
9218
|
+
var sessionId = snapshot && snapshot.sessionId;
|
|
9219
|
+
if (!sessionId) return info;
|
|
9220
|
+
var sessions = ctx.sessions || (ctx.get && ctx.get('sessions'));
|
|
9221
|
+
var list = sessions && sessions.list ? sessions.list : sessions;
|
|
9222
|
+
var sessionState = list && typeof list.getSnapshot === 'function' ? list.getSnapshot() : null;
|
|
9223
|
+
var record = sessionState && sessionState.byId ? sessionState.byId[sessionId] : null;
|
|
9224
|
+
if (record) {
|
|
9225
|
+
info.cwd = record.cwd || '';
|
|
9226
|
+
info.workspaceId = record.workspaceId || '';
|
|
9227
|
+
}
|
|
9228
|
+
} catch (error) { /* fall back to an empty scope */ }
|
|
9229
|
+
return info;
|
|
9230
|
+
}
|
|
9231
|
+
|
|
9232
|
+
function activeScope() {
|
|
9233
|
+
activeScopeCache = readActiveScope();
|
|
9234
|
+
return activeScopeCache;
|
|
9235
|
+
}
|
|
9236
|
+
|
|
9237
|
+
function linkedTabHidden() {
|
|
9238
|
+
var scope = activeScope();
|
|
9239
|
+
return !(isLinkedScope(scope) || isLinkedWorkspaceId(scope.workspaceId));
|
|
9240
|
+
}
|
|
9241
|
+
|
|
9242
|
+
function remoteTabHidden() {
|
|
9243
|
+
var scope = activeScope();
|
|
9244
|
+
return !(isRemoteScope(scope) || isRemoteWorkspaceId(scope.workspaceId));
|
|
9245
|
+
}
|
|
9246
|
+
|
|
9247
|
+
// `hidden` is read whenever the sidebar builds its "+" entries, so the
|
|
9248
|
+
// answer is always fresh — but the sidebar only rebuilds those entries
|
|
9249
|
+
// when something notifies it. Re-registering the same two descriptors
|
|
9250
|
+
// notifies without touching the stored tabs, so open pages survive.
|
|
9251
|
+
var visibilitySignature = '';
|
|
9252
|
+
|
|
9253
|
+
function currentVisibilitySignature() {
|
|
9254
|
+
return (linkedTabHidden() ? '0' : '1') + (remoteTabHidden() ? '0' : '1');
|
|
9255
|
+
}
|
|
9256
|
+
|
|
9257
|
+
function syncTabVisibility() {
|
|
9258
|
+
var next = currentVisibilitySignature();
|
|
9259
|
+
if (next === visibilitySignature) return;
|
|
9260
|
+
visibilitySignature = next;
|
|
9261
|
+
if (linkedTabDisposer === null && remoteTabDisposer === null) return;
|
|
9262
|
+
disposeLinkedTab();
|
|
9263
|
+
disposeRemoteTab();
|
|
9264
|
+
installLinkedTab(false);
|
|
9265
|
+
installRemoteTab(false);
|
|
9266
|
+
}
|
|
9267
|
+
|
|
9268
|
+
function watchSessionScope() {
|
|
9269
|
+
visibilitySignature = currentVisibilitySignature();
|
|
9270
|
+
try {
|
|
9271
|
+
var sessions = ctx.sessions || (ctx.get && ctx.get('sessions'));
|
|
9272
|
+
var list = sessions && (sessions.list || sessions);
|
|
9273
|
+
if (!list || typeof list.subscribe !== 'function') return;
|
|
9274
|
+
var unsubscribe = list.subscribe(function () { syncTabVisibility(); });
|
|
9275
|
+
if (typeof unsubscribe === 'function') tabDisposers.push(unsubscribe);
|
|
9276
|
+
} catch (error) { /* without a store the entries simply stay as they are */ }
|
|
9277
|
+
}
|
|
9278
|
+
|
|
9279
|
+
function installLinkedTab(track) {
|
|
8321
9280
|
if (linkedTabDisposer !== null) return;
|
|
8322
9281
|
linkedTabDisposer = sidebar.registerTab({
|
|
8323
9282
|
id: TREE_TAB_TYPE,
|
|
8324
9283
|
title: function () { return makeT(readLocale(ctx))('tabTitle'); },
|
|
8325
9284
|
description: function () { return makeT(readLocale(ctx))('tabDesc'); },
|
|
8326
|
-
icon: function (size) { return
|
|
9285
|
+
icon: function (size) { return IconLinkedWorkspace(size); },
|
|
8327
9286
|
order: 62,
|
|
8328
9287
|
single: true,
|
|
8329
|
-
|
|
9288
|
+
get hidden() { return linkedTabHidden(); },
|
|
9289
|
+
available: function () { return true; },
|
|
8330
9290
|
component: function (props) {
|
|
8331
9291
|
var currentLocale = useLocale(ctx);
|
|
8332
9292
|
var t = useMemo(function () { return makeT(currentLocale); }, [currentLocale]);
|
|
8333
9293
|
return h(RemoteDirectoryTab, Object.assign({}, props, { ctx: ctx, t: t, locale: currentLocale, variant: 'linked' }));
|
|
8334
9294
|
},
|
|
8335
9295
|
});
|
|
9296
|
+
if (track !== false) tabDisposers.push(function () { disposeLinkedTab(); });
|
|
8336
9297
|
}
|
|
8337
9298
|
|
|
8338
9299
|
function disposeLinkedTab() {
|
|
@@ -8341,22 +9302,24 @@ function attributeViolation(name, value, tagName) {
|
|
|
8341
9302
|
linkedTabDisposer = null;
|
|
8342
9303
|
}
|
|
8343
9304
|
|
|
8344
|
-
function installRemoteTab() {
|
|
9305
|
+
function installRemoteTab(track) {
|
|
8345
9306
|
if (remoteTabDisposer !== null) return;
|
|
8346
9307
|
remoteTabDisposer = sidebar.registerTab({
|
|
8347
|
-
id:
|
|
9308
|
+
id: REMOTE_TREE_TAB_TYPE,
|
|
8348
9309
|
title: function () { return makeT(readLocale(ctx))('remoteTabTitle'); },
|
|
8349
9310
|
description: function () { return makeT(readLocale(ctx))('remoteTabDesc'); },
|
|
8350
|
-
icon: function (size) { return
|
|
9311
|
+
icon: function (size) { return IconRemoteWorkspace(size); },
|
|
8351
9312
|
order: 61,
|
|
8352
9313
|
single: true,
|
|
8353
|
-
|
|
9314
|
+
get hidden() { return remoteTabHidden(); },
|
|
9315
|
+
available: function () { return true; },
|
|
8354
9316
|
component: function (props) {
|
|
8355
9317
|
var currentLocale = useLocale(ctx);
|
|
8356
9318
|
var t = useMemo(function () { return makeT(currentLocale); }, [currentLocale]);
|
|
8357
9319
|
return h(RemoteDirectoryTab, Object.assign({}, props, { ctx: ctx, t: t, locale: currentLocale, variant: 'remote' }));
|
|
8358
9320
|
},
|
|
8359
9321
|
});
|
|
9322
|
+
if (track !== false) tabDisposers.push(function () { disposeRemoteTab(); });
|
|
8360
9323
|
}
|
|
8361
9324
|
|
|
8362
9325
|
function disposeRemoteTab() {
|
|
@@ -8365,50 +9328,25 @@ function attributeViolation(name, value, tagName) {
|
|
|
8365
9328
|
remoteTabDisposer = null;
|
|
8366
9329
|
}
|
|
8367
9330
|
|
|
8368
|
-
|
|
8369
|
-
|
|
8370
|
-
|
|
8371
|
-
|
|
8372
|
-
|
|
8373
|
-
var snapshot = list && typeof list.getSnapshot === 'function' ? list.getSnapshot() : null;
|
|
8374
|
-
var record = snapshot && snapshot.byId ? snapshot.byId[sessionId] : null;
|
|
8375
|
-
if (!record) return null;
|
|
8376
|
-
var header = record.header || record;
|
|
8377
|
-
return { cwd: header.cwd || record.cwd || '', workspaceId: header.workspaceId || record.workspaceId || '' };
|
|
8378
|
-
} catch (error) {
|
|
8379
|
-
return null;
|
|
8380
|
-
}
|
|
8381
|
-
}
|
|
8382
|
-
|
|
8383
|
-
function isLinkedSessionInfo(info) {
|
|
8384
|
-
return Boolean(info && ((info.cwd && isLinkedScope({ cwd: info.cwd })) || isLinkedWorkspaceId(info.workspaceId)));
|
|
8385
|
-
}
|
|
8386
|
-
|
|
9331
|
+
// Both page kinds stay registered for the whole session: `available`
|
|
9332
|
+
// only greys out the "+" entry for a mismatched session, while
|
|
9333
|
+
// `openTab` refuses a kind it has never seen. Registering lazily per
|
|
9334
|
+
// session meant "open the tree" from the settings page silently did
|
|
9335
|
+
// nothing whenever the workspace was not the one on screen.
|
|
8387
9336
|
function syncDirectoryTabs() {
|
|
8388
9337
|
if (syncDirectoryTabsInFlight) return;
|
|
8389
9338
|
syncDirectoryTabsInFlight = true;
|
|
8390
9339
|
refreshDirectoryAvailability().catch(function () { /* ignore */ }).then(function () {
|
|
8391
|
-
|
|
8392
|
-
|
|
8393
|
-
var snapshot = typeof sidebar.getSnapshot === 'function' ? sidebar.getSnapshot() : null;
|
|
8394
|
-
var sessionId = snapshot && snapshot.sessionId;
|
|
8395
|
-
if (!sessionId) {
|
|
8396
|
-
disposeLinkedTab();
|
|
8397
|
-
return undefined;
|
|
8398
|
-
}
|
|
8399
|
-
var clientInfo = activeSessionClientInfo(sessionId);
|
|
8400
|
-
if (isLinkedSessionInfo(clientInfo)) {
|
|
8401
|
-
installLinkedTab();
|
|
8402
|
-
return undefined;
|
|
8403
|
-
}
|
|
8404
|
-
return apiCall('session.info', { sessionId: sessionId }).then(function (info) {
|
|
8405
|
-
if (isLinkedSessionInfo(info)) installLinkedTab();
|
|
8406
|
-
else disposeLinkedTab();
|
|
8407
|
-
}).catch(function () { disposeLinkedTab(); });
|
|
8408
|
-
}).catch(function () { /* ignore */ }).then(function () { syncDirectoryTabsInFlight = false; });
|
|
9340
|
+
syncDirectoryTabsInFlight = false;
|
|
9341
|
+
});
|
|
8409
9342
|
}
|
|
8410
9343
|
|
|
8411
9344
|
syncDirectoryTabsRef = syncDirectoryTabs;
|
|
9345
|
+
refreshTabVisibilityRef = syncTabVisibility;
|
|
9346
|
+
installLinkedTab();
|
|
9347
|
+
installRemoteTab();
|
|
9348
|
+
watchSessionScope();
|
|
9349
|
+
syncTabVisibility();
|
|
8412
9350
|
try {
|
|
8413
9351
|
tabDisposers.push(sidebar.subscribeState(function () { syncDirectoryTabs(); }));
|
|
8414
9352
|
} catch (error) { /* state subscription is optional */ }
|
|
@@ -8453,22 +9391,11 @@ function attributeViolation(name, value, tagName) {
|
|
|
8453
9391
|
}
|
|
8454
9392
|
}
|
|
8455
9393
|
|
|
8456
|
-
// Tabs persisted before the 0.3.0 rename still carry the old type
|
|
8457
|
-
// register hidden
|
|
8458
|
-
// showing "no available view" for the legacy tab.
|
|
9394
|
+
// Tabs persisted before the 0.3.0 rename still carry the old file type
|
|
9395
|
+
// id; register a hidden alias so a reloaded page restores it instead of
|
|
9396
|
+
// showing "no available view" for the legacy tab. The legacy tree kind
|
|
9397
|
+
// ("dsh-remote-workspace") is now the real remote-workspace tab.
|
|
8459
9398
|
try {
|
|
8460
|
-
tabDisposers.push(sidebar.registerTab({
|
|
8461
|
-
id: 'dsh-remote-workspace',
|
|
8462
|
-
title: function () { return makeT(readLocale(ctx))('tabTitle'); },
|
|
8463
|
-
hidden: true,
|
|
8464
|
-
order: 64,
|
|
8465
|
-
single: true,
|
|
8466
|
-
component: function (props) {
|
|
8467
|
-
var currentLocale = useLocale(ctx);
|
|
8468
|
-
var t = useMemo(function () { return makeT(currentLocale); }, [currentLocale]);
|
|
8469
|
-
return h(RemoteDirectoryTab, Object.assign({}, props, { ctx: ctx, t: t, locale: currentLocale, variant: 'linked' }));
|
|
8470
|
-
},
|
|
8471
|
-
}));
|
|
8472
9399
|
tabDisposers.push(sidebar.registerTab({
|
|
8473
9400
|
id: 'dsh-remote-workspace:file',
|
|
8474
9401
|
title: function () { return makeT(readLocale(ctx))('fileTabTitle'); },
|