diff --git a/src/pages/cipp/settings/licenses.js b/src/pages/cipp/settings/licenses.js index b5816cadde66..d734f7eac437 100644 --- a/src/pages/cipp/settings/licenses.js +++ b/src/pages/cipp/settings/licenses.js @@ -2,11 +2,16 @@ import tabOptions from "./tabOptions"; import { TabbedLayout } from "../../../layouts/TabbedLayout"; import { Layout as DashboardLayout } from "../../../layouts/index.js"; import { CippTablePage } from "../../../components/CippComponents/CippTablePage.jsx"; -import { Button, SvgIcon, Stack } from "@mui/material"; +import { Button, SvgIcon, Stack, Box } from "@mui/material"; import { TrashIcon } from "@heroicons/react/24/outline"; import { Add, RestartAlt } from "@mui/icons-material"; import { CippApiDialog } from "../../../components/CippComponents/CippApiDialog"; import { useDialog } from "../../../hooks/use-dialog"; +import CippFormComponent from "../../../components/CippComponents/CippFormComponent"; +import { CippFormCondition } from "../../../components/CippComponents/CippFormCondition"; +import M365LicensesDefault from "../../../data/M365Licenses.json"; +import M365LicensesAdditional from "../../../data/M365Licenses-additional.json"; +import { useMemo, useCallback } from "react"; const Page = () => { const pageTitle = "Excluded Licenses"; @@ -15,6 +20,34 @@ const Page = () => { const resetDialog = useDialog(); const simpleColumns = ["Product_Display_Name", "GUID"]; + const allLicenseOptions = useMemo(() => { + const allLicenses = [...M365LicensesDefault, ...M365LicensesAdditional]; + const uniqueLicenses = new Map(); + + allLicenses.forEach((license) => { + if (license.GUID && license.Product_Display_Name) { + if (!uniqueLicenses.has(license.GUID)) { + uniqueLicenses.set(license.GUID, { + label: license.Product_Display_Name, + value: license.GUID, + }); + } + } + }); + + const options = Array.from(uniqueLicenses.values()); + const nameCounts = {}; + options.forEach((opt) => { + nameCounts[opt.label] = (nameCounts[opt.label] || 0) + 1; + }); + + return options + .map((opt) => + nameCounts[opt.label] > 1 ? { ...opt, label: `${opt.label} (${opt.value})` } : opt + ) + .sort((a, b) => a.label.localeCompare(b.label)); + }, []); + const actions = [ { label: "Delete Exclusion", @@ -65,6 +98,21 @@ const Page = () => { actions: actions, }; + const addExclusionFormatter = useCallback((row, action, formData) => { + if (formData.advancedMode) { + return { + Action: "AddExclusion", + GUID: formData.GUID, + SKUName: formData.SKUName, + }; + } + return { + Action: "AddExclusion", + GUID: formData.selectedLicense?.value, + SKUName: formData.selectedLicense?.label, + }; + }, []); + return ( <> { + > + {({ formHook }) => ( + <> + + + + + + + + + + + + + + + + )} +