Skip to content

Commit

Permalink
Merge pull request #3840 from greenbone/GEA-124_ignore_pagination
Browse files Browse the repository at this point in the history
Add: Added an option to ignore the pagination for alert reports.
  • Loading branch information
timopollmeier authored Aug 18, 2023
2 parents ff66e0e + 73cfd0f commit 9df053a
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/gmp/commands/alerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const log = logger.getLogger('gmp.commands.alerts');

const event_data_fields = ['status', 'feed_event', 'secinfo_type'];
const method_data_fields = [
'composer_ignore_pagination',
'composer_include_notes',
'composer_include_overrides',
'details_url',
Expand Down
20 changes: 20 additions & 0 deletions src/web/pages/alerts/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,13 @@ class AlertComponent extends React.Component {

closeContentComposerDialog() {
const {
method_data_composer_ignore_pagination,
method_data_composer_include_notes,
method_data_composer_include_overrides,
filter_id,
} = this.state;
this.setState({
composerIgnorePagination: method_data_composer_ignore_pagination,
composerIncludeNotes: method_data_composer_include_notes,
composerIncludeOverrides: method_data_composer_include_overrides,
composerFilterId: filter_id,
Expand All @@ -253,6 +255,7 @@ class AlertComponent extends React.Component {
}

handleSaveComposerContent({
ignorePagination,
includeNotes,
includeOverrides,
filterId,
Expand All @@ -263,13 +266,15 @@ class AlertComponent extends React.Component {
const defaults = {
...reportComposerDefaults,
reportResultFilterId: filterId === UNSET_VALUE ? undefined : filterId,
ignorePagination,
includeNotes,
includeOverrides,
};
this.props.saveReportComposerDefaults(defaults);
}
this.setState({
filter_id: filterId,
method_data_composer_ignore_pagination: ignorePagination,
method_data_composer_include_notes: includeNotes,
method_data_composer_include_overrides: includeOverrides,
composerStoreAsDefault: NO_VALUE,
Expand Down Expand Up @@ -437,6 +442,9 @@ class AlertComponent extends React.Component {
composerFilterId: isDefined(alert.filter)
? alert.filter.id
: undefined,
composerIgnorePagination: getValue(
method.data.composer_ignore_pagination,
),
composerIncludeNotes: getValue(method.data.composer_include_notes),
composerIncludeOverrides: getValue(
method.data.composer_include_overrides,
Expand Down Expand Up @@ -477,6 +485,9 @@ class AlertComponent extends React.Component {

method: alert.method.type,

method_data_composer_ignore_pagination: getValue(
method.data.composer_ignore_pagination,
),
method_data_composer_include_notes: getValue(
method.data.composer_include_notes,
),
Expand Down Expand Up @@ -699,11 +710,13 @@ class AlertComponent extends React.Component {
filter_id: filterId,
filters,
composerFilterId: reportComposerDefaults.reportResultFilterId,
composerIgnorePagination: reportComposerDefaults.ignorePagination,
composerIncludeNotes: reportComposerDefaults.includeNotes,
composerIncludeOverrides: reportComposerDefaults.includeOverrides,
composerStoreAsDefault: NO_VALUE,
id: undefined,
method: undefined,
method_data_composer_ignore_pagination: undefined,
method_data_composer_include_notes: undefined,
method_data_composer_include_overrides: undefined,
method_data_defense_center_ip: undefined,
Expand Down Expand Up @@ -780,6 +793,7 @@ class AlertComponent extends React.Component {

handleCloseAlertDialog() {
this.setState({
composerIgnorePagination: undefined,
composerIncludeNotes: undefined,
composerIncludeOverrides: undefined,
composerFilterId: undefined,
Expand Down Expand Up @@ -924,6 +938,7 @@ class AlertComponent extends React.Component {
filters,
filter_id,
composerFilterId,
composerIgnorePagination,
composerIncludeNotes,
composerIncludeOverrides,
credentials,
Expand All @@ -942,6 +957,7 @@ class AlertComponent extends React.Component {
event_data_feed_event,
event_data_secinfo_type,
method,
method_data_composer_ignore_pagination,
method_data_composer_include_notes,
method_data_composer_include_overrides,
method_data_defense_center_ip,
Expand Down Expand Up @@ -1051,6 +1067,9 @@ class AlertComponent extends React.Component {
event_data_feed_event={event_data_feed_event}
event_data_secinfo_type={event_data_secinfo_type}
method={method}
method_data_composer_ignore_pagination={
method_data_composer_ignore_pagination
}
method_data_composer_include_notes={
method_data_composer_include_notes
}
Expand Down Expand Up @@ -1184,6 +1203,7 @@ class AlertComponent extends React.Component {
)}
{contentComposerDialogVisible && (
<ContentComposerDialog
ignorePagination={parseYesNo(composerIgnorePagination)}
includeNotes={parseYesNo(composerIncludeNotes)}
includeOverrides={parseYesNo(composerIncludeOverrides)}
filterId={composerFilterId}
Expand Down
17 changes: 17 additions & 0 deletions src/web/pages/alerts/contentcomposerdialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ 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;
Expand All @@ -47,6 +48,7 @@ const StyledDiv = styled.div`
const ContentComposerDialog = ({
filterId = UNSET_VALUE,
filters = [],
ignorePagination = YES_VALUE,
includeNotes = COMPOSER_CONTENT_DEFAULTS.includeNotes,
includeOverrides = COMPOSER_CONTENT_DEFAULTS.includeOverrides,
storeAsDefault,
Expand All @@ -60,6 +62,7 @@ const ContentComposerDialog = ({

const controlledValues = {
filterId,
ignorePagination,
includeNotes,
includeOverrides,
storeAsDefault,
Expand Down Expand Up @@ -93,6 +96,19 @@ const ContentComposerDialog = ({
includeOverrides={values.includeOverrides}
onValueChange={onChange}
/>
<FormGroup title={_('Pagination')} titleSize="3">
<Divider>
<CheckBox
data-testid="ignorePagination"
name="ignorePagination"
checked={values.ignorePagination}
checkedValue={YES_VALUE}
uncheckedValue={NO_VALUE}
title={_('Ignore')}
onChange={onChange}
/>
</Divider>
</FormGroup>
<StyledDiv>
<CheckBox
name="storeAsDefault"
Expand All @@ -117,6 +133,7 @@ ContentComposerDialog.propTypes = {
filterId: PropTypes.toString,
filterString: PropTypes.string,
filters: PropTypes.array,
ignorePagination: PropTypes.number,
includeNotes: PropTypes.number,
includeOverrides: PropTypes.number,
reportFormatId: PropTypes.id,
Expand Down
3 changes: 3 additions & 0 deletions src/web/pages/alerts/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ class AlertDialog extends React.Component {
title = _('New Alert'),
report_formats,
report_format_ids,
method_data_composer_ignore_pagination,
method_data_composer_include_notes,
method_data_composer_include_overrides,
method_data_recipient_credential,
Expand Down Expand Up @@ -484,6 +485,7 @@ class AlertDialog extends React.Component {
event,
filter_id,
method_data_pkcs12_credential,
method_data_composer_ignore_pagination,
method_data_composer_include_notes,
method_data_composer_include_overrides,
method_data_recipient_credential,
Expand Down Expand Up @@ -888,6 +890,7 @@ AlertDialog.propTypes = {
filter_id: PropTypes.idOrZero,
method: PropTypes.string,
method_data_URL: PropTypes.string,
method_data_composer_ignore_pagination: PropTypes.number,
method_data_composer_include_notes: PropTypes.number,
method_data_composer_include_overrides: PropTypes.number,
method_data_defense_center_ip: PropTypes.string,
Expand Down

0 comments on commit 9df053a

Please sign in to comment.