Skip to content

Commit b6df884

Browse files
authored
feat(targets): implement create target cidr and ip address (#309)
* fix(workflows): simplify workflow name normalization logic * feat(workflows): update event names for target domain actions and add domain assets discovery workflow * fix(workflows): update default workflow name for consistency * feat(jobs-registry): implement data source mapping for tool categories in job queries * feat(targets): add target type support for DOMAIN and CIDR with validation and migration * feat(targets): implement start discovery page and update target type handling * feat(targets): add support for IP target type with validation and migration * fix(vulnerabilities): correct file path for vulnerability scan configuration * feat(targets): update target service to track total asset services and enhance UI representation * feat(start-discovery): enhance UI by updating target type styling and textarea border color
1 parent 78b1dc7 commit b6df884

File tree

25 files changed

+1555
-601
lines changed

25 files changed

+1555
-601
lines changed

console/src/components/ui/create-target.tsx

Lines changed: 0 additions & 237 deletions
This file was deleted.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* ScanStatusFilter Component
3+
*
4+
* A dropdown select component for filtering targets by scan status
5+
* (pending/in_progress/completed/failed/cancelled/All).
6+
* Used in the targets list page toolbar.
7+
*/
8+
9+
import {
10+
Select,
11+
SelectContent,
12+
SelectItem,
13+
SelectTrigger,
14+
SelectValue,
15+
} from '@/components/ui/select';
16+
import { JobStatus } from '@/services/apis/gen/queries';
17+
18+
/** All option value for filtering */
19+
const ALL_VALUE = 'ALL';
20+
21+
/** Status filter options with display labels and colors matching JobStatusBadge */
22+
const STATUS_OPTIONS = [
23+
{ value: ALL_VALUE, label: 'All statuses', color: 'bg-muted-foreground' },
24+
{ value: JobStatus.pending, label: 'Pending', color: 'bg-yellow-500' },
25+
{ value: JobStatus.in_progress, label: 'In Progress', color: 'bg-purple-500' },
26+
{ value: JobStatus.completed, label: 'Completed', color: 'bg-green-500' },
27+
{ value: JobStatus.failed, label: 'Failed', color: 'bg-red-500' },
28+
{ value: JobStatus.cancelled, label: 'Cancelled', color: 'bg-gray-500' },
29+
] as const;
30+
31+
interface ScanStatusFilterProps {
32+
/** Current selected status value */
33+
value: JobStatus | undefined;
34+
/** Callback when status selection changes */
35+
onValueChange: (value: JobStatus | undefined) => void;
36+
}
37+
38+
/**
39+
* Renders a select dropdown for filtering targets by scan status.
40+
*/
41+
export function ScanStatusFilter({ value, onValueChange }: ScanStatusFilterProps) {
42+
const currentValue = value ?? ALL_VALUE;
43+
44+
const handleChange = (val: string) => {
45+
onValueChange(val === ALL_VALUE ? undefined : (val as JobStatus));
46+
};
47+
48+
return (
49+
<Select value={currentValue} onValueChange={handleChange}>
50+
<SelectTrigger className="border-dashed text-xs py-0 focus:ring-0 focus:ring-offset-0 focus:outline-none">
51+
<SelectValue placeholder="Status" />
52+
</SelectTrigger>
53+
<SelectContent>
54+
{STATUS_OPTIONS.map((option) => (
55+
<SelectItem key={option.value} value={option.value}>
56+
<div className="flex items-center gap-2">
57+
<span className={`size-2 rounded-full ${option.color}`} />
58+
{option.label}
59+
</div>
60+
</SelectItem>
61+
))}
62+
</SelectContent>
63+
</Select>
64+
);
65+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* TargetTypeFilter Component
3+
*
4+
* A dropdown select component for filtering targets by type (DOMAIN/CIDR/IP/All).
5+
* Used in the targets list page toolbar.
6+
*/
7+
8+
import {
9+
Select,
10+
SelectContent,
11+
SelectItem,
12+
SelectTrigger,
13+
SelectValue,
14+
} from '@/components/ui/select';
15+
import { TargetType } from '@/services/apis/gen/queries';
16+
17+
/** All option value for filtering */
18+
const ALL_VALUE = 'ALL';
19+
20+
/** Type filter options with display labels and colors */
21+
const TYPE_OPTIONS = [
22+
{ value: ALL_VALUE, label: 'All types', color: 'bg-muted-foreground' },
23+
{ value: TargetType.DOMAIN, label: 'DOMAIN', color: 'bg-blue-500' },
24+
{ value: TargetType.CIDR, label: 'CIDR', color: 'bg-green-500' },
25+
{ value: TargetType.IP, label: 'IP', color: 'bg-orange-500' },
26+
] as const;
27+
28+
interface TargetTypeFilterProps {
29+
/** Current selected type value */
30+
value: TargetType | undefined;
31+
/** Callback when type selection changes */
32+
onValueChange: (value: TargetType | undefined) => void;
33+
}
34+
35+
/**
36+
* Renders a select dropdown for filtering targets by type.
37+
*/
38+
export function TargetTypeFilter({ value, onValueChange }: TargetTypeFilterProps) {
39+
const currentValue = value ?? ALL_VALUE;
40+
41+
const handleChange = (val: string) => {
42+
onValueChange(val === ALL_VALUE ? undefined : (val as TargetType));
43+
};
44+
45+
return (
46+
<Select value={currentValue} onValueChange={handleChange}>
47+
<SelectTrigger className="border-dashed text-xs py-0 focus:ring-0 focus:ring-offset-0 focus:outline-none">
48+
<SelectValue placeholder="Type" />
49+
</SelectTrigger>
50+
<SelectContent>
51+
{TYPE_OPTIONS.map((option) => (
52+
<SelectItem key={option.value} value={option.value}>
53+
<div className="flex items-center gap-2">
54+
<span className={`size-2 rounded-full ${option.color}`} />
55+
{option.label}
56+
</div>
57+
</SelectItem>
58+
))}
59+
</SelectContent>
60+
</Select>
61+
);
62+
}

0 commit comments

Comments
 (0)