Schedule Page - New Feature! (#1333)
- Schedule page functionality: Create (modal), delete (modal), view schedule, advanced options - Replaces Packs tab with Schedules tab - Updates e2e tests, mocks, stubs, etc - Defaults logging type to snapshot for packs - Adds conversion helpers and tests helper functions - Adds global_scheduled_queries to redux
This commit is contained in:
@@ -8,6 +8,12 @@ import Form from "components/forms/Form";
|
||||
import formFieldInterface from "interfaces/form_field";
|
||||
import InputField from "components/forms/fields/InputField";
|
||||
import validate from "components/forms/ConfigurePackQueryForm/validate";
|
||||
import {
|
||||
FREQUENCY_DROPDOWN_OPTIONS,
|
||||
PLATFORM_OPTIONS,
|
||||
LOGGING_TYPE_OPTIONS,
|
||||
MIN_OSQUERY_VERSION_OPTIONS,
|
||||
} from "utilities/constants";
|
||||
|
||||
const baseClass = "configure-pack-query-form";
|
||||
const fieldNames = [
|
||||
@@ -18,47 +24,6 @@ const fieldNames = [
|
||||
"shard",
|
||||
"version",
|
||||
];
|
||||
const platformOptions = [
|
||||
{ label: "All", value: "" },
|
||||
{ label: "Windows", value: "windows" },
|
||||
{ label: "Linux", value: "linux" },
|
||||
{ label: "macOS", value: "darwin" },
|
||||
];
|
||||
const loggingTypeOptions = [
|
||||
{ label: "Differential", value: "differential" },
|
||||
{
|
||||
label: "Differential (Ignore Removals)",
|
||||
value: "differential_ignore_removals",
|
||||
},
|
||||
{ label: "Snapshot", value: "snapshot" },
|
||||
];
|
||||
const minOsqueryVersionOptions = [
|
||||
{ label: "All", value: "" },
|
||||
{ label: "4.7.0 +", value: "4.7.0" },
|
||||
{ label: "4.6.0 +", value: "4.6.0" },
|
||||
{ label: "4.5.1 +", value: "4.5.1" },
|
||||
{ label: "4.5.0 +", value: "4.5.0" },
|
||||
{ label: "4.4.0 +", value: "4.4.0" },
|
||||
{ label: "4.3.0 +", value: "4.3.0" },
|
||||
{ label: "4.2.0 +", value: "4.2.0" },
|
||||
{ label: "4.1.2 +", value: "4.1.2" },
|
||||
{ label: "4.1.1 +", value: "4.1.1" },
|
||||
{ label: "4.1.0 +", value: "4.1.0" },
|
||||
{ label: "4.0.2 +", value: "4.0.2" },
|
||||
{ label: "4.0.1 +", value: "4.0.1" },
|
||||
{ label: "4.0.0 +", value: "4.0.0" },
|
||||
{ label: "3.4.0 +", value: "3.4.0" },
|
||||
{ label: "3.3.2 +", value: "3.3.2" },
|
||||
{ label: "3.3.1 +", value: "3.3.1" },
|
||||
{ label: "3.2.6 +", value: "3.2.6" },
|
||||
{ label: "2.2.1 +", value: "2.2.1" },
|
||||
{ label: "2.2.0 +", value: "2.2.0" },
|
||||
{ label: "2.1.2 +", value: "2.1.2" },
|
||||
{ label: "2.1.1 +", value: "2.1.1" },
|
||||
{ label: "2.0.0 +", value: "2.0.0" },
|
||||
{ label: "1.8.2 +", value: "1.8.2" },
|
||||
{ label: "1.8.1 +", value: "1.8.1" },
|
||||
];
|
||||
|
||||
export class ConfigurePackQueryForm extends Component {
|
||||
static propTypes = {
|
||||
@@ -134,15 +99,19 @@ export class ConfigurePackQueryForm extends Component {
|
||||
const { fields, handleSubmit } = this.props;
|
||||
const { handlePlatformChoice, renderCancelButton } = this;
|
||||
|
||||
// Uncontrolled form field defaults to snapshot if !fields.logging_type
|
||||
const loggingType = fields.logging_type.value || "snapshot";
|
||||
|
||||
return (
|
||||
<form className={baseClass} onSubmit={handleSubmit}>
|
||||
<h2 className={`${baseClass}__title`}>Configuration</h2>
|
||||
<div className={`${baseClass}__fields`}>
|
||||
<Dropdown
|
||||
{...fields.logging_type}
|
||||
options={loggingTypeOptions}
|
||||
options={LOGGING_TYPE_OPTIONS}
|
||||
placeholder="- - -"
|
||||
label="Logging"
|
||||
value={loggingType}
|
||||
wrapperClassName={`${baseClass}__form-field ${baseClass}__form-field--logging`}
|
||||
/>
|
||||
<InputField
|
||||
@@ -155,7 +124,7 @@ export class ConfigurePackQueryForm extends Component {
|
||||
/>
|
||||
<Dropdown
|
||||
{...fields.platform}
|
||||
options={platformOptions}
|
||||
options={PLATFORM_OPTIONS}
|
||||
placeholder="- - -"
|
||||
label="Platform"
|
||||
onChange={handlePlatformChoice}
|
||||
@@ -164,7 +133,7 @@ export class ConfigurePackQueryForm extends Component {
|
||||
/>
|
||||
<Dropdown
|
||||
{...fields.version}
|
||||
options={minOsqueryVersionOptions}
|
||||
options={MIN_OSQUERY_VERSION_OPTIONS}
|
||||
placeholder="- - -"
|
||||
label="Minimum osquery version"
|
||||
wrapperClassName={`${baseClass}__form-field ${baseClass}__form-field--osquer-vers`}
|
||||
|
||||
@@ -75,7 +75,7 @@ describe("ConfigurePackQueryForm - component", () => {
|
||||
|
||||
expect(spy).toHaveBeenCalledWith({
|
||||
interval: 123,
|
||||
logging_type: "differential",
|
||||
logging_type: "snapshot",
|
||||
platform: "",
|
||||
query_id: 1,
|
||||
version: "",
|
||||
|
||||
@@ -17,9 +17,7 @@ const validate = (formData) => {
|
||||
errors.interval = "Frequency must be a number";
|
||||
}
|
||||
|
||||
if (!formData.logging_type) {
|
||||
errors.logging_type = "A Logging Type must be selected";
|
||||
}
|
||||
// logging_type does not need to be validated because it is defaulted "snapshot" if unspecified.
|
||||
|
||||
if (formData.shard) {
|
||||
if (formData.shard < 0 || formData.shard > 100) {
|
||||
|
||||
Reference in New Issue
Block a user