Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix testing alerts #1260

Merged
merged 2 commits into from
Apr 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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