-
Notifications
You must be signed in to change notification settings - Fork 212
[$60]Forums tab must be displayed for all roles like copilot approver etc #4672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Contest https://www.topcoder.com/challenges/30134485 has been created for this ticket. |
Contest https://www.topcoder.com/challenges/30134485 has been updated - it has been assigned to cagdas001. |
TL;DR; Needs a backend change at resource-api The current code uses community-app/src/shared/components/challenge-detail/Header/TabSelector/index.jsx Line 37 in aabe3f7
It fetches user challenges and populates this field from user challenges. (see below code block for more detail) community-app/src/shared/actions/challenge-listing/index.js Lines 108 to 124 in aabe3f7
The issue is that, V5 API doesn't return such a field in challenges. I have also checked the V4 API, it also doesn't return. Looks like these are very old codes, were added 1-3 years ago, so I guess However, we still need a way to get user's role(s) for a particular challenge. Challenge API doesn't return any helpful info. Looks like there is a function named /**
* Gets roles of a user in the specified challenge. The user tested is
* the owner of authentication token used to instantiate the service.
*
* Notice, if you have already loaded the challenge as that user, these roles
* are attached to the challenge object under `userDetails.roles` path during
* challenge normalization. However, if you have not, this method is the most
* efficient way to get them, as it by-passes any unnecessary normalizations
* of the challenge object.
*
* @param {Number} challengeId Challenge ID.
*/
async getUserRolesInChallenge(challengeId) {
const user = decodeToken(this.private.tokenV3);
const url = `/resources?challengeId=${challengeId}?memberHandle=${user.handle}`;
const resources = await this.private.apiV5.get(url);
if (resources) return _.map(resources, 'roleId');
throw new Error(`Failed to fetch user role from challenge #${challengeId}`);
}
} This is exactly what we're looking for. However, there is an issue with resource-api. It only returns the Submitter role if the user is not an admin or machine. So, we can't get the roleId of other roles like co-pilot etc. if (!currentUser || (!currentUser.isMachine && !helper.hasAdminRole(currentUser))) {
// await checkAccess(currentUser, resources)
// if not admin, and not machine, only return submitters
boolQuery.push({ match_phrase: { roleId: config.SUBMITTER_RESOURCE_ROLE_ID } })
} else if (roleId) {
boolQuery.push({ match_phrase: { roleId } })
} Maybe we can make a change at resource-api, if I'm querying another user's resources it's understandable to return only Submitter roles, however, if I'm querying my own resources (this is our case), I think it can return all the resources with all roles. Currently it only returns resources with Submitter roles, even if I'm querying with my own I can make the above change at the resource-api if someone confirms |
@rootelement will confirm that. That's a good analysis @cagdas001 |
PR (topcoder-react-lib): topcoder-platform/topcoder-react-lib#214 Use this version of topcoder-react-lib when testing the community-app (you can add it as local dependency) |
topcoder-platform/community-app#4672 luiz #214 1000.19.41
#4672 luiz topcoder-platform/topcoder-react-lib#214 1000.19.41
Payment task has been updated: https://software.topcoder.com/review/actions/ViewProjectDetails?pid=30134485 |
Forums tab must be displayed for all roles like copilot approver etc

example:
https://www.topcoder.com/challenges/30133520
https://beta-community-app.topcoder.com/challenges/0c8061f0-076f-47d3-a901-7cf13f99500c
user: picachui (copilot and appprover for the contest)
The text was updated successfully, but these errors were encountered: