fleet/frontend/pages/admin/IntegrationsPage/IntegrationsPage.tsx
Roberto Dip e06b00df11
Add readonly MDM.EnabledAndConfigured to app config and device responses (#9575)
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.
2023-02-01 14:47:52 -03:00

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;