-
Notifications
You must be signed in to change notification settings - Fork 18
Conversation
i'm surprised you have to associate the user to the org first. But you're right!
But if it do a curl put beforehand to the org users, it works
However, there's another problem. If I log in as the space-manager instead. It won't work because the space-manager can't associate someone to the org. There might be a separate UI for the space-managers to only pick people who are already associated to the org to choose from. |
049039f
to
ec3098a
Compare
return message; | ||
} | ||
|
||
get entityType() { | ||
return /space/.test(this.props.inviteEntityType) ? 'space' : 'organization'; |
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 a future PR, we will want to have some kind of service class or utility code that takes the raw name of the entity and gives us the human-friendly version.
@jcscottiii So given that, will we need to figure out what that UI looks like before this PR will be valuable? |
@el-mapache in the meantime, you can do a check and show error. 2 3 4 |
@jcscottiii Just so I am totally clear: we want to prevent the invite from ever hitting the UAA API, correct? |
Jumping on this |
5ebac53
to
1f4aea0
Compare
1f4aea0
to
cd6cf88
Compare
static_src/components/users.jsx
Outdated
const { currentUser } = this.state; | ||
const { currentOrgGuid } = OrgStore; | ||
|
||
// TODO this is not 100% robust. |
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 isn't it robust?
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.
left this in by mistake!
entityUsers = cfApi.fetchSpaceUserRoles(entityGuid); | ||
} | ||
return Promise.resolve(entityUsers); | ||
return cfApi[(entityType === ORG_NAME) ? 'fetchOrgUsers' : 'fetchSpaceUserRoles'](entityGuid); |
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.
while this makes the code more concise, i wonder if this takes away from the clarify and future expansion of the code (stuff to do in the branches)
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.
If we were doing more things in the branch, I would advocate to move the code into separate methods to maintain readability. I think this is ok as is, for now.
static_src/components/user_list.jsx
Outdated
@@ -134,8 +134,6 @@ export default class UserList extends React.Component { | |||
|
|||
if (this.props.empty) { | |||
content = this.emptyState; | |||
} else if (this.props.users.length === 1) { |
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 did this get removed?
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 didn't think the onlyOneState
makes sense anymore. If the user is an org manager, we will want to show the invite component, and if they are a space manager, we want to show the message telling them to ask their org manager to invite users.
@jcscottiii Maybe we need to show it regardless?
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.
leave it in for now. we can revisit this when we develop the UI for the space managers to move exiting org users into the space.
if it's a hassle to maintain that separate onlyOneState
state, let's talk about it then though.
); | ||
} | ||
|
||
get userInvite() { |
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.
(at first glance, i could be wrong), will this come up on the org page for a non admin, non org manager user? (this text is catered to the space page)
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 you are correct! I will need to add the entityType
interpolation we will in the UserInvite
component. I might just move this to a separate component so there isn't a ton of logic in the method.
return message; | ||
} | ||
|
||
get entityType() { | ||
return this.isOrganization ? 'organization' : 'space'; |
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.
const values for organization and space
} | ||
|
||
get isOrganization() { | ||
return /org/.test(this.props.inviteEntityType); |
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.
is there a comparison we can do without a regex?
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 only ask because, we should know for sure what values inviteEntityType
could be
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 could compare against the exact string that inviteEntityType
is. I didn't use a const because we don't currently (I dont think?) have a consistent way that we are handling those in the app.
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'll just add the constant for now, I'll make a ticket to go through an audit our use of strings/constants, and where we put the constants e.g. all in the constants.js
file, or in additional domain specific files, etc.
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'll make a ticket to go through an audit our use of strings/constants, and where we put the constants e.g. all in the constants.js file
That's a great idea!
cd6cf88
to
c6be7ac
Compare
@jcscottiii Updated based on your feedback + rebased with master |
@el-mapache whoops you were right about that one comment. i meant to say if you think |
@jcscottiii Ahh ok. I think maybe calling it users is misleading, we are filtering all the users down to just the current user. What do you think about grabbing the first element immediately and just checking |
describe('when at org level', function () { | ||
beforeEach(function () { | ||
describe('when at org level', () => { | ||
it('doesnt have permissions to edit users', () => { |
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 know this was here before, but let's change this statement (or change the test, but probably the former). it doesn't test the permissions of the users.
|
||
it('doesnt have permissions to edit users', function () { | ||
describe('when at space level', () => { | ||
it('doesnt have permissions to edit users', () => { |
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.
@@ -134,22 +135,25 @@ describe('UserStore', function () { | |||
expectedUsers = [ | |||
{ | |||
guid: userGuidA, | |||
roles: { [spaceGuid]: ['space_developer'] } | |||
roles: { [spaceGuid]: ['space_developer'] }, | |||
space_roles: [ 'space_developer' ] |
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.
is there a reason we need this new attribute space_roles
when we already have a mapping between the space guid and the roles that person has for the 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.
Its not a new attribute, its an old one. space_roles
is returned when we fetch the user from the API. We do a transformation that adds the roles
key, but in order to pass a deep equality test, the object needs to retain the space_roles
key.
We could edit the code to the delete space_roles
from the underlying object, but I don't think it hurts to have the extra field.
For context, the test originally passed without it because the code wasn't set up to handle the case of a new user being created from the spaces
view. In the old code, we would get the new user object from the database, and then overwrite it with a new object that just contained a guid
and 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.
ahh didn't know it was already there. in that case, we can leave it. i think we need to revisit the whole topic of the post-processing of data (like this transformation). but another day!
sorry i didn't go through everything last time. just finished now. left one main question. |
@el-mapache re: #1162 (comment) i like that much better |
@jcscottiii alright, updated based on current round of feedback! |
once the tests pass |
Pass in entitytype to UserInvite component Fix lint errors, only show invites when org manager is current user Fixup unit tests Add specs, remove unused sandbox refs * Use <PanelDocumentation /> component for invite fallback message Store users before merging roles Linting an spec fixes Address PR feedback
b7e5de7
to
f6f1abd
Compare
@el-mapache thanks for squashing the commits! |
Thanks for this! It looks great! |
Org managers can now associate users with spaces.
Screenshot:
In the case of a space manager who is not an org manager, they are directed to use the cloud foundry api (in the case of associating an existing user) or to ask their org manager to do it for them.
Screenshot: