diff --git a/web/packages/teleport/src/Roles/RoleEditor/StandardEditor.tsx b/web/packages/teleport/src/Roles/RoleEditor/StandardEditor.tsx index 46a53abf472b6..64192868b3a5a 100644 --- a/web/packages/teleport/src/Roles/RoleEditor/StandardEditor.tsx +++ b/web/packages/teleport/src/Roles/RoleEditor/StandardEditor.tsx @@ -939,6 +939,9 @@ export function AdminRules({ function setRule(rule: RuleModel) { onChange?.(value.map(r => (r.id === rule.id ? rule : r))); } + function removeRule(id: string) { + onChange?.(value.filter(r => r.id !== id)); + } return ( {value.map((rule, i) => ( @@ -948,6 +951,7 @@ export function AdminRules({ value={rule} onChange={setRule} validation={validation[i]} + onRemove={() => removeRule(rule.id)} /> ))} @@ -963,15 +967,20 @@ function AdminRule({ isProcessing, validation, onChange, -}: SectionProps) { + onRemove, +}: SectionProps & { + onRemove?(): void; +}) { const { resources, verbs } = value; const theme = useTheme(); return ( - - + ); }