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

Reuse scanconfig edit dialogs for policies and add tests for san config edit dialogs #1573

Merged
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
[#1466](https://github.com/greenbone/gsa/pull/1466) [#1467](https://github.com/greenbone/gsa/pull/1467)

### Changed
- Reuse scanconfig edit dialogs for policies [#1573](https://github.com/greenbone/gsa/pull/1573)
- Use styled-components to render global styles [#1557](https://github.com/greenbone/gsa/pull/1557)
- Use fast xml parser by default [#1556](https://github.com/greenbone/gsa/pull/1556)
- Updated dependencies [#1555](https://github.com/greenbone/gsa/pull/1555)
Expand Down
27 changes: 27 additions & 0 deletions gsa/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ set (GSA_JS_SRC_FILES
${GSA_SRC_DIR}/src/gmp/command.js
${GSA_SRC_DIR}/src/gmp/commands/agents.js
${GSA_SRC_DIR}/src/gmp/commands/alerts.js
${GSA_SRC_DIR}/src/gmp/commands/audits.js
${GSA_SRC_DIR}/src/gmp/commands/auth.js
${GSA_SRC_DIR}/src/gmp/commands/certbund.js
${GSA_SRC_DIR}/src/gmp/commands/cpes.js
Expand All @@ -80,6 +81,7 @@ set (GSA_JS_SRC_FILES
${GSA_SRC_DIR}/src/gmp/commands/ovaldefs.js
${GSA_SRC_DIR}/src/gmp/commands/overrides.js
${GSA_SRC_DIR}/src/gmp/commands/permissions.js
${GSA_SRC_DIR}/src/gmp/commands/policies.js
${GSA_SRC_DIR}/src/gmp/commands/portlists.js
${GSA_SRC_DIR}/src/gmp/commands/reportformats.js
${GSA_SRC_DIR}/src/gmp/commands/reports.js
Expand Down Expand Up @@ -118,6 +120,7 @@ set (GSA_JS_SRC_FILES
${GSA_SRC_DIR}/src/gmp/models/agent.js
${GSA_SRC_DIR}/src/gmp/models/alert.js
${GSA_SRC_DIR}/src/gmp/models/asset.js
${GSA_SRC_DIR}/src/gmp/models/audit.js
${GSA_SRC_DIR}/src/gmp/models/certbund.js
${GSA_SRC_DIR}/src/gmp/models/cpe.js
${GSA_SRC_DIR}/src/gmp/models/credential.js
Expand All @@ -140,6 +143,7 @@ set (GSA_JS_SRC_FILES
${GSA_SRC_DIR}/src/gmp/models/ovaldef.js
${GSA_SRC_DIR}/src/gmp/models/override.js
${GSA_SRC_DIR}/src/gmp/models/permission.js
${GSA_SRC_DIR}/src/gmp/models/policy.js
${GSA_SRC_DIR}/src/gmp/models/portlist.js
${GSA_SRC_DIR}/src/gmp/models/reportformat.js
${GSA_SRC_DIR}/src/gmp/models/report.js
Expand Down Expand Up @@ -179,6 +183,7 @@ set (GSA_JS_SRC_FILES
${GSA_SRC_DIR}/src/gmp/utils/string.js
${GSA_SRC_DIR}/src/web/app.js
${GSA_SRC_DIR}/src/web/components/badge/badge.js
${GSA_SRC_DIR}/src/web/components/bar/compliancestatusbar.js
${GSA_SRC_DIR}/src/web/components/bar/menubar.js
${GSA_SRC_DIR}/src/web/components/bar/progressbar.js
${GSA_SRC_DIR}/src/web/components/bar/severitybar.js
Expand Down Expand Up @@ -645,6 +650,16 @@ set (GSA_JS_SRC_FILES
${GSA_SRC_DIR}/src/web/pages/alerts/ticketeventpart.js
${GSA_SRC_DIR}/src/web/pages/alerts/tippingpointmethodpart.js
${GSA_SRC_DIR}/src/web/pages/alerts/verinicemethodpart.js
${GSA_SRC_DIR}/src/web/pages/audits/actions.js
${GSA_SRC_DIR}/src/web/pages/audits/component.js
${GSA_SRC_DIR}/src/web/pages/audits/details.js
${GSA_SRC_DIR}/src/web/pages/audits/detailspage.js
${GSA_SRC_DIR}/src/web/pages/audits/dialog.js
${GSA_SRC_DIR}/src/web/pages/audits/icons/resumeicon.js
${GSA_SRC_DIR}/src/web/pages/audits/icons/starticon.js
${GSA_SRC_DIR}/src/web/pages/audits/listpage.js
${GSA_SRC_DIR}/src/web/pages/audits/row.js
${GSA_SRC_DIR}/src/web/pages/audits/table.js
${GSA_SRC_DIR}/src/web/pages/credentials/component.js
${GSA_SRC_DIR}/src/web/pages/credentials/details.js
${GSA_SRC_DIR}/src/web/pages/credentials/detailspage.js
Expand Down Expand Up @@ -819,6 +834,14 @@ set (GSA_JS_SRC_FILES
${GSA_SRC_DIR}/src/web/pages/permissions/multipledialog.js
${GSA_SRC_DIR}/src/web/pages/permissions/row.js
${GSA_SRC_DIR}/src/web/pages/permissions/table.js
${GSA_SRC_DIR}/src/web/pages/policies/component.js
${GSA_SRC_DIR}/src/web/pages/policies/details.js
${GSA_SRC_DIR}/src/web/pages/policies/detailspage.js
${GSA_SRC_DIR}/src/web/pages/policies/dialog.js
${GSA_SRC_DIR}/src/web/pages/policies/header.js
${GSA_SRC_DIR}/src/web/pages/policies/listpage.js
${GSA_SRC_DIR}/src/web/pages/policies/row.js
${GSA_SRC_DIR}/src/web/pages/policies/table.js
${GSA_SRC_DIR}/src/web/pages/portlists/component.js
${GSA_SRC_DIR}/src/web/pages/portlists/details.js
${GSA_SRC_DIR}/src/web/pages/portlists/detailspage.js
Expand Down Expand Up @@ -904,6 +927,7 @@ set (GSA_JS_SRC_FILES
${GSA_SRC_DIR}/src/web/pages/scanconfigs/importdialog.js
${GSA_SRC_DIR}/src/web/pages/scanconfigs/listpage.js
${GSA_SRC_DIR}/src/web/pages/scanconfigs/row.js
${GSA_SRC_DIR}/src/web/pages/scanconfigs/table.js
${GSA_SRC_DIR}/src/web/pages/scanconfigs/trend.js
${GSA_SRC_DIR}/src/web/pages/scanners/component.js
${GSA_SRC_DIR}/src/web/pages/scanners/details.js
Expand Down Expand Up @@ -968,6 +992,7 @@ set (GSA_JS_SRC_FILES
${GSA_SRC_DIR}/src/web/pages/tasks/dashboard/severityclassdisplay.js
${GSA_SRC_DIR}/src/web/pages/tasks/dashboard/statusdisplay.js
${GSA_SRC_DIR}/src/web/pages/tasks/details.js
${GSA_SRC_DIR}/src/web/pages/tasks/detailspage.js
${GSA_SRC_DIR}/src/web/pages/tasks/dialog.js
${GSA_SRC_DIR}/src/web/pages/tasks/filterdialog.js
${GSA_SRC_DIR}/src/web/pages/tasks/icons/importreporticon.js
Expand Down Expand Up @@ -1041,6 +1066,7 @@ set (GSA_JS_SRC_FILES
${GSA_SRC_DIR}/src/web/store/reducers.js
${GSA_SRC_DIR}/src/web/store/entities/agents.js
${GSA_SRC_DIR}/src/web/store/entities/alerts.js
${GSA_SRC_DIR}/src/web/store/entities/audits.js
${GSA_SRC_DIR}/src/web/store/entities/certbund.js
${GSA_SRC_DIR}/src/web/store/entities/cpes.js
${GSA_SRC_DIR}/src/web/store/entities/credentials.js
Expand All @@ -1055,6 +1081,7 @@ set (GSA_JS_SRC_FILES
${GSA_SRC_DIR}/src/web/store/entities/ovaldefs.js
${GSA_SRC_DIR}/src/web/store/entities/overrides.js
${GSA_SRC_DIR}/src/web/store/entities/permissions.js
${GSA_SRC_DIR}/src/web/store/entities/policies.js
${GSA_SRC_DIR}/src/web/store/entities/portlists.js
${GSA_SRC_DIR}/src/web/store/entities/reducers.js
${GSA_SRC_DIR}/src/web/store/entities/reportformats.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -783,9 +783,6 @@ exports[`GlobalStyles tests should render global styles 1`] = `
/* sc-component-id: sc-gRnDUn */


/* sc-component-id: sc-cmjSyW */


/* sc-component-id: sc-global-2342249302 */
html{box-sizing:border-box;} *,*:before,*:after{box-sizing:inherit;} body{margin:0;font-family:Verdana,sans-serif;font-size:12px;color:#000;} a:link{color:#0000ff;-webkit-text-decoration:none;text-decoration:none;} a:hover,a:focus{color:blue;-webkit-text-decoration:underline;text-decoration:underline;} pre{white-space:pre-wrap;word-wrap:break-word;} img{border:0;} svg{overflow:hidden;} h1{font-size:20px;} h2{font-size:18px;} h3{font-size:16px;} h4{font-size:14px;margin-bottom:0;} p{margin:0 0 10px;}
</style>
Expand Down
35 changes: 18 additions & 17 deletions gsa/src/web/pages/policies/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ import withGmp from 'web/utils/withGmp';

import EntityComponent from 'web/entity/component';

import EditPolicyFamilyDialog from 'web/pages/policies/editpolicyfamilydialog';
import EditPolicyDialog from 'web/pages/policies/editdialog';
import EditNvtDetailsDialog from 'web/pages/policies/editnvtdetailsdialog';
import EditPolicyFamilyDialog from 'web/pages/scanconfigs/editconfigfamilydialog';
import EditPolicyDialog from 'web/pages/scanconfigs/editdialog';
import EditNvtDetailsDialog from 'web/pages/scanconfigs/editnvtdetailsdialog';
import AuditDialog from 'web/pages/audits/dialog';
import ImportDialog from 'web/pages/scanconfigs/importdialog';
import PolicyDialog from 'web/pages/policies/dialog';
Expand Down Expand Up @@ -319,7 +319,7 @@ class PolicyComponent extends React.Component {
.then(() => this.closeCreateAuditDialog());
}

openEditPolicyFamilyDialog({policy, name}) {
openEditPolicyFamilyDialog({config: policy, name}) {
this.loadEditPolicyFamilySettings(policy, name).then(state => {
this.setState({
...state,
Expand All @@ -342,7 +342,7 @@ class PolicyComponent extends React.Component {
this.handleInteraction();
}

openEditNvtDetailsDialog({policy, nvt}) {
openEditNvtDetailsDialog({config: policy, nvt}) {
this.loadEditPolicyNvtSettings(policy, nvt).then(state => {
this.setState({
...state,
Expand Down Expand Up @@ -378,13 +378,14 @@ class PolicyComponent extends React.Component {

handleSavePolicyFamily(data) {
const {gmp} = this.props;
const policy = data.config;

this.handleInteraction();

return gmp.policy
.savePolicyFamily(data)
.then(() => {
return this.loadEditPolicySettings(data.policy);
return this.loadEditPolicySettings(policy);
})
.then(state => {
this.closeEditPolicyFamilyDialog();
Expand All @@ -394,22 +395,20 @@ class PolicyComponent extends React.Component {

handleSavePolicyNvt(values) {
const {gmp} = this.props;
const {config: policy, family_name} = values;

this.handleInteraction();

return gmp.policy
.savePolicyNvt(values)
.then(response => {
// update nvt timeouts in nvt family dialog
this.loadEditPolicyFamilySettings(
values.policy,
values.family_name,
).then(state => {
this.loadEditPolicyFamilySettings(policy, family_name).then(state => {
this.setState({state});
});

// update nvt preference values in edit dialog
this.loadEditPolicySettings(values.policy).then(state => {
this.loadEditPolicySettings(policy).then(state => {
this.setState({state});
});
})
Expand Down Expand Up @@ -720,7 +719,7 @@ class PolicyComponent extends React.Component {
<EditPolicyDialog
base={base}
comment={comment}
policy={policy}
config={policy}
families={families}
name={name}
scanner_id={scanner_id}
Expand All @@ -730,7 +729,7 @@ class PolicyComponent extends React.Component {
title={title}
trend={trend}
onClose={this.handleCloseEditPolicyDialog}
onEditPolicyFamilyClick={this.openEditPolicyFamilyDialog}
onEditConfigFamilyClick={this.openEditPolicyFamilyDialog}
onEditNvtDetailsClick={this.openEditNvtDetailsDialog}
onSave={d => {
this.handleInteraction();
Expand All @@ -751,8 +750,9 @@ class PolicyComponent extends React.Component {
)}
{editPolicyFamilyDialogVisible && (
<EditPolicyFamilyDialog
policy={policy}
policyName={policyName}
config={policy}
configNameLabel={_('Policy')}
config_name={policyName}
family_name={family_name}
id={id}
nvts={nvts}
Expand All @@ -765,8 +765,9 @@ class PolicyComponent extends React.Component {
)}
{editNvtDetailsDialogVisible && (
<EditNvtDetailsDialog
policy={policy}
policyName={policyName}
config={policy}
configNameLabel={_('Policy')}
config_name={policyName}
family_name={family_name}
manual_timeout={manual_timeout}
nvt={nvt}
Expand Down
Loading