-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support more fields to the role editor #51458
base: bl-nero/fieldinput-labelsinput
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,12 +18,14 @@ | |
|
||
import { memo } from 'react'; | ||
import { components, MultiValueProps } from 'react-select'; | ||
import styled from 'styled-components'; | ||
import styled, { useTheme } from 'styled-components'; | ||
|
||
import { ButtonSecondary } from 'design/Button'; | ||
import Flex from 'design/Flex'; | ||
import { Plus } from 'design/Icon'; | ||
import Text from 'design/Text'; | ||
import { HoverTooltip } from 'design/Tooltip'; | ||
import FieldInput from 'shared/components/FieldInput'; | ||
import { | ||
FieldSelect, | ||
FieldSelectCreatable, | ||
|
@@ -78,7 +80,8 @@ const AccessRule = memo(function AccessRule({ | |
validation, | ||
dispatch, | ||
}: SectionPropsWithDispatch<RuleModel, AccessRuleValidationResult>) { | ||
const { id, resources, verbs } = value; | ||
const { id, resources, verbs, where } = value; | ||
const theme = useTheme(); | ||
function setRule(rule: RuleModel) { | ||
dispatch({ type: 'set-access-rule', payload: rule }); | ||
} | ||
|
@@ -112,6 +115,26 @@ const AccessRule = memo(function AccessRule({ | |
value={verbs} | ||
onChange={v => setRule({ ...value, verbs: v })} | ||
rule={precomputed(validation.fields.verbs)} | ||
/> | ||
<FieldInput | ||
label="Condition" | ||
toolTipContent={ | ||
<> | ||
Additional condition, expressed using the{' '} | ||
<Text | ||
as="a" | ||
href="https://goteleport.com/docs/reference/predicate-language/" | ||
target="_blank" | ||
color={theme.colors.interactive.solid.accent.default} | ||
> | ||
Teleport predicate language | ||
</Text> | ||
Comment on lines
+123
to
+131
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about something like: |
||
</> | ||
} | ||
tooltipSticky | ||
disabled={isProcessing} | ||
value={where} | ||
onChange={e => setRule({ ...value, where: e.target.value })} | ||
mb={0} | ||
/> | ||
</SectionBox> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ import ButtonIcon from 'design/ButtonIcon'; | |
import Flex from 'design/Flex'; | ||
import { Add, Plus, Trash } from 'design/Icon'; | ||
import { Mark } from 'design/Mark'; | ||
import Text, { H4 } from 'design/Text'; | ||
import { H4 } from 'design/Text'; | ||
import FieldInput from 'shared/components/FieldInput'; | ||
import { FieldMultiInput } from 'shared/components/FieldMultiInput/FieldMultiInput'; | ||
import { | ||
|
@@ -232,10 +232,8 @@ export function ServerAccessSection({ | |
}: SectionProps<ServerAccess, ServerAccessValidationResult>) { | ||
return ( | ||
<> | ||
<Text typography="body3" mb={1}> | ||
Labels | ||
</Text> | ||
<LabelsInput | ||
legend="Labels" | ||
disableBtns={isProcessing} | ||
labels={value.labels} | ||
setLabels={labels => onChange?.({ ...value, labels })} | ||
|
@@ -281,10 +279,21 @@ export function KubernetesAccessSection({ | |
onChange={groups => onChange?.({ ...value, groups })} | ||
/> | ||
|
||
<Text typography="body3" mb={1}> | ||
Labels | ||
</Text> | ||
<FieldSelectCreatable | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the inputs placeholder says |
||
isMulti | ||
label="Users" | ||
isDisabled={isProcessing} | ||
formatCreateLabel={label => `User: ${label}`} | ||
components={{ | ||
DropdownIndicator: null, | ||
}} | ||
openMenuOnClick={false} | ||
value={value.users} | ||
onChange={users => onChange?.({ ...value, users })} | ||
/> | ||
|
||
<LabelsInput | ||
legend="Labels" | ||
disableBtns={isProcessing} | ||
labels={value.labels} | ||
rule={precomputed(validation.fields.labels)} | ||
|
@@ -433,17 +442,13 @@ export function AppAccessSection({ | |
}: SectionProps<AppAccess, AppAccessValidationResult>) { | ||
return ( | ||
<Flex flexDirection="column" gap={3}> | ||
<Box> | ||
<Text typography="body3" mb={1}> | ||
Labels | ||
</Text> | ||
<LabelsInput | ||
disableBtns={isProcessing} | ||
labels={value.labels} | ||
setLabels={labels => onChange?.({ ...value, labels })} | ||
rule={precomputed(validation.fields.labels)} | ||
/> | ||
</Box> | ||
<LabelsInput | ||
legend="Labels" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we also add a tooltip explaining labels as well? |
||
disableBtns={isProcessing} | ||
labels={value.labels} | ||
setLabels={labels => onChange?.({ ...value, labels })} | ||
rule={precomputed(validation.fields.labels)} | ||
/> | ||
<FieldMultiInput | ||
label="AWS Role ARNs" | ||
disabled={isProcessing} | ||
|
@@ -478,10 +483,8 @@ export function DatabaseAccessSection({ | |
return ( | ||
<> | ||
<Box mb={3}> | ||
<Text typography="body3" mb={1}> | ||
Labels | ||
</Text> | ||
<LabelsInput | ||
legend="Labels" | ||
disableBtns={isProcessing} | ||
labels={value.labels} | ||
setLabels={labels => onChange?.({ ...value, labels })} | ||
|
@@ -537,7 +540,14 @@ export function DatabaseAccessSection({ | |
value={value.roles} | ||
onChange={roles => onChange?.({ ...value, roles })} | ||
rule={precomputed(validation.fields.roles)} | ||
mb={0} | ||
/> | ||
<LabelsInput | ||
legend="Database Service Labels" | ||
tooltipContent="The database service labels have no influence on which databases' access is controlled by this role. Instead, they control which database services are discoverable while enrolling a new database." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
disableBtns={isProcessing} | ||
labels={value.dbServiceLabels} | ||
setLabels={dbServiceLabels => onChange?.({ ...value, dbServiceLabels })} | ||
rule={precomputed(validation.fields.dbServiceLabels)} | ||
/> | ||
</> | ||
); | ||
|
@@ -552,10 +562,8 @@ export function WindowsDesktopAccessSection({ | |
return ( | ||
<> | ||
<Box mb={3}> | ||
<Text typography="body3" mb={1}> | ||
Labels | ||
</Text> | ||
<LabelsInput | ||
legend="Labels" | ||
disableBtns={isProcessing} | ||
labels={value.labels} | ||
setLabels={labels => onChange?.({ ...value, labels })} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
personally i think it's okay to label it this way, but i'd also double check with product team because we try to teach users consistent wording