Challenge Overview
Show individual errors when inviting several members to a project.
Project Background
Topcode Connect is client facing application of Topcoder. Customer use Topcoder Connect to input requirements of their projects, then managers and copilots take it from there.
We can invite several members to a project by entering their handles and/or emails. Currently, if inviting at least one of members is failed in some reason, all invites will fail and one error message will be shown for the first happened error.
We want to change this behavior so the invites which can be created should be created successfully, and for the invites which have errors, we want to show individual error messages.
We will need to update Project Service together with Connect app.
Technology Stack
Project Service
-
Node.js
-
PostgreSQL
-
ElastiSearch
Connect app
-
React
-
Redux
-
CSS Modules
Code access
The work for this challenge has to be done in two repositories:
- Project Service repo https://github.com/topcoder-platform/tc-project-service dev branch
- Connect App repo https://github.com/appirio-tech/connect-app dev branch
- For the local deployment check info on the forum.
Individual requirements
1. Update Project Service
Currently, when we invite several members in a batch even if one member invitation has an error, we don’t create all the invitation in the batch at all.
We should update the code in Project Service so that if some members in a batch can be invited successfully - they should be invited.
For the members which couldn’t be invited, we should return a list with individual reasons for errors.
There are could be two types of errors during members invitation.
General errors
-
Errors related to the whole request should stay as they are. Only one error message should be returned for the whole request.
-
The list of general errors:
- Either userIds or emails are required
- You are not allowed to invite user as ${invite.role}
- Any other errors which happen during processing the request in general -
Format of the response stays the same as now:
{
message: ‘Either userIds or emails are required’
} -
And we return the corresponding HTTP error code which is already done.
Individual errors
-
Errors related to individual invitations should be returned for each invited members separately.
-
The list of individual invite errors:
- emails can only be used for ${PROJECT_MEMBER_ROLE.CUSTOMER}
- ${forbidUserList.join()} cannot be added with a Manager role to the project This error should be reformatted to cannot be added with a Manager role to the project without the list of users.
- Any other errors which happen during processing individual invitations should not contain mentioning of a particular user. -
Format of the response:
{
// the list of failed invitations
failed:[{
email: ‘test@email.com’,
message: ‘emails can only be used for ${PROJECT_MEMBER_ROLE.CUSTOMER}’
}, {
id: 214234234,
message: ‘cannot be added with a Manager role to the project’
}],
// now the success list is returned directly
success: [{
}],
// general error message
message: ‘Some members couldn’t be invited.’
} -
If at least one invitation failed, we return HTTP code 403. (as mostly invites will fail because of permissions and have to choose one response).
-
If all invitations were successful, return HTTP code 201 as it’s done now.
Success responses
When the response doesn’t have any errors we will now return data inside success property, not directly, like before:
{
success: [{
}],
}
This is to keep it consistent with the case where there are some individual errors.
2. Update Connect App
In the Connect app we should keep showing the alert popup when created invites successfully or we got an error.
If there is an error we keep showing only a general error from `message` property in the alter popup. This part stays as it is.
-
As now we return an array of successful invites inside `success` property instead of directly, we should update Connect App to this new response format.
-
When there are any invitations failed we should:
- keep failed handles/emails in the input as it’s done now
- remove handles/emails from the input which were successfully invited -
Under the input, we should show the list of errors grouped by error text in the format: “<comma-separated list of handles/emails with a particular error> - <error message>”.
-
Note. When we enter handles client side, we get their ids client side and send a request to the server with ids. So when the server returns the user ids of failed invitations the client already knows the mapping between ids and handles to format these errors.
General requirements
Project Service
-
Cover essentials cases with unit tests: all invites are successful, all invites are failed, some invites are failed (each kind of error if possible), general error during the request (each kind of error if possible)
-
Lint should pass
-
Update postman if necessary
-
Update swagger if necessary
Connect App
-
Use React + Redux best practices.
-
Lint should pass
-
Existent unit tests should pass (no new tests needed)
Deployment guide and validation document
Please, provide a brief guide on how to verify the submission.
Final Submission Guidelines
-
Patch to the dev branch of Connect App
-
Patch to the dev branch of Project Service
-
Brief submission verification guide