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

Create space user's dropdown form for adding other org users #1172

Merged
merged 29 commits into from
Aug 1, 2017

Conversation

rememberlenny
Copy link
Contributor

record

const ORG_NAME = OrgStore.cfName;
// const SPACE_NAME = SpaceStore.cfName;
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets delete it!

Copy link
Contributor Author

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 {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

if (!this.currentUserIsSpaceManager) {
return (
<PanelDocumentation>
ORG AND SPACE MANAGERS CAN DO THIS.
Copy link
Contributor

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.

Copy link
Contributor Author

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);
Copy link
Contributor

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.

Copy link
Contributor Author

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() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test for this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy!

Copy link
Contributor

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() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test for this

Copy link
Contributor

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() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test for this

Copy link
Contributor

@jcscottiii jcscottiii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some feedback

@jcscottiii jcscottiii requested review from fureigh and el-mapache July 28, 2017 14:49
Copy link
Contributor

@el-mapache el-mapache left a 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);
Copy link
Contributor

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';
Copy link
Contributor

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() {
Copy link
Contributor

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() {
Copy link
Contributor

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() {
Copy link
Contributor

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 {
Copy link
Contributor

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

Copy link
Contributor Author

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.

@rememberlenny rememberlenny force-pushed the lkb-dropdown-space-org-users branch from 01d461d to b98bf11 Compare July 28, 2017 22:15
_onSubmitForm(errs, values) {
const { currentEntity } = this.props;
const { currentEntityGuid } = this.props;
const apiKey = AUDITOR_NAME;
Copy link
Contributor

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!

Copy link
Contributor

@jcscottiii jcscottiii Jul 31, 2017

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)

Copy link
Contributor

@jcscottiii jcscottiii Jul 31, 2017

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.

}

return (
<OrgUsersSelector
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On it!

@rememberlenny rememberlenny force-pushed the lkb-dropdown-space-org-users branch 4 times, most recently from 93793bc to 0a2aa6d Compare August 1, 2017 14:33
@rememberlenny rememberlenny force-pushed the lkb-dropdown-space-org-users branch from 0a2aa6d to 80ca7d6 Compare August 1, 2017 14:35
@@ -146,7 +148,7 @@ const userActions = {
});
},

addUserRoles(roles, apiKey, userGuid, entityGuid, entityType) {
addUserRoles(resource_role_name, user_role, userGuid, entityGuid, entityType) {
Copy link
Contributor

@jcscottiii jcscottiii Aug 1, 2017

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

Copy link
Contributor

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,
Copy link
Contributor

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

Copy link
Contributor

@jcscottiii jcscottiii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fureigh
Copy link
Contributor

fureigh commented Aug 1, 2017

@rememberlenny
Copy link
Contributor Author

@fureigh It was a copy over. Ill change for specificity.

@rememberlenny
Copy link
Contributor Author

@fureigh Its a react syntax. If you take a look at the other components, you will see that they all have a test- prefix class. This allows us to target the elements in a test.

@rememberlenny rememberlenny merged commit 4317913 into master Aug 1, 2017
@rememberlenny rememberlenny deleted the lkb-dropdown-space-org-users branch August 1, 2017 18:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants