fleet/frontend/components/queries/QueryPageSelectTargets/QueryPageSelectTargets.jsx
RachelElysia 78fb7e22cc
Query Edit/Run Page: Conditionally render Teams grouping in select targets dropdown (#1040)
* Conditionally render teams in targets dropdown
* Modify tests accordingly
2021-06-10 11:35:42 -04:00

71 lines
2.0 KiB
JavaScript

import React, { Component } from "react";
import PropTypes from "prop-types";
import campaignInterface from "interfaces/campaign";
import QueryProgressDetails from "components/queries/QueryProgressDetails";
import SelectTargetsDropdown from "components/forms/fields/SelectTargetsDropdown";
import targetInterface from "interfaces/target";
const baseClass = "query-page-select-targets";
class QueryPageSelectTargets extends Component {
static propTypes = {
campaign: campaignInterface,
error: PropTypes.string,
onFetchTargets: PropTypes.func.isRequired,
onRunQuery: PropTypes.func.isRequired,
onStopQuery: PropTypes.func.isRequired,
onTargetSelect: PropTypes.func.isRequired,
queryIsRunning: PropTypes.bool,
selectedTargets: PropTypes.arrayOf(targetInterface),
targetsCount: PropTypes.number,
queryTimerMilliseconds: PropTypes.number,
disableRun: PropTypes.bool,
queryId: PropTypes.number,
isBasicTier: PropTypes.bool,
};
render() {
const {
error,
onFetchTargets,
onTargetSelect,
selectedTargets,
targetsCount,
campaign,
onRunQuery,
onStopQuery,
queryIsRunning,
queryTimerMilliseconds,
disableRun,
queryId,
isBasicTier,
} = this.props;
return (
<div className={`${baseClass}__wrapper body-wrap`}>
<SelectTargetsDropdown
error={error}
onFetchTargets={onFetchTargets}
onSelect={onTargetSelect}
selectedTargets={selectedTargets}
targetsCount={targetsCount}
label="Select targets"
queryId={queryId}
isBasicTier={isBasicTier}
/>
<QueryProgressDetails
campaign={campaign}
onRunQuery={onRunQuery}
onStopQuery={onStopQuery}
queryIsRunning={queryIsRunning}
queryTimerMilliseconds={queryTimerMilliseconds}
disableRun={disableRun}
/>
</div>
);
}
}
export default QueryPageSelectTargets;