fleet/frontend/components/GenericMsgWithNavButton/GenericMsgWithNavButton.tsx
Gabriel Hernandez e16c3c7272
change TurnOnMDMMessage component to generic TurnOnMessage and use in end user auth page (#36477)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Resolves #35296

This makes the TurnOnMDMMessage component more generic and display a
configurage "Turn on" message. We then are able to use this in the End
user auth page on the controls page.

- [x] 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.
- [x] QA'd all new/changed functionality manually
2025-12-02 12:11:10 +00:00

59 lines
1.4 KiB
TypeScript

import React, { useContext } from "react";
import { AppContext } from "context/app";
import EmptyTable from "components/EmptyTable";
import Button from "components/buttons/Button";
import { InjectedRouter } from "react-router";
const baseClass = "generic-msg-with-nav-button";
interface IGenericMsgWithNavButtonProps {
router: InjectedRouter;
header: string;
info: string;
/** The path to navigate the user to when they press the button. */
path: string;
buttonText: string;
}
/** This is a generic component that renders a message with a header, info, and button that will navigate to a path
* for global admins
*
* TODO: consider removing isGlobalAdmin check in here and pushing up to parent */
const GenericMsgWithNavButton = ({
router,
header,
info,
path,
buttonText,
}: IGenericMsgWithNavButtonProps) => {
const { isGlobalAdmin } = useContext(AppContext);
const onConnectClick = () => {
router.push(path);
};
const renderConnectButton = () => {
return isGlobalAdmin ? (
<Button
onClick={onConnectClick}
className={`${baseClass}__connectAPC-button`}
>
{buttonText}
</Button>
) : (
<></>
);
};
return (
<EmptyTable
className={baseClass}
header={header}
info={info}
primaryButton={renderConnectButton()}
/>
);
};
export default GenericMsgWithNavButton;