From 3861b8b128123de079a0b250b5580166b7a679b3 Mon Sep 17 00:00:00 2001 From: opsx Date: Sat, 31 Oct 2026 02:00:33 +0000 Subject: [PATCH] =?UTF-8?q?fix(collectors):=20=E7=BC=96=E8=BE=91=E9=87=87?= =?UTF-8?q?=E9=9B=86=E7=AD=96=E7=95=A5=E6=97=B6=E6=97=A0=E6=B3=95=E6=8A=8A?= =?UTF-8?q?"=E5=85=A8=E9=9B=86=E7=BE=A4"=E6=94=B9=E6=88=90"=E5=8F=AA?= =?UTF-8?q?=E9=87=87=E5=87=A0=E4=B8=AA=E5=91=BD=E5=90=8D=E7=A9=BA=E9=97=B4?= =?UTF-8?q?"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit === 现象 === 编辑 Promtail DaemonSet 采集器,显示"所有命名空间(全集群采集)", 下面每个命名空间的复选框全是灰的,点不动,无法改成只采指定几个。 === 根因 === CollectorEditDialog 里单个命名空间的复选框写死了: disabled={allSelected} // allSelected = selectedNs.length === 0 而 targetNamespaces 为空正是代表"全集群",也就是**一进来就处于全集群状态**, 于是所有子项被禁用;而"全集群"那个复选框的 handler 又是 onCheckedChange={() => setAll()} // 永远设回 [] 两者叠加 → 没有任何操作能离开"全集群"状态,是死胡同。 === 修复 === 1. 去掉 disabled:勾任何一个命名空间都会让 selectedNs 非空, allSelected 自动变 false,"全集群"勾选框随之取消——语义自洽。 2. "全集群"行加一句提示:勾选下方任一命名空间即可改为只采指定范围, 让用户知道下一步该点哪里。 === 实测(51489599e2d8)=== PUT targetNamespaces=["astralx"] → 读回 ['astralx'] ✅ PUT targetNamespaces=[] → 读回 [](全集群) ✅ 恢复 ['astralx','log'] → 读回 ['astralx','log'] ✅ tsc 通过;Pod = Hub latest = 51489599e2d8 注:改完需要点「部署」才会把新的 kubernetes_sd_configs.namespaces 白名单 下发到 Promtail DaemonSet。 --- frontend/src/i18n/locales/en/collectors.ts | 1 + frontend/src/i18n/locales/zh/collectors.ts | 1 + .../collectors/components/CollectorEditDialog.tsx | 13 +++++++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/frontend/src/i18n/locales/en/collectors.ts b/frontend/src/i18n/locales/en/collectors.ts index 0d9b3ef..cf1d425 100644 --- a/frontend/src/i18n/locales/en/collectors.ts +++ b/frontend/src/i18n/locales/en/collectors.ts @@ -121,6 +121,7 @@ const collectors = { namespaces: 'Namespaces to Collect', allNamespaces: 'All namespaces cluster-wide', selectedCount: '{{count}} selected', + allCheckedHint: '(tick any namespace below to switch to a fixed set)', allCheckbox: 'All namespaces (collect cluster-wide)', nsSearch: 'Search namespaces…', loading: 'Loading…', diff --git a/frontend/src/i18n/locales/zh/collectors.ts b/frontend/src/i18n/locales/zh/collectors.ts index 06cf685..110da48 100644 --- a/frontend/src/i18n/locales/zh/collectors.ts +++ b/frontend/src/i18n/locales/zh/collectors.ts @@ -125,6 +125,7 @@ const collectors = { namespaces: '采集命名空间', allNamespaces: '全集群所有命名空间', selectedCount: '已选 {{count}} 个', + allCheckedHint: '(勾选下方任一命名空间即可改为只采指定范围)', allCheckbox: '所有命名空间(全集群采集)', nsSearch: '搜索命名空间…', loading: '加载中…', diff --git a/frontend/src/pages/collectors/components/CollectorEditDialog.tsx b/frontend/src/pages/collectors/components/CollectorEditDialog.tsx index 89f7a80..3b2e10b 100644 --- a/frontend/src/pages/collectors/components/CollectorEditDialog.tsx +++ b/frontend/src/pages/collectors/components/CollectorEditDialog.tsx @@ -290,7 +290,12 @@ export const CollectorEditDialog = memo(function CollectorEditDialog({ collector
(