fix: keep previous run checkbox visible and fall back to main worker

This commit is contained in:
jialin
2026-04-28 14:41:36 +08:00
committed by jialin
parent 52211cd4ea
commit e7aac14ef1
@@ -131,16 +131,34 @@ const ViewLogsModal: React.FC<ViewModalProps> = (props) => {
}; };
const showCascader = const showCascader =
countOptions?.some((option) => option.children!?.length >= 2) || countOptions?.some((option) => option.children?.length >= 2) ||
countOptions?.length > 1; countOptions?.length > 1;
const handleOnChecked = (e: any) => { const handleOnChecked = (e: any) => {
const checked = e.target.checked; const checked = e.target.checked;
const selectItem = currentWorkerCountList.find(
(item) => item.previous === checked
);
setShowPrevious(checked); setShowPrevious(checked);
handleOnChange(selectItem);
if (checked) {
const currentPrev = currentWorkerCountList.find((item) => item.previous);
if (currentPrev) {
handleOnChange(currentPrev);
return;
}
const mainOptionWithPrev = countOptions?.find(
(option) =>
option.isMain && option.children?.some((child) => child.previous)
);
const prevChild = mainOptionWithPrev?.children?.find(
(child) => child.previous
);
if (prevChild) {
handleOnChange(prevChild);
}
return;
}
const currentItem = currentWorkerCountList.find((item) => !item.previous);
handleOnChange(currentItem);
}; };
const optionRender = (option: any) => { const optionRender = (option: any) => {
@@ -177,7 +195,6 @@ const ViewLogsModal: React.FC<ViewModalProps> = (props) => {
marginRight: 8 marginRight: 8
}} }}
> >
{currentWorkerCountList.length > 1 && (
<Checkbox onChange={handleOnChecked} checked={showPrevious}> <Checkbox onChange={handleOnChecked} checked={showPrevious}>
<Tooltip <Tooltip
title={ title={
@@ -202,7 +219,6 @@ const ViewLogsModal: React.FC<ViewModalProps> = (props) => {
<QuestionCircleOutlined style={{ marginLeft: 4 }} /> <QuestionCircleOutlined style={{ marginLeft: 4 }} />
</Tooltip> </Tooltip>
</Checkbox> </Checkbox>
)}
<BaseSelect <BaseSelect
prefix={ prefix={
<span <span