Challenge Overview
Avoid unnecessary server requests after updating objects in the metadata editors.
Project Background
Topcode Connect is a client-facing application of Topcoder. We have the ability to edit various metadata objects for admins. Currently, after editing and saving any object to the server we additionally trigger reloading the data from the server. Which is unnecessary and should be avoided.
Technology Stack
-
React
-
Redux
Code access
The work for this challenge has to be done in one repository:
- Connect App repo https://github.com/appirio-tech/connect-app dev branch.
- A user for testing is provided on the forum.
Individual requirements
At the moment after making request to update an object in metadata editor we are reloading that object or even all the metadata objects in the next lines. We have to remove the “then” part to stop reloading objects as we already getting the updated data in response from the server in the PATCH request.
Instead of that, we should properly implement “updateProjectsMetadata” action. So far UPDATE_PROJECTS_METADATA_SUCCESS is not implemented properly, and the line “metadata: action.payload” does nothing and should be removed. Instead of that, we should implement it properly to update the saved object in the Redux state.
Note, that we have two types of objects: with revision (Forms, Plan Configs, Price Configs) and without revision (others). When we update objects which have revision, then server doesn’t actually update the object but returns a new object with the next revision. So such objects should be added to the Redux store, not updated.
If you have any questions or concerns, don’t hesitate to raise a question on the forum.
General requirements
-
Follow React and Redux best practices. In particular, don’t mutate the Redux state.
-
Lint should pass
-
Existent unit tests should pass
Local development
-
For local development, you would have to deploy not only the Connect App but also Project Service by following “Steps to run locally”.
-
After that, you would have to point the locally deployed Connect App to the locally deployed Project Service as per “Run Connect App with Project Service locally”.
-
And populate demo data by following “Import sample metadata & projects”.
-
As we provide a non-admin user, but editing metadata requires admin permission, we should disable checking for admin permission in Project Service. For this purpose update line 8 in this file https://github.com/topcoder-platform/tc-project-service/blob/dev/src/permissions/index.js#L8 with “const projectAdmin = true;”.
-
Now you can edit all the metadata locally http://local.topcoder-dev.com:3000/metadata/projectTemplates using provided user on the forum.
Verification Guide
Basically, the task here is to refactor the code so we keep the same functionality but without additional server calls. So all the functionality should work as it is. Here are essential use cases to check.
- After updating object it should be also updated in the list of objects, see a demo video.
- After updating an object with revision, we should see that an object with latest revision is loaded on the page, and also we should see it in the Revision History, see a demo video.
Final Submission Guidelines
-
Patch to the Connect App.
-
The winner is required to raise a PR to the repository.