mirror of
https://github.com/hansjone/netx.git
synced 2026-10-09 05:30:46 +08:00
Require explicit VRF bindings and toggle select-all in discover.
Drop default-all-VRF mode so collects must bind VRFs manually; discover starts with none selected and select-all toggles to deselect. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
771f7e21c2
commit
3c3013dd73
6 changed files with 61 additions and 118 deletions
|
|
@ -237,13 +237,11 @@ const en = {
|
|||
cancel: "Close",
|
||||
bindTitle: "Select VRF bindings",
|
||||
unbound: "Not bound",
|
||||
allVrfsDefault: "All VRFs (default)",
|
||||
bindHintRequired: "Bind VRF params before collect",
|
||||
bindHintOptional: "Bind VRFs, or leave empty for all",
|
||||
discoverLoading: "Discovering VRFs…",
|
||||
discoverEmpty: "No VRFs discovered",
|
||||
selectAllVrfs: "Select all",
|
||||
clearVrfs: "Clear",
|
||||
deselectAllVrfs: "Deselect all",
|
||||
batches: "Batches",
|
||||
viewBatch: "Open",
|
||||
export: "Export",
|
||||
|
|
|
|||
|
|
@ -237,13 +237,11 @@ const zh = {
|
|||
cancel: "关闭",
|
||||
bindTitle: "选择 VRF 绑定",
|
||||
unbound: "未关联",
|
||||
allVrfsDefault: "默认全部 VRF",
|
||||
bindHintRequired: "需关联 VRF 参数后才可采集",
|
||||
bindHintOptional: "可关联指定 VRF,未关联则采集全部",
|
||||
discoverLoading: "正在发现 VRF…",
|
||||
discoverEmpty: "未发现可用 VRF",
|
||||
selectAllVrfs: "全选",
|
||||
clearVrfs: "清空",
|
||||
deselectAllVrfs: "取消全选",
|
||||
batches: "采集批次",
|
||||
viewBatch: "查看",
|
||||
export: "导出",
|
||||
|
|
|
|||
|
|
@ -800,7 +800,9 @@ export function BizStatePage() {
|
|||
const existing = (item.bindings || [])
|
||||
.filter((b: any) => b.placeholder === ph.name)
|
||||
.map((b: any) => String(b.value));
|
||||
setSelectedVrfs(existing.length ? existing : cand.map((c) => c.value));
|
||||
// Keep prior bindings if still in candidates; otherwise start with none selected.
|
||||
const keep = existing.filter((v: string) => cand.some((c) => c.value === v));
|
||||
setSelectedVrfs(keep);
|
||||
if (!cand.length) {
|
||||
setDiscoverError(t("bizState.discoverEmpty"));
|
||||
}
|
||||
|
|
@ -819,9 +821,8 @@ export function BizStatePage() {
|
|||
const item = (detail?.items || []).find((it: any) => it.id === bindItemId);
|
||||
const prof = profiles.find((p) => p.profile_id === item?.source_profile_id);
|
||||
const phName = (prof?.placeholders || [])[0]?.name || "vrf";
|
||||
const bindOptional = (prof?.placeholders || []).every((ph) => ph.required === false);
|
||||
const picked = values !== undefined ? values : selectedVrfs;
|
||||
if (!picked.length && !bindOptional) return;
|
||||
if (!picked.length) return;
|
||||
setBusy(true);
|
||||
try {
|
||||
await bizStateSetBindings(
|
||||
|
|
@ -1352,15 +1353,10 @@ export function BizStatePage() {
|
|||
const enabled = Boolean(it?.enabled);
|
||||
const binds = it?.bindings || [];
|
||||
const needsBind = (prof.placeholders || []).length > 0;
|
||||
const bindOptional = (prof.placeholders || []).every(
|
||||
(ph) => ph.required === false,
|
||||
);
|
||||
const bindHint = needsBind
|
||||
? binds.length
|
||||
? binds.map((b: any) => b.value).join(", ")
|
||||
: bindOptional
|
||||
? t("bizState.allVrfsDefault")
|
||||
: t("bizState.unbound")
|
||||
: t("bizState.unbound")
|
||||
: "—";
|
||||
return (
|
||||
<tr key={prof.profile_id}>
|
||||
|
|
@ -1376,22 +1372,12 @@ export function BizStatePage() {
|
|||
<div className="pt-list-task-name">{prof.title}</div>
|
||||
{prof.description ? <div className="muted">{prof.description}</div> : null}
|
||||
{needsBind ? (
|
||||
<div className="bs-bind-hint muted">
|
||||
{bindOptional
|
||||
? t("bizState.bindHintOptional")
|
||||
: t("bizState.bindHintRequired")}
|
||||
</div>
|
||||
<div className="bs-bind-hint muted">{t("bizState.bindHintRequired")}</div>
|
||||
) : null}
|
||||
</td>
|
||||
<td className="bs-params-cell">
|
||||
{needsBind ? (
|
||||
<span
|
||||
className={
|
||||
!binds.length && !bindOptional
|
||||
? "bs-params-warn"
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
<span className={!binds.length ? "bs-params-warn" : undefined}>
|
||||
{bindHint}
|
||||
</span>
|
||||
) : (
|
||||
|
|
@ -1577,17 +1563,17 @@ export function BizStatePage() {
|
|||
size="sm"
|
||||
variant="ghost"
|
||||
isDisabled={busy}
|
||||
onPress={() => setSelectedVrfs(candidates.map((c) => c.value))}
|
||||
onPress={() => {
|
||||
const allSelected =
|
||||
candidates.length > 0 &&
|
||||
candidates.every((c) => selectedVrfs.includes(c.value));
|
||||
setSelectedVrfs(allSelected ? [] : candidates.map((c) => c.value));
|
||||
}}
|
||||
>
|
||||
{t("bizState.selectAllVrfs")}
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
isDisabled={busy}
|
||||
onPress={() => setSelectedVrfs([])}
|
||||
>
|
||||
{t("bizState.clearVrfs")}
|
||||
{candidates.length > 0 &&
|
||||
candidates.every((c) => selectedVrfs.includes(c.value))
|
||||
? t("bizState.deselectAllVrfs")
|
||||
: t("bizState.selectAllVrfs")}
|
||||
</Button>
|
||||
</div>
|
||||
<div className="bs-bind-list bs-bind-list--modal">
|
||||
|
|
@ -1614,43 +1600,22 @@ export function BizStatePage() {
|
|||
) : null}
|
||||
</Modal.Body>
|
||||
<Modal.Footer>
|
||||
{(() => {
|
||||
const item = (detail?.items || []).find((it: any) => it.id === bindItemId);
|
||||
const prof = profiles.find((p) => p.profile_id === item?.source_profile_id);
|
||||
const bindOptional = (prof?.placeholders || []).every((ph) => ph.required === false);
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="primary"
|
||||
isDisabled={
|
||||
busy || discoverLoading || (!selectedVrfs.length && !bindOptional)
|
||||
}
|
||||
onPress={() => void saveBindings()}
|
||||
>
|
||||
{t("bizState.saveBindings")}
|
||||
</Button>
|
||||
{bindOptional ? (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
isDisabled={busy || discoverLoading}
|
||||
onPress={() => void saveBindings([])}
|
||||
>
|
||||
{t("bizState.allVrfsDefault")}
|
||||
</Button>
|
||||
) : null}
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
isDisabled={discoverLoading}
|
||||
onPress={closeBindModal}
|
||||
>
|
||||
{t("bizState.cancel")}
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
})()}
|
||||
<Button
|
||||
size="sm"
|
||||
variant="primary"
|
||||
isDisabled={busy || discoverLoading || !selectedVrfs.length}
|
||||
onPress={() => void saveBindings()}
|
||||
>
|
||||
{t("bizState.saveBindings")}
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
isDisabled={discoverLoading}
|
||||
onPress={closeBindModal}
|
||||
>
|
||||
{t("bizState.cancel")}
|
||||
</Button>
|
||||
</Modal.Footer>
|
||||
</AppModalShell>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue