fleet/frontend/components/GitOpsModeTooltipWrapper/GitOpsModeTooltipWrapper.tsx
jacobshandling 3049d3c3d0
UI: Add configuration option for customer-preston (#28941)
## For #28221, frontend portion

- In desired places, read new config option and render desired UI
accordingly
- Code refactors to more elegantly support this functionality
- Backend branch [here](https://github.com/fleetdm/fleet/pull/28893) for
testing
![Screenshot 2025-05-07 at 2 38
14 PM](https://github.com/user-attachments/assets/5130a96d-ee6e-480f-a1f7-9ff0b3c0dda3)
![Screenshot 2025-05-07 at 2 37
36 PM](https://github.com/user-attachments/assets/f487212d-2620-4c01-9f9d-534fc34396e5)
![Screenshot 2025-05-07 at 2 29
17 PM](https://github.com/user-attachments/assets/d3814704-8d72-4a57-9d81-3f5345d60d46)
<img width="1012" alt="Screenshot 2025-05-07 at 12 00 04 PM"
src="https://github.com/user-attachments/assets/81519388-7696-4a7e-a55a-0d0874c17aad"
/>

**Teams dropdowns:**

![ezgif-7e20570dcd7c58](https://github.com/user-attachments/assets/2bf2b8ca-0d55-495d-8653-ab564320aa13)


- [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>
2025-05-12 13:36:38 -07:00

52 lines
1.4 KiB
TypeScript

import TooltipWrapper, {
ITooltipWrapper,
} from "components/TooltipWrapper/TooltipWrapper";
import { AppContext } from "context/app";
import React, { useContext } from "react";
import { getGitOpsModeTipContent } from "utilities/helpers";
interface IGitOpsModeTooltipWrapper {
renderChildren: (disableChildren?: boolean) => React.ReactNode;
position?: ITooltipWrapper["position"];
tipOffset?: ITooltipWrapper["tipOffset"];
fixedPositionStrategy?: ITooltipWrapper["fixedPositionStrategy"];
}
const baseClass = "gitops-mode-tooltip-wrapper";
const GitOpsModeTooltipWrapper = ({
position = "top",
tipOffset,
renderChildren,
fixedPositionStrategy,
}: IGitOpsModeTooltipWrapper) => {
const { config } = useContext(AppContext);
const gitOpsModeEnabled = config?.gitops.gitops_mode_enabled;
const repoURL = config?.gitops.repository_url;
if (!gitOpsModeEnabled) {
return <>{renderChildren()}</>;
}
const tipContent = (
<div className={`${baseClass}__tooltip-content`}>
{repoURL && getGitOpsModeTipContent(repoURL)}
</div>
);
return (
<TooltipWrapper
className={baseClass}
position={position}
tipOffset={tipOffset}
tipContent={tipContent}
underline={false}
showArrow
fixedPositionStrategy={fixedPositionStrategy}
>
{renderChildren(true)}
</TooltipWrapper>
);
};
export default GitOpsModeTooltipWrapper;