Skip to content

Commit

Permalink
extension updates
Browse files Browse the repository at this point in the history
fix api results for new object format
prevent error fields from being selected in CippAutocomplete
add halo ticket type selection
  • Loading branch information
JohnDuprey committed Feb 6, 2025
1 parent ec900fa commit 1779fba
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 40 deletions.
63 changes: 35 additions & 28 deletions src/components/CippComponents/CippApiResults.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,40 +52,47 @@ const extractAllResults = (data) => {
return;
}

const ignoreKeys = ["metadata", "Metadata"];

if (typeof obj === "object") {
Object.keys(obj).forEach((key) => {
const value = obj[key];
if (ignoreKeys.includes(key)) return;
if (["Results", "Result", "results", "result"].includes(key)) {
if (Array.isArray(value)) {
value.forEach((valItem) => {
const processed = processResultItem(valItem);
if (obj?.resultText) {
const processed = processResultItem(obj);
if (processed) {
results.push(processed);
}
} else {
const ignoreKeys = ["metadata", "Metadata"];

if (typeof obj === "object") {
Object.keys(obj).forEach((key) => {
const value = obj[key];
if (ignoreKeys.includes(key)) return;
if (["Results", "Result", "results", "result"].includes(key)) {
if (Array.isArray(value)) {
value.forEach((valItem) => {
const processed = processResultItem(valItem);
if (processed) {
results.push(processed);
} else {
extractFrom(valItem);
}
});
} else if (typeof value === "object") {
const processed = processResultItem(value);
if (processed) {
results.push(processed);
} else {
extractFrom(valItem);
extractFrom(value);
}
});
} else if (typeof value === "object") {
const processed = processResultItem(value);
if (processed) {
results.push(processed);
} else {
extractFrom(value);
} else if (typeof value === "string") {
results.push({
text: value,
copyField: value,
severity: getSeverity(value),
});
}
} else if (typeof value === "string") {
results.push({
text: value,
copyField: value,
severity: getSeverity(value),
});
} else {
extractFrom(value);
}
} else {
extractFrom(value);
}
});
});
}
}
};

Expand Down
14 changes: 11 additions & 3 deletions src/components/CippComponents/CippAutocomplete.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { ArrowDropDown } from "@mui/icons-material";
import { Autocomplete, CircularProgress, createFilterOptions, TextField, IconButton } from "@mui/material";
import {
Autocomplete,
CircularProgress,
createFilterOptions,
TextField,
IconButton,
} from "@mui/material";
import { useEffect, useState } from "react";
import { useSettings } from "../../hooks/use-settings";
import { getCippError } from "../../utils/get-cipp-error";
Expand Down Expand Up @@ -189,7 +195,9 @@ export const CippAutoComplete = (props) => {
}
return item;
});
newValue = newValue.filter((item) => item.value && item.value.trim() !== "" && item.value !== "error");
newValue = newValue.filter(
(item) => item.value && item.value !== "" && item.value !== "error" && item.value !== -1
);
} else {
if (newValue?.manual || !newValue?.label) {
newValue = {
Expand All @@ -200,7 +208,7 @@ export const CippAutoComplete = (props) => {
onCreateOption(newValue, newValue?.addedFields);
}
}
if (!newValue?.value || !newValue.value.trim() || newValue.value === "error") {
if (!newValue?.value || newValue.value === "error") {
newValue = null;
}
}
Expand Down
53 changes: 44 additions & 9 deletions src/data/Extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,25 @@
"type": "textField",
"name": "HaloPSA.Tenant",
"label": "HaloPSA Tenant",
"placeholder": "Enter your HaloPSA Tenant (Leave blank if self-hosted",
"placeholder": "Enter your HaloPSA Tenant (Leave blank if self-hosted)",
"required": true
},
{
"type": "textField",
"type": "autoComplete",
"name": "HaloPSA.TicketType",
"label": "HaloPSA Ticket Type ID",
"placeholder": "Enter your HaloPSA ticket type to use for CIPP Tickets. Leave blank for default.",
"required": true
"label": "Select your HaloPSA Ticket Type, leave blank for default.",
"multiple": false,
"api": {
"url": "/api/ExecExtensionMapping",
"data": {
"List": "HaloPSAFields"
},
"queryKey": "HaloTicketTypes",
"dataKey": "TicketTypes",
"labelField": "name",
"valueField": "id",
"showRefresh": true
}
},
{
"type": "textField",
Expand Down Expand Up @@ -344,6 +354,11 @@
"name": "PWPush.Enabled",
"label": "Enable Integration - Replace passwords with PWPush links"
},
{
"type": "switch",
"name": "PWPush.PWPushPro",
"label": "PWPush Pro/Premium account"
},
{
"type": "textField",
"name": "PWPush.BaseUrl",
Expand All @@ -354,7 +369,7 @@
"type": "textField",
"name": "PWPush.EmailAddress",
"label": "PWPush email address",
"placeholder": "Enter your email address for PWPush. (optional)"
"placeholder": "Enter your email address for PWPush. (Free/Self-Hosted only)"
},
{
"type": "password",
Expand All @@ -363,10 +378,25 @@
"placeholder": "Enter your PWPush API Key. (optional)"
},
{
"type": "switch",
"name": "PWPush.RetrievalStep",
"label": "Click to retrieve password (recommended)"
"type": "autoComplete",
"name": "PWPush.AccountId",
"label": "Select your PWPush Account for branding (Pro/Premium only)",
"multiple": false,
"api": {
"url": "/api/ExecExtensionMapping?List=PWPushFields",
"queryKey": "PWPushAccounts",
"dataKey": "Accounts",
"labelField": "name",
"valueField": "id",
"showRefresh": true
},
"condition": {
"field": "PWPush.PWPushPro",
"compareType": "is",
"compareValue": true
}
},

{
"type": "number",
"name": "PWPush.ExpireAfterDays",
Expand All @@ -379,6 +409,11 @@
"label": "Expiration after views",
"placeholder": "Expiration after views. (optional)"
},
{
"type": "switch",
"name": "PWPush.RetrievalStep",
"label": "Click to retrieve password (recommended)"
},
{
"type": "switch",
"name": "PWPush.DeletableByViewer",
Expand Down

0 comments on commit 1779fba

Please sign in to comment.