Skip to content

Commit

Permalink
Merge pull request #1435 from bjoernricks/user-dialog
Browse files Browse the repository at this point in the history
User dialog
  • Loading branch information
bjoernricks authored Jun 4, 2019
2 parents 95ac11a + 8ee4aaa commit 26dfea4
Showing 1 changed file with 160 additions and 166 deletions.
326 changes: 160 additions & 166 deletions gsa/src/web/pages/users/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class Dialog extends React.Component {
role_ids: roleIds,
};

const is_edit = isDefined(user);
const isEdit = isDefined(user);

const rolesOptions = map(roles, role => ({
label: role.name,
Expand All @@ -148,6 +148,10 @@ class Dialog extends React.Component {
value: group.id,
}));

const hasLdapEnabled =
settings.get('method:ldap_connect').enable === YES_VALUE;
const hasRadiusEnabled =
settings.get('method:radius_connect').enable === YES_VALUE;
return (
<React.Fragment>
<SaveDialog
Expand All @@ -157,32 +161,32 @@ class Dialog extends React.Component {
onSave={d => this.handleSaveClick(onSave, d)}
defaultValues={data}
>
{({values: state, onValueChange}) => {
return (
<React.Fragment>
<Layout flex="column">
<FormGroup title={_('Login Name')}>
<TextField
name="name"
grow="1"
value={state.name}
size="30"
onChange={onValueChange}
/>
</FormGroup>

<FormGroup title={_('Comment')}>
<TextField
name="comment"
value={state.comment}
grow="1"
size="30"
onChange={onValueChange}
/>
</FormGroup>
{({values: state, onValueChange}) => (
<React.Fragment>
<Layout flex="column">
<FormGroup title={_('Login Name')}>
<TextField
name="name"
grow="1"
value={state.name}
size="30"
onChange={onValueChange}
/>
</FormGroup>

<FormGroup title={_('Comment')}>
<TextField
name="comment"
value={state.comment}
grow="1"
size="30"
onChange={onValueChange}
/>
</FormGroup>

{!is_edit && (
<FormGroup title={_('Authentication')} flex="column">
{!isEdit && (
<FormGroup title={_('Authentication')} flex="column">
<Divider flex="column">
<Divider>
<Radio
title={_('Password')}
Expand All @@ -193,48 +197,43 @@ class Dialog extends React.Component {
/>
<PasswordField
name="password"
autoComplete="new-password"
value={state.password}
onChange={onValueChange}
/>
</Divider>
{settings.get('method:ldap_connect').enable ===
YES_VALUE && (
<Divider>
<Radio
title={_('LDAP Authentication Only')}
name="auth_method"
value={AUTH_METHOD_LDAP}
checked={state.auth_method === AUTH_METHOD_LDAP}
onChange={onValueChange}
/>
</Divider>
)}
{settings.get('method:radius_connect').enable ===
YES_VALUE && (
<Divider>
<Radio
title={_('RADIUS Authentication Only')}
name="auth_method"
value={AUTH_METHOD_RADIUS}
checked={state.auth_method === AUTH_METHOD_RADIUS}
onChange={onValueChange}
/>
</Divider>
{hasLdapEnabled && (
<Radio
title={_('LDAP Authentication Only')}
name="auth_method"
value={AUTH_METHOD_LDAP}
checked={state.auth_method === AUTH_METHOD_LDAP}
onChange={onValueChange}
/>
)}
</FormGroup>
)}

{is_edit && (
<FormGroup title={_('Authentication')} flex="column">
<Divider>
{hasRadiusEnabled && (
<Radio
title={_('Password: Use existing Password')}
title={_('RADIUS Authentication Only')}
name="auth_method"
value={AUTH_METHOD_PASSWORD}
checked={state.auth_method === AUTH_METHOD_PASSWORD}
value={AUTH_METHOD_RADIUS}
checked={state.auth_method === AUTH_METHOD_RADIUS}
onChange={onValueChange}
/>
</Divider>
)}
</Divider>
</FormGroup>
)}

{isEdit && (
<FormGroup title={_('Authentication')} flex="column">
<Divider flex="column">
<Radio
title={_('Password: Use existing Password')}
name="auth_method"
value={AUTH_METHOD_PASSWORD}
checked={state.auth_method === AUTH_METHOD_PASSWORD}
onChange={onValueChange}
/>
<Divider>
<Radio
title={_('New Password')}
Expand All @@ -247,129 +246,124 @@ class Dialog extends React.Component {
/>
<PasswordField
name="password"
autoComplete="new-password"
value={state.password}
onChange={onValueChange}
/>
</Divider>
{settings.get('method:ldap_connect').enable ===
YES_VALUE && (
<Divider>
<Radio
title={_('LDAP Authentication Only')}
name="auth_method"
value={AUTH_METHOD_LDAP}
checked={state.auth_method === AUTH_METHOD_LDAP}
onChange={onValueChange}
/>
</Divider>
)}
{settings.get('method:radius_connect').enable ===
YES_VALUE && (
<Divider>
<Radio
title={_('RADIUS Authentication Only')}
name="auth_method"
value={AUTH_METHOD_RADIUS}
checked={state.auth_method === AUTH_METHOD_RADIUS}
onChange={onValueChange}
/>
</Divider>
)}
</FormGroup>
)}

{capabilities.mayAccess('roles') && (
<FormGroup title={_('Roles')}>
<MultiSelect
name="role_ids"
items={rolesOptions}
value={roleIds}
onChange={this.handleRoleIdsChange}
/>
</FormGroup>
)}

{capabilities.mayAccess('groups') && (
<FormGroup title={_('Groups')}>
<MultiSelect
name="group_ids"
items={groupsOptions}
value={state.group_ids}
onChange={onValueChange}
/>
</FormGroup>
)}

<FormGroup title={_('Host Access')}>
<Divider flex="column">
<Divider>
{hasLdapEnabled && (
<Radio
name="hosts_allow"
title={_('Allow all and deny')}
value={ACCESS_ALLOW_ALL}
checked={state.hosts_allow === ACCESS_ALLOW_ALL}
title={_('LDAP Authentication Only')}
name="auth_method"
value={AUTH_METHOD_LDAP}
checked={state.auth_method === AUTH_METHOD_LDAP}
onChange={onValueChange}
/>
)}
{hasRadiusEnabled && (
<Radio
name="hosts_allow"
title={_('Deny all and allow')}
value={ACCESS_DENY_ALL}
checked={state.hosts_allow === ACCESS_DENY_ALL}
title={_('RADIUS Authentication Only')}
name="auth_method"
value={AUTH_METHOD_RADIUS}
checked={state.auth_method === AUTH_METHOD_RADIUS}
onChange={onValueChange}
/>
</Divider>
<TextField
name="access_hosts"
size="30"
value={state.access_hosts}
onChange={onValueChange}
/>
)}
</Divider>
</FormGroup>
)}

<FormGroup title={_('Interface Access')}>
<Divider flex="column">
<Divider>
<Radio
name="ifaces_allow"
title={_('Allow all and deny')}
value={ACCESS_ALLOW_ALL}
checked={state.ifaces_allow === ACCESS_ALLOW_ALL}
onChange={onValueChange}
/>
<Radio
name="ifaces_allow"
title={_('Deny all and allow')}
value={ACCESS_DENY_ALL}
checked={state.ifaces_allow === ACCESS_DENY_ALL}
onChange={onValueChange}
/>
</Divider>
<TextField
name="access_ifaces"
size="30"
value={state.access_ifaces}
{capabilities.mayAccess('roles') && (
<FormGroup title={_('Roles')}>
<MultiSelect
name="role_ids"
items={rolesOptions}
value={roleIds}
onChange={this.handleRoleIdsChange}
/>
</FormGroup>
)}

{capabilities.mayAccess('groups') && (
<FormGroup title={_('Groups')}>
<MultiSelect
name="group_ids"
items={groupsOptions}
value={state.group_ids}
onChange={onValueChange}
/>
</FormGroup>
)}

<FormGroup title={_('Host Access')}>
<Divider flex="column">
<Divider>
<Radio
name="hosts_allow"
title={_('Allow all and deny')}
value={ACCESS_ALLOW_ALL}
checked={state.hosts_allow === ACCESS_ALLOW_ALL}
onChange={onValueChange}
/>
<Radio
name="hosts_allow"
title={_('Deny all and allow')}
value={ACCESS_DENY_ALL}
checked={state.hosts_allow === ACCESS_DENY_ALL}
onChange={onValueChange}
/>
</Divider>
</FormGroup>
</Layout>
{confirmationDialogVisible && (
<ConfirmationDialog
text={_(
'Please note: You are about to create a user ' +
'without a role. This user will not have any ' +
'permissions and as a result will not be able to login.',
)}
title={_('User without a role')}
width="400px"
onClose={this.closeConfirmationDialog}
onResumeClick={this.handleResumeClick}
/>
)}
</React.Fragment>
);
}}
<TextField
name="access_hosts"
size="30"
value={state.access_hosts}
onChange={onValueChange}
/>
</Divider>
</FormGroup>

<FormGroup title={_('Interface Access')}>
<Divider flex="column">
<Divider>
<Radio
name="ifaces_allow"
title={_('Allow all and deny')}
value={ACCESS_ALLOW_ALL}
checked={state.ifaces_allow === ACCESS_ALLOW_ALL}
onChange={onValueChange}
/>
<Radio
name="ifaces_allow"
title={_('Deny all and allow')}
value={ACCESS_DENY_ALL}
checked={state.ifaces_allow === ACCESS_DENY_ALL}
onChange={onValueChange}
/>
</Divider>
<TextField
name="access_ifaces"
size="30"
value={state.access_ifaces}
onChange={onValueChange}
/>
</Divider>
</FormGroup>
</Layout>
{confirmationDialogVisible && (
<ConfirmationDialog
text={_(
'Please note: You are about to create a user ' +
'without a role. This user will not have any ' +
'permissions and as a result will not be able to login.',
)}
title={_('User without a role')}
width="400px"
onClose={this.closeConfirmationDialog}
onResumeClick={this.handleResumeClick}
/>
)}
</React.Fragment>
)}
</SaveDialog>
</React.Fragment>
);
Expand Down

0 comments on commit 26dfea4

Please sign in to comment.