-
Notifications
You must be signed in to change notification settings - Fork 18
Create space user's dropdown form for adding other org users #1172
Conversation
rememberlenny
commented
Jul 28, 2017
static_src/actions/user_actions.js
Outdated
const ORG_NAME = OrgStore.cfName; | ||
// const SPACE_NAME = SpaceStore.cfName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why was this commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has a linking error because it's not used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets delete it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
}; | ||
} | ||
|
||
export default class UsersParentEntityUserSelector extends React.Component { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we might want to change the name of this. at first glance it's not that clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I totally agree. Originally it was supposed to be a module. Not it only does one thing, check org users, if user is in a space.
static_src/components/users.jsx
Outdated
if (!this.currentUserIsSpaceManager) { | ||
return ( | ||
<PanelDocumentation> | ||
ORG AND SPACE MANAGERS CAN DO THIS. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure you meant to have this text here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hahaha. No it should be :)
const roles = 'space_auditor'; | ||
if (values.userGuid) { | ||
const userGuid = values.userGuid.value; | ||
userActions.addUserRoles(roles, apiKey, userGuid, entityGuid, entityType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think in order to prevent confusion, we should only show org users currently without space roles. then here, upon successful submission, we should remove the user from the list so we don't see them here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was working on last night, but didn't know quite how the EventEmitter on the UserStore worked. I need to dig in a bit.
Basically, the logic to do this works.
} | ||
} | ||
|
||
get errorMessage() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is copied from the UserInvite component, seems like a good time to extract a out module or higher-order component.
return message; | ||
} | ||
|
||
get invitationMessage() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above ^^
` to this ${currentEntity}.`; | ||
} | ||
|
||
get userSelector() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some feedback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good thus far! The two things I noticed most were:
- new component name is fairly verbose and maybe not as clear as it could be
- The new component borrows a lot from the
UsersInvite
component. There is probably a way to extract the common functionality and share it between the two components
export default class UsersParentEntityUserSelector extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
FormStore.create(USERS_PARENT_ENTITY_USER_FORM_GUID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a form here could produce unwanted side effects e.g. if this component subscribed to the FormStore's change event. It should be called in componentDidMount
_onSubmitForm(errs, values) { | ||
const entityType = this.state.currentEntity; | ||
const entityGuid = this.state.currentEntityGuid; | ||
const apiKey = 'auditors'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets make these constants
} | ||
} | ||
|
||
get errorMessage() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is copied from the UserInvite component, seems like a good time to extract a out module or higher-order component.
return message; | ||
} | ||
|
||
get invitationMessage() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above ^^
@@ -682,6 +682,19 @@ describe('UserStore', function () { | |||
}); | |||
}); | |||
|
|||
describe('getAllInOrgAndNotSpace()', function() { | |||
it('should find all users that are in an org, without the space users', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am probably misreading this spec, but from the description, shouldn't the testUser
be excluded here? They don't have a space_roles
key on their object, they do have a space role in their roles
.
Should the corresponding method in UserStore
also check for the existence of space roles within the roles
object?
|
||
|
||
function stateSetter(props) { | ||
return { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is state needed in this component if everything is passed down from props? https://github.com/18F/cg-dashboard/blob/master/CONTRIBUTING.md#components
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its not. This is a great document. Thanks.
01d461d
to
b98bf11
Compare
_onSubmitForm(errs, values) { | ||
const { currentEntity } = this.props; | ||
const { currentEntityGuid } = this.props; | ||
const apiKey = AUDITOR_NAME; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be renamed to endpoint
? When I read api key, I think of an access key, or a secret. I know you didn't introduce this pattern, but maybe we can start renaming now!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i like the idea of renaming it! let's move it to resource
(i think of endpoint as being the full path).
(coming from me, the person who introduced the pattern lol)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's another refactor while we are talking about it, (but outside the scope of this PR)
addUserRoles currently only takes one role but it and the argument are plural roles
.
This needs to be made singular. Also, apiKey
/ resource
/ endpoint
are the actual role in the uri. it could be confusing between whichever variable name is used vs the roles
which is a map to the roles
used in the frontend for the check boxes.
would like to rename roles
but not sure to what.
static_src/components/users.jsx
Outdated
} | ||
|
||
return ( | ||
<OrgUsersSelector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this component has a lot of attributes. for a lot of attributes, you can make this generic like UserSelector
.
For OrgUserSelector, you probably wouldn't need all this. I'm leaning to keeping all of these and just rename to UserSelector
and we can refactor for more generic cases later on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On it!
93793bc
to
0a2aa6d
Compare
0a2aa6d
to
80ca7d6
Compare
static_src/actions/user_actions.js
Outdated
@@ -146,7 +148,7 @@ const userActions = { | |||
}); | |||
}, | |||
|
|||
addUserRoles(roles, apiKey, userGuid, entityGuid, entityType) { | |||
addUserRoles(resource_role_name, user_role, userGuid, entityGuid, entityType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh sorry for the confusing conversation.
we were saying apiKey
-> resource
and you can revert resource_role_name
to roles
and leave roles
as-is for now.
we will address the naming when we address addUserRoles
and addedUserRoles
and the mapping to the frontend roles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should stick to camel case as well
const USERS_PARENT_ENTITY_USER_FORM_GUID = 'users-parent-entity-users-form'; | ||
|
||
const propTypes = { | ||
orgUsersSelectorDisabled: PropTypes.bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be renamed to selectorDisabled
or usersSelectorDisabled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rememberlenny: Is the class in line 78 of https://github.com/18F/cg-dashboard/blob/339846c962783db8afa63f054be202af00b1a0e0/static_src/components/users_selector.jsx meant to be "test-users"? If so, LGTM. |
@fureigh It was a copy over. Ill change for specificity. |
@fureigh Its a react syntax. If you take a look at the other components, you will see that they all have a |