-
Notifications
You must be signed in to change notification settings - Fork 18
Add error message when Space user exists on Org user removal. #1163
Changes from 8 commits
88c99a3
c48c3eb
4487850
28b56da
b123cd9
f4b550f
e8c967e
1e30a66
d0a8766
faf2819
f782d65
24b0ba7
01eef76
ba99e8d
67d0596
0ed162f
3c883d5
792214e
9e8ea37
fd13220
46bbd74
684ab14
45bc78b
b7815d0
3c72fe2
d9984cc
49465de
22ecabf
e00d4a6
2afb68e
07e0ddb
237dc7e
607daf9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -200,10 +200,25 @@ const userActions = { | |
|
||
clearInviteNotifications() { | ||
AppDispatcher.handleViewAction({ | ||
type: userActionTypes.USER_INVITE_STATUS_DISMISSED | ||
type: userActionTypes.USER_LIST_NOTICE_DISMISSED | ||
}); | ||
}, | ||
|
||
createUserListNotification(noticeType, description) { | ||
AppDispatcher.handleViewAction({ | ||
type: userActionTypes.USER_LIST_NOTICE_CREATED, | ||
noticeType, | ||
description | ||
}); | ||
}, | ||
|
||
createUserSpaceAssociationNotification(notification) { | ||
const description = notification; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Simplified |
||
const noticeType = 'error'; | ||
|
||
userActions.createUserListNotification(noticeType, description); | ||
}, | ||
|
||
createInviteNotification(verified, email) { | ||
let description; | ||
const noticeType = 'finish'; | ||
|
@@ -223,11 +238,7 @@ const userActions = { | |
'be controlled below.'; | ||
} | ||
|
||
AppDispatcher.handleViewAction({ | ||
type: userActionTypes.USER_INVITE_STATUS_DISPLAYED, | ||
noticeType, | ||
description | ||
}); | ||
userActions.createUserListNotification(noticeType, description); | ||
}, | ||
|
||
userInviteError(err, contextualMessage) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -258,6 +258,8 @@ const userActionTypes = keymirror({ | |
USER_INVITE_TRIGGER: null, | ||
// Action to trigger when invite status is triggered for front end. | ||
USER_INVITE_STATUS_UPDATED: null, | ||
// Action to trigger when user list notice is created. | ||
USER_LIST_NOTICE_CREATED: null, | ||
// Action to trigger email sent to user with cloud.gov invite url. | ||
USER_ORG_ASSOCIATE: null, | ||
// Action to associate user to organization on the server. | ||
|
@@ -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 commentThe 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 commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you dont need this. you have |
||
// Action to dismiss an invite notification | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Got it! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this comment still accurate? |
||
USER_INVITE_STATUS_DISMISSED: null, | ||
USER_LIST_NOTICE_DISMISSED: null, | ||
// Action to delete a user from an org. | ||
USER_DELETE: null, | ||
// Action when a user was deleted from an org on the server. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -403,7 +403,19 @@ export default { | |
deleteOrgUserPermissions(userGuid, orgGuid, apiKey) { | ||
return http.delete(`${APIV}/organizations/${orgGuid}/${apiKey}/${userGuid}`) | ||
.then((res) => res.response | ||
); | ||
).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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. done! |
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Uncapitalize non-proper nouns. also, spell out organization. |
||
'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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case, we dont need one. The |
||
} | ||
} | ||
return Promise.reject(err); | ||
}); | ||
}, | ||
|
||
putOrgUserPermissions(userGuid, orgGuid, permissions) { | ||
|
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:
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 withaction
. 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.