Skip to content

Commit

Permalink
Merge pull request #1260 from swaterkamp/TestAlert
Browse files Browse the repository at this point in the history
Fix testing alerts
  • Loading branch information
bjoernricks committed Apr 9, 2019
2 parents 9440bdf + 61c44d9 commit 9837b8a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 45 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -8,6 +8,7 @@ $ cd gsa && git checkout gsa-8.0 && git log

## gsa 8.0.1 (unreleased)

* Fix testing alerts #1260
* Fix release build #1259

## gsa 8.0.0 (2018-04-05)
Expand Down
9 changes: 0 additions & 9 deletions gsa/src/gmp/commands/alerts.js
Expand Up @@ -18,7 +18,6 @@
*/
import logger from '../log';

import {isDefined} from '../utils/identity';
import {map} from '../utils/array';

import registerCommand from '../command';
Expand Down Expand Up @@ -249,14 +248,6 @@ class AlertCommand extends EntityCommand {
return this.httpPost({
cmd: 'test_alert',
id,
}).then(response => {
const {action_result} = response.data;
const {status, details} = action_result;
return response.setData({
...action_result,
details: isDefined(details) && details.length > 0 ? details : undefined,
success: status[0] === '2',
});
});
}

Expand Down
73 changes: 37 additions & 36 deletions gsa/src/web/pages/alerts/component.js
Expand Up @@ -812,46 +812,47 @@ class AlertComponent extends React.Component {

this.handleInteraction();

gmp.alert.test(alert).then(
response => {
const {success, details, message} = response.data;
if (success) {
if (isDefined(onTestSuccess)) {
onTestSuccess(
_('Testing the alert {{name}} was successful.', alert),
);
gmp.alert
.test(alert)
.then(response => {
if (isDefined(onTestSuccess)) {
onTestSuccess(_('Testing the alert {{name}} was successful.', alert));
}
})
.catch(
response => {
const {details, message} = response;
if (isDefined(onTestError)) {
if (isDefined(details)) {
onTestError(
<React.Fragment>
<p>
{_('Testing the alert {{name}} failed. {{message}}.', {
name: alert.name,
message,
})}
</p>
<FootNote>{details}</FootNote>
</React.Fragment>,
);
} else {
onTestError(
_('Testing the alert {{name}} failed. {{message}}.', {
name: alert.name,
message,
}),
);
}
}
} else if (isDefined(onTestError)) {
if (isDefined(details)) {
onTestError(
<React.Fragment>
<p>
{_('Testing the alert {{name}} failed. {{message}}.', {
name: alert.name,
message,
})}
</p>
<FootNote>{details}</FootNote>
</React.Fragment>,
);
} else {
},
() => {
if (isDefined(onTestError)) {
onTestError(
_('Testing the alert {{name}} failed. {{message}}.', {
name: alert.name,
message,
}),
_('An error occurred during Testing the alert {{name}}', alert),
);
}
}
},
() => {
if (isDefined(onTestError)) {
onTestError(
_('An error occurred during Testing the alert {{name}}', alert),
);
}
},
);
},
);
}

handlePasswordOnlyCredentialChange(credential) {
Expand Down

0 comments on commit 9837b8a

Please sign in to comment.