mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
_Only merge to `main` after [back end](https://github.com/fleetdm/fleet/pull/29149) and [back end extension](https://github.com/fleetdm/fleet/pull/29312)_ ## For #28699, #29143, #29281 - Run scripts by filter - View batch script run summary via activity feed - Code clean up ### Run scripts by filter: <img width="1280" alt="Screenshot 2025-05-09 at 5 21 51 PM" src="https://github.com/user-attachments/assets/bcf2e275-f229-461b-8411-0e99c34af5bf" /> <img width="1280" alt="Screenshot 2025-05-09 at 5 22 47 PM" src="https://github.com/user-attachments/assets/d4882ed3-cfa6-4952-acbe-89c60d65d482" /> ### View script run summary:  - [x] Changes file added for user-visible changes in `changes/` - [x] A detailed QA plan exists on the associated ticket (if it isn't there, work with the product group's QA engineer to add it) - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
87 lines
2.1 KiB
TypeScript
87 lines
2.1 KiB
TypeScript
import React from "react";
|
|
import classnames from "classnames";
|
|
|
|
import { IconNames } from "components/icons";
|
|
import Icon from "components/Icon";
|
|
import TooltipWrapper from "components/TooltipWrapper";
|
|
|
|
const baseClass = "status-indicator-with-icon";
|
|
|
|
export type IndicatorStatus =
|
|
| "success"
|
|
| "successPartial"
|
|
| "pending"
|
|
| "pendingPartial"
|
|
| "error"
|
|
| "failure"
|
|
| "actionRequired";
|
|
|
|
interface IStatusIndicatorWithIconProps {
|
|
/** Determines which icon to display */
|
|
status: IndicatorStatus;
|
|
/** The text to be displayed */
|
|
value: string;
|
|
tooltip?: {
|
|
tooltipText: string | JSX.Element;
|
|
position?: "top" | "bottom";
|
|
};
|
|
layout?: "horizontal" | "vertical";
|
|
className?: string;
|
|
/** Classname to add to the value text */
|
|
valueClassName?: string;
|
|
}
|
|
|
|
const statusIconNameMapping: Record<IndicatorStatus, IconNames> = {
|
|
success: "success",
|
|
successPartial: "success-outline",
|
|
pending: "pending",
|
|
pendingPartial: "pending-outline",
|
|
error: "error",
|
|
failure: "error-outline",
|
|
actionRequired: "error",
|
|
};
|
|
|
|
const StatusIndicatorWithIcon = ({
|
|
status,
|
|
value,
|
|
tooltip,
|
|
layout = "horizontal",
|
|
className,
|
|
valueClassName,
|
|
}: IStatusIndicatorWithIconProps) => {
|
|
const classNames = classnames(baseClass, className);
|
|
|
|
const valueClasses = classnames(`${baseClass}__value`, valueClassName, {
|
|
[`${baseClass}__value-vertical`]: layout === "vertical",
|
|
});
|
|
const valueContent = (
|
|
<span className={valueClasses}>
|
|
<Icon
|
|
name={statusIconNameMapping[status]}
|
|
color={status === "failure" ? "ui-fleet-black-50" : undefined}
|
|
/>
|
|
<span>{value}</span>
|
|
</span>
|
|
);
|
|
|
|
const indicatorContent = tooltip ? (
|
|
<TooltipWrapper
|
|
className={`${baseClass}__tooltip`}
|
|
tooltipClass="indicator-tip-text"
|
|
position="top"
|
|
tipContent={tooltip.tooltipText}
|
|
tipOffset={10}
|
|
showArrow
|
|
underline={false}
|
|
fixedPositionStrategy
|
|
>
|
|
{valueContent}
|
|
</TooltipWrapper>
|
|
) : (
|
|
<span>{valueContent}</span>
|
|
);
|
|
|
|
return <div className={classNames}>{indicatorContent}</div>;
|
|
};
|
|
|
|
export default StatusIndicatorWithIcon;
|