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

Add loading indicator for select #1716

Merged
merged 11 commits into from
Nov 5, 2019
Prev Previous commit
Next Next commit
add isLoading props for entities in task dialog
  • Loading branch information
sarahd93 committed Oct 28, 2019
commit 07a11e1cba72bbfcd5dc7bbc3f5c425374176cbc
47 changes: 41 additions & 6 deletions gsa/src/web/pages/tasks/component.js
Original file line number Diff line number Diff line change
@@ -16,6 +16,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
import 'core-js/features/promise/finally';

import React from 'react';

import {connect} from 'react-redux';
@@ -399,12 +401,33 @@ class TaskComponent extends React.Component {
openStandardTaskDialog(task) {
const {capabilities} = this.props;

this.props.loadAlerts();
this.props.loadScanConfigs();
this.props.loadScanners();
this.props.loadSchedules();
this.props.loadTargets();
this.props.loadTags();
this.setState({
isLoadingAlerts: true,
isLoadingConfigs: true,
isLoadingScanners: true,
isLoadingSchedules: true,
isLoadingTargets: true,
isLoadingTags: true,
});

this.props.loadAlerts().finally(() => {
this.setState({isLoadingAlerts: false});
});
this.props.loadScanConfigs().finally(() => {
this.setState({isLoadingConfigs: false});
});
this.props.loadScanners().finally(() => {
this.setState({isLoadingScanners: false});
});
this.props.loadSchedules().finally(() => {
this.setState({isLoadingSchedules: false});
});
this.props.loadTargets().finally(() => {
this.setState({isLoadingTargets: false});
});
this.props.loadTags().finally(() => {
this.setState({isLoadingTags: false});
});

if (isDefined(task)) {
const canAccessSchedules =
@@ -706,6 +729,12 @@ class TaskComponent extends React.Component {
hosts_ordering,
id,
in_assets,
isLoadingAlerts,
isLoadingConfigs,
isLoadingScanners,
isLoadingSchedules,
isLoadingTargets,
isLoadingTags,
max_checks,
max_hosts,
min_qod,
@@ -793,6 +822,12 @@ class TaskComponent extends React.Component {
hosts_ordering={hosts_ordering}
id={id}
in_assets={in_assets}
isLoadingAlerts={isLoadingAlerts}
isLoadingConfigs={isLoadingConfigs}
isLoadingScanners={isLoadingScanners}
isLoadingSchedules={isLoadingSchedules}
isLoadingTargets={isLoadingTargets}
isLoadingTags={isLoadingTags}
max_checks={max_checks}
max_hosts={max_hosts}
min_qod={min_qod}
22 changes: 21 additions & 1 deletion gsa/src/web/pages/tasks/dialog.js
Original file line number Diff line number Diff line change
@@ -102,7 +102,7 @@ const get_scanner = (scanners, scanner_id) => {
};

const ScannerSelect = props => {
const {changeTask, scannerId, scanners, onChange} = props;
const {changeTask, loading, scannerId, scanners, onChange} = props;
sarahd93 marked this conversation as resolved.
Show resolved Hide resolved

return (
<FormGroup title={_('Scanner')}>
@@ -111,6 +111,7 @@ const ScannerSelect = props => {
value={scannerId}
disabled={!changeTask}
items={renderSelectItems(scanners)}
loading={loading}
sarahd93 marked this conversation as resolved.
Show resolved Hide resolved
onChange={onChange}
/>
</FormGroup>
@@ -119,6 +120,7 @@ const ScannerSelect = props => {

ScannerSelect.propTypes = {
changeTask: PropTypes.bool.isRequired,
loading: PropTypes.bool,
sarahd93 marked this conversation as resolved.
Show resolved Hide resolved
scanConfigs: PropTypes.shape({
[OPENVAS_SCANNER_TYPE]: PropTypes.array,
[OSP_SCANNER_TYPE]: PropTypes.array,
@@ -141,6 +143,12 @@ const TaskDialog = ({
config_id,
hosts_ordering = HOSTS_ORDERING_SEQUENTIAL,
in_assets = YES_VALUE,
isLoadingAlerts = false,
isLoadingConfigs = false,
isLoadingScanners = false,
isLoadingSchedules = false,
isLoadingTargets = false,
isLoadingTags = false,
max_checks = DEFAULT_MAX_CHECKS,
max_hosts = DEFAULT_MAX_HOSTS,
min_qod = DEFAULT_MIN_QOD,
@@ -348,6 +356,7 @@ const TaskDialog = ({
name="target_id"
disabled={!change_task}
items={target_items}
loading={isLoadingTargets}
sarahd93 marked this conversation as resolved.
Show resolved Hide resolved
value={state.target_id}
width="260px"
onChange={onTargetChange}
@@ -370,6 +379,7 @@ const TaskDialog = ({
<MultiSelect
name="alert_ids"
items={alert_items}
loading={isLoadingAlerts}
sarahd93 marked this conversation as resolved.
Show resolved Hide resolved
value={state.alert_ids}
width="260px"
onChange={onAlertsChange}
@@ -391,6 +401,7 @@ const TaskDialog = ({
name="schedule_id"
value={state.schedule_id}
items={schedule_items}
loading={isLoadingSchedules}
sarahd93 marked this conversation as resolved.
Show resolved Hide resolved
width="201px"
onChange={onScheduleChange}
/>
@@ -469,6 +480,7 @@ const TaskDialog = ({
scanners={scanners}
scannerId={state.scanner_id}
changeTask={change_task}
loading={isLoadingScanners}
sarahd93 marked this conversation as resolved.
Show resolved Hide resolved
onChange={handleScannerChange}
/>
</div>
@@ -488,6 +500,7 @@ const TaskDialog = ({
name="config_id"
disabled={!change_task}
items={openvas_scan_config_items}
loading={isLoadingConfigs}
sarahd93 marked this conversation as resolved.
Show resolved Hide resolved
value={openvas_config_id}
onChange={value => {
onScanConfigChange(value);
@@ -586,6 +599,7 @@ const TaskDialog = ({
disabled={state.add_tag !== YES_VALUE}
name="tag_id"
items={tag_items}
loading={isLoadingTags}
sarahd93 marked this conversation as resolved.
Show resolved Hide resolved
value={state.tag_id}
onChange={onValueChange}
/>
@@ -613,6 +627,12 @@ TaskDialog.propTypes = {
config_id: PropTypes.idOrZero,
hosts_ordering: PropTypes.oneOf(['sequential', 'random', 'reverse']),
in_assets: PropTypes.yesno,
isLoadingAlerts: PropTypes.bool,
isLoadingConfigs: PropTypes.bool,
isLoadingScanners: PropTypes.bool,
isLoadingSchedules: PropTypes.bool,
isLoadingTags: PropTypes.bool,
isLoadingTargets: PropTypes.bool,
max_checks: PropTypes.number,
max_hosts: PropTypes.number,
min_qod: PropTypes.number,