mirror of
https://github.com/freedbygrace/ActiveDirectoryManager.git
synced 2026-07-26 11:59:14 +00:00
Improve dynamic group rule editor variable handling
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/48afe50d-f402-46e5-9380-44e8ffa1a918.jpg
This commit is contained in:
@@ -439,12 +439,15 @@ export const RuleEditor: React.FC<RuleEditorProps> = ({ rule, onSave, onCancel }
|
||||
<div className="absolute right-1 top-1">
|
||||
<VariableSelector
|
||||
onSelectVariable={(variable) => {
|
||||
// Direct insertion of variable or prefixed OU segment
|
||||
// Direct insertion of variable which should already be properly formatted
|
||||
// with OU= or DC= prefix by the VariableSelector
|
||||
const currentValue = formData.targetOU || '';
|
||||
// Check if this is a variable or a direct DC value
|
||||
const newValue = variable.startsWith("DC=") || variable.startsWith("OU=")
|
||||
? (currentValue && !currentValue.endsWith(",") ? currentValue + "," : currentValue) + variable
|
||||
|
||||
// Add a comma if needed before adding the variable
|
||||
const newValue = (currentValue && !currentValue.endsWith(",") && variable !== '')
|
||||
? currentValue + "," + variable
|
||||
: currentValue + variable;
|
||||
|
||||
setFormData({ ...formData, targetOU: newValue });
|
||||
}}
|
||||
connections={formData.connections}
|
||||
@@ -482,9 +485,9 @@ export const RuleEditor: React.FC<RuleEditorProps> = ({ rule, onSave, onCancel }
|
||||
<div className="absolute right-1 top-1">
|
||||
<VariableSelector
|
||||
onSelectVariable={(variable) => {
|
||||
const variableText = `{${variable}}`;
|
||||
// Variable was already formatted with CN= prefix by the VariableSelector
|
||||
const currentValue = formData.targetGroupName || '';
|
||||
const newValue = currentValue + variableText;
|
||||
const newValue = currentValue + variable;
|
||||
setFormData({ ...formData, targetGroupName: newValue });
|
||||
}}
|
||||
connections={formData.connections}
|
||||
|
||||
@@ -88,7 +88,9 @@ const VariableSelector: React.FC<VariableSelectorProps> = ({ onSelectVariable, c
|
||||
const formattedVar = `OU={${attribute}}`;
|
||||
onSelectVariable(formattedVar);
|
||||
} else {
|
||||
onSelectVariable(attribute);
|
||||
// Format for group name with CN prefix
|
||||
const formattedVar = `CN={${attribute}}`;
|
||||
onSelectVariable(formattedVar);
|
||||
}
|
||||
setIsOpen(false);
|
||||
};
|
||||
@@ -108,7 +110,9 @@ const VariableSelector: React.FC<VariableSelectorProps> = ({ onSelectVariable, c
|
||||
const formattedVar = `OU={${customAttribute.trim()}}`;
|
||||
onSelectVariable(formattedVar);
|
||||
} else {
|
||||
onSelectVariable(customAttribute.trim());
|
||||
// Format custom attribute for group name with CN prefix
|
||||
const formattedVar = `CN={${customAttribute.trim()}}`;
|
||||
onSelectVariable(formattedVar);
|
||||
}
|
||||
setCustomAttribute('');
|
||||
setIsOpen(false);
|
||||
|
||||
Reference in New Issue
Block a user