mirror of
https://github.com/fleetdm/fleet
synced 2026-05-03 21:38:24 +00:00
> Related issue: #9956 # Checklist for submitter If some of the following don't apply, delete the relevant line. <!-- Note that API documentation changes are now addressed by the product design team. --> - [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/Committing-Changes.md#changes-files) for more information. - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) - [x] Added/updated tests - [x] If paths of existing endpoints are modified without backwards compatibility, checked the frontend/CLI for any necessary changes - [x] If database migrations are included, checked table schema to confirm autoupdate - For database migrations: - [x] Checked schema for all modified table for columns that will auto-update timestamps during migration. - [x] Confirmed that updating the timestamps is acceptable, and will not cause unwanted side effects. - [x] Ensured the correct collation is explicitly set for character columns (`COLLATE utf8mb4_unicode_ci`). - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Martin Angers <martin.n.angers@gmail.com> Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com> Co-authored-by: Roberto Dip <rroperzh@gmail.com> Co-authored-by: Sarah Gillespie <73313222+gillespi314@users.noreply.github.com> Co-authored-by: Dante Catalfamo <43040593+dantecatalfamo@users.noreply.github.com> Co-authored-by: Roberto Dip <dip.jesusr@gmail.com>
99 lines
2.9 KiB
TypeScript
99 lines
2.9 KiB
TypeScript
import React, { ReactNode, useContext } from "react";
|
|
import classnames from "classnames";
|
|
import { formatDistanceToNow } from "date-fns";
|
|
import { hasLicenseExpired, willExpireWithinXDays } from "utilities/helpers";
|
|
|
|
import SandboxExpiryMessage from "components/Sandbox/SandboxExpiryMessage";
|
|
import AppleBMTermsMessage from "components/MDM/AppleBMTermsMessage";
|
|
|
|
import SandboxGate from "components/Sandbox/SandboxGate";
|
|
import { AppContext } from "context/app";
|
|
import LicenseExpirationBanner from "components/LicenseExpirationBanner";
|
|
import ApplePNCertRenewalMessage from "components/MDM/ApplePNCertRenewalMessage";
|
|
import AppleBMRenewalMessage from "components/MDM/AppleBMRenewalMessage";
|
|
import VppRenewalMessage from "./banners/VppRenewalMessage";
|
|
|
|
interface IMainContentProps {
|
|
children: ReactNode;
|
|
/** An optional classname to pass to the main content component.
|
|
* This can be used to apply styles directly onto the main content div
|
|
*/
|
|
className?: string;
|
|
}
|
|
|
|
const baseClass = "main-content";
|
|
|
|
/**
|
|
* A component that controls the layout and styling of the main content region
|
|
* of the application.
|
|
*/
|
|
const MainContent = ({
|
|
children,
|
|
className,
|
|
}: IMainContentProps): JSX.Element => {
|
|
const classes = classnames(baseClass, className);
|
|
const {
|
|
sandboxExpiry,
|
|
config,
|
|
isPremiumTier,
|
|
noSandboxHosts,
|
|
isApplePnsExpired,
|
|
isAppleBmExpired,
|
|
isVppExpired,
|
|
needsAbmTermsRenewal,
|
|
willAppleBmExpire,
|
|
willApplePnsExpire,
|
|
willVppExpire,
|
|
} = useContext(AppContext);
|
|
|
|
const sandboxExpiryTime =
|
|
sandboxExpiry === undefined
|
|
? "..."
|
|
: formatDistanceToNow(new Date(sandboxExpiry));
|
|
|
|
const renderAppWideBanner = () => {
|
|
const isFleetLicenseExpired = hasLicenseExpired(
|
|
config?.license.expiration || ""
|
|
);
|
|
|
|
let banner: JSX.Element | null = null;
|
|
|
|
if (isPremiumTier) {
|
|
if (isApplePnsExpired || willApplePnsExpire) {
|
|
banner = <ApplePNCertRenewalMessage expired={isApplePnsExpired} />;
|
|
} else if (isAppleBmExpired || willAppleBmExpire) {
|
|
banner = <AppleBMRenewalMessage expired={isAppleBmExpired} />;
|
|
} else if (needsAbmTermsRenewal) {
|
|
banner = <AppleBMTermsMessage />;
|
|
} else if (isVppExpired || willVppExpire) {
|
|
banner = <VppRenewalMessage expired={isVppExpired} />;
|
|
} else if (isFleetLicenseExpired) {
|
|
banner = <LicenseExpirationBanner />;
|
|
}
|
|
}
|
|
|
|
if (banner) {
|
|
return <div className={`${baseClass}__warning-banner`}>{banner}</div>;
|
|
}
|
|
|
|
return null;
|
|
};
|
|
return (
|
|
<div className={classes}>
|
|
<div className={`${baseClass}--animation-disabled`}>
|
|
{renderAppWideBanner()}
|
|
<SandboxGate
|
|
fallbackComponent={() => (
|
|
<SandboxExpiryMessage
|
|
expiry={sandboxExpiryTime}
|
|
noSandboxHosts={noSandboxHosts}
|
|
/>
|
|
)}
|
|
/>
|
|
</div>
|
|
{children}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default MainContent;
|