-
-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
697 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* . .o8 oooo | ||
* .o8 "888 `888 | ||
* .o888oo oooo d8b oooo oooo .oooo888 .ooooo. .oooo.o 888 oooo | ||
* 888 `888""8P `888 `888 d88' `888 d88' `88b d88( "8 888 .8P' | ||
* 888 888 888 888 888 888 888ooo888 `"Y88b. 888888. | ||
* 888 . 888 888 888 888 888 888 .o o. )88b 888 `88b. | ||
* "888" d888b `V88V"V8P' `Y8bod88P" `Y8bod8P' 8""888P' o888o o888o | ||
* ======================================================================== | ||
* Author: Chris Brame | ||
* Updated: 2/16/19 4:29 PM | ||
* Copyright (c) 2014-2019. All rights reserved. | ||
*/ | ||
|
||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { observer } from 'mobx-react' | ||
import { observable } from 'mobx' | ||
import { connect } from 'react-redux' | ||
|
||
import { createRole } from 'actions/settings' | ||
|
||
import Button from 'components/Button' | ||
import BaseModal from './BaseModal' | ||
|
||
@observer | ||
class CreateRoleModal extends React.Component { | ||
@observable name = '' | ||
|
||
onNameChange (e) { | ||
this.name = e.target.value | ||
} | ||
|
||
onCreateRoleClicked (e) { | ||
e.preventDefault() | ||
|
||
this.props.createRole({ name: this.name }) | ||
} | ||
|
||
render () { | ||
return ( | ||
<BaseModal> | ||
<div className={'uk-form-stacked'}> | ||
<div> | ||
<h2 className={'nomargin mb-5'}>Create Role</h2> | ||
<p className='uk-text-muted'>Once created, the role will become editable in the permission editor</p> | ||
|
||
<label>Role Name</label> | ||
<input | ||
type='text' | ||
className={'md-input'} | ||
name={'name'} | ||
data-validation='length' | ||
data-validation-length='min3' | ||
data-validation-error-msg='Please enter a valid role name. Role name must contain at least 3 characters.' | ||
value={this.name} | ||
onChange={e => this.onNameChange(e)} | ||
/> | ||
</div> | ||
<div className='uk-modal-footer uk-text-right'> | ||
<Button text={'Close'} extraClass={'uk-modal-close'} flat={true} waves={true} /> | ||
<Button | ||
text={'Create'} | ||
type={'button'} | ||
flat={true} | ||
waves={true} | ||
style={'success'} | ||
onClick={e => this.onCreateRoleClicked(e)} | ||
/> | ||
</div> | ||
</div> | ||
</BaseModal> | ||
) | ||
} | ||
} | ||
|
||
CreateRoleModal.propTypes = { | ||
createRole: PropTypes.func.isRequired | ||
} | ||
|
||
export default connect( | ||
null, | ||
{ createRole } | ||
)(CreateRoleModal) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
* . .o8 oooo | ||
* .o8 "888 `888 | ||
* .o888oo oooo d8b oooo oooo .oooo888 .ooooo. .oooo.o 888 oooo | ||
* 888 `888""8P `888 `888 d88' `888 d88' `88b d88( "8 888 .8P' | ||
* 888 888 888 888 888 888 888ooo888 `"Y88b. 888888. | ||
* 888 . 888 888 888 888 888 888 .o o. )88b 888 `88b. | ||
* "888" d888b `V88V"V8P' `Y8bod88P" `Y8bod8P' 8""888P' o888o o888o | ||
* ======================================================================== | ||
* Author: Chris Brame | ||
* Updated: 2/16/19 5:49 PM | ||
* Copyright (c) 2014-2019. All rights reserved. | ||
*/ | ||
|
||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { connect } from 'react-redux' | ||
import { observer } from 'mobx-react' | ||
import { observable } from 'mobx' | ||
|
||
import { deleteRole } from 'actions/settings' | ||
|
||
import BaseModal from './BaseModal' | ||
import Button from 'components/Button' | ||
import SingleSelect from 'components/SingleSelect' | ||
|
||
@observer | ||
class DeleteRoleModal extends React.Component { | ||
@observable selectedRole = '' | ||
|
||
onSelectChanged (e) { | ||
this.selectedRole = e.target.value | ||
} | ||
|
||
onFormSubmit (e) { | ||
e.preventDefault() | ||
|
||
this.props.deleteRole({ _id: this.props.role.get('_id'), newRoleId: this.selectedRole }) | ||
} | ||
|
||
render () { | ||
const { role } = this.props | ||
const mappedRoles = this.props.shared.roles | ||
.filter(obj => { | ||
return obj.get('_id') !== role.get('_id') | ||
}) | ||
.map(r => { | ||
return { text: r.get('name'), value: r.get('_id') } | ||
}) | ||
.toArray() | ||
return ( | ||
<BaseModal {...this.props} options={{ bgclose: false }}> | ||
<form className={'uk-form-stacked'} onSubmit={e => this.onFormSubmit(e)}> | ||
<div className='uk-margin-medium-bottom uk-clearfix'> | ||
<h2>Remove Role</h2> | ||
<span>Please select the role you wish to assign ALL users to</span> | ||
{/*<hr style={{ margin: '10px 0' }} />*/} | ||
</div> | ||
<div className='uk-margin-medium-bottom uk-clearfix'> | ||
<div className='uk-float-left' style={{ width: '100%' }}> | ||
<label className={'uk-form-label nopadding nomargin'}>Type</label> | ||
<SingleSelect | ||
showTextbox={false} | ||
items={mappedRoles} | ||
onSelectChange={e => this.onSelectChanged(e)} | ||
value={this.selectedRole} | ||
/> | ||
</div> | ||
</div> | ||
<div className='uk-margin-medium-bottom uk-clearfix'> | ||
<span className='uk-text-danger'> | ||
WARNING: This will change all accounts with role <strong>{role.get('name')}</strong> to the selected role | ||
above. | ||
{role.get('isAdmin') && ( | ||
<span className={'uk-text-danger'}> | ||
The role you are about to remove is an admin role. Please ensure there is another Admin role or you | ||
could be locked out! | ||
</span> | ||
)} | ||
<br /> | ||
<br /> | ||
<strong style={{ fontSize: '18px' }}>This is permanent!</strong> | ||
</span> | ||
</div> | ||
<div className='uk-modal-footer uk-text-right'> | ||
<Button text={'Cancel'} flat={true} waves={true} extraClass={'uk-modal-close'} /> | ||
<Button text={'Delete'} style={'danger'} flat={true} type={'submit'} /> | ||
</div> | ||
</form> | ||
</BaseModal> | ||
) | ||
} | ||
} | ||
|
||
DeleteRoleModal.propTypes = { | ||
role: PropTypes.object, | ||
deleteRole: PropTypes.func.isRequired, | ||
shared: PropTypes.object.isRequired | ||
} | ||
|
||
const mapStateToProps = state => ({ | ||
shared: state.shared | ||
}) | ||
|
||
export default connect( | ||
mapStateToProps, | ||
{ deleteRole } | ||
)(DeleteRoleModal) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.