fleet/frontend/components/side_panels/ScheduleQuerySidePanel/ScheduleQuerySidePanel.jsx
RachelElysia 05691d49ca
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
2021-07-26 14:41:36 -04:00

66 lines
1.7 KiB
JavaScript

import React from "react";
import PropTypes from "prop-types";
import ConfigurePackQueryForm from "components/forms/ConfigurePackQueryForm";
import queryInterface from "interfaces/query";
import scheduledQueryInterface from "interfaces/scheduled_query";
import SearchPackQuery from "./SearchPackQuery";
import SecondarySidePanelContainer from "../SecondarySidePanelContainer";
const baseClass = "schedule-query-side-panel";
const ScheduleQuerySidePanel = ({
allQueries,
onConfigurePackQuerySubmit,
onFormCancel,
onUpdateScheduledQuery,
onSelectQuery,
selectedQuery,
selectedScheduledQuery,
}) => {
const renderForm = () => {
if (!selectedQuery) {
return false;
}
const formData = selectedScheduledQuery || { logging_type: "snapshot" };
formData.query_id = selectedQuery.id;
const handleSubmit = selectedScheduledQuery
? onUpdateScheduledQuery
: onConfigurePackQuerySubmit;
return (
<ConfigurePackQueryForm
formData={formData}
handleSubmit={handleSubmit}
onCancel={onFormCancel}
/>
);
};
return (
<SecondarySidePanelContainer className={baseClass}>
<SearchPackQuery
allQueries={allQueries}
onSelectQuery={onSelectQuery}
selectedQuery={selectedQuery}
/>
{renderForm()}
</SecondarySidePanelContainer>
);
};
ScheduleQuerySidePanel.propTypes = {
allQueries: PropTypes.arrayOf(queryInterface),
onConfigurePackQuerySubmit: PropTypes.func,
onFormCancel: PropTypes.func,
onSelectQuery: PropTypes.func,
onUpdateScheduledQuery: PropTypes.func,
selectedQuery: queryInterface,
selectedScheduledQuery: scheduledQueryInterface,
};
export default ScheduleQuerySidePanel;