Skip to content

Commit

Permalink
Review
Browse files Browse the repository at this point in the history
  • Loading branch information
bl-nero committed Dec 9, 2024
1 parent 95f0386 commit 776ea6e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 71 deletions.
107 changes: 38 additions & 69 deletions web/packages/teleport/src/Roles/RoleEditor/StandardEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export const StandardEditor = ({
onChange={setCurrentTab}
/>
</Box>
<div
<Box
id={overviewTabId}
style={{
display: currentTab === StandardEditorTab.Overview ? '' : 'none',
Expand All @@ -280,8 +280,8 @@ export const StandardEditor = ({
validation={validation.metadata}
onChange={metadata => handleChange({ ...roleModel, metadata })}
/>
</div>
<div
</Box>
<Box
id={resourcesTabId}
style={{
display: currentTab === StandardEditorTab.Resources ? '' : 'none',
Expand Down Expand Up @@ -333,8 +333,8 @@ export const StandardEditor = ({
</MenuButton>
</Box>
</Flex>
</div>
<div
</Box>
<Box
id={accessRulesTabId}
style={{
display: currentTab === StandardEditorTab.AccessRules ? '' : 'none',
Expand All @@ -346,8 +346,8 @@ export const StandardEditor = ({
onChange={setRules}
validation={validation.rules}
/>
</div>
<div
</Box>
<Box
id={optionsTabId}
style={{
display: currentTab === StandardEditorTab.Options ? '' : 'none',
Expand All @@ -358,7 +358,7 @@ export const StandardEditor = ({
value={roleModel.options}
onChange={setOptions}
/>
</div>
</Box>
</EditorWrapper>
<EditorSaveCancelButton
onSave={() => handleSave()}
Expand Down Expand Up @@ -1036,25 +1036,13 @@ function Options({
const requireMFATypeId = `${id}-require-mfa-type`;
const createHostUserModeId = `${id}-create-host-user-mode`;
return (
<Box
<OptionsGridContainer
border={1}
borderColor={theme.colors.interactive.tonal.neutral[0]}
borderRadius={3}
p={3}
css={`
display: grid;
grid-template-columns: 1fr 1fr;
align-items: baseline;
row-gap: ${theme.space[3]}px;
`}
>
<H4
css={`
grid-column: 1/3;
`}
>
Global Settings
</H4>
<OptionsHeader>Global Settings</OptionsHeader>

<OptionLabel htmlFor={maxSessionTTLId}>Max Session TTL</OptionLabel>
<Input
Expand All @@ -1076,7 +1064,7 @@ function Options({
}
/>

<div>Disconnect When Certificate Expires</div>
<Box>Disconnect When Certificate Expires</Box>
<BoolRadioGroup
name="disconnect-expired-cert"
value={value.disconnectExpiredCert}
Expand All @@ -1092,16 +1080,7 @@ function Options({
onChange={t => onChange?.({ ...value, requireMFAType: t })}
/>

<H4
css={`
grid-column: 1/3;
border-top: ${theme.borders[1]}
${theme.colors.interactive.tonal.neutral[0]};
padding-top: ${theme.space[3]}px;
`}
>
SSH
</H4>
<OptionsHeader separator>SSH</OptionsHeader>

<OptionLabel htmlFor={createHostUserModeId}>
Create Host User Mode
Expand All @@ -1114,71 +1093,61 @@ function Options({
onChange={m => onChange?.({ ...value, createHostUserMode: m })}
/>

<H4
css={`
grid-column: 1/3;
border-top: ${theme.borders[1]}
${theme.colors.interactive.tonal.neutral[0]};
padding-top: ${theme.space[3]}px;
`}
>
Database
</H4>
<OptionsHeader separator>Database</OptionsHeader>

<div>Create Database User</div>
<Box>Create Database User</Box>
<BoolRadioGroup
name="create-db-user"
value={value.createDBUser}
onChange={c => onChange({ ...value, createDBUser: c })}
/>

{/* TODO(bl-nero): a bug in YAML unmarshalling backend breaks this option. Fix it. */}
{/* <OptionLabel htmlFor={createDBUserModeId}>
Create Database User Mode
</OptionLabel>
<Select
inputId={createDBUserModeId}
isDisabled={isProcessing}
options={createDBUserModeOptions}
value={value.createDBUserMode}
onChange={m => onChange?.({ ...value, createDBUserMode: m })}
/> */}
{/* TODO(bl-nero): a bug in YAML unmarshalling backend breaks the
createDBUserMode field. Fix it and add the field here. */}

<H4
css={`
grid-column: 1/3;
border-top: ${theme.borders[1]}
${theme.colors.interactive.tonal.neutral[0]};
padding-top: ${theme.space[3]}px;
`}
>
Desktop
</H4>
<OptionsHeader separator>Desktop</OptionsHeader>

<div>Create Desktop User</div>
<Box>Create Desktop User</Box>
<BoolRadioGroup
name="create-desktop-user"
value={value.createDesktopUser}
onChange={c => onChange({ ...value, createDesktopUser: c })}
/>

<div>Allow Clipboard Sharing</div>
<Box>Allow Clipboard Sharing</Box>
<BoolRadioGroup
name="desktop-clipboard"
value={value.desktopClipboard}
onChange={c => onChange({ ...value, desktopClipboard: c })}
/>

<div>Allow Directory Sharing</div>
<Box>Allow Directory Sharing</Box>
<BoolRadioGroup
name="desktop-directory-sharing"
value={value.desktopDirectorySharing}
onChange={s => onChange({ ...value, desktopDirectorySharing: s })}
/>
</Box>
</OptionsGridContainer>
);
}

const OptionsGridContainer = styled(Box)`
display: grid;
grid-template-columns: 1fr 1fr;
align-items: baseline;
row-gap: ${props => props.theme.space[3]}px;
`;

const OptionsHeader = styled(H4)<{ separator?: boolean }>`
grid-column: 1/3;
border-top: ${props =>
props.separator
? `${props.theme.borders[1]} ${props.theme.colors.interactive.tonal.neutral[0]}`
: 'none'};
padding-top: ${props =>
props.separator ? `${props.theme.space[3]}px` : '0'};
`;

function BoolRadioGroup({
name,
value,
Expand Down
4 changes: 2 additions & 2 deletions web/packages/teleport/src/Roles/RoleEditor/standardmodel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ function optionsToModel(options: RoleOptions): {
record_session,
ssh_file_copy,

...others
...unsupported
} = options;

const requireMFATypeOption =
Expand Down Expand Up @@ -703,7 +703,7 @@ function optionsToModel(options: RoleOptions): {
requireMFATypeOption === undefined ||
createHostUserModeOption === undefined ||
createDBUserModeOption === undefined ||
!isEmpty(others),
!isEmpty(unsupported),
};
}

Expand Down

0 comments on commit 776ea6e

Please sign in to comment.