mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 13:37:30 +00:00
For #[26070](https://github.com/fleetdm/fleet/issues/26070) This adds the UI for enabling a manual agent install for a bootstrap package. This includes: **The new form option for enabling manual agent install of a bootstrap package**  **disabling adding install software and run script options when user has enabled manual agent install**   **improvements to the setup experience content styling. I've created a `SetupExperienceContentContainer` component to centralise the styles for the content of these sub sections.** **updates to the preview sections copy and replacing the gifs with videos** - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. - [ ] Added/updated automated tests - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Sarah Gillespie <73313222+gillespi314@users.noreply.github.com>
108 lines
3.1 KiB
TypeScript
108 lines
3.1 KiB
TypeScript
import React from "react";
|
|
import { InjectedRouter } from "react-router";
|
|
import PATHS from "router/paths";
|
|
import { useQuery } from "react-query";
|
|
|
|
import configAPI from "services/entities/config";
|
|
import teamsAPI, { ILoadTeamResponse } from "services/entities/teams";
|
|
import { IConfig, IMdmConfig } from "interfaces/config";
|
|
import { ITeamConfig } from "interfaces/team";
|
|
|
|
import SectionHeader from "components/SectionHeader/SectionHeader";
|
|
import Spinner from "components/Spinner";
|
|
|
|
import RequireEndUserAuth from "./components/RequireEndUserAuth/RequireEndUserAuth";
|
|
import EndUserAuthForm from "./components/EndUserAuthForm/EndUserAuthForm";
|
|
import EndUserExperiencePreview from "./components/EndUserExperiencePreview";
|
|
import SetupExperienceContentContainer from "../../components/SetupExperienceContentContainer";
|
|
|
|
const baseClass = "end-user-authentication";
|
|
|
|
const getEnabledEndUserAuth = (
|
|
currentTeamId: number,
|
|
globalConfig?: IConfig,
|
|
teamConfig?: ITeamConfig
|
|
) => {
|
|
if (globalConfig === undefined && teamConfig === undefined) {
|
|
return false;
|
|
}
|
|
|
|
// team is "No team" when currentTeamId === 0
|
|
if (currentTeamId === 0) {
|
|
return (
|
|
globalConfig?.mdm?.macos_setup.enable_end_user_authentication ?? false
|
|
);
|
|
}
|
|
|
|
return teamConfig?.mdm?.macos_setup.enable_end_user_authentication ?? false;
|
|
};
|
|
|
|
const isIdPConfigured = ({
|
|
end_user_authentication: idp,
|
|
}: Pick<IMdmConfig, "end_user_authentication">) => {
|
|
return (
|
|
!!idp.entity_id && !!idp.idp_name && (!!idp.metadata_url || !!idp.metadata)
|
|
);
|
|
};
|
|
|
|
interface IEndUserAuthenticationProps {
|
|
currentTeamId: number;
|
|
router: InjectedRouter;
|
|
}
|
|
|
|
const EndUserAuthentication = ({
|
|
currentTeamId,
|
|
router,
|
|
}: IEndUserAuthenticationProps) => {
|
|
const { data: globalConfig, isLoading: isLoadingGlobalConfig } = useQuery<
|
|
IConfig,
|
|
Error
|
|
>(["config", currentTeamId], () => configAPI.loadAll(), {
|
|
refetchOnWindowFocus: false,
|
|
retry: false,
|
|
});
|
|
|
|
const { data: teamConfig, isLoading: isLoadingTeamConfig } = useQuery<
|
|
ILoadTeamResponse,
|
|
Error,
|
|
ITeamConfig
|
|
>(["team", currentTeamId], () => teamsAPI.load(currentTeamId), {
|
|
refetchOnWindowFocus: false,
|
|
retry: false,
|
|
enabled: currentTeamId !== 0,
|
|
select: (res) => res.team,
|
|
});
|
|
|
|
const defaultIsEndUserAuthEnabled = getEnabledEndUserAuth(
|
|
currentTeamId,
|
|
globalConfig,
|
|
teamConfig
|
|
);
|
|
|
|
const onClickConnect = () => {
|
|
router.push(PATHS.ADMIN_INTEGRATIONS_MDM);
|
|
};
|
|
|
|
return (
|
|
<section className={baseClass}>
|
|
<SectionHeader title="End user authentication" />
|
|
{isLoadingGlobalConfig || isLoadingTeamConfig ? (
|
|
<Spinner />
|
|
) : (
|
|
<SetupExperienceContentContainer>
|
|
{!globalConfig || !isIdPConfigured(globalConfig.mdm) ? (
|
|
<RequireEndUserAuth onClickConnect={onClickConnect} />
|
|
) : (
|
|
<EndUserAuthForm
|
|
currentTeamId={currentTeamId}
|
|
defaultIsEndUserAuthEnabled={defaultIsEndUserAuthEnabled}
|
|
/>
|
|
)}
|
|
<EndUserExperiencePreview />
|
|
</SetupExperienceContentContainer>
|
|
)}
|
|
</section>
|
|
);
|
|
};
|
|
|
|
export default EndUserAuthentication;
|