mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 09:18:59 +00:00
05691d49ca
- 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
66 lines
1.7 KiB
JavaScript
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;
|