diff --git a/client/src/components/dynamic-groups/condition-builder.tsx b/client/src/components/dynamic-groups/condition-builder.tsx index d6bc98f..4396963 100644 --- a/client/src/components/dynamic-groups/condition-builder.tsx +++ b/client/src/components/dynamic-groups/condition-builder.tsx @@ -85,9 +85,11 @@ const ConditionBuilder: React.FC = ({ // Update available attributes when data is loaded useEffect(() => { if (attributesData.length > 0) { - setAvailableAttributes([ - ...new Set(attributesData.map(attr => attr.name)) - ]); + // Extract unique attribute names + const uniqueAttributes = Array.from( + new Set(attributesData.map(attr => attr.name)) + ); + setAvailableAttributes(uniqueAttributes); } }, [attributesData]); @@ -137,7 +139,11 @@ const ConditionBuilder: React.FC = ({ // Automatically expand the new group if (newGroup.id) { - setExpandedGroups(prev => new Set([...prev, newGroup.id!])); + setExpandedGroups(prev => { + const expanded = new Set(prev); + expanded.add(newGroup.id!); + return expanded; + }); } } }; @@ -591,24 +597,29 @@ const generateLdapFilter = (conditions: Condition[]): string => { return `(${operator}${childFilters})`; } else { + // Get actual attribute name (custom or selected) + const attributeName = condition.attribute === 'custom' && condition.customAttribute + ? condition.customAttribute + : condition.attribute; + // Regular condition switch (condition.operator) { case '=': - return `(${condition.attribute}=${condition.value})`; + return `(${attributeName}=${condition.value})`; case '!=': - return `(!(${condition.attribute}=${condition.value}))`; + return `(!(${attributeName}=${condition.value}))`; case 'contains': - return `(${condition.attribute}=*${condition.value}*)`; + return `(${attributeName}=*${condition.value}*)`; case 'startsWith': - return `(${condition.attribute}=${condition.value}*)`; + return `(${attributeName}=${condition.value}*)`; case 'endsWith': - return `(${condition.attribute}=*${condition.value})`; + return `(${attributeName}=*${condition.value})`; case 'present': - return `(${condition.attribute}=*)`; + return `(${attributeName}=*)`; case 'notPresent': - return `(!(${condition.attribute}=*))`; + return `(!(${attributeName}=*))`; default: - return `(${condition.attribute}=${condition.value})`; + return `(${attributeName}=${condition.value})`; } } }; diff --git a/client/src/components/dynamic-groups/rule-editor.tsx b/client/src/components/dynamic-groups/rule-editor.tsx index dc2f5aa..e2a00a1 100644 --- a/client/src/components/dynamic-groups/rule-editor.tsx +++ b/client/src/components/dynamic-groups/rule-editor.tsx @@ -33,6 +33,7 @@ export interface Condition { ruleId?: number; parentId?: number | null; attribute: string; + customAttribute?: string; operator: string; value: string; logicalOperator?: string | null; @@ -337,11 +338,11 @@ export const RuleEditor: React.FC = ({ rule, onSave, onCancel } name="variablePattern" value={formData.variablePattern} onChange={handleInputChange} - placeholder="e.g., {attribute} Value" + placeholder="e.g., {attributeName} Value" />

Optional pattern for generating variable values in name or description. - Use {attribute} to insert attribute values. + Use {attributeName} to insert attribute values.

diff --git a/client/src/pages/settings-page.tsx b/client/src/pages/settings-page.tsx index 903e346..23a0db7 100644 --- a/client/src/pages/settings-page.tsx +++ b/client/src/pages/settings-page.tsx @@ -348,9 +348,9 @@ export default function SettingsPage() {
- +

- Use {{username}} as a placeholder for the user's input + Use {{username}} as a placeholder for the user's input