From 0c409e4684d5d17d6e12a9a0bd09ac00610fe4a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Mon, 3 Sep 2018 08:41:36 +0200 Subject: [PATCH 01/14] Update imports at ldappage --- gsa/src/web/pages/ldap/ldappage.js | 33 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/gsa/src/web/pages/ldap/ldappage.js b/gsa/src/web/pages/ldap/ldappage.js index 29fa958621..81ff9c5d81 100644 --- a/gsa/src/web/pages/ldap/ldappage.js +++ b/gsa/src/web/pages/ldap/ldappage.js @@ -29,30 +29,29 @@ import {YES_VALUE, NO_VALUE} from 'gmp/parser'; import {isDefined} from 'gmp/utils/identity'; -import Button from '../../components/form/button.js'; -import CheckBox from '../../components/form/checkbox.js'; -import FileField from '../../components/form/filefield.js'; -import FormGroup from '../../components/form/formgroup.js'; -import TextField from '../../components/form/textfield.js'; +import Button from 'web/components/form/button'; +import CheckBox from 'web/components/form/checkbox'; +import FileField from 'web/components/form/filefield'; +import FormGroup from 'web/components/form/formgroup'; +import TextField from 'web/components/form/textfield'; -import ManualIcon from '../../components/icon/manualicon.js'; +import ManualIcon from 'web/components/icon/manualicon'; -import Layout from '../../components/layout/layout.js'; -import Section from '../../components/section/section.js'; +import Layout from 'web/components/layout/layout'; +import Section from 'web/components/section/section'; -import Table from '../../components/table/simpletable.js'; -import TableBody from '../../components/table/body.js'; -import TableData from '../../components/table/data.js'; -import TableRow from '../../components/table/row.js'; +import Table from 'web/components/table/simpletable'; +import TableBody from 'web/components/table/body'; +import TableData from 'web/components/table/data'; +import TableRow from 'web/components/table/row'; -import Loading from '../../components/loading/loading.js'; - -import PropTypes from '../../utils/proptypes.js'; - -import withGmp from '../../utils/withGmp.js'; +import Loading from 'web/components/loading/loading'; +import PropTypes from 'web/utils/proptypes'; +import withGmp from 'web/utils/withGmp'; class LdapAuthentication extends React.Component { + constructor() { super(); this.state = { From 8cafd9ae88a9c6b61070b4fb3e33779bc2f62c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Mon, 3 Sep 2018 08:55:35 +0200 Subject: [PATCH 02/14] Renew the user session when the ldap settings are saved --- gsa/src/web/pages/ldap/ldappage.js | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/gsa/src/web/pages/ldap/ldappage.js b/gsa/src/web/pages/ldap/ldappage.js index 81ff9c5d81..c715d6e564 100644 --- a/gsa/src/web/pages/ldap/ldappage.js +++ b/gsa/src/web/pages/ldap/ldappage.js @@ -20,9 +20,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ - import React from 'react'; +import {connect} from 'react-redux'; + import _ from 'gmp/locale'; import {YES_VALUE, NO_VALUE} from 'gmp/parser'; @@ -47,6 +48,9 @@ import TableRow from 'web/components/table/row'; import Loading from 'web/components/loading/loading'; +import {renewSessionTimeout} from 'web/store/usersettings/actions'; + +import compose from 'web/utils/compose'; import PropTypes from 'web/utils/proptypes'; import withGmp from 'web/utils/withGmp'; @@ -73,7 +77,7 @@ class LdapAuthentication extends React.Component { load() { this.getLdapAuth() - .then(this.setState({loading: false})); + .then(this.setState({loading: false})); } getLdapAuth() { @@ -93,6 +97,13 @@ class LdapAuthentication extends React.Component { return auth_data; } + handleInteraction() { + const {onInteraction} = this.props; + if (isDefined(onInteraction)) { + onInteraction(); + } + } + handleSaveSettings() { const { authdn, @@ -107,6 +118,9 @@ class LdapAuthentication extends React.Component { ldaphost, }; const {gmp} = this.props; + + this.handleInteraction(); + return gmp.auth.saveLdap(data); } @@ -234,8 +248,16 @@ class LdapAuthentication extends React.Component { LdapAuthentication.propTypes = { gmp: PropTypes.gmp.isRequired, + onInteraction: PropTypes.func.isRequired, }; -export default withGmp(LdapAuthentication); +const mapDispatchToProps = (dispatch, {gmp}) => ({ + onInteraction: () => dispatch(renewSessionTimeout(gmp)()), +}); + +export default compose( + withGmp, + connect(undefined, mapDispatchToProps), +)(LdapAuthentication); // vim: set ts=2 sw=2 tw=80: From 3e0e3d27f7753ead303e607b2518d0c8710e5248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Mon, 3 Sep 2018 08:59:29 +0200 Subject: [PATCH 03/14] Update imports at radiuspage --- gsa/src/web/pages/radius/radiuspage.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/gsa/src/web/pages/radius/radiuspage.js b/gsa/src/web/pages/radius/radiuspage.js index 5e3e7b9ac5..45b4daf1bf 100644 --- a/gsa/src/web/pages/radius/radiuspage.js +++ b/gsa/src/web/pages/radius/radiuspage.js @@ -26,23 +26,22 @@ import _ from 'gmp/locale'; import {YES_VALUE, NO_VALUE} from 'gmp/parser'; -import Button from '../../components/form/button.js'; -import CheckBox from '../../components/form/checkbox.js'; -import FormGroup from '../../components/form/formgroup.js'; -import PasswordField from '../../components/form/passwordfield.js'; -import TextField from '../../components/form/textfield.js'; +import Button from 'web/components/form/button'; +import CheckBox from 'web/components/form/checkbox'; +import FormGroup from 'web/components/form/formgroup'; +import PasswordField from 'web/components/form/passwordfield'; +import TextField from 'web/components/form/textfield'; -import ManualIcon from '../../components/icon/manualicon.js'; +import ManualIcon from 'web/components/icon/manualicon'; -import Layout from '../../components/layout/layout.js'; -import Section from '../../components/section/section.js'; +import Layout from 'web/components/layout/layout'; -import Loading from '../../components/loading/loading.js'; +import Section from 'web/components/section/section'; -import PropTypes from '../../utils/proptypes.js'; - -import withGmp from '../../utils/withGmp.js'; +import Loading from 'web/components/loading/loading'; +import PropTypes from 'web/utils/proptypes'; +import withGmp from 'web/utils/withGmp'; class RadiusAuthentication extends React.Component { constructor() { From 1b1f200b66093d229f24c65deed64fcdefccdcf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Mon, 3 Sep 2018 09:00:02 +0200 Subject: [PATCH 04/14] Pass all arguments to React.Component Update LdapPage and RadiusPage components to forwards constructor arguments to React.Component. --- gsa/src/web/pages/ldap/ldappage.js | 5 +++-- gsa/src/web/pages/radius/radiuspage.js | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gsa/src/web/pages/ldap/ldappage.js b/gsa/src/web/pages/ldap/ldappage.js index c715d6e564..37862801a1 100644 --- a/gsa/src/web/pages/ldap/ldappage.js +++ b/gsa/src/web/pages/ldap/ldappage.js @@ -56,8 +56,9 @@ import withGmp from 'web/utils/withGmp'; class LdapAuthentication extends React.Component { - constructor() { - super(); + constructor(...args) { + super(...args); + this.state = { authdn: '', ldaphost: '', diff --git a/gsa/src/web/pages/radius/radiuspage.js b/gsa/src/web/pages/radius/radiuspage.js index 45b4daf1bf..e99c135f89 100644 --- a/gsa/src/web/pages/radius/radiuspage.js +++ b/gsa/src/web/pages/radius/radiuspage.js @@ -44,8 +44,10 @@ import PropTypes from 'web/utils/proptypes'; import withGmp from 'web/utils/withGmp'; class RadiusAuthentication extends React.Component { - constructor() { - super(); + + constructor(...args) { + super(...args); + this.state = { enable: '', radiushost: '', From bbd17054765f4a79173addfdd29249bd4afb7afe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Mon, 3 Sep 2018 09:03:10 +0200 Subject: [PATCH 05/14] Renew user session when radius settings are saved --- gsa/src/web/pages/radius/radiuspage.js | 28 ++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/gsa/src/web/pages/radius/radiuspage.js b/gsa/src/web/pages/radius/radiuspage.js index e99c135f89..b54398e61e 100644 --- a/gsa/src/web/pages/radius/radiuspage.js +++ b/gsa/src/web/pages/radius/radiuspage.js @@ -22,10 +22,14 @@ */ import React from 'react'; +import {connect} from 'react-redux'; + import _ from 'gmp/locale'; import {YES_VALUE, NO_VALUE} from 'gmp/parser'; +import {isDefined} from 'gmp/utils/identity'; + import Button from 'web/components/form/button'; import CheckBox from 'web/components/form/checkbox'; import FormGroup from 'web/components/form/formgroup'; @@ -42,6 +46,8 @@ import Loading from 'web/components/loading/loading'; import PropTypes from 'web/utils/proptypes'; import withGmp from 'web/utils/withGmp'; +import compose from 'web/utils/compose'; +import {renewSessionTimeout} from 'web/store/usersettings/actions'; class RadiusAuthentication extends React.Component { @@ -66,7 +72,7 @@ class RadiusAuthentication extends React.Component { load() { this.getRadiusAuth() - .then(this.setState({loading: false})); + .then(this.setState({loading: false})); } getRadiusAuth() { @@ -85,6 +91,13 @@ class RadiusAuthentication extends React.Component { return auth_data; } + handleInteraction() { + const {onInteraction} = this.props; + if (isDefined(onInteraction)) { + onInteraction(); + } + } + handleSaveSettings() { const { enable, @@ -97,6 +110,9 @@ class RadiusAuthentication extends React.Component { radiuskey, }; const {gmp} = this.props; + + this.handleInteraction(); + return gmp.auth.saveRadius(data); } @@ -170,8 +186,16 @@ class RadiusAuthentication extends React.Component { RadiusAuthentication.propTypes = { gmp: PropTypes.gmp.isRequired, + onInteraction: PropTypes.func.isRequired, }; -export default withGmp(RadiusAuthentication); +const mapDispatchToProps = (dispatch, {gmp}) => ({ + onInteraction: () => dispatch(renewSessionTimeout(gmp)()), +}); + +export default compose( + withGmp, + connect(undefined, mapDispatchToProps), +)(RadiusAuthentication); // vim: set ts=2 sw=2 tw=80: From 46ac9ff56d9f822d8701e9e35b58ef7b9994205d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Mon, 3 Sep 2018 11:08:16 +0200 Subject: [PATCH 06/14] Update imports at trashcanpage --- gsa/src/web/pages/extras/trashcanpage.js | 86 ++++++++++++------------ 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/gsa/src/web/pages/extras/trashcanpage.js b/gsa/src/web/pages/extras/trashcanpage.js index b70863f97c..ec5c475925 100644 --- a/gsa/src/web/pages/extras/trashcanpage.js +++ b/gsa/src/web/pages/extras/trashcanpage.js @@ -28,49 +28,49 @@ import _ from 'gmp/locale'; import {isDefined} from 'gmp/utils/identity'; -import AlertsTable from '../alerts/table.js'; -import AgentsTable from '../agents/table.js'; -import ScanConfigsTable from '../scanconfigs/table.js'; -import CredentialsTable from '../credentials/table.js'; -import FiltersTable from '../filters/table.js'; -import GroupsTable from '../groups/table.js'; -import NotesTable from '../notes/table.js'; -import OverridesTable from '../overrides/table.js'; -import PermissionsTable from '../permissions/table.js'; -import PortListsTable from '../portlists/table.js'; -import ReportFormatsTable from '../reportformats/table.js'; -import RolesTable from '../roles/table.js'; -import ScannersTable from '../scanners/table.js'; -import SchedulesTable from '../schedules/table.js'; -import TagsTable from '../tags/table.js'; -import TargetsTable from '../targets/table.js'; -import TasksTable from '../tasks/table.js'; - -import Table from '../../components/table/stripedtable.js'; -import TableBody from '../../components/table/body.js'; -import TableData from '../../components/table/data.js'; -import TableRow from '../../components/table/row.js'; -import TableHead from '../../components/table/head.js'; -import TableHeader from '../../components/table/header.js'; - -import Layout from '../../components/layout/layout.js'; -import Section from '../../components/section/section.js'; - -import InnerLink from '../../components/link/innerlink.js'; -import LinkTarget from '../../components/link/target.js'; - -import Button from '../../components/form/button.js'; - -import ManualIcon from '../../components/icon/manualicon.js'; - -import Loading from '../../components/loading/loading.js'; - -import PropTypes from '../../utils/proptypes.js'; -import withCapabilities from '../../utils/withCapabilities.js'; -import withGmp from '../../utils/withGmp.js'; - -import TrashActions from './trashactions.js'; - +import Button from 'web/components/form/button'; + +import ManualIcon from 'web/components/icon/manualicon'; + +import Layout from 'web/components/layout/layout'; + +import InnerLink from 'web/components/link/innerlink'; +import LinkTarget from 'web/components/link/target'; + +import Loading from 'web/components/loading/loading'; + +import Section from 'web/components/section/section'; + +import Table from 'web/components/table/stripedtable'; +import TableBody from 'web/components/table/body'; +import TableData from 'web/components/table/data'; +import TableRow from 'web/components/table/row'; +import TableHead from 'web/components/table/head'; +import TableHeader from 'web/components/table/header'; + +import PropTypes from 'web/utils/proptypes'; +import withCapabilities from 'web/utils/withCapabilities'; +import withGmp from 'web/utils/withGmp'; + +import AlertsTable from '../alerts/table'; +import AgentsTable from '../agents/table'; +import ScanConfigsTable from '../scanconfigs/table'; +import CredentialsTable from '../credentials/table'; +import FiltersTable from '../filters/table'; +import GroupsTable from '../groups/table'; +import NotesTable from '../notes/table'; +import OverridesTable from '../overrides/table'; +import PermissionsTable from '../permissions/table'; +import PortListsTable from '../portlists/table'; +import ReportFormatsTable from '../reportformats/table'; +import RolesTable from '../roles/table'; +import ScannersTable from '../scanners/table'; +import SchedulesTable from '../schedules/table'; +import TagsTable from '../tags/table'; +import TargetsTable from '../targets/table'; +import TasksTable from '../tasks/table'; + +import TrashActions from './trashactions'; const ToolBarIcons = () => ( Date: Mon, 3 Sep 2018 11:12:17 +0200 Subject: [PATCH 07/14] Renew session if user interacts with trashcan --- gsa/src/web/pages/extras/trashcanpage.js | 33 ++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/gsa/src/web/pages/extras/trashcanpage.js b/gsa/src/web/pages/extras/trashcanpage.js index ec5c475925..ce2df188ec 100644 --- a/gsa/src/web/pages/extras/trashcanpage.js +++ b/gsa/src/web/pages/extras/trashcanpage.js @@ -22,6 +22,8 @@ */ import React from 'react'; +import {connect} from 'react-redux'; + import {Col} from 'glamorous'; import _ from 'gmp/locale'; @@ -48,6 +50,9 @@ import TableRow from 'web/components/table/row'; import TableHead from 'web/components/table/head'; import TableHeader from 'web/components/table/header'; +import {renewSessionTimeout} from 'web/store/usersettings/actions'; + +import compose from 'web/utils/compose'; import PropTypes from 'web/utils/proptypes'; import withCapabilities from 'web/utils/withCapabilities'; import withGmp from 'web/utils/withGmp'; @@ -110,7 +115,7 @@ class Trashcan extends React.Component { } componentDidMount() { - this.getTrash(); + this.getTrash(); } getTrash() { @@ -122,18 +127,34 @@ class Trashcan extends React.Component { return data; } + handleInteraction() { + const {onInteraction} = this.props; + if (isDefined(onInteraction)) { + onInteraction(); + } + } + handleRestore(entity) { const {gmp} = this.props; + + this.handleInteraction(); + gmp.trashcan.restore(entity).then(this.getTrash); } handleDelete(entity) { const {gmp} = this.props; + + this.handleInteraction(); + gmp.trashcan.delete(entity).then(this.getTrash); } handleEmpty() { const {gmp} = this.props; + + this.handleInteraction(); + gmp.trashcan.empty().then(this.getTrash); } @@ -434,8 +455,16 @@ class Trashcan extends React.Component { Trashcan.propTypes = { gmp: PropTypes.gmp.isRequired, + onInteraction: PropTypes.func.isRequired, }; -export default withGmp(Trashcan); +const mapDispatchToProps = (dispatch, {gmp}) => ({ + onInteraction: () => dispatch(renewSessionTimeout(gmp)()), +}); + +export default compose( + withGmp, + connect(undefined, mapDispatchToProps), +)(Trashcan); // vim: set ts=2 sw=2 tw=80: From 16d0187d06bf1eb6c1b04dea0091f998b4451803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Mon, 3 Sep 2018 11:22:26 +0200 Subject: [PATCH 08/14] Fix calling loadUserSettingsDefaults Use consistent api configurationFunc => callFunc => reduxThunkFunc => promise. Fix usersettings to not pass filter. --- gsa/src/web/pages/usersettings/usersettingspage.js | 2 +- .../web/store/usersettings/defaults/__tests__/actions.js | 6 +++--- gsa/src/web/store/usersettings/defaults/actions.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gsa/src/web/pages/usersettings/usersettingspage.js b/gsa/src/web/pages/usersettings/usersettingspage.js index ed0856872f..fa5ac4b507 100644 --- a/gsa/src/web/pages/usersettings/usersettingspage.js +++ b/gsa/src/web/pages/usersettings/usersettingspage.js @@ -1060,7 +1060,7 @@ const mapDispatchToProps = (dispatch, {gmp}) => ({ loadScanConfigs: () => dispatch(loadScanConfigs(gmp)(ALL_FILTER)), loadScanners: () => dispatch(loadScanners(gmp)(ALL_FILTER)), loadSchedules: () => dispatch(loadSchedules(gmp)(ALL_FILTER)), - loadSettings: () => dispatch(loadUserSettingDefaults(gmp)(ALL_FILTER)), + loadSettings: () => dispatch(loadUserSettingDefaults(gmp)()), loadTargets: () => dispatch(loadTargets(gmp)(ALL_FILTER)), loadAlert: id => dispatch(loadAlert(gmp)(id)), setLocale: locale => gmp.setLocale(locale), diff --git a/gsa/src/web/store/usersettings/defaults/__tests__/actions.js b/gsa/src/web/store/usersettings/defaults/__tests__/actions.js index cc3b9527df..25ad2c4325 100644 --- a/gsa/src/web/store/usersettings/defaults/__tests__/actions.js +++ b/gsa/src/web/store/usersettings/defaults/__tests__/actions.js @@ -81,7 +81,7 @@ describe('UserSettings Defaults action tests', () => { expect(isFunction(loadUserSettingDefaults)).toBe(true); - return loadUserSettingDefaults(gmp)(dispatch, getState).then(() => { + return loadUserSettingDefaults(gmp)()(dispatch, getState).then(() => { expect(getState).toBeCalled(); expect(dispatch).not.toBeCalled(); expect(currentSettings).not.toBeCalled(); @@ -110,7 +110,7 @@ describe('UserSettings Defaults action tests', () => { expect(isFunction(loadUserSettingDefaults)).toBe(true); - return loadUserSettingDefaults(gmp)(dispatch, getState).then(() => { + return loadUserSettingDefaults(gmp)()(dispatch, getState).then(() => { expect(getState).toBeCalled(); expect(currentSettings).toBeCalled(); expect(dispatch).toHaveBeenCalledTimes(2); @@ -145,7 +145,7 @@ describe('UserSettings Defaults action tests', () => { expect(isFunction(loadUserSettingDefaults)).toBe(true); - return loadUserSettingDefaults(gmp)(dispatch, getState).then(() => { + return loadUserSettingDefaults(gmp)()(dispatch, getState).then(() => { expect(getState).toBeCalled(); expect(currentSettings).toBeCalled(); expect(dispatch).toHaveBeenCalledTimes(2); diff --git a/gsa/src/web/store/usersettings/defaults/actions.js b/gsa/src/web/store/usersettings/defaults/actions.js index 2d5f40dd40..d869e6ba40 100644 --- a/gsa/src/web/store/usersettings/defaults/actions.js +++ b/gsa/src/web/store/usersettings/defaults/actions.js @@ -44,7 +44,7 @@ export const loadingActions = { }), }; -export const loadUserSettingDefaults = gmp => (dispatch, getState) => { +export const loadUserSettingDefaults = gmp => () => (dispatch, getState) => { const rootState = getState(); const selector = getUserSettingsDefaults(rootState); From 568dcac35416a90fa136096e722e6318c2fef4b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Mon, 3 Sep 2018 11:29:52 +0200 Subject: [PATCH 09/14] Renew session on user interaction at usersettings page --- .../pages/usersettings/usersettingspage.js | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/gsa/src/web/pages/usersettings/usersettingspage.js b/gsa/src/web/pages/usersettings/usersettingspage.js index fa5ac4b507..3d82e6fde0 100644 --- a/gsa/src/web/pages/usersettings/usersettingspage.js +++ b/gsa/src/web/pages/usersettings/usersettingspage.js @@ -99,7 +99,10 @@ import { } from 'web/store/usersettings/defaults/selectors'; import {getTimezone} from 'web/store/usersettings/selectors'; -import {updateTimezone} from 'web/store/usersettings/actions'; +import { + updateTimezone, + renewSessionTimeout, +} from 'web/store/usersettings/actions'; import Table from 'web/components/table/table'; import TableBody from 'web/components/table/body'; @@ -199,7 +202,7 @@ class UserSettings extends React.Component { }; this.openDialog = this.openDialog.bind(this); - this.closeDialog = this.closeDialog.bind(this); + this.handleCloseDialog = this.handleCloseDialog.bind(this); this.handleSaveSettings = this.handleSaveSettings.bind(this); this.handleValueChange = this.handleValueChange.bind(this); } @@ -223,12 +226,25 @@ class UserSettings extends React.Component { openDialog() { this.setState({dialogVisible: true}); + this.handleInteraction(); } closeDialog() { this.setState({dialogVisible: false}); } + handleCloseDialog() { + this.closeDialog(); + this.handleInteraction(); + } + + handleInteraction() { + const {onInteraction} = this.props; + if (isDefined(onInteraction)) { + onInteraction(); + } + } + getSeverityClassNameById(id) { const specifiedClass = SEVERITY_CLASSES.find( clas => { @@ -244,6 +260,9 @@ class UserSettings extends React.Component { userInterfaceLanguage = BROWSER_LANGUAGE, timezone, } = data; + + this.handleInteraction(); + return gmp.user.saveSettings(data).then(() => { this.closeDialog(); this.props.setLocale(userInterfaceLanguage === BROWSER_LANGUAGE ? @@ -760,7 +779,7 @@ class UserSettings extends React.Component { certBundFilter={certBundFilter.id} dfnCertFilter={dfnCertFilter.id} secInfoFilter={secInfoFilter.id} - onClose={this.closeDialog} + onClose={this.handleCloseDialog} onSave={this.handleSaveSettings} onValueChange={this.handleValueChange} /> @@ -844,6 +863,7 @@ UserSettings.propTypes = { tasksFilter: PropTypes.object, timezone: PropTypes.string, userInterfaceLanguage: PropTypes.object, + onInteraction: PropTypes.func.isRequired, }; const mapStateToProps = rootState => { @@ -1063,6 +1083,7 @@ const mapDispatchToProps = (dispatch, {gmp}) => ({ loadSettings: () => dispatch(loadUserSettingDefaults(gmp)()), loadTargets: () => dispatch(loadTargets(gmp)(ALL_FILTER)), loadAlert: id => dispatch(loadAlert(gmp)(id)), + onInteraction: () => dispatch(renewSessionTimeout(gmp)()), setLocale: locale => gmp.setLocale(locale), setTimezone: timezone => dispatch(updateTimezone(gmp)(timezone)), }); From 80721b4062a40f2c8fc7e500f79ce6004b8affc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Mon, 3 Sep 2018 11:36:29 +0200 Subject: [PATCH 10/14] Update imports at performancepage --- .../web/pages/performance/performancepage.js | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/gsa/src/web/pages/performance/performancepage.js b/gsa/src/web/pages/performance/performancepage.js index 4bdf06901e..f129c40c09 100644 --- a/gsa/src/web/pages/performance/performancepage.js +++ b/gsa/src/web/pages/performance/performancepage.js @@ -31,28 +31,28 @@ import {isDefined} from 'gmp/utils/identity'; import date from 'gmp/models/date'; import {SLAVE_SCANNER_TYPE} from 'gmp/models/scanner'; -import PropTypes from '../../utils/proptypes.js'; -import withGmp from '../../utils/withGmp.js'; -import {renderSelectItems} from '../../utils/render.js'; +import FormGroup from 'web/components/form/formgroup'; +import Select from 'web/components/form/select'; +import withClickHandler from 'web/components/form/withClickHandler'; -import FormGroup from '../../components/form/formgroup.js'; -import Select from '../../components/form/select.js'; -import withClickHandler from '../../components/form/withClickHandler.js'; +import ManualIcon from 'web/components/icon/manualicon'; -import ManualIcon from '../../components/icon/manualicon.js'; +import Divider from 'web/components/layout/divider'; +import IconDivider from 'web/components/layout/icondivider'; +import Layout from 'web/components/layout/layout'; -import Divider from '../../components/layout/divider.js'; -import IconDivider from '../../components/layout/icondivider.js'; -import Layout from '../../components/layout/layout.js'; +import LinkTarget from 'web/components/link/target'; -import LinkTarget from '../../components/link/target.js'; +import IconMenu from 'web/components/menu/iconmenu'; +import MenuEntry from 'web/components/menu/menuentry'; -import IconMenu from '../../components/menu/iconmenu.js'; -import MenuEntry from '../../components/menu/menuentry.js'; +import Section from 'web/components/section/section'; -import Section from '../../components/section/section.js'; +import PropTypes from 'web/utils/proptypes'; +import withGmp from 'web/utils/withGmp'; +import {renderSelectItems} from 'web/utils/render'; -import StartEndTimeSelection from './startendtimeselection.js'; +import StartEndTimeSelection from './startendtimeselection'; const DURATION_HOUR = 60 * 60; const DURATION_DAY = DURATION_HOUR * 24; From e1ec7b523665f0afdd99bc35b9f2d8ac70babfb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Mon, 3 Sep 2018 11:41:40 +0200 Subject: [PATCH 11/14] Update session if user interacts with performance page --- .../web/pages/performance/performancepage.js | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/gsa/src/web/pages/performance/performancepage.js b/gsa/src/web/pages/performance/performancepage.js index f129c40c09..88e99da774 100644 --- a/gsa/src/web/pages/performance/performancepage.js +++ b/gsa/src/web/pages/performance/performancepage.js @@ -22,6 +22,8 @@ */ import React from 'react'; +import {connect} from 'react-redux'; + import glamorous from 'glamorous'; import _ from 'gmp/locale'; @@ -48,6 +50,9 @@ import MenuEntry from 'web/components/menu/menuentry'; import Section from 'web/components/section/section'; +import {renewSessionTimeout} from 'web/store/usersettings/actions'; + +import compose from 'web/utils/compose'; import PropTypes from 'web/utils/proptypes'; import withGmp from 'web/utils/withGmp'; import {renderSelectItems} from 'web/utils/render'; @@ -237,6 +242,8 @@ class PerformancePage extends React.Component { end_hour: end.hour(), end_minute: end.minute(), }); + + this.handleInteraction(); } } @@ -249,6 +256,15 @@ class PerformancePage extends React.Component { ...data, duration: undefined, }); + + this.handleInteraction(); + } + + handleInteraction() { + const {onInteraction} = this.props; + if (isDefined(onInteraction)) { + onInteraction(); + } } render() { @@ -359,8 +375,16 @@ class PerformancePage extends React.Component { PerformancePage.propTypes = { gmp: PropTypes.gmp.isRequired, + onInteraction: PropTypes.func.isRequired, }; -export default withGmp(PerformancePage); +const mapDispatchToProps = (dispatch, {gmp}) => ({ + onInteraction: () => dispatch(renewSessionTimeout(gmp)()), +}); + +export default compose( + withGmp, + connect(undefined, mapDispatchToProps), +)(PerformancePage); // vim: set ts=2 sw=2 tw=80: From 1874cd5c04c96b3e1a34b984e62701ae1121d374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Mon, 3 Sep 2018 12:30:13 +0200 Subject: [PATCH 12/14] Don't crash if cvss vector is a empty --- gsa/src/gmp/parser.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gsa/src/gmp/parser.js b/gsa/src/gmp/parser.js index 63c6121837..eb4fec7422 100644 --- a/gsa/src/gmp/parser.js +++ b/gsa/src/gmp/parser.js @@ -271,7 +271,7 @@ export const parseCvssBaseVector = ({ }; export const parseCvssBaseFromVector = vector => { - if (!isDefined(vector)) { + if (!isDefined(vector) && vector.length > 0) { return {}; } @@ -288,7 +288,7 @@ export const parseCvssBaseFromVector = vector => { let [metric, value] = currentvalue.split(':'); metric = metric.toLowerCase(); - value = value.toLowerCase(); + value = isDefined(value) ? value.toLowerCase() : ''; switch (metric) { case 'av': From 3a6ff0fdae42d22a762b87e6d2bb20ba3c194b98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Mon, 3 Sep 2018 12:33:50 +0200 Subject: [PATCH 13/14] Update imports at cvsscalculator page --- .../web/pages/extras/cvsscalculatorpage.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/gsa/src/web/pages/extras/cvsscalculatorpage.js b/gsa/src/web/pages/extras/cvsscalculatorpage.js index a3c06c4dac..193a329c56 100644 --- a/gsa/src/web/pages/extras/cvsscalculatorpage.js +++ b/gsa/src/web/pages/extras/cvsscalculatorpage.js @@ -35,21 +35,20 @@ import { parseCvssBaseFromVector, } from 'gmp/parser'; -import SeverityBar from '../../components/bar/severitybar.js'; +import SeverityBar from 'web/components/bar/severitybar'; -import ManualIcon from '../../components/icon/manualicon.js'; +import FormGroup from 'web/components/form/formgroup'; +import Select from 'web/components/form/select'; +import TextField from 'web/components/form/textfield'; -import FormGroup from '../../components/form/formgroup.js'; -import Select from '../../components/form/select.js'; -import TextField from '../../components/form/textfield.js'; +import ManualIcon from 'web/components/icon/manualicon'; -import Section from '../../components/section/section.js'; +import Layout from 'web/components/layout/layout'; -import Layout from '../../components/layout/layout.js'; +import Section from 'web/components/section/section'; -import withGmp from '../../utils/withGmp.js'; - -import PropTypes from '../../utils/proptypes.js'; +import PropTypes from 'web/utils/proptypes'; +import withGmp from 'web/utils/withGmp'; const StyledTextField = glamorous(TextField)({ width: '180px', From 07f4ddd9b6ee68ba1101d39badbdf2380ac6d27c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Mon, 3 Sep 2018 12:46:22 +0200 Subject: [PATCH 14/14] Update session when user interacts with the cvss calculator --- .../web/pages/extras/cvsscalculatorpage.js | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/gsa/src/web/pages/extras/cvsscalculatorpage.js b/gsa/src/web/pages/extras/cvsscalculatorpage.js index 193a329c56..df4159b50d 100644 --- a/gsa/src/web/pages/extras/cvsscalculatorpage.js +++ b/gsa/src/web/pages/extras/cvsscalculatorpage.js @@ -20,9 +20,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ - import React from 'react'; +import {connect} from 'react-redux'; + import glamorous from 'glamorous'; import _ from 'gmp/locale'; @@ -47,6 +48,9 @@ import Layout from 'web/components/layout/layout'; import Section from 'web/components/section/section'; +import {renewSessionTimeout} from 'web/store/usersettings/actions'; + +import compose from 'web/utils/compose'; import PropTypes from 'web/utils/proptypes'; import withGmp from 'web/utils/withGmp'; @@ -136,7 +140,16 @@ class CvssCalculator extends React.Component { }); } + handleInteraction() { + const {onInteraction} = this.props; + if (isDefined(onInteraction)) { + onInteraction(); + } + } + handleMetricsChange(value, name) { + this.handleInteraction(); + this.calculateVector({[name]: value}); } @@ -146,6 +159,9 @@ class CvssCalculator extends React.Component { handleVectorChange() { const {userVector} = this.state; + + this.handleInteraction(); + const cvssValues = parseCvssBaseFromVector(userVector); const { accessVector, @@ -292,6 +308,16 @@ class CvssCalculator extends React.Component { CvssCalculator.propTypes = { gmp: PropTypes.gmp.isRequired, + onInteraction: PropTypes.func.isRequired, }; -export default withGmp(CvssCalculator); +const mapDispatchToProps = (dispatch, {gmp}) => ({ + onInteraction: () => dispatch(renewSessionTimeout(gmp)()), +}); + +export default compose( + withGmp, + connect(undefined, mapDispatchToProps), +)(CvssCalculator); + +// vim: set ts=2 sw=2 tw=80: