forked from longtao.wu/droboticflow
🐛 Make review/acceptance random-claim entries always usable (all-tabs, all-projects) and rename to 随机领取
This commit is contained in:
parent
bc58adb1a6
commit
fc52ae9e3d
@ -1767,6 +1767,16 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
|
||||
() => poolItems.filter((item) => matchesPoolFilters(item, taskPoolView)),
|
||||
[poolItems, taskPoolView, matchesPoolFilters],
|
||||
);
|
||||
// Random claim draws from the available pool regardless of the active pool
|
||||
// tab, so the entry stays usable from "mine"/"reviewed" views too.
|
||||
const availableClaimableItems = useMemo(
|
||||
() => humanPools.available.filter((item) => humanItemVisibleInMode(item, workspaceMode, "available")),
|
||||
[humanPools.available, workspaceMode],
|
||||
);
|
||||
const claimablePrepackageAcceptanceItems = useMemo(
|
||||
() => availableClaimableItems.filter((item) => item.currentStageId === "prepackage_acceptance"),
|
||||
[availableClaimableItems],
|
||||
);
|
||||
const prepackageAcceptanceItems = useMemo(
|
||||
() => visiblePoolItems.filter((item) => item.currentStageId === "prepackage_acceptance"),
|
||||
[visiblePoolItems],
|
||||
@ -3967,8 +3977,8 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
|
||||
};
|
||||
|
||||
const randomClaimAcceptanceTask = async () => {
|
||||
if (randomClaimBusy || saving || taskPoolView === "reviewed") return;
|
||||
const candidates = prepackageAcceptanceItems.filter(
|
||||
if (randomClaimBusy || saving) return;
|
||||
const candidates = claimablePrepackageAcceptanceItems.filter(
|
||||
(item) =>
|
||||
!item.assignedUserId && ["ready", "submitted", "rework"].includes(item.status) && canCurrentUserClaimItem(item),
|
||||
);
|
||||
@ -3995,15 +4005,15 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
|
||||
};
|
||||
|
||||
const randomReviewClaimTask = async () => {
|
||||
if (isManager || !reviewOnly || acceptanceWorkspace || saving || loading || !projectId) return;
|
||||
if (isManager || !reviewOnly || acceptanceWorkspace || saving || loading) return;
|
||||
if (!reviewDraftGuardRef.current()) return;
|
||||
const candidates = visiblePoolItems.filter(
|
||||
const candidates = availableClaimableItems.filter(
|
||||
(item) =>
|
||||
!item.assignedUserId && ["ready", "rework", "submitted"].includes(item.status) && canCurrentUserClaimItem(item),
|
||||
);
|
||||
const candidate = candidates[Math.floor(Math.random() * candidates.length)];
|
||||
if (!candidate) {
|
||||
setRandomClaimNotice("当前项目暂无可领取的审核任务。");
|
||||
setRandomClaimNotice("当前暂无可领取的审核任务。");
|
||||
return;
|
||||
}
|
||||
setRandomClaimBusy(true);
|
||||
@ -4015,7 +4025,8 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
|
||||
setSelectedAnnotationTaskId(claimed.legacyTaskId || "");
|
||||
setExpandedDeliveryPackageId("");
|
||||
const next = new URLSearchParams(searchParams);
|
||||
next.set("projectId", projectId);
|
||||
const claimProjectId = claimed.projectId || candidate.projectId || projectId;
|
||||
if (claimProjectId) next.set("projectId", claimProjectId);
|
||||
next.set("taskId", claimed.legacyTaskId || "");
|
||||
next.delete("sliceId");
|
||||
next.delete("eventId");
|
||||
@ -5433,14 +5444,14 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
|
||||
)}
|
||||
{reviewOnly && !isManager && !acceptanceWorkspace && (
|
||||
<div className="mt-3 space-y-2" data-testid="review-random-claim">
|
||||
<p className="text-xs text-slate-500">从当前项目可领取池随机领取一条并直接进入审核。</p>
|
||||
<p className="text-xs text-slate-500">从可领取池随机领取一条并直接进入审核,支持全部项目。</p>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => void randomReviewClaimTask()}
|
||||
disabled={!projectId || saving || loading || randomClaimBusy || taskPoolView === "reviewed"}
|
||||
disabled={saving || loading || randomClaimBusy}
|
||||
className="w-full rounded-lg bg-orange-500 px-3 py-2 font-semibold text-white disabled:opacity-50"
|
||||
>
|
||||
{randomClaimBusy ? "正在领取…" : "随机领取并开始审核"}
|
||||
{randomClaimBusy ? "正在领取…" : "随机领取"}
|
||||
</button>
|
||||
{randomClaimNotice && (
|
||||
<p role="status" className="break-words text-xs text-slate-600">
|
||||
@ -5449,16 +5460,16 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{reviewOnly && workspaceMode === "acceptance" && taskPoolView === "available" && (
|
||||
{reviewOnly && workspaceMode === "acceptance" && !isManager && (
|
||||
<div className="mt-3 space-y-2" data-testid="acceptance-random-claim">
|
||||
<p className="text-xs text-slate-500">从当前项目可验收任务中随机领取一条。</p>
|
||||
<p className="text-xs text-slate-500">随机领取一条最终验收任务,支持全部项目。</p>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => void randomClaimAcceptanceTask()}
|
||||
disabled={!projectId || loading || saving || randomClaimBusy || Boolean(projectLoadError)}
|
||||
disabled={loading || saving || randomClaimBusy || Boolean(projectLoadError)}
|
||||
className="w-full rounded-lg bg-orange-500 px-3 py-2 font-semibold text-white disabled:opacity-50"
|
||||
>
|
||||
{randomClaimBusy ? "正在领取…" : "随机领取验收任务"}
|
||||
{randomClaimBusy ? "正在领取…" : "随机领取"}
|
||||
</button>
|
||||
{randomClaimNotice && (
|
||||
<p role="status" className="break-words text-xs text-slate-600">
|
||||
|
||||
@ -16,7 +16,8 @@ test("annotation workbench separates available, mine, and administrator task poo
|
||||
assert.match(source, /我的任务/);
|
||||
assert.match(source, /全部任务/);
|
||||
assert.match(source, /data-testid="acceptance-random-claim"/);
|
||||
assert.match(source, /随机领取验收任务/);
|
||||
assert.match(source, /\{randomClaimBusy \? "正在领取…" : "随机领取"\}/);
|
||||
assert.match(source, /claimablePrepackageAcceptanceItems/);
|
||||
assert.match(source, /管理员任务改派/);
|
||||
assert.match(source, /humanLoopApi\.assign/);
|
||||
assert.match(source, /problemSliceIds/);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user