fleet/frontend/pages/queries/edit/components/SaveNewQueryModal/SaveNewQueryModal.tsx

368 lines
12 KiB
TypeScript
Raw Normal View History

import React, { useState, useEffect, useContext } from "react";
import { useQuery } from "react-query";
import { size } from "lodash";
import { AppContext } from "context/app";
import useDeepEffect from "hooks/useDeepEffect";
import { IPlatformSelector } from "hooks/usePlatformSelector";
import {
FREQUENCY_DROPDOWN_OPTIONS,
LOGGING_TYPE_OPTIONS,
MIN_OSQUERY_VERSION_OPTIONS,
DEFAULT_USE_QUERY_OPTIONS,
} from "utilities/constants";
import { CommaSeparatedPlatformString } from "interfaces/platform";
import {
ICreateQueryRequestBody,
ISchedulableQuery,
QueryLoggingOption,
} from "interfaces/schedulable_query";
import Checkbox from "components/forms/fields/Checkbox";
import InputField from "components/forms/fields/InputField";
// @ts-ignore
import Dropdown from "components/forms/fields/Dropdown";
import Slider from "components/forms/fields/Slider";
import TooltipWrapper from "components/TooltipWrapper";
import Icon from "components/Icon";
import Button from "components/buttons/Button";
import Modal from "components/Modal";
import RevealButton from "components/buttons/RevealButton";
import LogDestinationIndicator from "components/LogDestinationIndicator";
import TargetLabelSelector from "components/TargetLabelSelector";
import labelsAPI, {
getCustomLabels,
ILabelsSummaryResponse,
} from "services/entities/labels";
UI – Componentize "Discard data" option and add it to Edit Query page (#14343) ## Addresses #13470 - [x] Save query - [x] Add checkbox - [x] default unchecked - [x] If global setting is disabled (that is, "Disable query reports" is _enabled_) - [x] this box is disabled - [x] copy below is changed - [x] If enabled locally but globally disabled, box is checked and disabled - [x] If user clicks "Edit anyway", the normal checkbox state is restored, allowing them to edit it anyway., e.g. to prepare for enabling globally before doing so - [x] banner under [certain conditions](https://www.figma.com/file/ss8dSfoueq3REJxoGaxkNw/%237766-See-latest-query-results?type=design&node-id=470%3A9996&mode=design&t=XDBlQetD7kqdEdh9-1) - [x] 2 x update help text - [x] Edit query - [x] checkbox - [x] back button - [x] 2 x help text updates - [x] save changes modals when [conditions](https://www.figma.com/file/ss8dSfoueq3REJxoGaxkNw/%237766-See-latest-query-results?type=design&node-id=470%3A8745&mode=design&t=XDBlQetD7kqdEdh9-1) are met: - [x] changed SQL - [x] other - [x] Mange queries - update[ tooltip](https://www.figma.com/file/ss8dSfoueq3REJxoGaxkNw/%237766-See-latest-query-results?type=design&node-id=470%3A10035&mode=design&t=ACwsj3wVdqzCXulq-1) - [x] Significant cleanup and improvement of styles and structure around the Edit Queries page <img width="854" alt="Screenshot 2023-10-05 at 3 44 05 PM" src="https://github.com/fleetdm/fleet/assets/61553566/9831570f-3c83-4e59-b040-649d52faa257"> <img width="854" alt="Screenshot 2023-10-05 at 3 44 15 PM" src="https://github.com/fleetdm/fleet/assets/61553566/dec76eba-46d1-4e43-87e9-e7fc44e84691"> <img width="854" alt="Screenshot 2023-10-05 at 3 45 09 PM" src="https://github.com/fleetdm/fleet/assets/61553566/a7879b21-49b0-476a-81ab-6b465967510f"> <img width="854" alt="Screenshot 2023-10-05 at 3 45 29 PM" src="https://github.com/fleetdm/fleet/assets/61553566/14a90d0a-2a52-4e59-8ee8-fb76fce55417"> <img width="1105" alt="Screenshot 2023-10-05 at 3 46 58 PM" src="https://github.com/fleetdm/fleet/assets/61553566/6c488fbe-4e5a-442b-8b62-2ddd15bda1fe"> <img width="1105" alt="Screenshot 2023-10-05 at 3 47 10 PM" src="https://github.com/fleetdm/fleet/assets/61553566/649534c5-d859-41f9-8c8a-6882b1dc2219"> <img width="1105" alt="Screenshot 2023-10-05 at 3 47 24 PM" src="https://github.com/fleetdm/fleet/assets/61553566/eaa0469c-a57a-474d-87bc-21cf2133dd3c"> ## Checklist for submitter - [x] Added/updated tests - [ ] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2023-10-09 18:31:31 +00:00
import DiscardDataOption from "../DiscardDataOption";
const baseClass = "save-query-modal";
export interface ISaveNewQueryModalProps {
queryValue: string;
apiTeamIdForQuery?: number; // query will be global if omitted
isLoading: boolean;
saveQuery: (formData: ICreateQueryRequestBody) => void;
toggleSaveNewQueryModal: () => void;
backendValidators: { [key: string]: string };
existingQuery?: ISchedulableQuery;
UI – Componentize "Discard data" option and add it to Edit Query page (#14343) ## Addresses #13470 - [x] Save query - [x] Add checkbox - [x] default unchecked - [x] If global setting is disabled (that is, "Disable query reports" is _enabled_) - [x] this box is disabled - [x] copy below is changed - [x] If enabled locally but globally disabled, box is checked and disabled - [x] If user clicks "Edit anyway", the normal checkbox state is restored, allowing them to edit it anyway., e.g. to prepare for enabling globally before doing so - [x] banner under [certain conditions](https://www.figma.com/file/ss8dSfoueq3REJxoGaxkNw/%237766-See-latest-query-results?type=design&node-id=470%3A9996&mode=design&t=XDBlQetD7kqdEdh9-1) - [x] 2 x update help text - [x] Edit query - [x] checkbox - [x] back button - [x] 2 x help text updates - [x] save changes modals when [conditions](https://www.figma.com/file/ss8dSfoueq3REJxoGaxkNw/%237766-See-latest-query-results?type=design&node-id=470%3A8745&mode=design&t=XDBlQetD7kqdEdh9-1) are met: - [x] changed SQL - [x] other - [x] Mange queries - update[ tooltip](https://www.figma.com/file/ss8dSfoueq3REJxoGaxkNw/%237766-See-latest-query-results?type=design&node-id=470%3A10035&mode=design&t=ACwsj3wVdqzCXulq-1) - [x] Significant cleanup and improvement of styles and structure around the Edit Queries page <img width="854" alt="Screenshot 2023-10-05 at 3 44 05 PM" src="https://github.com/fleetdm/fleet/assets/61553566/9831570f-3c83-4e59-b040-649d52faa257"> <img width="854" alt="Screenshot 2023-10-05 at 3 44 15 PM" src="https://github.com/fleetdm/fleet/assets/61553566/dec76eba-46d1-4e43-87e9-e7fc44e84691"> <img width="854" alt="Screenshot 2023-10-05 at 3 45 09 PM" src="https://github.com/fleetdm/fleet/assets/61553566/a7879b21-49b0-476a-81ab-6b465967510f"> <img width="854" alt="Screenshot 2023-10-05 at 3 45 29 PM" src="https://github.com/fleetdm/fleet/assets/61553566/14a90d0a-2a52-4e59-8ee8-fb76fce55417"> <img width="1105" alt="Screenshot 2023-10-05 at 3 46 58 PM" src="https://github.com/fleetdm/fleet/assets/61553566/6c488fbe-4e5a-442b-8b62-2ddd15bda1fe"> <img width="1105" alt="Screenshot 2023-10-05 at 3 47 10 PM" src="https://github.com/fleetdm/fleet/assets/61553566/649534c5-d859-41f9-8c8a-6882b1dc2219"> <img width="1105" alt="Screenshot 2023-10-05 at 3 47 24 PM" src="https://github.com/fleetdm/fleet/assets/61553566/eaa0469c-a57a-474d-87bc-21cf2133dd3c"> ## Checklist for submitter - [x] Added/updated tests - [ ] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2023-10-09 18:31:31 +00:00
queryReportsDisabled?: boolean;
platformSelector: IPlatformSelector;
}
const validateQueryName = (name: string) => {
const errors: { [key: string]: string } = {};
if (!name) {
errors.name = "Report name must be present";
}
const valid = !size(errors);
return { valid, errors };
};
const SaveNewQueryModal = ({
queryValue,
apiTeamIdForQuery,
isLoading,
saveQuery,
toggleSaveNewQueryModal,
backendValidators,
existingQuery,
UI – Componentize "Discard data" option and add it to Edit Query page (#14343) ## Addresses #13470 - [x] Save query - [x] Add checkbox - [x] default unchecked - [x] If global setting is disabled (that is, "Disable query reports" is _enabled_) - [x] this box is disabled - [x] copy below is changed - [x] If enabled locally but globally disabled, box is checked and disabled - [x] If user clicks "Edit anyway", the normal checkbox state is restored, allowing them to edit it anyway., e.g. to prepare for enabling globally before doing so - [x] banner under [certain conditions](https://www.figma.com/file/ss8dSfoueq3REJxoGaxkNw/%237766-See-latest-query-results?type=design&node-id=470%3A9996&mode=design&t=XDBlQetD7kqdEdh9-1) - [x] 2 x update help text - [x] Edit query - [x] checkbox - [x] back button - [x] 2 x help text updates - [x] save changes modals when [conditions](https://www.figma.com/file/ss8dSfoueq3REJxoGaxkNw/%237766-See-latest-query-results?type=design&node-id=470%3A8745&mode=design&t=XDBlQetD7kqdEdh9-1) are met: - [x] changed SQL - [x] other - [x] Mange queries - update[ tooltip](https://www.figma.com/file/ss8dSfoueq3REJxoGaxkNw/%237766-See-latest-query-results?type=design&node-id=470%3A10035&mode=design&t=ACwsj3wVdqzCXulq-1) - [x] Significant cleanup and improvement of styles and structure around the Edit Queries page <img width="854" alt="Screenshot 2023-10-05 at 3 44 05 PM" src="https://github.com/fleetdm/fleet/assets/61553566/9831570f-3c83-4e59-b040-649d52faa257"> <img width="854" alt="Screenshot 2023-10-05 at 3 44 15 PM" src="https://github.com/fleetdm/fleet/assets/61553566/dec76eba-46d1-4e43-87e9-e7fc44e84691"> <img width="854" alt="Screenshot 2023-10-05 at 3 45 09 PM" src="https://github.com/fleetdm/fleet/assets/61553566/a7879b21-49b0-476a-81ab-6b465967510f"> <img width="854" alt="Screenshot 2023-10-05 at 3 45 29 PM" src="https://github.com/fleetdm/fleet/assets/61553566/14a90d0a-2a52-4e59-8ee8-fb76fce55417"> <img width="1105" alt="Screenshot 2023-10-05 at 3 46 58 PM" src="https://github.com/fleetdm/fleet/assets/61553566/6c488fbe-4e5a-442b-8b62-2ddd15bda1fe"> <img width="1105" alt="Screenshot 2023-10-05 at 3 47 10 PM" src="https://github.com/fleetdm/fleet/assets/61553566/649534c5-d859-41f9-8c8a-6882b1dc2219"> <img width="1105" alt="Screenshot 2023-10-05 at 3 47 24 PM" src="https://github.com/fleetdm/fleet/assets/61553566/eaa0469c-a57a-474d-87bc-21cf2133dd3c"> ## Checklist for submitter - [x] Added/updated tests - [ ] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2023-10-09 18:31:31 +00:00
queryReportsDisabled,
platformSelector,
}: ISaveNewQueryModalProps): JSX.Element => {
const { config, isPremiumTier, currentTeam } = useContext(AppContext);
const [name, setName] = useState("");
const [description, setDescription] = useState("");
const [selectedFrequency, setSelectedFrequency] = useState(
existingQuery?.interval ?? 3600
);
const [
selectedMinOsqueryVersionOptions,
setSelectedMinOsqueryVersionOptions,
] = useState(existingQuery?.min_osquery_version ?? "");
const [
selectedLoggingType,
setSelectedLoggingType,
] = useState<QueryLoggingOption>(existingQuery?.logging ?? "snapshot");
const [observerCanRun, setObserverCanRun] = useState(false);
const [automationsEnabled, setAutomationsEnabled] = useState(false);
const [selectedTargetType, setSelectedTargetType] = useState("All hosts");
const [selectedLabels, setSelectedLabels] = useState({});
const [discardData, setDiscardData] = useState(false);
const [errors, setErrors] = useState<{ [key: string]: string }>(
backendValidators
);
const [showAdvancedOptions, setShowAdvancedOptions] = useState(false);
const {
data: { labels } = { labels: [] },
isFetching: isFetchingLabels,
} = useQuery<ILabelsSummaryResponse, Error>(
["custom_labels"],
() => labelsAPI.summary(currentTeam?.id, true),
{
...DEFAULT_USE_QUERY_OPTIONS,
// Wait for the current team to load from context before pulling labels, otherwise on a page load
// directly on the page this gets called with currentTeam not set, then again
// with the correct team value. If we don't trigger on currentTeam changes we'll just start with a
// null team ID here and never populate with the correct team unless we navigate from another page
// where team context is already set prior to navigation.
enabled: isPremiumTier && !!currentTeam,
staleTime: 10000,
select: (res) => ({ labels: getCustomLabels(res.labels) }),
}
);
const onSelectLabel = ({
name: labelName,
value,
}: {
name: string;
value: boolean;
}) => {
setSelectedLabels({
...selectedLabels,
[labelName]: value,
});
};
const toggleAdvancedOptions = () => {
setShowAdvancedOptions(!showAdvancedOptions);
};
useDeepEffect(() => {
if (name) {
setErrors({});
}
}, [name]);
useEffect(() => {
setErrors(backendValidators);
}, [backendValidators]);
// Disable saving if "Custom" targeting is selected, but no labels are selected.
const canSave =
platformSelector.isAnyPlatformSelected &&
(selectedTargetType === "All hosts" ||
Object.entries(selectedLabels).some(([, value]) => {
return value;
}));
const onClickSaveQuery = (evt: React.MouseEvent<HTMLFormElement>) => {
evt.preventDefault();
const trimmedName = name.trim();
const { valid, errors: newErrors } = validateQueryName(trimmedName);
setErrors({
...errors,
...newErrors,
});
setName(trimmedName);
const newPlatformString = platformSelector
.getSelectedPlatforms()
.join(",") as CommaSeparatedPlatformString;
if (valid) {
saveQuery({
// from modal fields
name: trimmedName,
description,
interval: selectedFrequency,
observer_can_run: observerCanRun,
automations_enabled: automationsEnabled,
discard_data: discardData,
platform: newPlatformString,
min_osquery_version: selectedMinOsqueryVersionOptions,
logging: selectedLoggingType,
// from previous New query page
query: queryValue,
// from doubly previous ManageQueriesPage
Update API calls in front-end to use new, non-deprecated URLs and params (#41515) <!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #41391 # Details This PR updates front-end API calls to use new URLs and API params, so that the front end doesn't cause deprecation warnings to appear on the server. # Checklist for submitter If some of the following don't apply, delete the relevant line. - [ ] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files) for more information. n/a, should not be user-visible ## Testing - [X] Added/updated automated tests - [ ] QA'd all new/changed functionality manually The biggest risk here is not that we missed a spot that still causes a deprecation warning, but that we might inadvertently make a change that breaks the front end, for instance by sending `fleet_id` to a function that drops it silently and thus sends no ID to the server. Fortunately we use TypeScript in virtually every place affected by these changes, so the code would not compile if there were mismatches between the API expectation and what we're sending. Still, spot checking as many places as possible both for deprecation-warning leaks and loss of functionality is important. ## Summary by CodeRabbit * **Refactor** * Updated API nomenclature across the application to use "fleets" instead of "teams" and "reports" instead of "queries" in endpoint paths and request/response payloads. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-03-13 03:26:48 +00:00
fleet_id: apiTeamIdForQuery,
labels_include_any:
selectedTargetType === "Custom"
? Object.entries(selectedLabels)
.filter(([, selected]) => selected)
.map(([labelName]) => labelName)
: [],
});
}
};
return (
<Modal title="Save report" onExit={toggleSaveNewQueryModal}>
<form
onSubmit={onClickSaveQuery}
className={baseClass}
autoComplete="off"
>
<InputField
name="name"
onChange={(value: string) => setName(value)}
onBlur={() => {
setName(name.trim());
}}
value={name}
error={errors.name}
inputClassName={`${baseClass}__name`}
label="Name"
autofocus
ignore1password
/>
<InputField
name="description"
onChange={(value: string) => setDescription(value)}
value={description}
inputClassName={`${baseClass}__description`}
label="Description"
type="textarea"
helpText="What information does your report reveal? (optional)"
/>
<Dropdown
searchable={false}
options={FREQUENCY_DROPDOWN_OPTIONS}
onChange={(value: number) => {
setSelectedFrequency(value);
}}
placeholder="Every hour"
value={selectedFrequency}
label="Interval"
UI – Componentize "Discard data" option and add it to Edit Query page (#14343) ## Addresses #13470 - [x] Save query - [x] Add checkbox - [x] default unchecked - [x] If global setting is disabled (that is, "Disable query reports" is _enabled_) - [x] this box is disabled - [x] copy below is changed - [x] If enabled locally but globally disabled, box is checked and disabled - [x] If user clicks "Edit anyway", the normal checkbox state is restored, allowing them to edit it anyway., e.g. to prepare for enabling globally before doing so - [x] banner under [certain conditions](https://www.figma.com/file/ss8dSfoueq3REJxoGaxkNw/%237766-See-latest-query-results?type=design&node-id=470%3A9996&mode=design&t=XDBlQetD7kqdEdh9-1) - [x] 2 x update help text - [x] Edit query - [x] checkbox - [x] back button - [x] 2 x help text updates - [x] save changes modals when [conditions](https://www.figma.com/file/ss8dSfoueq3REJxoGaxkNw/%237766-See-latest-query-results?type=design&node-id=470%3A8745&mode=design&t=XDBlQetD7kqdEdh9-1) are met: - [x] changed SQL - [x] other - [x] Mange queries - update[ tooltip](https://www.figma.com/file/ss8dSfoueq3REJxoGaxkNw/%237766-See-latest-query-results?type=design&node-id=470%3A10035&mode=design&t=ACwsj3wVdqzCXulq-1) - [x] Significant cleanup and improvement of styles and structure around the Edit Queries page <img width="854" alt="Screenshot 2023-10-05 at 3 44 05 PM" src="https://github.com/fleetdm/fleet/assets/61553566/9831570f-3c83-4e59-b040-649d52faa257"> <img width="854" alt="Screenshot 2023-10-05 at 3 44 15 PM" src="https://github.com/fleetdm/fleet/assets/61553566/dec76eba-46d1-4e43-87e9-e7fc44e84691"> <img width="854" alt="Screenshot 2023-10-05 at 3 45 09 PM" src="https://github.com/fleetdm/fleet/assets/61553566/a7879b21-49b0-476a-81ab-6b465967510f"> <img width="854" alt="Screenshot 2023-10-05 at 3 45 29 PM" src="https://github.com/fleetdm/fleet/assets/61553566/14a90d0a-2a52-4e59-8ee8-fb76fce55417"> <img width="1105" alt="Screenshot 2023-10-05 at 3 46 58 PM" src="https://github.com/fleetdm/fleet/assets/61553566/6c488fbe-4e5a-442b-8b62-2ddd15bda1fe"> <img width="1105" alt="Screenshot 2023-10-05 at 3 47 10 PM" src="https://github.com/fleetdm/fleet/assets/61553566/649534c5-d859-41f9-8c8a-6882b1dc2219"> <img width="1105" alt="Screenshot 2023-10-05 at 3 47 24 PM" src="https://github.com/fleetdm/fleet/assets/61553566/eaa0469c-a57a-474d-87bc-21cf2133dd3c"> ## Checklist for submitter - [x] Added/updated tests - [ ] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2023-10-09 18:31:31 +00:00
wrapperClassName={`${baseClass}__form-field form-field--frequency`}
helpText="This is how often your report collects data."
/>
<Checkbox
name="observerCanRun"
onChange={setObserverCanRun}
value={observerCanRun}
wrapperClassName="observer-can-run-wrapper"
helpText="Users with the Observer role will be able to run this report as a live report."
>
Observers can run
</Checkbox>
<Slider
onChange={() => setAutomationsEnabled(!automationsEnabled)}
value={automationsEnabled}
activeText={
<>
Automations on
{selectedFrequency === 0 && (
<TooltipWrapper
tipContent={
<>
Automations and reporting will be paused <br />
for this report until an interval is set.
</>
}
position="right"
tipOffset={9}
showArrow
underline={false}
>
<Icon name="warning" />
</TooltipWrapper>
)}
</>
}
inactiveText="Automations off"
helpText={
<>
Historical results will {!automationsEnabled ? "not " : ""}be sent
to your log destination:{" "}
<b>
<LogDestinationIndicator
logDestination={config?.logging.result.plugin || ""}
filesystemDestination={
config?.logging.result.config?.result_log_file
}
webhookDestination={config?.logging.result.config?.result_url}
excludeTooltip
/>
</b>
.
</>
}
/>
{platformSelector.render()}
{isPremiumTier && (
<TargetLabelSelector
selectedTargetType={selectedTargetType}
selectedLabels={selectedLabels}
className={`${baseClass}__target`}
onSelectTargetType={setSelectedTargetType}
onSelectLabel={onSelectLabel}
labels={labels || []}
customHelpText={
<span className="form-field__help-text">
Report will target hosts that <b>have any</b> of these labels:
</span>
}
suppressTitle
/>
)}
<RevealButton
isShowing={showAdvancedOptions}
className="advanced-options-toggle"
hideText="Advanced options"
showText="Advanced options"
caretPosition="after"
onClick={toggleAdvancedOptions}
/>
{showAdvancedOptions && (
<>
<Dropdown
options={MIN_OSQUERY_VERSION_OPTIONS}
onChange={setSelectedMinOsqueryVersionOptions}
placeholder="Select"
value={selectedMinOsqueryVersionOptions}
label="Minimum osquery version"
wrapperClassName={`${baseClass}__form-field ${baseClass}__form-field--osquer-vers`}
/>
<Dropdown
options={LOGGING_TYPE_OPTIONS}
onChange={setSelectedLoggingType}
placeholder="Select"
value={selectedLoggingType}
label="Logging"
wrapperClassName={`${baseClass}__form-field ${baseClass}__form-field--logging`}
/>
UI – Componentize "Discard data" option and add it to Edit Query page (#14343) ## Addresses #13470 - [x] Save query - [x] Add checkbox - [x] default unchecked - [x] If global setting is disabled (that is, "Disable query reports" is _enabled_) - [x] this box is disabled - [x] copy below is changed - [x] If enabled locally but globally disabled, box is checked and disabled - [x] If user clicks "Edit anyway", the normal checkbox state is restored, allowing them to edit it anyway., e.g. to prepare for enabling globally before doing so - [x] banner under [certain conditions](https://www.figma.com/file/ss8dSfoueq3REJxoGaxkNw/%237766-See-latest-query-results?type=design&node-id=470%3A9996&mode=design&t=XDBlQetD7kqdEdh9-1) - [x] 2 x update help text - [x] Edit query - [x] checkbox - [x] back button - [x] 2 x help text updates - [x] save changes modals when [conditions](https://www.figma.com/file/ss8dSfoueq3REJxoGaxkNw/%237766-See-latest-query-results?type=design&node-id=470%3A8745&mode=design&t=XDBlQetD7kqdEdh9-1) are met: - [x] changed SQL - [x] other - [x] Mange queries - update[ tooltip](https://www.figma.com/file/ss8dSfoueq3REJxoGaxkNw/%237766-See-latest-query-results?type=design&node-id=470%3A10035&mode=design&t=ACwsj3wVdqzCXulq-1) - [x] Significant cleanup and improvement of styles and structure around the Edit Queries page <img width="854" alt="Screenshot 2023-10-05 at 3 44 05 PM" src="https://github.com/fleetdm/fleet/assets/61553566/9831570f-3c83-4e59-b040-649d52faa257"> <img width="854" alt="Screenshot 2023-10-05 at 3 44 15 PM" src="https://github.com/fleetdm/fleet/assets/61553566/dec76eba-46d1-4e43-87e9-e7fc44e84691"> <img width="854" alt="Screenshot 2023-10-05 at 3 45 09 PM" src="https://github.com/fleetdm/fleet/assets/61553566/a7879b21-49b0-476a-81ab-6b465967510f"> <img width="854" alt="Screenshot 2023-10-05 at 3 45 29 PM" src="https://github.com/fleetdm/fleet/assets/61553566/14a90d0a-2a52-4e59-8ee8-fb76fce55417"> <img width="1105" alt="Screenshot 2023-10-05 at 3 46 58 PM" src="https://github.com/fleetdm/fleet/assets/61553566/6c488fbe-4e5a-442b-8b62-2ddd15bda1fe"> <img width="1105" alt="Screenshot 2023-10-05 at 3 47 10 PM" src="https://github.com/fleetdm/fleet/assets/61553566/649534c5-d859-41f9-8c8a-6882b1dc2219"> <img width="1105" alt="Screenshot 2023-10-05 at 3 47 24 PM" src="https://github.com/fleetdm/fleet/assets/61553566/eaa0469c-a57a-474d-87bc-21cf2133dd3c"> ## Checklist for submitter - [x] Added/updated tests - [ ] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2023-10-09 18:31:31 +00:00
{queryReportsDisabled !== undefined && (
<DiscardDataOption
{...{
queryReportsDisabled,
selectedLoggingType,
discardData,
setDiscardData,
breakHelpText: true,
}}
/>
)}
</>
)}
<div className="modal-cta-wrap">
<Button
type="submit"
className="save-query-loading"
isLoading={isLoading || isFetchingLabels}
disabled={!canSave}
>
Save
</Button>
<Button onClick={toggleSaveNewQueryModal} variant="inverse">
Cancel
</Button>
</div>
</form>
</Modal>
);
};
export default SaveNewQueryModal;