diff --git a/frontend/components/MainContent/MainContent.tsx b/frontend/components/MainContent/MainContent.tsx index 16c15dac54..a34fd47925 100644 --- a/frontend/components/MainContent/MainContent.tsx +++ b/frontend/components/MainContent/MainContent.tsx @@ -42,11 +42,12 @@ const MainContent = ({ ? "..." : formatDistanceToNow(new Date(sandboxExpiry)); + const showAppleABMBanner = + isAppleBmTermsExpired && isPremiumTier && !isSandboxMode; + return (
- {isAppleBmTermsExpired && isPremiumTier && !isSandboxMode && ( - - )} + {showAppleABMBanner && } ( ( null ); const [isUpdatingHost, setIsUpdatingHost] = useState(false); - const [refetchStartTime, setRefetchStartTime] = useState(null); const [showRefetchSpinner, setShowRefetchSpinner] = useState(false); const [schedule, setSchedule] = useState(); @@ -693,14 +691,6 @@ const HostDetailsPage = ({ router.push(navPath); }; - const isMdmUnenrolled = - host?.mdm.enrollment_status === "Off" || !host?.mdm.enrollment_status; - - const showDiskEncryptionUserActionRequired = - config?.mdm.enabled_and_configured && - host?.mdm.name === "Fleet" && - host?.mdm.macos_settings?.disk_encryption === "action_required"; - /* Context team id might be different that host's team id Observer plus must be checked against host's team id */ const isGlobalOrHostsTeamObserverPlus = @@ -729,22 +719,12 @@ const HostDetailsPage = ({ return (
- {host?.platform === "darwin" && - isMdmUnenrolled && - config?.mdm.enabled_and_configured && ( - - To change settings and install software, ask the end user to - follow the Turn on MDM instructions on their{" "} - My device page. - - )} - {showDiskEncryptionUserActionRequired && ( - - Disk encryption: Requires action from the end user. Ask the end user - to follow Disk encryption instructions on their{" "} - My device page. - - )} +
{ + const { config, isSandboxMode, isPremiumTier } = useContext(AppContext); + + // checks to see if the ABM message is being shown in a parent component. + // We want this to be the only banner shown to the user so we need to know + // if it's already being shown so we can suppress other banners. + const isAppleBmTermsExpired = config?.mdm?.apple_bm_terms_expired; + const showingAppleABMBanner = + (isAppleBmTermsExpired && isPremiumTier && !isSandboxMode) ?? false; + + const isMdmUnenrolled = + hostMdmEnrollmentStatus === "Off" || !hostMdmEnrollmentStatus; + + const showTurnOnMdmInfoBanner = + !showingAppleABMBanner && + hostPlatform === "darwin" && + isMdmUnenrolled && + config?.mdm.enabled_and_configured; + + const showDiskEncryptionUserActionRequired = + !showingAppleABMBanner && + config?.mdm.enabled_and_configured && + mdmName === "Fleet" && + diskEncryptionStatus === "action_required"; + + return ( +
+ {showTurnOnMdmInfoBanner && ( + + To change settings and install software, ask the end user to follow + the Turn on MDM instructions on their{" "} + My device page. + + )} + {showDiskEncryptionUserActionRequired && ( + + Disk encryption: Requires action from the end user. Ask the end user + to follow Disk encryption instructions on their{" "} + My device page. + + )} +
+ ); +}; + +export default HostDetailsBanners; diff --git a/frontend/pages/hosts/details/HostDetailsPage/components/HostDetailsBanners/_styles.scss b/frontend/pages/hosts/details/HostDetailsPage/components/HostDetailsBanners/_styles.scss new file mode 100644 index 0000000000..bc0cf1f673 --- /dev/null +++ b/frontend/pages/hosts/details/HostDetailsPage/components/HostDetailsBanners/_styles.scss @@ -0,0 +1,5 @@ +.host-details-banners { + display: flex; + flex-direction: column; + gap: $pad-medium +} diff --git a/frontend/pages/hosts/details/HostDetailsPage/components/HostDetailsBanners/index.ts b/frontend/pages/hosts/details/HostDetailsPage/components/HostDetailsBanners/index.ts new file mode 100644 index 0000000000..4212a2a3fc --- /dev/null +++ b/frontend/pages/hosts/details/HostDetailsPage/components/HostDetailsBanners/index.ts @@ -0,0 +1 @@ +export { default } from "./HostDetailsBanners";