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
18 changes: 13 additions & 5 deletions src/components/CippComponents/CippFormCondition.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const CippFormCondition = (props) => {

if (
field === undefined ||
compareValue === undefined ||
(compareValue === undefined && compareType !== "hasValue") ||
children === undefined ||
formControl === undefined
) {
Expand Down Expand Up @@ -148,10 +148,18 @@ export const CippFormCondition = (props) => {
watcher.length >= compareValue
);
case "hasValue":
return (
(watcher !== undefined && watcher !== null && watcher !== "") ||
(watcher?.value !== undefined && watcher?.value !== null && watcher?.value !== "")
);
// Check watchedValue (the extracted value based on propertyName)
// For simple values (strings, numbers)
if (watchedValue === undefined || watchedValue === null || watchedValue === "") {
return false;
}
// If it's an array, check if it has elements
if (Array.isArray(watchedValue)) {
return watchedValue.length > 0;
}
console.log("watched value:", watchedValue);
// For any other truthy value (objects, numbers, strings), consider it as having a value
return true;
case "labelEq":
return Array.isArray(watcher) && watcher.some((item) => item?.label === compareValue);
case "labelContains":
Expand Down
40 changes: 0 additions & 40 deletions src/components/CippStandards/CippStandardsSideBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,34 +144,12 @@ const CippStandardsSideBar = ({
}

// Filter out current template if editing
console.log("Duplicate detection debug:", {
edit,
currentGUID: watchForm.GUID,
allTemplates: driftValidationApi.data?.map((t) => ({
GUID: t.GUID,
standardId: t.standardId,
standardName: t.standardName,
})),
});

const existingTemplates = driftValidationApi.data.filter((template) => {
const shouldInclude =
edit && watchForm.GUID ? template.standardId !== watchForm.GUID : true;
console.log(
`Template ${template.standardId} (${template.standardName}): shouldInclude=${shouldInclude}, currentGUID=${watchForm.GUID}`
);
return shouldInclude;
});

console.log(
"Filtered templates:",
existingTemplates?.map((t) => ({
GUID: t.GUID,
standardId: t.standardId,
standardName: t.standardName,
}))
);

// Get tenant groups data
const groups = tenantGroupsApi.data?.Results || [];

Expand All @@ -198,45 +176,27 @@ const CippStandardsSideBar = ({
});

// Check for conflicts with unique templates
console.log("Checking conflicts with unique templates:", uniqueTemplates);
console.log("Selected tenant list:", selectedTenantList);

for (const templateId in uniqueTemplates) {
const template = uniqueTemplates[templateId];
const templateTenants = template.tenants;

console.log(
`Checking template ${templateId} (${template.standardName}) with tenants:`,
templateTenants
);

const hasConflict = selectedTenantList.some((selectedTenant) => {
// Check if any template tenant matches the selected tenant
const conflict = templateTenants.some((templateTenant) => {
if (selectedTenant === "AllTenants" || templateTenant === "AllTenants") {
console.log(
`Conflict found: ${selectedTenant} vs ${templateTenant} (AllTenants match)`
);
return true;
}
const match = selectedTenant === templateTenant;
if (match) {
console.log(`Conflict found: ${selectedTenant} vs ${templateTenant} (exact match)`);
}
return match;
});
return conflict;
});

console.log(`Template ${templateId} has conflict: ${hasConflict}`);

if (hasConflict) {
conflicts.push(template.standardName || "Unknown Template");
}
}

console.log("Final conflicts:", conflicts);

if (conflicts.length > 0) {
setDriftError(
`This template has tenants that are assigned to another Drift Template. You can only assign one Drift Template to each tenant. Please check the ${conflicts.join(
Expand Down
5 changes: 1 addition & 4 deletions src/data/standards.json
Original file line number Diff line number Diff line change
Expand Up @@ -5056,10 +5056,7 @@
"queryKey": "ListIntuneTemplates-tag-autcomplete",
"url": "/api/ListIntuneTemplates?mode=Tag",
"labelField": "label",
"valueField": "value",
"addedField": {
"templates": "templates"
}
"valueField": "value"
}
},
{
Expand Down