Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 70 additions & 23 deletions src/components/CippIntegrations/CippIntegrationFieldMapping.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ import {
Tooltip,
Button,
Alert,
SvgIcon,
} from "@mui/material";
import CippFormSection from "../CippFormPages/CippFormSection";
import { useForm } from "react-hook-form";
import { ApiGetCall } from "../../api/ApiCall";
import { ApiGetCall, ApiPostCall } from "../../api/ApiCall";
import { useRouter } from "next/router";
import extensions from "../../data/Extensions.json";
import React, { useEffect, useState } from "react";
import CippFormComponent from "../CippComponents/CippFormComponent";
import { Sync } from "@mui/icons-material";
import { Stack, Grid } from "@mui/system";
import { PlusSmallIcon } from "@heroicons/react/24/outline";
import { CippApiResults } from "../CippComponents/CippApiResults";

const CippIntegrationFieldMapping = () => {
const router = useRouter();
Expand All @@ -36,6 +39,25 @@ const CippIntegrationFieldMapping = () => {
const extension = extensions.find((extension) => extension.id === router.query.id);
const [missingMappings, setMissingMappings] = useState([]);

const createFlexibleAssetCall = ApiPostCall({
urlFromData: true,
queryKey: "CreateFlexibleAssetType",
});

const handleCreateFlexibleAsset = (assetType) => {
createFlexibleAssetCall.mutate(
{
url: "/api/ExecITGlueCreateFlexibleAssetType",
data: { AssetType: assetType },
},
{
onSuccess: () => {
fieldMapping.refetch();
},
}
);
};

useEffect(() => {
if (fieldMapping.isSuccess) {
var newMappings = {};
Expand Down Expand Up @@ -116,28 +138,52 @@ const CippIntegrationFieldMapping = () => {
(field) => field.FieldType === header.FieldType
).map((field, fieldIndex) => (
<Grid size={{ xs: 12, md: 6 }} key={`field-${headerIndex}-${fieldIndex}`}>
<CippFormComponent
name={field.FieldName}
type="autoComplete"
label={field.FieldLabel}
options={fieldMapping?.data?.IntegrationFields?.filter(
(integrationField) =>
(integrationField?.type === field.Type &&
integrationField?.FieldType === field.FieldType) ||
integrationField?.type === "unset"
)?.map((integrationField) => {
return {
label: integrationField?.name,
value: integrationField?.value,
};
})}
formControl={formControl}
multiple={false}
creatable={false}
fullWidth
isFetching={fieldMapping.isFetching}
disableClearable={true}
/>
<Stack direction="row" spacing={1} alignItems="flex-start">
<Box sx={{ flexGrow: 1 }}>
<CippFormComponent
name={field.FieldName}
type="autoComplete"
label={field.FieldLabel}
options={fieldMapping?.data?.IntegrationFields?.filter(
(integrationField) =>
(integrationField?.type === field.Type &&
integrationField?.FieldType === field.FieldType) ||
integrationField?.type === "unset"
)?.map((integrationField) => {
return {
label: integrationField?.name,
value: integrationField?.value,
};
})}
formControl={formControl}
multiple={false}
creatable={false}
fullWidth
isFetching={fieldMapping.isFetching}
disableClearable={true}
/>
</Box>
{field.FieldName === "ConditionalAccessPolicies" &&
router.query.id === "ITGlue" && (
<Tooltip title="Create Flexible Asset Type">
<Button
size="small"
variant="contained"
onClick={() =>
handleCreateFlexibleAsset("ConditionalAccessPolicies")
}
disabled={
createFlexibleAssetCall.isPending || fieldMapping.isFetching
}
sx={{ mt: 1, minWidth: "auto" }}
>
<SvgIcon>
<PlusSmallIcon />
</SvgIcon>
</Button>
</Tooltip>
)}
</Stack>
</Grid>
))}
</Grid>
Expand All @@ -148,6 +194,7 @@ const CippIntegrationFieldMapping = () => {
The following mappings are missing: {missingMappings.join(", ")}
</Alert>
)}
<CippApiResults apiObject={createFlexibleAssetCall} />
</>
</CippFormSection>
) : (
Expand Down
122 changes: 122 additions & 0 deletions src/data/Extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,128 @@
"fieldMapping": true,
"showSyncButton": true
},
{
"name": "ITGlue",
"id": "ITGlue",
"type": "ITGlue",
"cat": "Documentation",
"logo": "/assets/integrations/itglue.png",
"logoDark": "/assets/integrations/itglue_dark.png",
"forceSyncButton": true,
"description": "Enable the ITGlue integration to sync M365 documentation",
"helpText": "This integration populates Flexible Assets, native Contacts, and native Configurations in ITGlue with Microsoft 365 tenant data including users, devices, domains, licenses, and mailboxes. Map your tenants to ITGlue organisations and optionally map Flexible Asset Types for rich M365 content.",
"links": [
{
"name": "ITGlue API Documentation",
"url": "https://api.itglue.com/developer"
}
],
"SettingOptions": [
{
"type": "switch",
"name": "ITGlue.Enabled",
"label": "Enable Integration"
},
{
"type": "select",
"name": "ITGlue.Region",
"label": "ITGlue Region",
"options": [
{ "label": "US (api.itglue.com)", "value": "api.itglue.com" },
{ "label": "EU (api.eu.itglue.com)", "value": "api.eu.itglue.com" }
],
"condition": {
"field": "ITGlue.Enabled",
"compareType": "is",
"compareValue": true,
"action": "disable"
}
},
{
"type": "password",
"name": "ITGlue.APIKey",
"label": "ITGlue API Key",
"placeholder": "Enter your ITGlue API Key",
"required": true,
"condition": {
"field": "ITGlue.Enabled",
"compareType": "is",
"compareValue": true,
"action": "disable"
}
},
{
"type": "switch",
"name": "ITGlue.CreateMissingContacts",
"label": "Create or update users as native ITGlue Contacts",
"condition": {
"field": "ITGlue.Enabled",
"compareType": "is",
"compareValue": true,
"action": "disable"
}
},
{
"type": "switch",
"name": "ITGlue.CreateMissingConfigurations",
"label": "Create or update devices as native ITGlue Configurations",
"condition": {
"field": "ITGlue.Enabled",
"compareType": "is",
"compareValue": true,
"action": "disable"
}
},
{
"type": "switch",
"name": "ITGlue.SyncConditionalAccessPolicies",
"label": "Sync Conditional Access Policies to Flexible Assets",
"condition": {
"field": "ITGlue.Enabled",
"compareType": "is",
"compareValue": true,
"action": "disable"
}
},
{
"type": "textField",
"name": "ITGlue.ExcludeSerials",
"label": "Exclude device serials (comma separated)",
"condition": {
"field": "ITGlue.Enabled",
"compareType": "is",
"compareValue": true,
"action": "disable"
}
},
{
"type": "switch",
"name": "ITGlue.ImportDomains",
"label": "Import domains and license summary into organisation Quick Notes",
"condition": {
"field": "ITGlue.Enabled",
"compareType": "is",
"compareValue": true,
"action": "disable"
}
},
{
"type": "datePicker",
"name": "ITGlue.NextSync",
"label": "Reschedule next sync date",
"helperText": "Set a future date to delay the next scheduled sync. Leave blank to sync during the next scheduled window.",
"condition": {
"field": "ITGlue.Enabled",
"compareType": "is",
"compareValue": true,
"action": "disable"
}
}
],
"mappingRequired": true,
"fieldMapping": true,
"showSyncButton": true
},
{
"name": "PasswordPusher",
"id": "PWPush",
Expand Down