diff --git a/apps/daas/tests/audit-log.test.ts b/apps/daas/tests/audit-log.test.ts
index a0367266b..f05e9da7f 100644
--- a/apps/daas/tests/audit-log.test.ts
+++ b/apps/daas/tests/audit-log.test.ts
@@ -1,17 +1,32 @@
import assert from 'node:assert/strict'
+import { readFileSync } from 'node:fs'
import test from 'node:test'
import {
+ actionMatchesEventType,
+ advancedFilterCount,
+ appliedFilterTags,
+ AUDIT_ACTIONS,
+ AUDIT_ACTIONS_BY_EVENT_TYPE,
+ AUDIT_EVENT_TYPES,
+ AUDIT_QUERY_LABEL_KEYS,
+ AUDIT_TAG_KEYS,
+ auditActionGroups,
+ auditActionLabelKey,
batchSummary,
buildAuditQuery,
changeText,
createAuditDetailLoader,
displayValue,
hasUnresolvedPlaceholder,
+ isQueryDirty,
isRetentionShortened,
isValidRetention,
+ isValidTimeRange,
nodeText,
operatorText,
outcomeView,
+ parseQuickRange,
+ quickRangeTimes,
} from '../src/views/audit/audit-log.ts'
const t = (key: string, args?: any[]) =>
@@ -27,8 +42,10 @@ test('builds query with known filter keys and drops blanks', () => {
keyword: null,
unknown: 'x',
operationId: 'op-1',
+ eventId: 'ev-1',
+ range: 'custom',
}),
- { start: 1, end: 2, user: 'ops', operationId: 'op-1' },
+ { start: 1, end: 2, user: 'ops' },
)
})
@@ -202,3 +219,131 @@ test('renders service node with instance and ip so same-host instances differ',
)
assert.equal(nodeText(undefined), '')
})
+
+test('quick ranges use the real current time', () => {
+ const now = new Date(2026, 10, 19, 15, 30, 45, 123).getTime()
+ assert.deepEqual(quickRangeTimes('last7d', now), [
+ new Date(2026, 10, 13, 0, 0, 0, 0).getTime(),
+ new Date(2026, 10, 19, 23, 59, 59, 999).getTime(),
+ ])
+ assert.deepEqual(quickRangeTimes('today', now), [
+ new Date(2026, 10, 19, 0, 0, 0, 0).getTime(),
+ new Date(2026, 10, 19, 23, 59, 59, 999).getTime(),
+ ])
+ assert.deepEqual(quickRangeTimes('last24h', now), [
+ now - 24 * 60 * 60 * 1000,
+ now,
+ ])
+ assert.equal(quickRangeTimes('custom', now), null)
+})
+
+test('quick range across a month boundary keeps seven calendar days', () => {
+ const now = new Date(2026, 2, 3, 8, 0, 0).getTime()
+ const [start] = quickRangeTimes('last7d', now)
+ assert.equal(start, new Date(2026, 1, 25, 0, 0, 0, 0).getTime())
+})
+
+test('parses quick range from route query', () => {
+ assert.equal(parseQuickRange({}), 'last7d')
+ assert.equal(parseQuickRange({ range: 'today', start: '1' }), 'today')
+ assert.equal(parseQuickRange({ start: '1', end: '2' }), 'custom')
+ assert.equal(parseQuickRange({ range: 'bogus', start: '1' }), 'custom')
+})
+
+test('validates required time range and start not later than end', () => {
+ assert.equal(isValidTimeRange(1, 2), true)
+ assert.equal(isValidTimeRange('5', '5'), true)
+ assert.equal(isValidTimeRange(3, 2), false)
+ assert.equal(isValidTimeRange('', 2), false)
+ assert.equal(isValidTimeRange(1, null), false)
+ assert.equal(isValidTimeRange('x', 2), false)
+})
+
+test('detects changes not applied regardless of value types', () => {
+ const applied = { start: 1, end: 2, keyword: 'ops', source: '' }
+ assert.equal(
+ isQueryDirty({ start: '1', end: '2', keyword: ' ops ' }, applied),
+ false,
+ )
+ assert.equal(isQueryDirty({ ...applied, outcome: 'FAILED' }, applied), true)
+ assert.equal(isQueryDirty({ ...applied, start: 0 }, applied), true)
+})
+
+test('counts only applied advanced filters', () => {
+ assert.equal(
+ advancedFilterCount({
+ keyword: 'k',
+ eventType: 'TASK',
+ source: 'UI',
+ user: ' ',
+ sourceIp: '10.0.0.1',
+ action: 'task.start',
+ }),
+ 3,
+ )
+ assert.equal(advancedFilterCount({}), 0)
+})
+
+test('builds applied filter tags without time conditions', () => {
+ assert.deepEqual(
+ appliedFilterTags({
+ start: 1,
+ end: 2,
+ object: 'orders',
+ keyword: 'sync',
+ outcome: 'FAILED',
+ user: '',
+ }),
+ [
+ { key: 'keyword', value: 'sync' },
+ { key: 'outcome', value: 'FAILED' },
+ { key: 'object', value: 'orders' },
+ ],
+ )
+ for (const key of AUDIT_TAG_KEYS) {
+ assert.ok(AUDIT_QUERY_LABEL_KEYS[key], key)
+ }
+})
+
+test('groups actions by event type and narrows by selected type', () => {
+ assert.equal(AUDIT_ACTIONS.length, 135)
+ assert.equal(new Set(AUDIT_ACTIONS).size, AUDIT_ACTIONS.length)
+ assert.deepEqual(
+ Object.keys(AUDIT_ACTIONS_BY_EVENT_TYPE).sort(),
+ [...AUDIT_EVENT_TYPES].sort(),
+ )
+ const all = auditActionGroups()
+ assert.equal(all.length, AUDIT_EVENT_TYPES.length)
+ const task = auditActionGroups('TASK')
+ assert.equal(task.length, 1)
+ assert.ok(task[0].actions.includes('task.start'))
+ assert.equal(auditActionLabelKey('auth.login'), 'audit_action_auth_login')
+})
+
+test('clears action that does not belong to the selected event type', () => {
+ assert.equal(actionMatchesEventType('task.start', 'TASK'), true)
+ assert.equal(actionMatchesEventType('auth.login', 'TASK'), false)
+ assert.equal(actionMatchesEventType('auth.login', ''), true)
+ assert.equal(actionMatchesEventType('', 'TASK'), true)
+})
+
+test('every action and query label is translated in all languages', () => {
+ const keys = [
+ ...AUDIT_ACTIONS.map(auditActionLabelKey),
+ ...Object.values(AUDIT_QUERY_LABEL_KEYS),
+ 'audit_query_range_last7d',
+ 'audit_query_range_today',
+ 'audit_query_range_last24h',
+ 'audit_query_range_custom',
+ 'audit_query_pending',
+ ]
+ for (const lang of ['en', 'zh-CN', 'zh-TW']) {
+ const text = readFileSync(
+ new URL(`../src/i18n/langs/${lang}.js`, import.meta.url),
+ 'utf8',
+ )
+ for (const key of keys) {
+ assert.match(text, new RegExp(`^ ${key}:\\s`, 'm'), `${lang} ${key}`)
+ }
+ }
+})
From 308ebb0698a19f882c511d28cdeb538df3ca3390 Mon Sep 17 00:00:00 2001
From: hardy <2545433047@qq.com>
Date: Fri, 20 Nov 2026 00:17:10 -0800
Subject: [PATCH 2/2] fix(TAP-13326): keep audit query bar inside the table
layout
- Render the query bar in TablePage's search slot so the table height
accounts for it and no longer overflows the card.
- Move "changes not applied" and refresh to the end of the action row and
show the applied-filter row only when filters exist, removing the blank
gap above the table.
- Use single i18n keys with named interpolation for the more-filters
count, filter tags and the remove-tag label.
---
apps/daas/src/i18n/langs/en.js | 4 +-
apps/daas/src/i18n/langs/zh-CN.js | 4 +-
apps/daas/src/i18n/langs/zh-TW.js | 4 +-
apps/daas/src/views/audit/AuditLog.vue | 451 +++++++++++++------------
apps/daas/tests/audit-log.test.ts | 3 +
5 files changed, 245 insertions(+), 221 deletions(-)
diff --git a/apps/daas/src/i18n/langs/en.js b/apps/daas/src/i18n/langs/en.js
index e9379f7b7..49f12b636 100644
--- a/apps/daas/src/i18n/langs/en.js
+++ b/apps/daas/src/i18n/langs/en.js
@@ -3137,6 +3137,7 @@ export default {
audit_query_outcome: 'Result',
audit_query_all: 'All',
audit_query_more: 'More filters',
+ audit_query_more_count: 'More filters ({count})',
audit_query_search: 'Search',
audit_query_reset: 'Reset',
audit_query_source: 'Source',
@@ -3151,7 +3152,8 @@ export default {
audit_query_applied: 'Filters',
audit_query_pending: 'Changes not applied',
audit_query_refresh: 'Refresh',
- audit_query_remove_tag: 'Remove filter {0}',
+ audit_query_remove_tag: 'Remove filter {name}',
+ audit_query_tag: '{label}: {value}',
audit_query_empty: 'No matching logs',
audit_query_invalid_range:
'Enter a valid time range. Start time must not be later than end time.',
diff --git a/apps/daas/src/i18n/langs/zh-CN.js b/apps/daas/src/i18n/langs/zh-CN.js
index 43db10452..e8266dd6a 100644
--- a/apps/daas/src/i18n/langs/zh-CN.js
+++ b/apps/daas/src/i18n/langs/zh-CN.js
@@ -2972,6 +2972,7 @@ export default {
audit_query_outcome: '操作结果',
audit_query_all: '全部',
audit_query_more: '更多筛选',
+ audit_query_more_count: '更多筛选({count})',
audit_query_search: '查询',
audit_query_reset: '重置',
audit_query_source: '来源',
@@ -2986,7 +2987,8 @@ export default {
audit_query_applied: '已选条件',
audit_query_pending: '条件已修改,待查询',
audit_query_refresh: '刷新',
- audit_query_remove_tag: '移除条件 {0}',
+ audit_query_remove_tag: '移除条件 {name}',
+ audit_query_tag: '{label}:{value}',
audit_query_empty: '暂无匹配的日志',
audit_query_invalid_range:
'请填写有效的起止时间,且开始时间不能晚于结束时间。',
diff --git a/apps/daas/src/i18n/langs/zh-TW.js b/apps/daas/src/i18n/langs/zh-TW.js
index dab8e9628..73bce556b 100644
--- a/apps/daas/src/i18n/langs/zh-TW.js
+++ b/apps/daas/src/i18n/langs/zh-TW.js
@@ -2959,6 +2959,7 @@ export default {
audit_query_outcome: '操作結果',
audit_query_all: '全部',
audit_query_more: '更多篩選',
+ audit_query_more_count: '更多篩選({count})',
audit_query_search: '查詢',
audit_query_reset: '重置',
audit_query_source: '來源',
@@ -2973,7 +2974,8 @@ export default {
audit_query_applied: '已選條件',
audit_query_pending: '條件已修改,待查詢',
audit_query_refresh: '重新整理',
- audit_query_remove_tag: '移除條件 {0}',
+ audit_query_remove_tag: '移除條件 {name}',
+ audit_query_tag: '{label}:{value}',
audit_query_empty: '暫無符合的日誌',
audit_query_invalid_range:
'請填寫有效的起訖時間,且開始時間不能晚於結束時間。',
diff --git a/apps/daas/src/views/audit/AuditLog.vue b/apps/daas/src/views/audit/AuditLog.vue
index 10ef204c4..541f524be 100644
--- a/apps/daas/src/views/audit/AuditLog.vue
+++ b/apps/daas/src/views/audit/AuditLog.vue
@@ -303,190 +303,212 @@ export default {
:closable="false"
:title="$t('audit_write_failure_alert', [status.writeFailures])"
/>
-