Skip to content

Commit d5d77b1

Browse files
committed
Create Scan Functionality Removed From Admin Tools
1 parent f433607 commit d5d77b1

File tree

1 file changed

+4
-51
lines changed

1 file changed

+4
-51
lines changed

frontend/src/pages/Scans/ScansView.tsx

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ import { useAuthContext } from 'context';
1919
// @ts-ignore:next-line
2020
import { formatDistanceToNow, parseISO } from 'date-fns';
2121
// import { Link } from 'react-router-dom';
22-
import { setFrequency } from 'pages/Scan/Scan';
23-
import { ScanForm, ScanFormValues } from 'components/ScanForm';
2422
import { DataGrid, GridColDef, GridRenderCellParams } from '@mui/x-data-grid';
2523
import {
2624
Alert,
@@ -64,28 +62,17 @@ const ScansView: React.FC = () => {
6462
const [selectedId, setSelectedId] = useState<string>('');
6563
const [selectedName, setSelectedName] = useState<string>('');
6664
const [scans, setScans] = useState<Scan[]>([]);
67-
const [organizationOptions, setOrganizationOptions] = useState<
65+
const [_organizationOptions, setOrganizationOptions] = useState<
6866
OrganizationOption[]
6967
>([]);
70-
const [tags, setTags] = useState<OrganizationTag[]>([]);
68+
void _organizationOptions; // Suppress unused variable warning
69+
const [_tags, setTags] = useState<OrganizationTag[]>([]);
70+
void _tags; // Suppress unused variable warning
7171
const [scanSchema, setScanSchema] = useState<ScanSchema>({});
7272
const deleteModalRef = useRef<ModalRef>(null);
7373
const [errors, setErrors] = useState<Errors>({});
7474
const [open, setOpen] = useState(false);
7575

76-
const [values] = useState<ScanFormValues>({
77-
name: 'censys',
78-
arguments: '{}',
79-
organizations: [],
80-
frequency: 1,
81-
frequencyUnit: 'minute',
82-
is_granular: false,
83-
is_user_modifiable: false,
84-
is_single_scan: false,
85-
tags: [],
86-
concurrent_tasks: 1
87-
});
88-
8976
const fetchScans = useCallback(async () => {
9077
try {
9178
const { scans, organizations, schema } = await apiGet<{
@@ -120,30 +107,6 @@ const ScansView: React.FC = () => {
120107
}
121108
};
122109

123-
const onSubmit = async (body: ScanFormValues) => {
124-
try {
125-
// For now, parse the arguments as JSON. We'll want to add a GUI for this in the future
126-
body.arguments = JSON.parse(body.arguments);
127-
setFrequency(body);
128-
129-
const scan = await apiPost('/scans', {
130-
body: {
131-
...body,
132-
organizations: body.organizations
133-
? body.organizations.map((e) => e.value)
134-
: [],
135-
tags: body.tags ? body.tags.map((e) => ({ id: e.value })) : []
136-
}
137-
});
138-
setScans(scans.concat(scan));
139-
} catch (e: any) {
140-
setErrors({
141-
global: e.message ?? e.toString()
142-
});
143-
console.log(e);
144-
}
145-
};
146-
147110
const invokeScheduler = async () => {
148111
setErrors({ ...errors, scheduler: '' });
149112
try {
@@ -385,16 +348,6 @@ const ScansView: React.FC = () => {
385348
Manually run scheduler
386349
</Button>
387350
{errors.scheduler && <p className={classes.error}>{errors.scheduler}</p>}
388-
<h2>Add a scan</h2>
389-
{errors.global && <p className={classes.error}>{errors.global}</p>}
390-
<ScanForm
391-
organizationOption={organizationOptions}
392-
tags={tags}
393-
propValues={values}
394-
onSubmit={onSubmit}
395-
type="create"
396-
scanSchema={scanSchema}
397-
></ScanForm>
398351
{/* To-Do: Undefined props are needed to avoid errors. This Modal needs to
399352
be replaced with a MUI Dialog. */}
400353
<Modal

0 commit comments

Comments
 (0)