mirror of
https://github.com/freedbygrace/ActiveDirectoryManager.git
synced 2026-08-21 15:47:41 +00:00
Improve dynamic group condition builder UI and fix LDAP filter generation.
Replit-Commit-Author: Agent Replit-Commit-Session-Id: 705f2157-ef97-4fbd-89e4-8c7f2ecaea90 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7ed01c5f-a82d-405a-b728-b2e3d127c60c/2b3dd059-5776-4ece-bced-b6e25e25634b.jpg
This commit is contained in:
@@ -175,7 +175,7 @@ const ConditionBuilder: React.FC<ConditionBuilderProps> = ({
|
|||||||
// Keep the condition if its ID is not in our removal list
|
// Keep the condition if its ID is not in our removal list
|
||||||
// and its parent ID is not in our removal list
|
// and its parent ID is not in our removal list
|
||||||
return !idsToRemove.has(c.id) &&
|
return !idsToRemove.has(c.id) &&
|
||||||
!idsToRemove.has(c.parentId);
|
!(c.parentId !== null && idsToRemove.has(c.parentId));
|
||||||
});
|
});
|
||||||
|
|
||||||
onChange(newConditions);
|
onChange(newConditions);
|
||||||
@@ -242,7 +242,7 @@ const ConditionBuilder: React.FC<ConditionBuilderProps> = ({
|
|||||||
return (
|
return (
|
||||||
<div className="mb-3">
|
<div className="mb-3">
|
||||||
<div
|
<div
|
||||||
className="border border-border rounded-md p-3"
|
className={`border ${isExpanded ? 'bg-background/50' : 'bg-accent/10'} border-border rounded-md p-3`}
|
||||||
style={{ marginLeft: level > 0 ? `${level * 20}px` : '0' }}
|
style={{ marginLeft: level > 0 ? `${level * 20}px` : '0' }}
|
||||||
>
|
>
|
||||||
<div className="flex items-center justify-between mb-2">
|
<div className="flex items-center justify-between mb-2">
|
||||||
@@ -341,7 +341,7 @@ const ConditionBuilder: React.FC<ConditionBuilderProps> = ({
|
|||||||
// Regular condition
|
// Regular condition
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="grid grid-cols-13 gap-2 items-center mb-2 border border-transparent hover:border-border p-2 rounded-md"
|
className="grid grid-cols-13 gap-2 items-center mb-2 border border-transparent hover:border-border p-2 rounded-md bg-background/50 hover:bg-background"
|
||||||
style={{ marginLeft: level > 0 ? `${level * 20}px` : '0' }}
|
style={{ marginLeft: level > 0 ? `${level * 20}px` : '0' }}
|
||||||
>
|
>
|
||||||
<div className="col-span-1 flex items-center justify-center">
|
<div className="col-span-1 flex items-center justify-center">
|
||||||
@@ -603,21 +603,28 @@ const generateLdapFilter = (conditions: Condition[]): string => {
|
|||||||
const operator = logicalOp === 'AND' ? '&' : '|';
|
const operator = logicalOp === 'AND' ? '&' : '|';
|
||||||
let groupFilter = `(${operator}`;
|
let groupFilter = `(${operator}`;
|
||||||
|
|
||||||
|
// Track if we've added any conditions to this group
|
||||||
|
let hasAddedCondition = false;
|
||||||
|
|
||||||
// Process regular conditions in this group
|
// Process regular conditions in this group
|
||||||
for (const condition of childConditions) {
|
for (const condition of childConditions) {
|
||||||
if (!condition.isGroup) {
|
if (!condition.isGroup) {
|
||||||
const filter = generateRegularFilter(condition);
|
const filter = generateRegularFilter(condition);
|
||||||
if (filter) groupFilter += filter;
|
if (filter) {
|
||||||
|
groupFilter += filter;
|
||||||
|
hasAddedCondition = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process subgroups in this group
|
// Process subgroups in this group
|
||||||
for (const condition of childConditions) {
|
for (const condition of childConditions) {
|
||||||
if (condition.isGroup && condition.id) {
|
if (condition.isGroup && condition.id !== undefined) {
|
||||||
// Use another group filter here
|
// Use another group filter here
|
||||||
const subGroupFilter = generateGroupFilter(condition.id);
|
const subGroupFilter = generateGroupFilter(condition.id);
|
||||||
if (subGroupFilter !== '(objectClass=*)') {
|
if (subGroupFilter !== '(objectClass=*)') {
|
||||||
groupFilter += subGroupFilter;
|
groupFilter += subGroupFilter;
|
||||||
|
hasAddedCondition = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -625,7 +632,7 @@ const generateLdapFilter = (conditions: Condition[]): string => {
|
|||||||
groupFilter += ')';
|
groupFilter += ')';
|
||||||
|
|
||||||
// If there are no actual conditions, return a default
|
// If there are no actual conditions, return a default
|
||||||
if (groupFilter === `(${operator})`) {
|
if (!hasAddedCondition) {
|
||||||
return '(objectClass=*)';
|
return '(objectClass=*)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user