dsh-linked-workspace 0.16.0 → 0.17.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 +25 -0
- package/README.en.md +16 -3
- package/README.md +17 -3
- package/docs/API.md +18 -4
- package/docs/VERIFY.md +21 -4
- package/lib/client.js +323 -12
- package/lib/index.js +374 -42
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -1958,6 +1958,15 @@ function attributeViolation(name, value, tagName) {
|
|
|
1958
1958
|
// but a full remote listing on a huge folder is expensive; 15 s keeps the
|
|
1959
1959
|
// tree fresh without hammering the SSH channel.
|
|
1960
1960
|
var REFRESH_MIN_INTERVAL_MS = 15000;
|
|
1961
|
+
// HTML previews read the whole document (a plotly/figure page is one big
|
|
1962
|
+
// inlined script), so they ask the Host for the 8 MB read cap instead of
|
|
1963
|
+
// the editor's 2 MB one.
|
|
1964
|
+
var PREVIEW_MAX_BYTES = 8 * 1024 * 1024;
|
|
1965
|
+
// Connection state is a live fact, not a property of the workspace: the
|
|
1966
|
+
// sidebar rows and the hover card poll the Host so a dropped socket turns
|
|
1967
|
+
// red within a few seconds and a recovered one turns back. The call reads
|
|
1968
|
+
// memory only (it never dials), so a short interval is cheap.
|
|
1969
|
+
var STATUS_POLL_MS = 6000;
|
|
1961
1970
|
var linkedLocalKeys = new Set();
|
|
1962
1971
|
var linkedWorkspaceKeys = new Set();
|
|
1963
1972
|
// Remote workspaces run inside a placeholder directory, so they are matched
|
|
@@ -2201,7 +2210,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
2201
2210
|
imageFit: '适应窗口',
|
|
2202
2211
|
imageActualSize: '原始大小',
|
|
2203
2212
|
htmlLoadError: '无法预览网页',
|
|
2204
|
-
|
|
2213
|
+
htmlPreviewTooLarge: '文件 {{size}} 超过预览上限 {{limit}},请右键「下载到默认文件夹」后用浏览器打开。',
|
|
2214
|
+
htmlPreviewBinary: '这是二进制文件,无法按网页预览。',
|
|
2215
|
+
htmlSandboxed: '沙箱预览(脚本可运行,无法访问 DSH 界面)',
|
|
2205
2216
|
previewOnly: '图片预览',
|
|
2206
2217
|
csvTable: '表格',
|
|
2207
2218
|
csvSource: '源码',
|
|
@@ -2483,6 +2494,18 @@ function attributeViolation(name, value, tagName) {
|
|
|
2483
2494
|
autoSaveHint: '编辑停顿约 1 秒后自动保存;关闭后请按 Ctrl+S 手动保存。',
|
|
2484
2495
|
autoSaveLabel: '开启自动保存',
|
|
2485
2496
|
autoSaveSaved: '自动保存设置已保存',
|
|
2497
|
+
execTitle: '远端命令执行',
|
|
2498
|
+
execHint: '默认关闭。开启后,会话里的模型可以通过 linked_workspace 的 exec 动作在远端跑命令;只对下面勾选的主机/工作区生效,每次尝试(含被拒)都记进审计日志。',
|
|
2499
|
+
execEnabledLabel: '允许在远端执行命令',
|
|
2500
|
+
execWarn: '命令会以你的 SSH 账号身份在远端运行,请只对可信主机开启。',
|
|
2501
|
+
execHostsTitle: '允许的主机',
|
|
2502
|
+
execHostsEmpty: '没有可用的 SSH 主机',
|
|
2503
|
+
execWorkspacesTitle: '允许的工作区(第二层)',
|
|
2504
|
+
execWorkspacesHint: '留空表示上一步勾选的主机全部放行;勾选后只允许这些工作区。',
|
|
2505
|
+
execTimeoutLabel: '默认超时(秒)',
|
|
2506
|
+
execOutputLabel: '输出上限(字符)',
|
|
2507
|
+
execAuditOpen: '打开审计日志',
|
|
2508
|
+
execSaved: '远端命令执行设置已保存',
|
|
2486
2509
|
shortcutTitle: '常用快捷键',
|
|
2487
2510
|
shortcutHint: '与 VS Code 类似的默认快捷键;macOS 上把 Ctrl 换成 ⌘。',
|
|
2488
2511
|
shortcutSave: '保存当前文件',
|
|
@@ -2678,7 +2701,9 @@ function attributeViolation(name, value, tagName) {
|
|
|
2678
2701
|
imageFit: 'Fit to window',
|
|
2679
2702
|
imageActualSize: 'Actual size',
|
|
2680
2703
|
htmlLoadError: 'Cannot preview this page',
|
|
2681
|
-
|
|
2704
|
+
htmlPreviewTooLarge: 'This file is {{size}}, above the {{limit}} preview limit. Download it to the default folder and open it in a browser.',
|
|
2705
|
+
htmlPreviewBinary: 'This is a binary file, so it cannot be previewed as a page.',
|
|
2706
|
+
htmlSandboxed: 'Sandboxed preview (scripts run, no access to the DSH UI)',
|
|
2682
2707
|
previewOnly: 'Image preview',
|
|
2683
2708
|
csvTable: 'Table',
|
|
2684
2709
|
csvSource: 'Source',
|
|
@@ -2960,6 +2985,18 @@ function attributeViolation(name, value, tagName) {
|
|
|
2960
2985
|
autoSaveHint: 'Saves about one second after you stop typing. When off, press Ctrl+S to save.',
|
|
2961
2986
|
autoSaveLabel: 'Enable auto save',
|
|
2962
2987
|
autoSaveSaved: 'Auto-save setting saved',
|
|
2988
|
+
execTitle: 'Remote command execution',
|
|
2989
|
+
execHint: 'Off by default. When on, the model can run commands on the remote host through the linked_workspace "exec" action — only for the hosts and workspaces ticked below, and every attempt (refusals included) is audited.',
|
|
2990
|
+
execEnabledLabel: 'Allow running commands remotely',
|
|
2991
|
+
execWarn: 'Commands run on the remote host with your SSH account. Enable this only for hosts you trust.',
|
|
2992
|
+
execHostsTitle: 'Allowed hosts',
|
|
2993
|
+
execHostsEmpty: 'No SSH hosts available',
|
|
2994
|
+
execWorkspacesTitle: 'Allowed workspaces (second layer)',
|
|
2995
|
+
execWorkspacesHint: 'Leave empty to allow every workspace on the hosts ticked above; tick some to restrict execution to them.',
|
|
2996
|
+
execTimeoutLabel: 'Default timeout (seconds)',
|
|
2997
|
+
execOutputLabel: 'Output limit (characters)',
|
|
2998
|
+
execAuditOpen: 'Open the audit log',
|
|
2999
|
+
execSaved: 'Remote-execution settings saved',
|
|
2963
3000
|
shortcutTitle: 'Keyboard shortcuts',
|
|
2964
3001
|
shortcutHint: 'VS Code-like defaults; use ⌘ instead of Ctrl on macOS.',
|
|
2965
3002
|
shortcutSave: 'Save the current file',
|
|
@@ -3152,7 +3189,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
3152
3189
|
* Host methods the running DSH process does not have yet, the directory
|
|
3153
3190
|
* pane says so instead of surfacing an unrelated error.
|
|
3154
3191
|
*/
|
|
3155
|
-
var HOST_API_REVISION =
|
|
3192
|
+
var HOST_API_REVISION = 3;
|
|
3156
3193
|
var hostInfoProbe = null;
|
|
3157
3194
|
|
|
3158
3195
|
function probeHostInfo() {
|
|
@@ -3630,6 +3667,11 @@ function attributeViolation(name, value, tagName) {
|
|
|
3630
3667
|
'.rw-option-desc{font-size:11.5px;line-height:17px;color:var(--dsw-alias-label-tertiary)}',
|
|
3631
3668
|
'.rw-warn-box{padding:8px 10px;border-radius:8px;border:1px solid color-mix(in srgb,var(--dsw-alias-state-warn-primary) 45%,transparent);background:color-mix(in srgb,var(--dsw-alias-state-warn-primary) 8%,var(--dsw-alias-bg-layer-1));font-size:12px;line-height:18px}',
|
|
3632
3669
|
'.rw-setting-row{display:flex;align-items:center;gap:10px;padding:10px 12px;border:1px solid var(--dsw-alias-border-l1);border-radius:9px;background:var(--dsw-alias-bg-layer-1)}',
|
|
3670
|
+
'.rw-exec-list{display:flex;flex-direction:column;gap:4px;margin-top:8px}',
|
|
3671
|
+
'.rw-exec-item{display:flex;align-items:center;gap:8px;padding:7px 10px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:var(--dsw-alias-bg-layer-1);cursor:pointer;font-size:13px}',
|
|
3672
|
+
'.rw-exec-item input[type=checkbox]{margin:0;flex:none}',
|
|
3673
|
+
'.rw-exec-name{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
3674
|
+
'.rw-exec-meta{flex:none;color:var(--dsw-alias-text-3);font-size:12px;font-variant-numeric:tabular-nums}',
|
|
3633
3675
|
'.rw-shortcut-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:4px 16px}',
|
|
3634
3676
|
'.rw-shortcut-row{display:flex;align-items:center;gap:10px;min-height:28px;font-size:12px;color:var(--dsw-alias-label-secondary)}',
|
|
3635
3677
|
'.rw-kbd{display:inline-flex;align-items:center;justify-content:center;min-width:64px;padding:2px 7px;border:1px solid var(--dsw-alias-border-l2);border-bottom-width:2px;border-radius:5px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font:11px/16px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;white-space:nowrap}',
|
|
@@ -3981,17 +4023,37 @@ function attributeViolation(name, value, tagName) {
|
|
|
3981
4023
|
}
|
|
3982
4024
|
}
|
|
3983
4025
|
|
|
4026
|
+
/** Repaint the "host · state" line of an already decorated card. */
|
|
4027
|
+
function refreshHoverStatus(card, scopeKey) {
|
|
4028
|
+
var line = card.querySelector('.rw-hover-host');
|
|
4029
|
+
if (!line) return;
|
|
4030
|
+
var record = workspaceHoverRecords[scopeKey];
|
|
4031
|
+
if (!record || !record.remotePath) return;
|
|
4032
|
+
var nextText = record.host ? record.host + ' · ' + record.status : record.status;
|
|
4033
|
+
var nextClass = 'rw-hover-host' + (record.disconnected ? ' is-off' : record.connected ? ' is-on' : '');
|
|
4034
|
+
if (line.textContent === nextText && line.className === nextClass) return;
|
|
4035
|
+
line.textContent = nextText;
|
|
4036
|
+
line.className = nextClass;
|
|
4037
|
+
}
|
|
4038
|
+
|
|
3984
4039
|
function decorateHoverCard(card) {
|
|
3985
4040
|
if (!card || !hoverCardState || !card.querySelector) return;
|
|
3986
4041
|
var pathEl = card.querySelector('[class*="hoverPath"]');
|
|
3987
4042
|
if (!pathEl) return;
|
|
3988
4043
|
var known = hoverCardState.get(card);
|
|
3989
4044
|
var current = (pathEl.textContent || '').trim();
|
|
3990
|
-
// Already decorated for this very content:
|
|
3991
|
-
|
|
4045
|
+
// Already decorated for this very content: the paths stay, but the status
|
|
4046
|
+
// may have moved on (the connection drops or comes back while the card is
|
|
4047
|
+
// open), so refresh that one line instead of giving up. The key has to be
|
|
4048
|
+
// remembered, because the path text has been rewritten by now.
|
|
4049
|
+
if (known && known.rendered === current) {
|
|
4050
|
+
refreshHoverStatus(card, known.key || linkedScopeKey(current));
|
|
4051
|
+
return;
|
|
4052
|
+
}
|
|
3992
4053
|
// The host re-rendered the card for another workspace: drop our lines.
|
|
3993
4054
|
if (known) clearHoverLines(card);
|
|
3994
|
-
var
|
|
4055
|
+
var key = linkedScopeKey(current);
|
|
4056
|
+
var record = workspaceHoverRecords[key];
|
|
3995
4057
|
if (!record || !record.remotePath) return;
|
|
3996
4058
|
var t = makeT(readLocale());
|
|
3997
4059
|
var remote = record.remotePath;
|
|
@@ -4026,7 +4088,7 @@ function attributeViolation(name, value, tagName) {
|
|
|
4026
4088
|
host.setAttribute('aria-label', label.split(current).join(remote));
|
|
4027
4089
|
}
|
|
4028
4090
|
|
|
4029
|
-
hoverCardState.set(card, { rendered: (pathEl.textContent || '').trim() });
|
|
4091
|
+
hoverCardState.set(card, { rendered: (pathEl.textContent || '').trim(), key: key });
|
|
4030
4092
|
}
|
|
4031
4093
|
|
|
4032
4094
|
function applyHoverCards() {
|
|
@@ -4383,6 +4445,46 @@ function attributeViolation(name, value, tagName) {
|
|
|
4383
4445
|
};
|
|
4384
4446
|
}, [load]);
|
|
4385
4447
|
|
|
4448
|
+
// Keep the connection state in step with reality. Only the status field is
|
|
4449
|
+
// patched, and only when it actually changed, so polling never re-renders
|
|
4450
|
+
// the whole page or re-fetches the trees.
|
|
4451
|
+
var dataRef = useRef(data);
|
|
4452
|
+
dataRef.current = data;
|
|
4453
|
+
useEffect(function () {
|
|
4454
|
+
var stopped = false;
|
|
4455
|
+
var tick = function () {
|
|
4456
|
+
apiCall('hosts.status', {}).then(function (result) {
|
|
4457
|
+
if (stopped) return;
|
|
4458
|
+
var statuses = (result && result.statuses) || {};
|
|
4459
|
+
var previous = dataRef.current;
|
|
4460
|
+
var changed = false;
|
|
4461
|
+
var apply = function (list) {
|
|
4462
|
+
return (list || []).map(function (item) {
|
|
4463
|
+
var status = item && item.hostId ? statuses[item.hostId] : null;
|
|
4464
|
+
if (!status) return item;
|
|
4465
|
+
if (JSON.stringify(item.status || null) === JSON.stringify(status)) return item;
|
|
4466
|
+
changed = true;
|
|
4467
|
+
return Object.assign({}, item, { status: status });
|
|
4468
|
+
});
|
|
4469
|
+
};
|
|
4470
|
+
var links = apply(previous.links);
|
|
4471
|
+
var remotes = apply(previous.remotes);
|
|
4472
|
+
if (!changed) return;
|
|
4473
|
+
setData(function (current) {
|
|
4474
|
+
return Object.assign({}, current, { links: links, remotes: remotes });
|
|
4475
|
+
});
|
|
4476
|
+
publishWorkspaceIcons(links, remotes);
|
|
4477
|
+
}).catch(function () {});
|
|
4478
|
+
};
|
|
4479
|
+
var timer = setInterval(tick, STATUS_POLL_MS);
|
|
4480
|
+
if (timer && typeof timer.unref === 'function') timer.unref();
|
|
4481
|
+
tick();
|
|
4482
|
+
return function () {
|
|
4483
|
+
stopped = true;
|
|
4484
|
+
clearInterval(timer);
|
|
4485
|
+
};
|
|
4486
|
+
}, []);
|
|
4487
|
+
|
|
4386
4488
|
return { data: data, reload: load };
|
|
4387
4489
|
}
|
|
4388
4490
|
|
|
@@ -4982,10 +5084,18 @@ function attributeViolation(name, value, tagName) {
|
|
|
4982
5084
|
return;
|
|
4983
5085
|
}
|
|
4984
5086
|
setView({ loading: true, error: null, data: null });
|
|
4985
|
-
var request = local ? { path: filePath } : Object.assign({ path: filePath }, params);
|
|
5087
|
+
var request = local ? { path: filePath, preview: true } : Object.assign({ path: filePath, preview: true }, params);
|
|
4986
5088
|
apiCall(local ? 'local.read' : 'fs.read', request).then(function (result) {
|
|
4987
|
-
if (result.
|
|
4988
|
-
setView({
|
|
5089
|
+
if (result.tooLarge || result.truncated) {
|
|
5090
|
+
setView({
|
|
5091
|
+
loading: false,
|
|
5092
|
+
error: new Error(t('htmlPreviewTooLarge', { size: formatBytes(result.size), limit: formatBytes(PREVIEW_MAX_BYTES) })),
|
|
5093
|
+
data: null,
|
|
5094
|
+
});
|
|
5095
|
+
return;
|
|
5096
|
+
}
|
|
5097
|
+
if (result.binary) {
|
|
5098
|
+
setView({ loading: false, error: new Error(t('htmlPreviewBinary')), data: null });
|
|
4989
5099
|
return;
|
|
4990
5100
|
}
|
|
4991
5101
|
setView({ loading: false, error: null, data: result });
|
|
@@ -5022,14 +5132,16 @@ function attributeViolation(name, value, tagName) {
|
|
|
5022
5132
|
h('iframe', {
|
|
5023
5133
|
className: 'rw-html-frame',
|
|
5024
5134
|
title: name,
|
|
5025
|
-
|
|
5135
|
+
// allow-scripts runs the page's own JS (charts need it) inside an
|
|
5136
|
+
// opaque origin: no access to the DSH UI, its storage or the tree.
|
|
5137
|
+
sandbox: 'allow-scripts',
|
|
5026
5138
|
srcDoc: data.content || '',
|
|
5027
5139
|
})),
|
|
5028
5140
|
h('div', { className: 'rw-editor-status' },
|
|
5029
5141
|
h('span', { className: 'rw-status-chip' }, 'HTML'),
|
|
5030
5142
|
h('span', { className: 'rw-status-chip' }, formatBytes(data.size || 0)),
|
|
5031
5143
|
h('span', { className: 'rw-fill', style: { flex: '1 1 auto' } }),
|
|
5032
|
-
h('span', { className: 'rw-status-chip' }, t('
|
|
5144
|
+
h('span', { className: 'rw-status-chip' }, t('htmlSandboxed'))));
|
|
5033
5145
|
}
|
|
5034
5146
|
|
|
5035
5147
|
// ── editor ─────────────────────────────────────────────────────────────
|
|
@@ -10372,6 +10484,199 @@ function rememberShowHidden(value) {
|
|
|
10372
10484
|
: null);
|
|
10373
10485
|
}
|
|
10374
10486
|
|
|
10487
|
+
function ExecSettingsGroup(props) {
|
|
10488
|
+
var t = props.t;
|
|
10489
|
+
var locale = props.locale;
|
|
10490
|
+
var hosts = props.hosts || [];
|
|
10491
|
+
var workspaces = props.workspaces || [];
|
|
10492
|
+
var state = useState({
|
|
10493
|
+
loading: true,
|
|
10494
|
+
saving: false,
|
|
10495
|
+
message: null,
|
|
10496
|
+
execEnabled: false,
|
|
10497
|
+
execHostIds: [],
|
|
10498
|
+
execWorkspaceIds: [],
|
|
10499
|
+
execTimeoutSec: 60,
|
|
10500
|
+
execMaxOutputChars: 200000,
|
|
10501
|
+
});
|
|
10502
|
+
var local = state[0];
|
|
10503
|
+
var setLocal = state[1];
|
|
10504
|
+
|
|
10505
|
+
var adopt = function (settings, extra) {
|
|
10506
|
+
var value = settings || {};
|
|
10507
|
+
setLocal(function (previous) {
|
|
10508
|
+
return Object.assign({}, previous, {
|
|
10509
|
+
loading: false,
|
|
10510
|
+
execEnabled: typeof value.execEnabled === 'boolean' ? value.execEnabled : previous.execEnabled,
|
|
10511
|
+
execHostIds: Array.isArray(value.execHostIds) ? value.execHostIds : previous.execHostIds,
|
|
10512
|
+
execWorkspaceIds: Array.isArray(value.execWorkspaceIds) ? value.execWorkspaceIds : previous.execWorkspaceIds,
|
|
10513
|
+
execTimeoutSec: Math.round((Number(value.execTimeoutMs) || previous.execTimeoutSec * 1000) / 1000),
|
|
10514
|
+
execMaxOutputChars: Number(value.execMaxOutputChars) || previous.execMaxOutputChars,
|
|
10515
|
+
}, extra || {});
|
|
10516
|
+
});
|
|
10517
|
+
};
|
|
10518
|
+
|
|
10519
|
+
useEffect(function () {
|
|
10520
|
+
var alive = true;
|
|
10521
|
+
apiCall('settings.get', {}).then(function (settings) {
|
|
10522
|
+
if (alive) adopt(settings);
|
|
10523
|
+
}).catch(function (error) {
|
|
10524
|
+
if (!alive) return;
|
|
10525
|
+
setLocal(function (previous) {
|
|
10526
|
+
return Object.assign({}, previous, {
|
|
10527
|
+
loading: false,
|
|
10528
|
+
message: { kind: 'error', text: messageOf(error, t, locale) },
|
|
10529
|
+
});
|
|
10530
|
+
});
|
|
10531
|
+
});
|
|
10532
|
+
return function () { alive = false; };
|
|
10533
|
+
}, []);
|
|
10534
|
+
|
|
10535
|
+
function save(patch, okText) {
|
|
10536
|
+
if (local.saving) return;
|
|
10537
|
+
setLocal(function (previous) { return Object.assign({}, previous, { saving: true, message: null }); });
|
|
10538
|
+
apiCall('settings.update', patch).then(function (settings) {
|
|
10539
|
+
adopt(settings, {
|
|
10540
|
+
saving: false,
|
|
10541
|
+
message: okText ? { kind: 'success', text: okText } : null,
|
|
10542
|
+
});
|
|
10543
|
+
}).catch(function (error) {
|
|
10544
|
+
setLocal(function (previous) {
|
|
10545
|
+
return Object.assign({}, previous, {
|
|
10546
|
+
saving: false,
|
|
10547
|
+
message: { kind: 'error', text: messageOf(error, t, locale) },
|
|
10548
|
+
});
|
|
10549
|
+
});
|
|
10550
|
+
});
|
|
10551
|
+
}
|
|
10552
|
+
|
|
10553
|
+
function withId(list, id, checked) {
|
|
10554
|
+
var next = (list || []).filter(function (item) { return item !== id; });
|
|
10555
|
+
if (checked) next.push(id);
|
|
10556
|
+
return next;
|
|
10557
|
+
}
|
|
10558
|
+
|
|
10559
|
+
function openAudit() {
|
|
10560
|
+
apiCall('meta.info', {}).then(function (info) {
|
|
10561
|
+
if (!info || !info.execAuditFile) return null;
|
|
10562
|
+
return apiCall('local.openExternal', { path: info.execAuditFile });
|
|
10563
|
+
}).catch(function (error) {
|
|
10564
|
+
setLocal(function (previous) {
|
|
10565
|
+
return Object.assign({}, previous, {
|
|
10566
|
+
message: { kind: 'error', text: messageOf(error, t, locale) },
|
|
10567
|
+
});
|
|
10568
|
+
});
|
|
10569
|
+
});
|
|
10570
|
+
}
|
|
10571
|
+
|
|
10572
|
+
function numberRow(label, value, min, max, step, onCommit) {
|
|
10573
|
+
return h('label', { className: 'rw-inline', style: { gap: 6 } },
|
|
10574
|
+
h('span', { className: 'rw-group-hint' }, label),
|
|
10575
|
+
h('input', {
|
|
10576
|
+
className: 'rw-input',
|
|
10577
|
+
style: { width: 92 },
|
|
10578
|
+
type: 'number',
|
|
10579
|
+
min: min,
|
|
10580
|
+
max: max,
|
|
10581
|
+
step: step,
|
|
10582
|
+
value: String(value),
|
|
10583
|
+
onChange: function (event) {
|
|
10584
|
+
var next = Number(event.currentTarget.value);
|
|
10585
|
+
setLocal(function (previous) {
|
|
10586
|
+
var patch = {};
|
|
10587
|
+
patch[onCommit.field] = Number.isFinite(next) ? next : previous[onCommit.field];
|
|
10588
|
+
return Object.assign({}, previous, patch);
|
|
10589
|
+
});
|
|
10590
|
+
},
|
|
10591
|
+
onBlur: function () { onCommit.commit(local[onCommit.field]); },
|
|
10592
|
+
}));
|
|
10593
|
+
}
|
|
10594
|
+
|
|
10595
|
+
var children = [
|
|
10596
|
+
h('div', { className: 'rw-group-head' },
|
|
10597
|
+
h('span', { className: 'rw-group-title' }, t('execTitle')),
|
|
10598
|
+
h('span', { className: 'rw-group-hint' }, t('execHint'))),
|
|
10599
|
+
h('div', { className: 'rw-setting-row' },
|
|
10600
|
+
h(Switch, {
|
|
10601
|
+
checked: local.execEnabled,
|
|
10602
|
+
onChange: function (next) { save({ execEnabled: Boolean(next) }, t('execSaved')); },
|
|
10603
|
+
label: t('execEnabledLabel'),
|
|
10604
|
+
text: t('execEnabledLabel'),
|
|
10605
|
+
}),
|
|
10606
|
+
local.saving ? Spinner(12) : null),
|
|
10607
|
+
];
|
|
10608
|
+
|
|
10609
|
+
if (local.execEnabled) {
|
|
10610
|
+
children.push(h('div', { className: 'rw-group-hint', style: { marginTop: 8, color: 'rgb(210,153,34)' } }, t('execWarn')));
|
|
10611
|
+
children.push(h('div', { className: 'rw-group-head', style: { marginTop: 12 } },
|
|
10612
|
+
h('span', { className: 'rw-group-title' }, t('execHostsTitle'))));
|
|
10613
|
+
children.push(hosts.length === 0
|
|
10614
|
+
? h('div', { className: 'rw-hint' }, t('execHostsEmpty'))
|
|
10615
|
+
: h('div', { className: 'rw-exec-list' }, hosts.map(function (host) {
|
|
10616
|
+
var checked = local.execHostIds.indexOf(host.id) >= 0;
|
|
10617
|
+
return h('label', { key: host.id, className: 'rw-exec-item' },
|
|
10618
|
+
h('input', {
|
|
10619
|
+
type: 'checkbox',
|
|
10620
|
+
checked: checked,
|
|
10621
|
+
onChange: function (event) {
|
|
10622
|
+
var on = event.currentTarget.checked;
|
|
10623
|
+
save({ execHostIds: withId(local.execHostIds, host.id, on) }, t('execSaved'));
|
|
10624
|
+
},
|
|
10625
|
+
}),
|
|
10626
|
+
h('span', { className: 'rw-exec-name' }, host.name || host.host || host.id),
|
|
10627
|
+
h('span', { className: 'rw-exec-meta' }, (host.username ? host.username + '@' : '') + (host.host || '') + (host.port ? ':' + host.port : '')));
|
|
10628
|
+
})));
|
|
10629
|
+
children.push(h('div', { className: 'rw-group-head', style: { marginTop: 12 } },
|
|
10630
|
+
h('span', { className: 'rw-group-title' }, t('execWorkspacesTitle')),
|
|
10631
|
+
h('span', { className: 'rw-group-hint' }, t('execWorkspacesHint'))));
|
|
10632
|
+
children.push(workspaces.length === 0
|
|
10633
|
+
? h('div', { className: 'rw-hint' }, t('execHostsEmpty'))
|
|
10634
|
+
: h('div', { className: 'rw-exec-list' }, workspaces.map(function (item) {
|
|
10635
|
+
var checked = local.execWorkspaceIds.indexOf(item.id) >= 0;
|
|
10636
|
+
return h('label', { key: item.id, className: 'rw-exec-item' },
|
|
10637
|
+
h('input', {
|
|
10638
|
+
type: 'checkbox',
|
|
10639
|
+
checked: checked,
|
|
10640
|
+
onChange: function (event) {
|
|
10641
|
+
var on = event.currentTarget.checked;
|
|
10642
|
+
save({ execWorkspaceIds: withId(local.execWorkspaceIds, item.id, on) }, t('execSaved'));
|
|
10643
|
+
},
|
|
10644
|
+
}),
|
|
10645
|
+
h('span', { className: 'rw-exec-name' }, item.name || item.id),
|
|
10646
|
+
h('span', { className: 'rw-exec-meta' }, item.remotePath || ''));
|
|
10647
|
+
})));
|
|
10648
|
+
children.push(h('div', { className: 'rw-inline', style: { marginTop: 12, flexWrap: 'wrap', gap: 12 } },
|
|
10649
|
+
numberRow(t('execTimeoutLabel'), local.execTimeoutSec, 1, 600, 1, {
|
|
10650
|
+
field: 'execTimeoutSec',
|
|
10651
|
+
commit: function (value) {
|
|
10652
|
+
save({ execTimeoutMs: Math.round((Number(value) || 60) * 1000) }, t('execSaved'));
|
|
10653
|
+
},
|
|
10654
|
+
}),
|
|
10655
|
+
numberRow(t('execOutputLabel'), local.execMaxOutputChars, 1000, 400000, 1000, {
|
|
10656
|
+
field: 'execMaxOutputChars',
|
|
10657
|
+
commit: function (value) {
|
|
10658
|
+
save({ execMaxOutputChars: Math.round(Number(value) || 200000) }, t('execSaved'));
|
|
10659
|
+
},
|
|
10660
|
+
}),
|
|
10661
|
+
h('button', {
|
|
10662
|
+
type: 'button',
|
|
10663
|
+
className: 'rw-btn rw-btn-ghost rw-btn-sm',
|
|
10664
|
+
onClick: openAudit,
|
|
10665
|
+
}, IconTerminal(13), t('execAuditOpen'))));
|
|
10666
|
+
}
|
|
10667
|
+
|
|
10668
|
+
if (local.message) {
|
|
10669
|
+
children.push(h(Banner, {
|
|
10670
|
+
kind: local.message.kind === 'success' ? 'success' : 'error',
|
|
10671
|
+
onClose: function () {
|
|
10672
|
+
setLocal(function (previous) { return Object.assign({}, previous, { message: null }); });
|
|
10673
|
+
},
|
|
10674
|
+
}, local.message.text));
|
|
10675
|
+
}
|
|
10676
|
+
|
|
10677
|
+
return h('div', { className: 'rw-group' }, children);
|
|
10678
|
+
}
|
|
10679
|
+
|
|
10375
10680
|
function ConnectionsPage(props) {
|
|
10376
10681
|
var ctx = props.ctx;
|
|
10377
10682
|
var locale = useLocale(ctx);
|
|
@@ -10432,6 +10737,12 @@ function rememberShowHidden(value) {
|
|
|
10432
10737
|
!sidebarAvailable ? h(Banner, { kind: 'warn' }, t('needsSidebar')) : null,
|
|
10433
10738
|
h(ThemeGroup, { t: t, locale: locale }),
|
|
10434
10739
|
h(EditorSettingsGroup, { t: t, locale: locale }),
|
|
10740
|
+
h(ExecSettingsGroup, {
|
|
10741
|
+
t: t,
|
|
10742
|
+
locale: locale,
|
|
10743
|
+
hosts: remote.data.hosts || [],
|
|
10744
|
+
workspaces: links.concat(remotes),
|
|
10745
|
+
}),
|
|
10435
10746
|
adding === 'linked'
|
|
10436
10747
|
? h(AddWorkspaceFlow, {
|
|
10437
10748
|
ctx: ctx, t: t, locale: locale,
|