Skip to content
This repository has been archived by the owner on Aug 4, 2020. It is now read-only.

Commit

Permalink
Merge pull request #28 from Nike-Inc/disallow_custom_owner_groups
Browse files Browse the repository at this point in the history
Only allow owners to which a user belongs
  • Loading branch information
sdford authored Dec 12, 2017
2 parents 3fc099f + 96441c1 commit c6490ca
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ build/metadata.json
reports/
logs/
vault/
*.tar.gz
*.tar.gz
package-lock.json
1 change: 1 addition & 0 deletions app/components/CreateSDBoxForm/CreateSDBoxForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export default class CreateSDBoxForm extends Component {
<label id="category-select-label" className='ncss-label'>Owner</label>
<GroupsSelect {...owner}
userGroups={userGroups}
allowCustomValues={false}
handleBeingTouched={() => {
dispatch(touch(formName, owner.name))
}} />
Expand Down
1 change: 1 addition & 0 deletions app/components/EditSDBoxForm/EditSDBoxForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class EditSDBoxForm extends Component {
<label id="category-select-label" className='ncss-label'>Owner</label>
<GroupsSelect {...owner}
userGroups={userGroups}
allowCustomValues={false}
handleBeingTouched={() => {
dispatch(touch(formName, owner.name))
}} />
Expand Down
27 changes: 19 additions & 8 deletions app/components/GroupSelect/GroupsSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import log from 'logger'
export default class GroupsSelect extends Component {

render() {
const {userGroups, value, onChange, handleBeingTouched, touched, error} = this.props
const {userGroups, allowCustomValues, value, onChange, handleBeingTouched, touched, error} = this.props

var options = userGroups.map(function(group) {
return {label: group, value: group}
Expand All @@ -28,13 +28,24 @@ export default class GroupsSelect extends Component {

return (
<div className='group-select ncss-form-group'>
<Select.Creatable
className={((touched && error) ? 'category-select select-container-error' : 'category-select select-container')}
onChange = {(v) => { handleBeingTouched(); onChange(v)}}
onBlur={() => { handleBeingTouched() }}
value={value}
placeholder="Select a user group"
options={options} />
{ allowCustomValues &&
<Select.Creatable
className={((touched && error) ? 'category-select select-container-error' : 'category-select select-container')}
onChange = {(v) => { handleBeingTouched(); onChange(v)}}
onBlur={() => { handleBeingTouched() }}
value={value}
placeholder="Select a user group"
options={options} />
}
{ !allowCustomValues &&
<Select
className={((touched && error) ? 'category-select select-container-error' : 'category-select select-container')}
onChange = {(v) => { handleBeingTouched(); onChange(v)}}
onBlur={() => { handleBeingTouched() }}
value={value}
placeholder="Select a user group"
options={options} />
}
{touched && error && <div className='select-error-msg'>{error}</div>}
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default class UserGroupPermissionsFieldSet extends Component {

<GroupsSelect {...permission.name}
userGroups={userGroups}
allowCustomValues={true}
handleBeingTouched={() => {
dispatch(touch(formName, permission.name.name))
}} />
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"isparta-loader": "2.0.0",
"json-loader": "0.5.4",
"lolex": "1.5.0",
"node-sass": "3.8.0",
"node-sass": "3.11.0",
"react-addons-test-utils": "15.1.0",
"redbird": "0.5.2",
"redux-devtools": "3.3.1",
Expand Down

0 comments on commit c6490ca

Please sign in to comment.