mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
relates to #19866 > NOTE: API integration work still needs to be done, which will happen in another PR. This adds the ability to add, remove, or disable a VPP token in the Fleet UI. This includes: **Vpp integration page with VPP card:**    **VPP setup page with steps to set up VPP:**  **VPP setup page with VPP info:**  **Disable VPP modal:**  **renew Vpp modal:**  - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://fleetdm.com/docs/contributing/committing-changes#changes-files) for more information. - [x] Manual QA for all new/changed functionality
89 lines
2.6 KiB
TypeScript
89 lines
2.6 KiB
TypeScript
import React, { useContext } from "react";
|
|
import { useQuery } from "react-query";
|
|
import { AxiosError } from "axios";
|
|
import { InjectedRouter } from "react-router";
|
|
|
|
import PATHS from "router/paths";
|
|
import { AppContext } from "context/app";
|
|
import { IMdmApple } from "interfaces/mdm";
|
|
import mdmAppleAPI from "services/entities/mdm_apple";
|
|
|
|
import Spinner from "components/Spinner";
|
|
import DataError from "components/DataError";
|
|
import PremiumFeatureMessage from "components/PremiumFeatureMessage/PremiumFeatureMessage";
|
|
import EmptyTable from "components/EmptyTable/EmptyTable";
|
|
import Button from "components/buttons/Button/Button";
|
|
|
|
import MdmPlatformsSection from "./components/MdmPlatformsSection/MdmPlatformsSection";
|
|
import DefaultTeamSection from "./components/DefaultTeamSection/DefaultTeamSection";
|
|
import IdpSection from "./components/IdpSection/IdpSection";
|
|
import EulaSection from "./components/EulaSection/EulaSection";
|
|
|
|
const baseClass = "automatic-enrollment";
|
|
|
|
interface IAutomaticEnrollment {
|
|
router: InjectedRouter;
|
|
}
|
|
|
|
const AutomaticEnrollment = ({ router }: IAutomaticEnrollment) => {
|
|
const { config, isPremiumTier } = useContext(AppContext);
|
|
|
|
const { isLoading: isLoadingAPNInfo, error: errorAPNInfo } = useQuery<
|
|
IMdmApple,
|
|
AxiosError
|
|
>(["appleAPNInfo"], () => mdmAppleAPI.getAppleAPNInfo(), {
|
|
refetchOnWindowFocus: false,
|
|
retry: false,
|
|
enabled: config?.mdm.enabled_and_configured,
|
|
});
|
|
|
|
const onClickConnect = () => {
|
|
router.push(PATHS.ADMIN_INTEGRATIONS_MDM);
|
|
};
|
|
|
|
if (!isPremiumTier) return <PremiumFeatureMessage />;
|
|
|
|
if (isLoadingAPNInfo) {
|
|
return (
|
|
<div className={baseClass}>
|
|
<Spinner />
|
|
</div>
|
|
);
|
|
}
|
|
|
|
if (errorAPNInfo?.status === 404) {
|
|
return (
|
|
<EmptyTable
|
|
header="Automatic enrollment for macOS hosts"
|
|
info="Connect Fleet to the Apple Push Certificates Portal to get started."
|
|
primaryButton={<Button onClick={onClickConnect}>Connect</Button>}
|
|
className={`${baseClass}__connect-message`}
|
|
/>
|
|
);
|
|
}
|
|
|
|
if (errorAPNInfo) {
|
|
return <DataError />;
|
|
}
|
|
|
|
return (
|
|
<div className={baseClass}>
|
|
<div className={`${baseClass}__section`}>
|
|
<MdmPlatformsSection router={router} />
|
|
</div>
|
|
{!!config?.mdm.apple_bm_enabled_and_configured && (
|
|
<div className={`${baseClass}__section`}>
|
|
<DefaultTeamSection />
|
|
</div>
|
|
)}
|
|
<div className={`${baseClass}__section`}>
|
|
<IdpSection />
|
|
</div>
|
|
<div className={`${baseClass}__section`}>
|
|
<EulaSection />
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default AutomaticEnrollment;
|