Skip to content

Commit

Permalink
Load vFire method_data fields when opening EditAlertDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
swaterkamp committed Dec 20, 2018
1 parent 88bafbb commit acf94cd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
4 changes: 3 additions & 1 deletion gsa/src/web/pages/alerts/alembavfiremethodpart.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const AlembaVfireMethodPart = ({
onChange,
onCredentialChange,
onNewVfireCredentialClick,
onReportFormatsChange,
}) => {
credentials = credentials.filter(
cred => cred.credential_type === USERNAME_PASSWORD_CREDENTIAL_TYPE);
Expand All @@ -73,7 +74,7 @@ const AlembaVfireMethodPart = ({
name={'report_format_ids'}
items={renderSelectItems(reportFormats)}
value={reportFormatIds}
onChange={onChange}
onChange={onReportFormatsChange}
/>
</FormGroup>

Expand Down Expand Up @@ -215,6 +216,7 @@ AlembaVfireMethodPart.propTypes = {
onChange: PropTypes.func.isRequired,
onCredentialChange: PropTypes.func.isRequired,
onNewVfireCredentialClick: PropTypes.func.isRequired,
onReportFormatsChange: PropTypes.func.isRequired,
};

export default withPrefix(AlembaVfireMethodPart);
Expand Down
8 changes: 7 additions & 1 deletion gsa/src/web/pages/alerts/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class AlertComponent extends React.Component {
this.handleTippingPointCredentialChange.bind(this);
this.handleVfireCredentialChange =
this.handleVfireCredentialChange.bind(this);
this.handleReportFormatsChange = this.handleReportFormatsChange.bind(this);

this.openAlertDialog = this.openAlertDialog.bind(this);
this.handleCloseAlertDialog = this.handleCloseAlertDialog.bind(this);
Expand Down Expand Up @@ -344,7 +345,7 @@ class AlertComponent extends React.Component {
result_filters,
secinfo_filters,
report_formats,
report_format_ids: alert.reportFormatIds,
report_format_ids: method.data.report_formats,

condition: condition.type,
condition_data_count: parseInt(value(condition.data.count, 1)),
Expand Down Expand Up @@ -599,6 +600,10 @@ class AlertComponent extends React.Component {
this.setState({method_data_vfire_credential: credential});
}

handleReportFormatsChange(report_format_ids) {
this.setState({report_format_ids});
}

handleInteraction() {
const {onInteraction} = this.props;
if (isDefined(onInteraction)) {
Expand Down Expand Up @@ -833,6 +838,7 @@ class AlertComponent extends React.Component {
this.handleInteraction();
return save(d).then(() => this.closeAlertDialog());
}}
onReportFormatsChange={this.handleReportFormatsChange}
onEmailCredentialChange={this.handleEmailCredentialChange}
onScpCredentialChange={this.handleScpCredentialChange}
onSmbCredentialChange={this.handleSmbCredentialChange}
Expand Down
14 changes: 13 additions & 1 deletion gsa/src/web/pages/alerts/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ class AlertDialog extends React.Component {
onNewVeriniceCredentialClick,
onNewVfireCredentialClick,
onNewTippingPointCredentialClick,
onReportFormatsChange,
onSave,
onScpCredentialChange,
onSmbCredentialChange,
Expand Down Expand Up @@ -403,7 +404,15 @@ class AlertDialog extends React.Component {
const data = {
...DEFAULTS,
...alert,
report_format_ids,
method_data_vfire_base_url,
method_data_vfire_client_id,
method_data_vfire_call_partition_name,
method_data_vfire_call_description,
method_data_vfire_call_template_name,
method_data_vfire_call_type_name,
method_data_vfire_call_impact_name,
method_data_vfire_call_urgency_name,
method_data_vfire_session_type,
};

for (const [key, value] of Object.entries(props)) {
Expand All @@ -419,6 +428,7 @@ class AlertDialog extends React.Component {
method_data_tp_sms_credential,
method_data_verinice_server_credential,
method_data_vfire_credential,
report_format_ids,
};

return (
Expand Down Expand Up @@ -756,6 +766,7 @@ class AlertDialog extends React.Component {
vFireSessionType={values.method_data_vfire_session_type}
onChange={onValueChange}
onCredentialChange={onVfireCredentialChange}
onReportFormatsChange={onReportFormatsChange}
onNewVfireCredentialClick={onNewVfireCredentialClick}
/>
}
Expand Down Expand Up @@ -857,6 +868,7 @@ AlertDialog.propTypes = {
onNewTippingPointCredentialClick: PropTypes.func.isRequired,
onNewVeriniceCredentialClick: PropTypes.func.isRequired,
onNewVfireCredentialClick: PropTypes.func.isRequired,
onReportFormatsChange: PropTypes.func.isRequired,
onSave: PropTypes.func.isRequired,
onScpCredentialChange: PropTypes.func.isRequired,
onSmbCredentialChange: PropTypes.func.isRequired,
Expand Down

0 comments on commit acf94cd

Please sign in to comment.