Skip to content

Commit

Permalink
[frontend] Fix warnings and fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumejparis committed May 21, 2024
1 parent 7678f36 commit 31a6418
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ const AssetGroupForm: React.FC<Props> = ({
</Tooltip>
</div>
<FilterField
labelId="dynamic-asset-filter"
clazz="Endpoint"
initialValue={value}
onChange={onChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const InjectList: FunctionComponent<Props> = ({
value: (injectDto: InjectResultDTO) => injectDto.inject_title,
},
{
field: 'inject_status',
field: 'inject_status.tracking_sent_date',
label: 'Execution Date',
isSortable: true,
value: (injectDto: InjectResultDTO) => fldt(injectDto.inject_status?.tracking_sent_date),
Expand All @@ -118,7 +118,7 @@ const InjectList: FunctionComponent<Props> = ({
},
},
{
field: 'inject_status',
field: 'inject_status.status_name',
label: 'Status',
isSortable: true,
value: (injectDto: InjectResultDTO) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const AtomicTesting = () => {
</Typography>
<div style={{ display: 'flex' }}>
{injectResultDto.inject_injector_contract.injector_contract_platforms?.map((platform: string) => (
<div key="platform" style={{ display: 'flex', marginRight: 15 }}>
<div key={platform} style={{ display: 'flex', marginRight: 15 }}>
<PlatformIcon width={20} platform={platform} marginRight={5} />
{platform}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useContext, useState } from 'react';
import { Alert, Button, Dialog, DialogActions, DialogContent, DialogContentText, Tooltip, Typography } from '@mui/material';
import { PlayArrowOutlined, SettingsOutlined } from '@mui/icons-material';
import { PlayArrowOutlined } from '@mui/icons-material';
import { makeStyles } from '@mui/styles';
import { fetchInjectResultDto, tryAtomicTesting } from '../../../../actions/atomic_testings/atomic-testing-actions';
import AtomicTestingPopover from './AtomicTestingPopover';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ const TargetResultsDetailFlow: FunctionComponent<Props> = ({
})));
setEdges([...Array(steps.length - 1)].map((_, i) => ({
id: `result-${i}->result-${i + 1}`,
type: 'result',
source: `result-${i}`,
target: `result-${i + 1}`,
label: i === 0 ? nsdt(lastExecutionStartDate) : nsdt(lastExecutionEndDate),
Expand Down Expand Up @@ -297,7 +296,6 @@ const TargetResultsDetailFlow: FunctionComponent<Props> = ({
})));
setEdges([...Array(mergedSteps.length - 1)].map((_, i) => ({
id: `result-${i}->result-${i + 1}`,
type: 'result',
source: `result-${i}`,
target: `result-${i + 1}`,
label: i === 0 ? nsdt(lastExecutionStartDate) : nsdt(lastExecutionEndDate),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ class InjectDefinition extends Component {
.map((f) => f.key)
.includes('assets');
const assets = assetIds
.map((a) => ({ ...endpointsMap[a], type: 'static' }))
.map((a) => ({ asset_id: a, ...endpointsMap[a], type: 'static' }))
.filter((a) => a !== undefined);
// -- ASSET GROUPS --
const hasAssetGroups = injectorContract.fields
Expand Down
8 changes: 4 additions & 4 deletions openbas-front/src/admin/components/common/injects/Injects.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ const Injects = (props) => {
style={{ float: 'right' }}
aria-label="Change view mode"
>
<>
<div>
{sortedInjects.length > 0 ? (
<CSVLink
data={exportData(
Expand Down Expand Up @@ -263,7 +263,7 @@ const Injects = (props) => {
<FileDownloadOutlined fontSize="small" color="primary" />
</ToggleButton>
)}
</>
</div>
<Tooltip title={t('List view')}>
<ToggleButton
value='list'
Expand All @@ -284,7 +284,7 @@ const Injects = (props) => {
</Tooltip>
</ToggleButtonGroup>
) : (
<>
<div>
{sortedInjects.length > 0 ? (
<CSVLink
data={exportData(
Expand Down Expand Up @@ -315,7 +315,7 @@ const Injects = (props) => {
<FileDownloadOutlined />
</IconButton>
)}
</>
</div>
)}
</div>
<div className="clearfix" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { makeStyles } from '@mui/styles';
import { Chip, List, ListItem, ListItemIcon, ListItemSecondaryAction, ListItemText, Tooltip } from '@mui/material';
import { useDispatch } from 'react-redux';
import { DescriptionOutlined, RowingOutlined } from '@mui/icons-material';
import { Link } from 'react-router-dom';
import { useNavigate } from 'react-router-dom';
import { useFormatter } from '../../../../components/i18n';
import { searchDocuments } from '../../../../actions/Document';
import { fetchTags } from '../../../../actions/Tag';
Expand Down Expand Up @@ -85,6 +85,7 @@ const Documents = () => {
// Standard hooks
const classes = useStyles();
const dispatch = useDispatch();
const navigate = useNavigate();
const { t } = useFormatter();
const { exercisesMap, scenariosMap, userAdmin } = useHelper((helper) => ({
exercisesMap: helper.getExercisesMap(),
Expand Down Expand Up @@ -206,9 +207,15 @@ const Documents = () => {
classes={{ root: classes.exercise }}
variant="outlined"
label={exercise.exercise_name}
component={Link}
clickable={true}
to={`/admin/exercises/${exercise.exercise_id}`}
onClick={
(event) => {
// prevent parent link from triggering
event.stopPropagation();
event.preventDefault();
navigate(`/admin/exercises/${exercise.exercise_id}`);
}
}
/>
</Tooltip>
);
Expand All @@ -231,9 +238,15 @@ const Documents = () => {
classes={{ root: classes.scenario }}
variant="outlined"
label={scenario.scenario_name}
component={Link}
clickable={true}
to={`/admin/scenarios/${scenario.scenario_id}`}
onClick={
(event) => {
// prevent parent link from triggering
event.stopPropagation();
event.preventDefault();
navigate(`/admin/scenarios/${scenario.scenario_id}`);
}
}
/>
</Tooltip>
);
Expand Down
3 changes: 2 additions & 1 deletion openbas-front/src/admin/components/scenarios/Scenarios.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ const Scenarios = () => {
}, [scenarios]);

const categoryCard = (category: string, count: number) => (
<Card
<Card key={category}
classes={{ root: classes.card }} variant="outlined"
onClick={() => handleOnClick(category)}
className={classNames({ [classes.cardSelected]: hasCategory(category) })}
Expand Down Expand Up @@ -194,6 +194,7 @@ const Scenarios = () => {
<Breadcrumbs variant="list" elements={[{ label: t('Scenarios'), current: true }]} />
<div style={{ display: 'flex', marginBottom: 30 }}>
<Card
key="all"
classes={{ root: classes.card }} variant="outlined"
onClick={() => handleOnClick()}
className={classNames({ [classes.cardSelected]: noCategory() })}
Expand Down
18 changes: 10 additions & 8 deletions openbas-front/src/components/common/filter/FilterChip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,16 @@ const FilterChip: FunctionComponent<Props> = ({
ref={chipRef}
/>
</Tooltip>
<FilterChipPopover
filter={filter}
helpers={helpers}
open={open}
onClose={handleClose}
anchorEl={chipRef.current || undefined}
propertySchema={propertySchema}
/>
{chipRef?.current
&& <FilterChipPopover
filter={filter}
helpers={helpers}
open={open}
onClose={handleClose}
anchorEl={chipRef.current}
propertySchema={propertySchema}
/>
}
</>
);
};
Expand Down
4 changes: 2 additions & 2 deletions openbas-front/src/components/common/filter/FilterChips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const FilterChips: FunctionComponent<Props> = ({
return (<></>);
}
return (
<>
<div key={filter.key}>
{idx !== 0
&& <div
onClick={handleSwitchMode}
Expand All @@ -74,7 +74,7 @@ const FilterChips: FunctionComponent<Props> = ({
helpers={helpers}
propertySchema={property}
/>
</>
</div>
);
})
}
Expand Down
4 changes: 0 additions & 4 deletions openbas-front/src/components/common/filter/FilterField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@ const useStyles = makeStyles(() => ({
type OptionPropertySchema = Option & { operator: Filter['operator'] };

interface Props {
labelId: string;
clazz: string;
initialValue?: FilterGroup;
onChange: (value: FilterGroup) => void;
style: CSSProperties;
}

const FilterField: FunctionComponent<Props> = ({
labelId,
clazz,
initialValue,
onChange,
Expand Down Expand Up @@ -69,8 +67,6 @@ const FilterField: FunctionComponent<Props> = ({
<>
<div className={classes.container}>
<MuiAutocomplete
// @ts-expect-error: labelId
labelId={labelId}
options={computeOptions()}
sx={{ width: 200 }}
value={null}
Expand Down

0 comments on commit 31a6418

Please sign in to comment.