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

Commit

Permalink
Use Dashboard IAM 'principal' language in Dashboard instead of 'role' (
Browse files Browse the repository at this point in the history
…#14)

* Rename IAM 'role' variables and classes to 'principal'
  • Loading branch information
sdford authored Apr 21, 2017
1 parent 45c6322 commit f3d7e98
Show file tree
Hide file tree
Showing 8 changed files with 470 additions and 263 deletions.
16 changes: 8 additions & 8 deletions app/components/CreateSDBoxForm/CreateSDBoxForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import GroupsSelect from '../GroupSelect/GroupsSelect'
import validate from './validator'
import * as cms from '../../constants/cms'
import UserGroupPermissionsFieldSet from '../UserGroupPermissionsFieldSet/UserGroupPermissionsFieldSet'
import IamRolePermissionsFieldSet from '../IamRolePermissionsFieldSet/IamRolePermissionsFieldSet'
import IamPrincipalPermissionsFieldSet from '../IamPrincipalPermissionsFieldSet/IamPrincipalPermissionsFieldSet'
import SDBDescriptionField from '../SDBDescriptionField/SDBDescriptionField'

import './CreateSDBoxForm.scss'
Expand All @@ -31,8 +31,8 @@ export const fields = [
'owner',
'userGroupPermissions[].name',
'userGroupPermissions[].roleId',
'iamRolePermissions[].iamPrincipalArn',
'iamRolePermissions[].roleId'
'iamPrincipalPermissions[].iamPrincipalArn',
'iamPrincipalPermissions[].roleId'
]

// connect to the store for the pieces we care about
Expand Down Expand Up @@ -81,7 +81,7 @@ export default class CreateSDBoxForm extends Component {
categoryId,
owner,
userGroupPermissions,
iamRolePermissions
iamPrincipalPermissions
},
categories,
handleSubmit,
Expand Down Expand Up @@ -141,10 +141,10 @@ export default class CreateSDBoxForm extends Component {
userGroups={userGroups}
roles={roles} />

<IamRolePermissionsFieldSet iamRolePermissions={iamRolePermissions}
dispatch={dispatch}
formName={formName}
roles={roles} />
<IamPrincipalPermissionsFieldSet iamPrincipalPermissions={iamPrincipalPermissions}
dispatch={dispatch}
formName={formName}
roles={roles} />

<div id="submit-btn-container">
<div id='cancel-btn'
Expand Down
14 changes: 7 additions & 7 deletions app/components/CreateSDBoxForm/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const doesContainNonAlphaNumericSpaceCharsRegex = /[^a-z\d\s]+/i
const validate = values => {
const errors = {}
errors.userGroupPermissions = {}
errors.iamRolePermissions = {}
errors.iamPrincipalPermissions = {}
errors.foo = {}

// Validate the Name field
Expand Down Expand Up @@ -37,7 +37,7 @@ const validate = values => {
}

if (values.userGroupPermissions) {
values.iamRolePermissions.map((permission, index) => { validateIamRolePermissions(permission, index, errors) })
values.iamPrincipalPermissions.map((permission, index) => { validateIamPrincipalPermissions(permission, index, errors) })
}

log.debug('Completed validation returning Error:\n' + JSON.stringify(errors, null, 2))
Expand All @@ -55,17 +55,17 @@ const validateUserGroupPermissions = (permission, index, errors) => {
}
}

const validateIamRolePermissions = (permission, index, errors) => {
errors.iamRolePermissions[`${index}`] = {}
const validateIamPrincipalPermissions = (permission, index, errors) => {
errors.iamPrincipalPermissions[`${index}`] = {}

if (! permission.iamPrincipalArn) {
errors.iamRolePermissions[`${index}`].iamPrincipalArn = 'You must enter a IAM principal ARN for this permission'
errors.iamPrincipalPermissions[`${index}`].iamPrincipalArn = 'You must enter a IAM principal ARN for this permission'
} else if (! /^arn:aws:(iam|sts)::.+$/.test(permission.iamPrincipalArn)) {
errors.iamRolePermissions[`${index}`].iamPrincipalArn = 'Invalid ARN'
errors.iamPrincipalPermissions[`${index}`].iamPrincipalArn = 'Invalid ARN'
}

if (! permission.roleId) {
errors.iamRolePermissions[`${index}`].roleId = 'Required'
errors.iamPrincipalPermissions[`${index}`].roleId = 'Required'
}
}

Expand Down
20 changes: 10 additions & 10 deletions app/components/EditSDBoxForm/EditSDBoxForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { reduxForm, touch } from 'redux-form'

import GroupsSelect from '../GroupSelect/GroupsSelect'
import UserGroupPermissionsFieldSet from '../UserGroupPermissionsFieldSet/UserGroupPermissionsFieldSet'
import IamRolePermissionsFieldSet from '../IamRolePermissionsFieldSet/IamRolePermissionsFieldSet'
import IamPrincipalPermissionsFieldSet from '../IamPrincipalPermissionsFieldSet/IamPrincipalPermissionsFieldSet'
import SDBDescriptionField from '../SDBDescriptionField/SDBDescriptionField'

import * as modalActions from '../../actions/modalActions'
Expand All @@ -24,15 +24,15 @@ export const fields = [
'owner',
'userGroupPermissions[].name',
'userGroupPermissions[].roleId',
'iamRolePermissions[].iamPrincipalArn',
'iamRolePermissions[].roleId'
'iamPrincipalPermissions[].iamPrincipalArn',
'iamPrincipalPermissions[].roleId'
]

class EditSDBoxForm extends Component {


render() {
const { fields: { description, owner, userGroupPermissions, iamRolePermissions },
const { fields: { description, owner, userGroupPermissions, iamPrincipalPermissions },
vaultToken, sdbId, roles, userGroups, hasDomainDataLoaded, dispatch, handleSubmit, isEditSubmitting } = this.props

// Lets not attempt to render everything until we have the data we need, when the domain data has loaded we can pass this
Expand Down Expand Up @@ -67,10 +67,10 @@ class EditSDBoxForm extends Component {
userGroups={userGroups}
roles={roles} />

<IamRolePermissionsFieldSet iamRolePermissions={iamRolePermissions}
dispatch={dispatch}
formName={formName}
roles={roles} />
<IamPrincipalPermissionsFieldSet iamPrincipalPermissions={iamPrincipalPermissions}
dispatch={dispatch}
formName={formName}
roles={roles} />

<div id="submit-btn-container">
<div id='cancel-btn'
Expand Down Expand Up @@ -99,7 +99,7 @@ let form = reduxForm({
})(EditSDBoxForm)

export default connect((state) => {
const { id, description, owner, userGroupPermissions, iamRolePermissions } = state.manageSafetyDepositBox.data
const { id, description, owner, userGroupPermissions, iamPrincipalPermissions } = state.manageSafetyDepositBox.data

return {
vaultToken: state.auth.vaultToken,
Expand All @@ -113,7 +113,7 @@ export default connect((state) => {
description: description,
owner: owner,
userGroupPermissions: userGroupPermissions,
iamRolePermissions: iamRolePermissions
iamPrincipalPermissions: iamPrincipalPermissions
}
}
})(form)
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,34 @@ import RoleSelect from '../RoleSelect/RoleSelect'
import Buttons from '../Buttons/Buttons'
import AddButton from '../AddButton/AddButton'
import { touch } from 'redux-form'
import './IamRolePermissionsFieldSet.scss'
import './IamPrincipalPermissionsFieldSet.scss'

/**
* Component for displaying User Group Permissions form field set
* @prop iamRolePermissions is the Redux form field for the array of IAM role permission objects (Group -> Role)
* @prop iamPrincipalPermissions is the Redux form field for the array of IAM role permission objects (Group -> Role)
* @prop dispatch from the store to dispatch touch events for the drop downs
* @prop formName The redux form name for touch events in the drop downs
* @props roles The list of roles that a user can select for the permission
*/
export default class IamRolePermissionsFieldSet extends Component {
export default class IamPrincipalPermissionsFieldSet extends Component {
static propTypes = {
iamRolePermissions: PropTypes.array.isRequired,
iamPrincipalPermissions: PropTypes.array.isRequired,
dispatch: PropTypes.func.isRequired,
formName: PropTypes.string.isRequired,
roles: PropTypes.array.isRequired
}

render() {
const {iamRolePermissions, dispatch, formName, roles} = this.props
const {iamPrincipalPermissions, dispatch, formName, roles} = this.props

return (
<div className='iam-role-permissions'>
<div className='iam-role-permissions-label ncss-label'>IAM Principal Permissions</div>
<div className="iam-role-permissions-perms-container">
<div className="iam-role-permissions-perms-container">
{iamRolePermissions.map((permission, index) =>
<div className='iam-principal-permissions'>
<div className='iam-principal-permissions-label ncss-label'>IAM Principal Permissions</div>
<div className="iam-principal-permissions-perms-container">
<div className="iam-principal-permissions-perms-container">
{iamPrincipalPermissions.map((permission, index) =>
<div key={index}>
<div className='iam-role-permissions-permission'>
<div className='iam-principal-permissions-permission'>

<div className='role-perm-principal-arn'>
<div className={((permission.iamPrincipalArn.touched && permission.iamPrincipalArn.error) ? 'ncss-input-container error' : 'ncss-input-container')}>
Expand All @@ -50,14 +50,14 @@ export default class IamRolePermissionsFieldSet extends Component {
}} />

<Buttons handleRemoveClicked={() => {
iamRolePermissions.removeField(index)
iamPrincipalPermissions.removeField(index)
}} />
</div>
</div>
)}
</div>
</div>
<AddButton handleClick={iamRolePermissions.addField} message="Add new permission" />
<AddButton handleClick={iamPrincipalPermissions.addField} message="Add new permission" />
</div>
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import '../../assets/styles/common.scss';

.iam-role-permissions {
.iam-principal-permissions {
margin-top: 15px;
border-style: solid;
border-radius: 2px;
Expand All @@ -10,15 +10,15 @@
padding-right: 7px;
padding-bottom: 7px;

.iam-role-permissions-label {
.iam-principal-permissions-label {
padding-top: 5px;
}

.iam-role-permissions-perms-container {
.iam-principal-permissions-perms-container {
margin-top: -7px;
}

.iam-role-permissions-permission {
.iam-principal-permissions-permission {
width: 100%;
padding-top: 10px;
display: flex;
Expand Down
8 changes: 4 additions & 4 deletions app/components/ManageSDBox/ManageSDBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export default class ManageSDBox extends Component {
{ displayPermissions &&
<div className="read-only-permissions">
{ readOnlyUserGroupPermissions(sdbData.userGroupPermissions, roles) }
{ readOnlyIamRolePermissions(sdbData.iamRolePermissions, roles) }
{ readOnlyIamPrincipalPermissions(sdbData.iamPrincipalPermissions, roles) }
</div>
}

Expand Down Expand Up @@ -171,8 +171,8 @@ const readOnlyUserGroupPermissions = (userGroupPermissions, roles) => {
}
}

const readOnlyIamRolePermissions = (iamRolePermissions, roles) => {
if (iamRolePermissions == null || iamRolePermissions.length < 1) {
const readOnlyIamPrincipalPermissions = (iamPrincipalPermissions, roles) => {
if (iamPrincipalPermissions == null || iamPrincipalPermissions.length < 1) {
return(<div>No IAM Principal Permissions Defined</div>)
} else {
return(
Expand All @@ -184,7 +184,7 @@ const readOnlyIamRolePermissions = (iamRolePermissions, roles) => {
<th className="iam-read-label">Role</th>
</tr>

{iamRolePermissions.map((perm, index) => {
{iamPrincipalPermissions.map((perm, index) => {
return (
<tr key={perm.id} className={(index + 1) % 2 == 0 ? "iam-read-only-perm even-row" : "iam-read-only-perm odd-row"}>
<td className="iam-read-only-perm-item iam-read-only-perm-principal-arn">{perm.iamPrincipalArn}</td>
Expand Down
Loading

0 comments on commit f3d7e98

Please sign in to comment.