mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 09:18:59 +00:00
e06b00df11
Related to #9571, this adds a new value to both responses which is calculated when the Fleet server is started, and only set to `true` if the server is properly configured for MDM. This helps the UI to determine wether or not we should show certain UI elements that we only want to show to servers with MDM enabled.
58 lines
1.6 KiB
TypeScript
58 lines
1.6 KiB
TypeScript
import { AppContext } from "context/app";
|
|
import React, { useContext } from "react";
|
|
import { Params } from "react-router/lib/Router";
|
|
|
|
import SideNav from "../components/SideNav";
|
|
import INTEGRATION_SETTINGS_NAV_ITEMS from "./IntegrationNavItems";
|
|
|
|
const baseClass = "integrations";
|
|
|
|
const MDM_DISABLED_DESCRIPTION =
|
|
"Add or edit integrations to create tickets when Fleet detects new vulnerabilities.";
|
|
|
|
const MDM_ENABLED_DESCRIPTION =
|
|
"Add ticket destinations and turn on mobile device management features.";
|
|
|
|
interface IIntegrationSettingsPageProps {
|
|
params: Params;
|
|
}
|
|
|
|
const IntegrationsPage = ({ params }: IIntegrationSettingsPageProps) => {
|
|
const { section } = params;
|
|
const DEFAULT_SETTINGS_SECTION = INTEGRATION_SETTINGS_NAV_ITEMS[0];
|
|
|
|
const { isMdmFeatureFlagEnabled } = useContext(AppContext);
|
|
|
|
// filter out mdm if not enabled.
|
|
let navItems = INTEGRATION_SETTINGS_NAV_ITEMS;
|
|
if (!isMdmFeatureFlagEnabled) {
|
|
navItems = INTEGRATION_SETTINGS_NAV_ITEMS.filter(
|
|
(item) => item.urlSection !== "mdm"
|
|
);
|
|
}
|
|
|
|
const currentSection =
|
|
navItems.find((item) => item.urlSection === section) ??
|
|
DEFAULT_SETTINGS_SECTION;
|
|
|
|
const CurrentCard = currentSection.Card;
|
|
|
|
return (
|
|
<div className={`${baseClass}`}>
|
|
<p className={`${baseClass}__page-description`}>
|
|
{isMdmFeatureFlagEnabled
|
|
? MDM_ENABLED_DESCRIPTION
|
|
: MDM_DISABLED_DESCRIPTION}
|
|
</p>
|
|
<SideNav
|
|
className={`${baseClass}__side-nav`}
|
|
navItems={navItems}
|
|
activeItem={currentSection.urlSection}
|
|
CurrentCard={<CurrentCard />}
|
|
/>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default IntegrationsPage;
|