Skip to content

Commit

Permalink
Add a way to delete an admin rule
Browse files Browse the repository at this point in the history
  • Loading branch information
bl-nero committed Dec 6, 2024
1 parent ac995c9 commit 0bacc2f
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions web/packages/teleport/src/Roles/RoleEditor/StandardEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Flex flexDirection="column" gap={3}>
{value.map((rule, i) => (
Expand All @@ -948,6 +951,7 @@ export function AdminRules({
value={rule}
onChange={setRule}
validation={validation[i]}
onRemove={() => removeRule(rule.id)}
/>
))}
<ButtonSecondary alignSelf="start" onClick={addRule}>
Expand All @@ -963,15 +967,20 @@ function AdminRule({
isProcessing,
validation,
onChange,
}: SectionProps<RuleModel, AdminRuleValidationResult>) {
onRemove,
}: SectionProps<RuleModel, AdminRuleValidationResult> & {
onRemove?(): void;
}) {
const { resources, verbs } = value;
const theme = useTheme();
return (
<Box
border={1}
borderColor={theme.colors.interactive.tonal.neutral[0]}
borderRadius={3}
p={3}
<Section
title="Admin Rule"
tooltip="A rule that gives users administrative access to certain kinds of resources"
removable
isProcessing={isProcessing}
validation={validation}
onRemove={onRemove}
>
<FieldSelect
isMulti
Expand All @@ -992,7 +1001,7 @@ function AdminRule({
rule={precomputed(validation.fields.verbs)}
mb={0}
/>
</Box>
</Section>
);
}

Expand Down

0 comments on commit 0bacc2f

Please sign in to comment.