mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 13:37:30 +00:00
<!-- 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
59 lines
1.4 KiB
TypeScript
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;
|