fix(ui): migrate remaining detail dialogs to drawers
This commit is contained in:
parent
42d8755a45
commit
715fef3e87
|
|
@ -63,3 +63,5 @@ NODE_PATH=/tmp/csai-ui-tools/node_modules node scripts/check-ui-design-system.cj
|
|||
浏览器回归使用真实 i18next 翻译函数,不再用固定中文替代函数覆盖它。
|
||||
|
||||
Skill 的“查看”入口动态创建 `skill-view-modal`,与编辑入口共用宽抽屉。回归同时验证摘要展示、按需加载全文、展开、Escape 清理以及“查看 → 编辑”切换,防止只验证编辑表单而遗漏只读详情入口。
|
||||
|
||||
信息收集的字段全文、AI 查询解析结果,以及 WebShell 数据库连接配置也使用公共抽屉。信息收集动态节点采用标准 header/body/footer 类和公共关闭逻辑;回归使用长文本、警告说明与离线数据库配置夹具,检查滚动、重复打开、复制、仅应用查询语法和关闭清理,不执行外部查询或数据库连接。
|
||||
|
|
|
|||
|
|
@ -348,6 +348,13 @@ const server = http.createServer((req, res) => {
|
|||
theme,
|
||||
out,
|
||||
});
|
||||
await require("./ui-extra-drawers.cjs")({
|
||||
page,
|
||||
width,
|
||||
height,
|
||||
theme,
|
||||
out,
|
||||
});
|
||||
await page.close();
|
||||
}
|
||||
fs.writeFileSync(
|
||||
|
|
|
|||
|
|
@ -0,0 +1,209 @@
|
|||
// Exercise the production dynamic renderers with offline data only.
|
||||
const assert = require("node:assert/strict");
|
||||
module.exports = async ({ page, width, height, theme, out }) => {
|
||||
for (const name of ["info-collect", "webshell"])
|
||||
await page.addScriptTag({ url: "/static/js/" + name + ".js" });
|
||||
const activate = (id) =>
|
||||
page.evaluate(
|
||||
(id) =>
|
||||
document
|
||||
.querySelectorAll(".page")
|
||||
.forEach((e) => e.classList.toggle("active", e.id === id)),
|
||||
id,
|
||||
);
|
||||
const verify = async (id, name) => {
|
||||
await page.locator("#" + id + " .modal-body").waitFor();
|
||||
await page.waitForTimeout(220);
|
||||
const box = await page.locator("#" + id).evaluate((e) => {
|
||||
const p = e.querySelector(".modal-content"),
|
||||
b = e.querySelector(".modal-body"),
|
||||
h = e.querySelector(".modal-header h2"),
|
||||
r = p.getBoundingClientRect(),
|
||||
s = getComputedStyle(p);
|
||||
return {
|
||||
surface: e.dataset.uiSurface,
|
||||
x: r.x,
|
||||
right: r.right,
|
||||
width: r.width,
|
||||
height: r.height,
|
||||
radius: s.borderRadius,
|
||||
bg: s.backgroundColor,
|
||||
titleColor: getComputedStyle(h).color,
|
||||
bodyWidth: b.clientWidth,
|
||||
bodyScroll: b.scrollWidth,
|
||||
footer: e.querySelector(".modal-footer").getBoundingClientRect().bottom,
|
||||
expandedButton: !!e.querySelector(".app-drawer-expand"),
|
||||
};
|
||||
});
|
||||
assert.equal(box.surface, "drawer");
|
||||
assert.equal(box.radius, "0px");
|
||||
assert(box.expandedButton);
|
||||
assert(
|
||||
Math.abs(box.right - width) < 2 && Math.abs(box.height - height) < 2,
|
||||
JSON.stringify(box),
|
||||
);
|
||||
assert(
|
||||
box.width <= (width < 768 ? width : width - 48) + 1 && box.width > 0,
|
||||
JSON.stringify(box),
|
||||
);
|
||||
assert(
|
||||
box.footer <= height + 1 && box.bodyScroll <= box.bodyWidth + 2,
|
||||
JSON.stringify(box),
|
||||
);
|
||||
assert.equal(
|
||||
box.bg,
|
||||
theme === "dark" ? "rgb(17, 24, 39)" : "rgb(255, 255, 255)",
|
||||
);
|
||||
if (theme === "dark")
|
||||
assert(Number(box.titleColor.match(/\d+/)[0]) > 150, JSON.stringify(box));
|
||||
await page.screenshot({
|
||||
animations: "disabled",
|
||||
path: `${out}/extra-${name}-${width}-${theme}.png`,
|
||||
});
|
||||
if (width >= 768) {
|
||||
await page.locator("#" + id + " .app-drawer-expand").click();
|
||||
assert(
|
||||
(await page.locator("#" + id + " .modal-content").boundingBox()).width >
|
||||
box.width,
|
||||
);
|
||||
await page.locator("#" + id + " .app-drawer-expand").click();
|
||||
}
|
||||
};
|
||||
await activate("page-info-collect");
|
||||
await page.evaluate(() => {
|
||||
window.extraDrawerRequests = [];
|
||||
window.apiFetch = async (url, options = {}) => {
|
||||
extraDrawerRequests.push({ url, method: options.method || "GET" });
|
||||
return { ok: true, json: async () => ({ conversations: [] }) };
|
||||
};
|
||||
Object.defineProperty(navigator, "clipboard", {
|
||||
configurable: true,
|
||||
value: {
|
||||
writeText: async (text) => {
|
||||
window.extraDrawerCopied = text;
|
||||
},
|
||||
},
|
||||
});
|
||||
window.extraDrawerText =
|
||||
"Content-Security-Policy: " +
|
||||
"example.test ".repeat(120) +
|
||||
"\n" +
|
||||
"详细字段内容 <script>不应执行</script>\n".repeat(60);
|
||||
showCellDetailModal("响应头完整内容", extraDrawerText);
|
||||
});
|
||||
await verify("info-collect-cell-modal", "cell-fulltext");
|
||||
assert.equal(
|
||||
await page.locator(".info-collect-cell-modal-pre").textContent(),
|
||||
await page.evaluate(() => extraDrawerText),
|
||||
);
|
||||
await page.locator("#info-collect-cell-modal-copy").click();
|
||||
assert.equal(
|
||||
await page.evaluate(() => extraDrawerCopied),
|
||||
await page.evaluate(() => extraDrawerText),
|
||||
);
|
||||
await page.keyboard.press("Escape");
|
||||
assert.equal(await page.locator("#info-collect-cell-modal").count(), 0);
|
||||
await page.evaluate(() => {
|
||||
showCellDetailModal("旧字段", "旧值");
|
||||
showCellDetailModal("新字段", "新值");
|
||||
});
|
||||
assert.equal(await page.locator("#info-collect-cell-modal").count(), 1);
|
||||
await page.locator("#info-collect-cell-modal-ok").click();
|
||||
assert.equal(
|
||||
await page.evaluate(() =>
|
||||
document.body.classList.contains("app-modal-open"),
|
||||
),
|
||||
false,
|
||||
);
|
||||
await page.evaluate(() =>
|
||||
showFofaParseModal("查找演示资产", {
|
||||
query: 'domain="example.test"',
|
||||
warnings: ["仅展示语法,未发起查询。".repeat(20)],
|
||||
explanation: "查询条件解释。\n".repeat(80),
|
||||
}),
|
||||
);
|
||||
await verify("fofa-parse-modal", "parse-result");
|
||||
await page.locator("#fofa-parse-query").fill('domain="demo.example.test"');
|
||||
await page.locator("#fofa-parse-apply").click();
|
||||
assert.equal(
|
||||
await page.locator("#fofa-query").inputValue(),
|
||||
'domain="demo.example.test"',
|
||||
);
|
||||
assert.equal(await page.locator("#fofa-parse-modal").count(), 0);
|
||||
assert.equal(
|
||||
await page.evaluate(() => extraDrawerRequests.length),
|
||||
0,
|
||||
"Applying syntax must not query a provider",
|
||||
);
|
||||
await page.evaluate(() => {
|
||||
showFofaParseModal("旧请求", { query: "old" });
|
||||
showFofaParseModal("新请求", { query: "new" });
|
||||
});
|
||||
await page.locator("#fofa-parse-query").waitFor();
|
||||
assert.equal(await page.locator("#fofa-parse-query").inputValue(), "new");
|
||||
await page.keyboard.press("Escape");
|
||||
assert.equal(await page.locator("#fofa-parse-modal").count(), 0);
|
||||
assert.equal(
|
||||
await page.evaluate(() =>
|
||||
document.body.classList.contains("app-modal-open"),
|
||||
),
|
||||
false,
|
||||
);
|
||||
await activate("page-webshell");
|
||||
await page.evaluate(() => {
|
||||
// Keep terminal and persistence transports out of this UI fixture. The actual
|
||||
// workspace renderer and DB add/edit/close handlers still execute unchanged.
|
||||
initWebshellTerminal = () => {};
|
||||
queueWebshellPersistStateSave = () => {};
|
||||
webshellConnections = [
|
||||
{
|
||||
id: "offline-ui",
|
||||
name: "离线界面回归",
|
||||
url: "https://example.test",
|
||||
type: "php",
|
||||
project_id: "",
|
||||
},
|
||||
];
|
||||
selectWebshell("offline-ui", true);
|
||||
});
|
||||
await page.locator('.webshell-tab[data-tab="db"]').click();
|
||||
await page.locator("#webshell-db-add-profile-btn").click();
|
||||
await verify("webshell-db-profile-modal", "db-add");
|
||||
await page.locator("#webshell-db-profile-cancel-btn").click();
|
||||
await page
|
||||
.locator('#webshell-db-profiles [data-action="edit"]')
|
||||
.first()
|
||||
.click();
|
||||
await verify("webshell-db-profile-modal", "db-edit");
|
||||
const toolbarBackground = await page
|
||||
.locator("#webshell-db-profile-modal .webshell-db-toolbar")
|
||||
.evaluate((e) => getComputedStyle(e).backgroundColor);
|
||||
if (theme === "dark")
|
||||
assert(Number(toolbarBackground.match(/\d+/)[0]) < 100, toolbarBackground);
|
||||
|
||||
await page.locator("#webshell-db-type").selectOption("sqlite");
|
||||
assert(await page.locator("#webshell-db-sqlite-path").isVisible());
|
||||
assert(!(await page.locator("#webshell-db-host").isVisible()));
|
||||
await page.keyboard.press("Escape");
|
||||
assert(!(await page.locator("#webshell-db-profile-modal").isVisible()));
|
||||
assert.equal(
|
||||
await page.evaluate(() =>
|
||||
document.body.classList.contains("app-modal-open"),
|
||||
),
|
||||
false,
|
||||
);
|
||||
const requests = await page.evaluate(() => extraDrawerRequests);
|
||||
assert(
|
||||
requests.every(
|
||||
(r) =>
|
||||
r.method === "GET" &&
|
||||
[
|
||||
"/api/roles",
|
||||
"/api/config",
|
||||
"/api/webshell/connections/offline-ui/ai-conversations",
|
||||
"/api/webshell/connections/offline-ui/ai-history",
|
||||
].includes(r.url),
|
||||
),
|
||||
JSON.stringify(requests),
|
||||
);
|
||||
};
|
||||
|
|
@ -294,3 +294,14 @@ html body #batch-queue-detail-modal .modal-header-actions .btn-primary:is(:hover
|
|||
border-color: var(--accent-hover);
|
||||
}
|
||||
html body #batch-queue-detail-modal #batch-queue-detail-title { display: block; }
|
||||
|
||||
/* Database profile fields are edited inside a narrower, scrollable drawer. */
|
||||
html body #webshell-db-profile-modal .webshell-db-toolbar {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
background: var(--ui-surface-muted);
|
||||
border-color: var(--ui-border);
|
||||
}
|
||||
html body #webshell-db-profile-modal .webshell-db-toolbar label > span { color: var(--text-secondary); }
|
||||
@media (max-width: 767.98px) {
|
||||
html body #webshell-db-profile-modal .webshell-db-toolbar { grid-template-columns: minmax(0, 1fr); }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -890,7 +890,7 @@ function setFofaParseLoading(loading, statusText) {
|
|||
|
||||
function showFofaParseModal(nlText, parsed) {
|
||||
const existing = document.getElementById('fofa-parse-modal');
|
||||
if (existing) existing.remove();
|
||||
if (existing) { closeAppModal(existing); existing.remove(); }
|
||||
|
||||
const provider = getInfoCollectProvider();
|
||||
const cfg = INFO_COLLECT_PROVIDERS[provider] || INFO_COLLECT_PROVIDERS.fofa;
|
||||
|
|
@ -908,13 +908,14 @@ function showFofaParseModal(nlText, parsed) {
|
|||
document.body.appendChild(modal);
|
||||
openAppModal(modal, { focus: false });
|
||||
deferModalContent(function () {
|
||||
if (!modal.isConnected) return;
|
||||
modal.innerHTML = `
|
||||
<div class="modal-content info-collect-parse-modal-content" style="max-width: 900px;">
|
||||
<div class="modal-header">
|
||||
<h2>${_t('infoCollect.parseResultTitle')}</h2>
|
||||
<span class="modal-close" id="fofa-parse-modal-close" title="${_t('common.close')}">×</span>
|
||||
</div>
|
||||
<div class="info-collect-parse-modal-body">
|
||||
<div class="modal-body info-collect-parse-modal-body">
|
||||
<div class="form-group">
|
||||
<label>${_t('infoCollect.naturalLanguageLabel')}</label>
|
||||
<div class="muted info-collect-parse-nl-text">${safeNL || '-'}</div>
|
||||
|
|
@ -990,14 +991,7 @@ function showFofaParseModal(nlText, parsed) {
|
|||
document.getElementById('fofa-parse-apply')?.addEventListener('click', () => applyToQuery(false));
|
||||
document.getElementById('fofa-parse-apply-run')?.addEventListener('click', () => applyToQuery(true));
|
||||
|
||||
// Esc 关闭
|
||||
const onKey = (e) => {
|
||||
if (e.key === 'Escape') {
|
||||
close();
|
||||
document.removeEventListener('keydown', onKey);
|
||||
}
|
||||
};
|
||||
document.addEventListener('keydown', onKey);
|
||||
// Escape is handled by the shared modal lifecycle.
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -1662,31 +1656,31 @@ async function batchScanSelectedFofaRows() {
|
|||
|
||||
function showCellDetailModal(field, fullText) {
|
||||
const existing = document.getElementById('info-collect-cell-modal');
|
||||
if (existing) existing.remove();
|
||||
if (existing) { closeAppModal(existing); existing.remove(); }
|
||||
|
||||
const text = fullText == null ? '' : String(fullText);
|
||||
const fieldName = field || _t('infoCollect.field');
|
||||
const charCountLabel = _t('infoCollect.cellValueLength', { count: Array.from(text).length });
|
||||
const modal = document.createElement('div');
|
||||
modal.id = 'info-collect-cell-modal';
|
||||
modal.className = 'info-collect-cell-modal';
|
||||
modal.className = 'modal info-collect-cell-modal';
|
||||
modal.innerHTML = `
|
||||
<div class="info-collect-cell-modal-content" role="dialog" aria-modal="true">
|
||||
<div class="info-collect-cell-modal-header">
|
||||
<div class="modal-content info-collect-cell-modal-content">
|
||||
<div class="modal-header info-collect-cell-modal-header">
|
||||
<div class="info-collect-cell-modal-heading">
|
||||
<div class="info-collect-cell-modal-title">${escapeHtml(fieldName)}</div>
|
||||
<h2 class="info-collect-cell-modal-title">${escapeHtml(fieldName)}</h2>
|
||||
<div class="info-collect-cell-modal-subtitle">${escapeHtml(charCountLabel)}</div>
|
||||
</div>
|
||||
<button class="btn-icon" type="button" id="info-collect-cell-modal-close" title="${_t('common.close')}">
|
||||
<button class="modal-close" type="button" id="info-collect-cell-modal-close" title="${_t('common.close')}">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M18 6L6 18M6 6l12 12" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<div class="info-collect-cell-modal-body">
|
||||
<div class="modal-body info-collect-cell-modal-body">
|
||||
<pre class="info-collect-cell-modal-pre">${escapeHtml(text)}</pre>
|
||||
</div>
|
||||
<div class="info-collect-cell-modal-footer">
|
||||
<div class="modal-footer info-collect-cell-modal-footer">
|
||||
<button class="btn-secondary" type="button" id="info-collect-cell-modal-copy">${_t('common.copy')}</button>
|
||||
<button class="btn-primary" type="button" id="info-collect-cell-modal-ok">${_t('common.close')}</button>
|
||||
</div>
|
||||
|
|
@ -1696,13 +1690,7 @@ function showCellDetailModal(field, fullText) {
|
|||
document.body.appendChild(modal);
|
||||
openAppModal(modal);
|
||||
|
||||
const onKey = (e) => {
|
||||
if (e.key === 'Escape') {
|
||||
close();
|
||||
}
|
||||
};
|
||||
const close = function () {
|
||||
document.removeEventListener('keydown', onKey);
|
||||
closeAppModal(modal);
|
||||
modal.remove();
|
||||
syncAppModalBodyLock();
|
||||
|
|
@ -1716,8 +1704,7 @@ function showCellDetailModal(field, fullText) {
|
|||
navigator.clipboard.writeText(text).then(() => showInlineToast(_t('common.copied'))).catch(() => alert(_t('common.copyFailed')));
|
||||
});
|
||||
|
||||
// Esc 关闭
|
||||
document.addEventListener('keydown', onKey);
|
||||
// Escape is handled by the shared modal lifecycle.
|
||||
}
|
||||
|
||||
// 暴露到全局(供 index.html onclick 调用)
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
'rbac-user-modal', 'rbac-role-modal', 'chat-files-edit-modal', 'webshell-modal',
|
||||
'workflow-package-import-modal', 'workflow-ai-modal', 'robot-commands-modal',
|
||||
'robot-account-binding-modal', 'c2-modal',
|
||||
'info-collect-cell-modal', 'fofa-parse-modal', 'webshell-db-profile-modal',
|
||||
]);
|
||||
const WIDE_IDS = new Set([
|
||||
'skill-modal', 'skill-view-modal', 'agent-md-modal', 'role-modal', 'fact-modal', 'vulnerability-modal',
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
<link rel="stylesheet" href="/static/css/mobile.css?v=20261015-project-table-3">
|
||||
<link rel="stylesheet" href="/static/css/vulnerability-workspace.css?v=20261113-aligned-overview">
|
||||
<link rel="stylesheet" href="/static/css/vulnerability-list.css?v=20261113-compact-rows">
|
||||
<link rel="stylesheet" href="/static/css/design-system.css?v=20261115-square-drawers">
|
||||
<link rel="stylesheet" href="/static/css/design-system.css?v=20261115-extra-drawers">
|
||||
<script src="/static/js/router.js?v=20261011-token-settings"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
|
@ -7066,7 +7066,7 @@
|
|||
<script src="/static/js/theme.js"></script>
|
||||
<script src="/static/js/builtin-tools.js"></script>
|
||||
<script src="/static/js/auth.js?v=20261008-password-eye-1"></script>
|
||||
<script src="/static/js/modal.js?v=20261115-skill-view-drawer"></script>
|
||||
<script src="/static/js/modal.js?v=20261115-extra-drawers"></script>
|
||||
<dialog id="vulnerability-download-dialog" aria-labelledby="vulnerability-download-heading" aria-describedby="vulnerability-download-hint">
|
||||
<div class="vulnerability-download-content">
|
||||
<h3 id="vulnerability-download-heading" data-i18n="vulnerabilityDownload.title">下载漏洞报告</h3>
|
||||
|
|
@ -7081,7 +7081,7 @@
|
|||
</dialog>
|
||||
|
||||
<script src="/static/js/notifications.js"></script>
|
||||
<script src="/static/js/info-collect.js?v=20260717-1"></script>
|
||||
<script src="/static/js/info-collect.js?v=20261115-extra-drawers"></script>
|
||||
<script src="/static/js/assets.js?v=20260717-7"></script>
|
||||
<script src="/static/js/agents.js"></script>
|
||||
<script src="/static/js/dashboard.js?v=20261011-token-settings-cache-only"></script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue