Skip to content

Commit

Permalink
Resolve PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
johanah29 committed Sep 6, 2024
1 parent 4e4ea76 commit 2ce3117
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 53 deletions.
4 changes: 2 additions & 2 deletions openbas-dev/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ services:
container_name: openbas-test-pgsql
image: postgres:16-alpine
environment:
POSTGRES_USER: openbas
POSTGRES_PASSWORD: openbas
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: openbas
ports:
- "5433:5432"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const InjectTestPopover: FunctionComponent<Props> = ({
const [anchorEl, setAnchorEl] = useState<Element | null>(null);
const [openDelete, setOpenDelete] = useState(false);
const [openTest, setOpenTest] = useState(false);
const [_injectTestResult, setInjectTestResult] = useState<InjectTestStatus | null>(null);

const handlePopoverOpen = (event: React.MouseEvent<HTMLButtonElement>) => {
event.stopPropagation();
Expand Down Expand Up @@ -56,13 +55,12 @@ const InjectTestPopover: FunctionComponent<Props> = ({

const handleCloseTest = () => {
setOpenTest(false);
setInjectTestResult(null);
};

const submitTest = () => {
testInject(injectTestStatus.inject_id!).then((result: { data: InjectTestStatus }) => {
onTest?.(result.data);
MESSAGING$.notifySuccess(`Test for ${injectTestStatus.inject_title} has been sent`);
MESSAGING$.notifySuccess(t(`Test for ${injectTestStatus.inject_title} has been sent`));
return result;
});
handleCloseTest();
Expand Down
49 changes: 3 additions & 46 deletions openbas-front/src/admin/components/injects/InjectTestReplayAll.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { FunctionComponent, useEffect, useState } from 'react';
import { Alert, Dialog, IconButton, SnackbarCloseReason, Tooltip } from '@mui/material';
import React, { FunctionComponent, useState } from 'react';
import { IconButton, Tooltip } from '@mui/material';
import { ForwardToInbox } from '@mui/icons-material';
import { useFormatter } from '../../../components/i18n';
import type { InjectTestStatus } from '../../../utils/api-types';
Expand All @@ -20,24 +20,6 @@ const ImportUploaderMapper: FunctionComponent<Props> = ({
const { t } = useFormatter();

const [openAllTest, setOpenAllTest] = useState(false);
const [openDialog, setOpenDialog] = React.useState<boolean>(false);
const handleCloseDialog = (
event?: React.SyntheticEvent | Event,
reason?: SnackbarCloseReason,
) => {
if (reason === 'clickaway') {
return;
}
setOpenDialog(false);
};

useEffect(() => {
if (openDialog) {
setTimeout(() => {
handleCloseDialog();
}, 6000);
}
}, [openDialog]);

const handleOpenAllTest = () => {
setOpenAllTest(true);
Expand All @@ -50,39 +32,14 @@ const ImportUploaderMapper: FunctionComponent<Props> = ({
const handleSubmitAllTest = () => {
bulkTestInjects(injectIds!).then((result: { data: InjectTestStatus[] }) => {
onTest?.(result.data);
MESSAGING$.notifySuccess(`${injectIds?.length} test(s) sent`);
MESSAGING$.notifySuccess(t(`${injectIds?.length} test(s) sent`));
return result;
});
handleCloseAllTest();
};

return (
<>
<Dialog open={openDialog}
slotProps={{
backdrop: {
sx: {
backgroundColor: 'transparent',
},
},
}}
PaperProps={{
sx: {
position: 'fixed',
top: '20px',
left: '660px',
margin: 0,
},
}}
>
<Alert
onClose={handleCloseDialog}
severity="success"
sx={{ width: '100%' }}
>
{t('Tests were sent')}
</Alert>
</Dialog>
<Tooltip title={t('Replay all the tests')}>
<span>
<IconButton
Expand Down
4 changes: 2 additions & 2 deletions openbas-front/src/components/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ class Message extends Component {
>
{error ? (
<Alert severity="error" onClose={this.handleCloseMessage.bind(this)}>
{text.length > 0 && (text)}
{text.length > 0 && text}
</Alert>
) : (
<Alert
severity="success"
onClose={this.handleCloseMessage.bind(this)}
>
{text.length > 0 && (text)}
{text.length > 0 && text}
</Alert>
)}
</Snackbar>
Expand Down

0 comments on commit 2ce3117

Please sign in to comment.