From e760cc059b500f8775c36b17087ba30a446d0f36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Tue, 30 Apr 2024 14:35:19 +0200 Subject: [PATCH] Update and improve layout of alert dialog --- .../pages/alerts/alembavfiremethodpart.jsx | 45 ++-- src/web/pages/alerts/condition.jsx | 5 +- .../pages/alerts/contentcomposerdialog.jsx | 96 +++----- src/web/pages/alerts/dialog.jsx | 211 ++++++++--------- src/web/pages/alerts/emailmethodpart.jsx | 216 +++++++++--------- src/web/pages/alerts/event.jsx | 5 +- .../filtercountchangedconditionpart.jsx | 12 +- .../alerts/filtercountleastconditionpart.jsx | 12 +- src/web/pages/alerts/httpmethodpart.jsx | 5 +- src/web/pages/alerts/method.jsx | 9 +- src/web/pages/alerts/scpmethodpart.jsx | 43 ++-- src/web/pages/alerts/secinfoeventpart.jsx | 119 +++++----- src/web/pages/alerts/sendmethodpart.jsx | 44 ++-- .../alerts/severitychangedconditionpart.jsx | 12 +- .../alerts/severityleastconditionpart.jsx | 12 +- src/web/pages/alerts/smbmethodpart.jsx | 56 ++--- src/web/pages/alerts/snmpmethodpart.jsx | 14 +- src/web/pages/alerts/sourcefiremethodpart.jsx | 5 +- src/web/pages/alerts/starttaskmethodpart.jsx | 27 ++- src/web/pages/alerts/taskeventpart.jsx | 96 ++++---- src/web/pages/alerts/ticketeventpart.jsx | 59 ++--- .../pages/alerts/tippingpointmethodpart.jsx | 42 ++-- src/web/pages/alerts/verinicemethodpart.jsx | 44 ++-- 23 files changed, 570 insertions(+), 619 deletions(-) diff --git a/src/web/pages/alerts/alembavfiremethodpart.jsx b/src/web/pages/alerts/alembavfiremethodpart.jsx index 261e1b95f3..8d13fb7ad5 100644 --- a/src/web/pages/alerts/alembavfiremethodpart.jsx +++ b/src/web/pages/alerts/alembavfiremethodpart.jsx @@ -17,13 +17,8 @@ */ import React from 'react'; -import _ from 'gmp/locale'; - import {USERNAME_PASSWORD_CREDENTIAL_TYPE} from 'gmp/models/credential'; -import Divider from 'web/components/layout/divider'; -import Layout from 'web/components/layout/layout'; - import PropTypes from 'web/utils/proptypes'; import {renderSelectItems} from 'web/utils/render'; import withPrefix from 'web/utils/withPrefix'; @@ -39,6 +34,8 @@ import NewIcon from 'web/components/icon/newicon'; import {VFIRE_CALL_DESCRIPTION} from 'web/pages/alerts/dialog'; +import useTranslation from 'web/hooks/useTranslation'; + const VFIRE_CREDENTIAL_TYPES = [USERNAME_PASSWORD_CREDENTIAL_TYPE]; const AlembaVfireMethodPart = ({ @@ -64,8 +61,9 @@ const AlembaVfireMethodPart = ({ credentials = credentials.filter( cred => cred.credential_type === USERNAME_PASSWORD_CREDENTIAL_TYPE, ); + const [_] = useTranslation(); return ( - + <> - - - + - + - + ); }; diff --git a/src/web/pages/alerts/condition.jsx b/src/web/pages/alerts/condition.jsx index 9fa830195b..dbf431302b 100644 --- a/src/web/pages/alerts/condition.jsx +++ b/src/web/pages/alerts/condition.jsx @@ -15,8 +15,6 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import _ from 'gmp/locale'; - import {isDefined} from 'gmp/utils/identity'; import {parseInt} from 'gmp/parser'; @@ -33,7 +31,10 @@ import { import PropTypes from 'web/utils/proptypes'; +import useTranslation from 'web/hooks/useTranslation'; + const Condition = ({condition = {}, event}) => { + const [_] = useTranslation(); if (!isDefined(condition.type) || !isDefined(condition.data)) { return null; } diff --git a/src/web/pages/alerts/contentcomposerdialog.jsx b/src/web/pages/alerts/contentcomposerdialog.jsx index 13e0521193..63306e204f 100644 --- a/src/web/pages/alerts/contentcomposerdialog.jsx +++ b/src/web/pages/alerts/contentcomposerdialog.jsx @@ -18,10 +18,6 @@ import React from 'react'; -import styled from 'styled-components'; - -import _ from 'gmp/locale'; - import {NO_VALUE, YES_VALUE} from 'gmp/parser'; import {isDefined} from 'gmp/utils/identity'; @@ -38,12 +34,7 @@ import CheckBox from 'web/components/form/checkbox'; import FormGroup from 'web/components/form/formgroup'; import Select from 'web/components/form/select'; -import Layout from 'web/components/layout/layout'; -import Divider from 'web/components/layout/divider'; - -const StyledDiv = styled.div` - text-align: end; -`; +import useTranslation from 'web/hooks/useTranslation'; const ContentComposerDialog = ({ filterId = UNSET_VALUE, @@ -57,6 +48,7 @@ const ContentComposerDialog = ({ onSave, onChange, }) => { + const [_] = useTranslation(); const filter = filterId === UNSET_VALUE ? undefined : filters.find(f => f.id === filterId); @@ -76,54 +68,42 @@ const ContentComposerDialog = ({ onClose={onClose} onSave={onSave} > - {({values, onValueChange}) => ( - - - + + + + ); }; diff --git a/src/web/pages/alerts/dialog.jsx b/src/web/pages/alerts/dialog.jsx index db4e3514c5..5701b320ef 100644 --- a/src/web/pages/alerts/dialog.jsx +++ b/src/web/pages/alerts/dialog.jsx @@ -62,7 +62,7 @@ import YesNoRadio from 'web/components/form/yesnoradio'; import ReportIcon from 'web/components/icon/reporticon'; import Divider from 'web/components/layout/divider'; -import Layout from 'web/components/layout/layout'; +import Row from 'web/components/layout/row'; import {UNSET_VALUE} from 'web/utils/render'; import withCapabilities from 'web/utils/withCapabilities'; @@ -507,13 +507,12 @@ class AlertDialog extends React.Component { > {({values, onValueChange}) => { return ( - + <> @@ -523,92 +522,88 @@ class AlertDialog extends React.Component { name="comment" value={values.comment} grow="1" - size="30" onChange={onValueChange} /> - - - - this.handleEventChange(value, onValueChange) - } + + + this.handleEventChange(value, onValueChange) + } + onChange={onValueChange} + /> + + + this.handleEventChange(value, onValueChange) + } + onChange={onValueChange} + /> + + + this.handleEventChange(value, onValueChange) + } + /> + + + + + + {taskEvent && ( + + )} - - this.handleEventChange(value, onValueChange) - } + {taskEvent && ( + - - this.handleEventChange(value, onValueChange) - } + )} + + {(secinfoEvent || taskEvent) && ( + - - - - - - - - {taskEvent && ( - - )} - - {taskEvent && ( - - )} - - {(secinfoEvent || taskEvent) && ( - - )} - - {taskEvent && ( - - )} - + )} {secinfoEvent && ( @@ -632,46 +627,42 @@ class AlertDialog extends React.Component { )} {taskEvent && ( - - + + + + + + - - - - - - - - + )} @@ -862,7 +853,7 @@ class AlertDialog extends React.Component { onChange={onValueChange} /> - + ); }} diff --git a/src/web/pages/alerts/emailmethodpart.jsx b/src/web/pages/alerts/emailmethodpart.jsx index 9c03906bcd..1d8b6cda94 100644 --- a/src/web/pages/alerts/emailmethodpart.jsx +++ b/src/web/pages/alerts/emailmethodpart.jsx @@ -18,8 +18,6 @@ import React from 'react'; -import _ from 'gmp/locale'; - import { isTaskEvent, isSecinfoEvent, @@ -40,18 +38,16 @@ import Radio from 'web/components/form/radio'; import NewIcon from 'web/components/icon/newicon'; -import Divider from 'web/components/layout/divider'; -import IconDivider from 'web/components/layout/icondivider'; -import Layout from 'web/components/layout/layout'; +import Row from 'web/components/layout/row'; -import compose from 'web/utils/compose'; import PropTypes from 'web/utils/proptypes'; import {renderSelectItems, UNSET_VALUE} from 'web/utils/render'; -import withCapabilities from 'web/utils/withCapabilities'; import withPrefix from 'web/utils/withPrefix'; +import useTranslation from 'web/hooks/useTranslation'; +import useCapabilities from 'web/utils/useCapabilities'; + const EmailMethodPart = ({ - capabilities, credentials = [], fromAddress, event, @@ -69,6 +65,8 @@ const EmailMethodPart = ({ onCredentialChange, onNewCredentialClick, }) => { + const [_] = useTranslation(); + const capabilities = useCapabilities(); const taskEvent = isTaskEvent(event); const secinfoEvent = isSecinfoEvent(event); const reportFormatItems = renderSelectItems( @@ -79,7 +77,7 @@ const EmailMethodPart = ({ ); credentials = credentials.filter(email_credential_filter); return ( - + <> )} - - - + {(taskEvent || secinfoEvent) && ( - - - - - {capabilities.mayOp('get_report_formats') && ( - - - - {taskEvent && ( -