fleet/frontend/pages/ManageControlsPage/MacOSSetup/MacOSSetup.tsx
Gabriel Hernandez 75212d81d4
Feat UI add end user auth to controls page (#11991)
relates to #11002

Implements the UI for mdm macos setup end user authentication page.


![image](https://github.com/fleetdm/fleet/assets/1153709/1af6c5d7-99d0-401d-9938-a78617eca817)


![image](https://github.com/fleetdm/fleet/assets/1153709/8f0ed8cc-63f5-425b-8f3a-f2f83ed018f7)



- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
- [x] Manual QA for all new/changed functionality
2023-06-02 14:14:39 +01:00

95 lines
2.4 KiB
TypeScript

import React, { useContext } from "react";
import PATHS from "router/paths";
import { InjectedRouter, Params } from "react-router/lib/Router";
import { AppContext } from "context/app";
import SideNav from "pages/admin/components/SideNav";
import Button from "components/buttons/Button/Button";
import PremiumFeatureMessage from "components/PremiumFeatureMessage";
import EmptyTable from "components/EmptyTable";
import MAC_OS_SETUP_NAV_ITEMS from "./MacOSSetupNavItems";
const baseClass = "macos-setup";
interface ISetupEmptyState {
router: InjectedRouter;
}
const SetupEmptyState = ({ router }: ISetupEmptyState) => {
const onClickEmptyConnect = () => {
router.push(PATHS.ADMIN_INTEGRATIONS_MDM);
};
return (
<EmptyTable
header="Setup experience for macOS hosts"
info="Connect Fleet to the Apple Business Manager to get started."
primaryButton={
<Button variant="brand" onClick={onClickEmptyConnect}>
Connect
</Button>
}
/>
);
};
interface IMacOSSetupProps {
params: Params;
location: { search: string };
router: any;
teamIdForApi: number;
}
const MacOSSetup = ({
params,
location: { search: queryString },
router,
teamIdForApi,
}: IMacOSSetupProps) => {
const { section } = params;
const { isPremiumTier, config } = useContext(AppContext);
const DEFAULT_SETTINGS_SECTION = MAC_OS_SETUP_NAV_ITEMS[0];
const currentFormSection =
MAC_OS_SETUP_NAV_ITEMS.find((item) => item.urlSection === section) ??
DEFAULT_SETTINGS_SECTION;
const CurrentCard = currentFormSection.Card;
if (isPremiumTier && !config?.mdm.apple_bm_enabled_and_configured) {
return <SetupEmptyState router={router} />;
}
return (
<div className={baseClass}>
<p>
Customize the setup experience for hosts that automatically enroll to
this team.
</p>
{!isPremiumTier ? (
<PremiumFeatureMessage />
) : (
<SideNav
className={`${baseClass}__side-nav`}
navItems={MAC_OS_SETUP_NAV_ITEMS.map((navItem) => ({
...navItem,
path: navItem.path.concat(queryString),
}))}
activeItem={currentFormSection.urlSection}
CurrentCard={
<CurrentCard
key={teamIdForApi}
currentTeamId={teamIdForApi}
router={router}
/>
}
/>
)}
</div>
);
};
export default MacOSSetup;