-
Notifications
You must be signed in to change notification settings - Fork 18
Add error message when Space user exists on Org user removal. #1163
Conversation
rememberlenny
commented
Jul 19, 2017
…it generic for the user list
…ming of user list notification
static_src/constants.js
Outdated
@@ -267,9 +269,9 @@ const userActionTypes = keymirror({ | |||
// Action when something goes wrong in user invite and email process. | |||
USER_INVITE_ERROR: null, | |||
// Action to display an invite notification | |||
USER_INVITE_STATUS_DISPLAYED: null, | |||
USER_INVITE_STATUS_CREATED: null, | |||
// Action to dismiss an invite notification |
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.
update comment
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.
Got it!
static_src/constants.js
Outdated
@@ -267,9 +269,9 @@ const userActionTypes = keymirror({ | |||
// Action when something goes wrong in user invite and email process. | |||
USER_INVITE_ERROR: null, | |||
// Action to display an invite notification | |||
USER_INVITE_STATUS_DISPLAYED: null, | |||
USER_INVITE_STATUS_CREATED: null, |
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 you meant to get rid of this since you created the new one above https://github.com/18F/cg-dashboard/pull/1163/files#diff-286a478a0e7b0544d442395e82edf6c1R262
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 was intentional. I moved away from having multiple constants that result in a notification being displayed. Instead, there are multiple constants that lead to the preparation of a notification, but only one actual constant that leads to the creation of a notification. As a result, this one is changed to reflect the preparation of the invite specific notification.
static_src/util/cf_api.js
Outdated
).catch(res => { | ||
const err = parseError(res); | ||
if (res && res.response && res.response.status === 400) { | ||
if (res.response.data.error_code === 'CF-AssociationNotEmpty') { |
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.
can you combine these two conditionals into one long one?
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.
done!
static_src/util/cf_api.js
Outdated
const err = parseError(res); | ||
if (res && res.response && res.response.status === 400) { | ||
if (res.response.data.error_code === 'CF-AssociationNotEmpty') { | ||
const description = 'This user can\'t be removed because they still have a 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.
Uncapitalize non-proper nouns.
s/Space/space
s/Organization/organization
s/User/user
also, spell out organization.
s/Org/organization
static_src/util/cf_api.js
Outdated
'role within the Organization. Please remove all Space ' + | ||
'associations before removing this User from the Org.'; | ||
userActions.createUserSpaceAssociationNotification(description); | ||
return Promise.reject(err); |
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.
you don't need this.
also, a noob JS question here, do you want to have a return on userActions.createUserSpaceAssociationNotification(description);
?
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.
In this case, we dont need one. The createUserSpaceAssociationNotification
kicks off the notification, but doesnt return anything.
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.
a few changes
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.
As a general note, I don't hate the name inviteNotice
. userListInviteNotice basically ties the data to a specific component. Was it changed because the UserList is the only current component with the invite functionality?
}); | ||
}, | ||
|
||
createUserListNotification(noticeType, description) { |
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 we should start writing new actions in this format:
type: RAD_TYPE,
data: {
datum1: false,
datum2: true
}
Then every action presents a consistent interface regardless of the information being passed in. What do you think?
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 thats a good idea. It currently uses the ES6 syntax for exampling the variable name as the key. Instead of data
, it does what you are describing with action
. I think it would be a lot of refactoring to change them all.
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 as well. but let's save that for a broader discussion.
static_src/actions/user_actions.js
Outdated
}, | ||
|
||
createUserSpaceAssociationNotification(notification) { | ||
const description = notification; |
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 these are unnecessary
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.
Simplified
@el-mapache Regarding the naming, Im a proponent of breaking out a global notification action. For now, this is highly tied into the User List panel because of where it sits. I was proposing starting with a global notification component, but since we didnt go that route, I think its better to explicitly tie the functionality to the location. |
static_src/constants.js
Outdated
// Action to display an invite notification | ||
USER_INVITE_STATUS_DISPLAYED: null, | ||
// Action to prepare an invite notification | ||
USER_INVITE_STATUS_CREATED: null, |
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.
you dont need this. you have USER_LIST_NOTICE_CREATED
static_src/util/cf_api.js
Outdated
res.response.data.error_code === 'CF-AssociationNotEmpty' | ||
); | ||
if (errorConditions) { | ||
const description = 'This user can\'t be removed because they still have a 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.
you don't have a test that calls deleteOrgUserPermissions
and verifies that createUserSpaceAssociationNotification
is called with the description
static_src/actions/user_actions.js
Outdated
} else { | ||
userActions.deleteUser(userGuid, orgGuid); | ||
} | ||
}); |
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 need a catch 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.
Looking good! I added a few inline questions and comments. Once those are addressed, let's .
static_src/actions/user_actions.js
Outdated
}); | ||
if (usersSpaces.length > 0) { | ||
const description = 'This user can\'t be removed because they still have a space ' + | ||
'role within the organization. Please remove all 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.
The natural response to "Please remove all space associations" is "How/where do I do that?" Let's add a link or a few words to point them in the right direction.
static_src/constants.js
Outdated
@@ -266,10 +268,8 @@ const userActionTypes = keymirror({ | |||
USER_ASSOCIATED_ORG_DISPLAYED: null, | |||
// Action when something goes wrong in user invite and email process. | |||
USER_INVITE_ERROR: null, | |||
// Action to display an invite notification | |||
USER_INVITE_STATUS_DISPLAYED: null, | |||
// Action to dismiss an invite notification |
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 this comment still accurate?
@@ -1007,6 +1007,46 @@ describe('cfApi', function() { | |||
done(); | |||
}).catch(done.fail); | |||
}); | |||
describe('error handling', function() { | |||
it('should return display a generic error if unsuccessful', function(done) { |
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 return display
the intended phrasing?
}).catch(done.fail); | ||
}); | ||
|
||
it('should return display a notification about user having existing roles', function(done) { |
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 return display
the intended phrasing?
response: {error_code: 'CF-AssociationNotEmpty'}, | ||
}); | ||
|
||
const description = "This user can't be removed because they still " + |
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.
Just noting that this will need to be updated if the other piece is.
static_src/util/cf_api.js
Outdated
@@ -386,9 +386,23 @@ export default { | |||
.then(() => { | |||
userActions.deletedUser(userGuid, orgGuid); | |||
}).catch((err) => { | |||
if (err.response.data) { | |||
userActions.errorRemoveUser(userGuid, err.data); | |||
// Check if we got caught on user roles in spaces |
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
--> whether
(not a big deal)
static_src/util/cf_api.js
Outdated
error.response.data.error_code === 'CF-AssociationNotEmpty' | ||
); | ||
if (userHasSpaceRoles) { | ||
const description = 'This user can\'t be removed because they still have a 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.
Similar note as above.
let's talk about the need for deleteUserIfNoSpaceAssociation
All the changes should be reflected! @jcscottiii @fureigh |
Note: I added some new documentation in the |
we need to talk because we have the https://github.com/18F/cg-dashboard/pull/1163/files#diff-d45ddca2d392b7558d8957b40dd036ccR397 needs to be a constant or something also, per my comment as to why i removed my approval last night
we need tests for that stuff. |
static_src/util/cf_api.js
Outdated
@@ -386,9 +386,24 @@ export default { | |||
.then(() => { | |||
userActions.deletedUser(userGuid, orgGuid); | |||
}).catch((err) => { | |||
if (err.response.data) { | |||
userActions.errorRemoveUser(userGuid, err.data); | |||
// Check whether we got caught on user roles in spaces |
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 we can probably move this error handling up into the calling function, it gives us a little more flexibility in case we want to handle the error another way in different contexts.
@@ -60,6 +60,35 @@ const userActions = { | |||
}); | |||
}, | |||
|
|||
receivedOrgSpacesToExtractSpaceUsers(orgSpaces) { |
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 these methods need some tests.
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.
Added!
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.
Thanks for those changes! I added some missing spaces in a quick commit (d9984cc).
LGTM, pending @el-mapache and @jcscottiii's comments being addressed.
da5e2be
to
2afb68e
Compare
Looks good! |