button shows how many selected

This commit is contained in:
DaKheera47 2026-01-23 13:43:37 +00:00
parent 3652abab3e
commit d7cbf81808
2 changed files with 16 additions and 32 deletions

View File

@ -81,14 +81,15 @@ describe("OrchestratorHeader", () => {
it("uses enabled sources for the all sources action", () => { it("uses enabled sources for the all sources action", () => {
const { props } = renderHeader({ enabledSources: ["gradcracker", "linkedin"] }); const { props } = renderHeader({ enabledSources: ["gradcracker", "linkedin"] });
fireEvent.click(screen.getByRole("menuitem", { name: /All sources/i })); fireEvent.click(screen.getByRole("menuitemcheckbox", { name: /Select all sources/i }));
expect(props.onSetPipelineSources).toHaveBeenCalledWith(["gradcracker", "linkedin"]); expect(props.onSetPipelineSources).toHaveBeenCalledWith(["gradcracker", "linkedin"]);
}); });
it("hides jobspy preset when no jobspy sources are enabled", () => { it("does not show source presets", () => {
renderHeader({ enabledSources: ["gradcracker"] }); renderHeader({ enabledSources: ["gradcracker", "linkedin"] });
expect(screen.queryByRole("menuitem", { name: /Gradcracker only/i })).not.toBeInTheDocument();
expect(screen.queryByRole("menuitem", { name: /Indeed \+ LinkedIn only/i })).not.toBeInTheDocument(); expect(screen.queryByRole("menuitem", { name: /Indeed \+ LinkedIn only/i })).not.toBeInTheDocument();
}); });
}); });

View File

@ -18,7 +18,6 @@ import {
DropdownMenu, DropdownMenu,
DropdownMenuCheckboxItem, DropdownMenuCheckboxItem,
DropdownMenuContent, DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel, DropdownMenuLabel,
DropdownMenuSeparator, DropdownMenuSeparator,
DropdownMenuTrigger, DropdownMenuTrigger,
@ -68,7 +67,8 @@ export const OrchestratorHeader: React.FC<OrchestratorHeaderProps> = ({
const location = useLocation(); const location = useLocation();
const navigate = useNavigate(); const navigate = useNavigate();
const visibleSources = orderedSources.filter((source) => enabledSources.includes(source)); const visibleSources = orderedSources.filter((source) => enabledSources.includes(source));
const enabledJobSpySources = visibleSources.filter((source) => source === "indeed" || source === "linkedin"); const allSourcesSelected =
visibleSources.length > 0 && visibleSources.every((source) => pipelineSources.includes(source));
return ( return (
<header className="sticky top-0 z-40 border-b bg-background/80 backdrop-blur supports-[backdrop-filter]:bg-background/60"> <header className="sticky top-0 z-40 border-b bg-background/80 backdrop-blur supports-[backdrop-filter]:bg-background/60">
@ -148,7 +148,9 @@ export const OrchestratorHeader: React.FC<OrchestratorHeaderProps> = ({
className="gap-2" className="gap-2"
> >
{isPipelineRunning ? <Loader2 className="h-4 w-4 animate-spin" /> : <Play className="h-4 w-4" />} {isPipelineRunning ? <Loader2 className="h-4 w-4 animate-spin" /> : <Play className="h-4 w-4" />}
<span className="hidden sm:inline">{isPipelineRunning ? "Running" : "Run pipeline"}</span> <span className="hidden sm:inline">
{isPipelineRunning ? `Running (${pipelineSources.length})` : `Run pipeline (${pipelineSources.length})`}
</span>
</Button> </Button>
<DropdownMenu> <DropdownMenu>
@ -177,34 +179,15 @@ export const OrchestratorHeader: React.FC<OrchestratorHeaderProps> = ({
</DropdownMenuCheckboxItem> </DropdownMenuCheckboxItem>
))} ))}
<DropdownMenuSeparator /> <DropdownMenuSeparator />
<DropdownMenuItem <DropdownMenuCheckboxItem
onSelect={(event) => { checked={allSourcesSelected}
event.preventDefault(); onCheckedChange={(checked) => {
onSetPipelineSources(visibleSources); onSetPipelineSources(checked ? visibleSources : visibleSources.slice(0, 1));
}} }}
onSelect={(event) => event.preventDefault()}
> >
All sources Select all sources
</DropdownMenuItem> </DropdownMenuCheckboxItem>
{visibleSources.includes("gradcracker") && (
<DropdownMenuItem
onSelect={(event) => {
event.preventDefault();
onSetPipelineSources(["gradcracker"]);
}}
>
Gradcracker only
</DropdownMenuItem>
)}
{enabledJobSpySources.length > 0 && (
<DropdownMenuItem
onSelect={(event) => {
event.preventDefault();
onSetPipelineSources(enabledJobSpySources);
}}
>
Indeed + LinkedIn only
</DropdownMenuItem>
)}
</DropdownMenuContent> </DropdownMenuContent>
</DropdownMenu> </DropdownMenu>
</div> </div>