mirror of
https://github.com/fleetdm/fleet
synced 2026-05-16 13:38:43 +00:00
92 lines
2.7 KiB
TypeScript
92 lines
2.7 KiB
TypeScript
import Checkbox from "components/forms/fields/Checkbox";
|
|
import Icon from "components/Icon";
|
|
import InfoBanner from "components/InfoBanner";
|
|
import TooltipWrapper from "components/TooltipWrapper";
|
|
import { QueryLoggingOption } from "interfaces/schedulable_query";
|
|
import React, { useState } from "react";
|
|
import { Link } from "react-router";
|
|
|
|
const baseClass = "discard-data-option";
|
|
|
|
interface IDiscardDataOptionProps {
|
|
queryReportsDisabled: boolean;
|
|
selectedLoggingType: QueryLoggingOption;
|
|
discardData: boolean;
|
|
setDiscardData: (value: boolean) => void;
|
|
}
|
|
|
|
const DiscardDataOption = ({
|
|
queryReportsDisabled,
|
|
selectedLoggingType,
|
|
discardData,
|
|
setDiscardData,
|
|
}: IDiscardDataOptionProps) => {
|
|
const [forceEditDiscardData, setForceEditDiscardData] = useState(false);
|
|
const disable = queryReportsDisabled && !forceEditDiscardData;
|
|
|
|
const renderHelpText = () => (
|
|
<div className="help-text">
|
|
{disable ? (
|
|
<>
|
|
This setting is ignored because query reports in Fleet have been{" "}
|
|
<TooltipWrapper
|
|
tipContent={
|
|
<>
|
|
A Fleet administrator can enable query reports under <br />
|
|
<b>
|
|
Organization settings > Advanced options > Disable query
|
|
reports
|
|
</b>
|
|
.
|
|
</>
|
|
}
|
|
>
|
|
{"globally disabled."}
|
|
</TooltipWrapper>{" "}
|
|
<Link
|
|
to=""
|
|
onClick={(e: React.MouseEvent) => {
|
|
e.preventDefault();
|
|
setForceEditDiscardData(true);
|
|
}}
|
|
className={`${baseClass}__edit-anyway`}
|
|
>
|
|
<>
|
|
Edit anyway
|
|
<Icon name="chevron-right" color="core-fleet-blue" size="small" />
|
|
</>
|
|
</Link>
|
|
</>
|
|
) : (
|
|
"The most recent results for each host will not be available in Fleet."
|
|
)}
|
|
</div>
|
|
);
|
|
return (
|
|
<div className={baseClass}>
|
|
{["differential", "differential_ignore_removals"].includes(
|
|
selectedLoggingType
|
|
) && (
|
|
<>
|
|
<InfoBanner color="purple">
|
|
The <b>Discard data</b> setting is ignored when differential logging
|
|
is enabled. This query's results will not be saved in Fleet.
|
|
</InfoBanner>
|
|
</>
|
|
)}
|
|
<Checkbox
|
|
name="discardData"
|
|
onChange={setDiscardData}
|
|
value={discardData}
|
|
wrapperClassName={
|
|
disable ? `${baseClass}__disabled-discard-data-checkbox` : ""
|
|
}
|
|
helpText={renderHelpText()}
|
|
>
|
|
Discard data
|
|
</Checkbox>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default DiscardDataOption;
|