Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 12d5fc9

Browse files
authored
Merge pull request #35 from topcoder-platform/dev
feat: add profile-app navigation
2 parents 2d5860f + 11ccd51 commit 12d5fc9

File tree

8 files changed

+62
-37
lines changed

8 files changed

+62
-37
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ workflows:
7575
only:
7676
- dev
7777
- challenge-listing-part-1
78+
- feat/profile-app
7879

7980
# Production builds are exectuted only on tagged commits to the
8081
# master branch.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,6 @@ dist
105105

106106
# VS Code settings
107107
.vscode/
108+
109+
# Webstorm setttings
110+
.idea/

config/dev.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module.exports = {
99
},
1010
API: {
1111
V3: "https://api.topcoder-dev.com/v3",
12+
V5: "https://api.topcoder-dev.com/v5",
1213
},
1314
REAUTH_OFFSET: 55, // seconds
1415
};

src/components/AllAppsMenu/index.jsx

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -51,41 +51,43 @@ const AllAppsMenu = () => {
5151
<div className="all-apps-menu-popover-content">
5252
<div className="all-apps-menu-list-title">SWITCH TOOLS</div>
5353
<ul className="all-apps-menu-list">
54-
{menu.map((appCategory) => (
55-
<Fragment>
56-
<div className="switch-category-title">
57-
<div className="menu-divider"></div>
58-
<div className="all-apps-menu-category-name">
59-
{appCategory.category}
54+
{menu
55+
.filter((appCategory) => !appCategory.hidden)
56+
.map((appCategory) => (
57+
<Fragment>
58+
<div className="switch-category-title">
59+
<div className="menu-divider"></div>
60+
<div className="all-apps-menu-category-name">
61+
{appCategory.category}
62+
</div>
63+
<div className="menu-divider"></div>
6064
</div>
61-
<div className="menu-divider"></div>
62-
</div>
63-
{appCategory.apps.map((app) => {
64-
// if app is roles restricted check for access
65-
if (app.roles) {
66-
// not logged-in
67-
if (!auth || !tokenData) return null;
68-
// roles in v3 token match?
69-
if (
70-
tokenData &&
71-
!intersection(app.roles, tokenData.roles).length
72-
)
73-
return null;
74-
}
75-
return (
76-
<li className="all-apps-menu-app" key={app.path}>
77-
<Link
78-
to={app.path}
79-
onClick={(e) => closeMenu(e, app)}
80-
>
81-
<img src={app.icon} alt={`${app.title} Icon`} />
82-
<span>{app.title}</span>
83-
</Link>
84-
</li>
85-
);
86-
})}
87-
</Fragment>
88-
))}
65+
{appCategory.apps.map((app) => {
66+
// if app is roles restricted check for access
67+
if (app.roles) {
68+
// not logged-in
69+
if (!auth || !tokenData) return null;
70+
// roles in v3 token match?
71+
if (
72+
tokenData &&
73+
!intersection(app.roles, tokenData.roles).length
74+
)
75+
return null;
76+
}
77+
return (
78+
<li className="all-apps-menu-app" key={app.path}>
79+
<Link
80+
to={app.path}
81+
onClick={(e) => closeMenu(e, app)}
82+
>
83+
<img src={app.icon} alt={`${app.title} Icon`} />
84+
<span>{app.title}</span>
85+
</Link>
86+
</li>
87+
);
88+
})}
89+
</Fragment>
90+
))}
8991
</ul>
9092
</div>
9193
</div>

src/components/UserMenu/index.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Shows logged-in user with user menu with options like log-out.
55
*/
66
import React, { useState, useCallback, Fragment } from "react";
7+
import { Link } from "@reach/router";
78
import Avatar from "../Avatar";
89
import cn from "classnames";
910
import OutsideClickHandler from "react-outside-click-handler";
@@ -62,6 +63,11 @@ const UserMenu = ({ profile }) => {
6263
<div className="user-menu-popover-arrow" />
6364
<div className="user-menu-popover-content">
6465
<ul className="user-menu-list">
66+
<li>
67+
<Link to={`/profile/${profile.handle}`} onClick={closeMenu}>
68+
Profile
69+
</Link>
70+
</li>
6571
<li>
6672
<a href={getLogoutUrl()} onClick={onLogoutClick}>
6773
Log Out

src/constants/apps.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,16 @@ export const APP_CATEGORIES = [
7171
},
7272
],
7373
},
74+
{
75+
category: "Profile",
76+
hidden: true,
77+
apps: [
78+
{
79+
title: "Profile App",
80+
path: "/profile/",
81+
isExact: false,
82+
menu: [],
83+
},
84+
],
85+
},
7486
];

src/services/auth.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ const loadProfile = (userTokenV3) => {
5757
if (!userTokenV3) return Promise.resolve(null);
5858
const user = decodeToken(userTokenV3);
5959
const fetcher = getFetcher(userTokenV3);
60-
return fetcher(`${config.API.V3}/members/${user.handle}`, {
60+
return fetcher(`${config.API.V5}/members/${user.handle}`, {
6161
method: "get",
6262
})
6363
.then((res) => res.json())
64-
.then((res) => (res.result.status === 200 ? res.result.content : {}));
64+
.then((res) => res || {});
6565
};
6666

6767
configureConnector({

webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module.exports = (webpackConfigEnv, options) => {
3434
rules: [
3535
{
3636
/* Loads svg images. */
37-
test: /[/\/]assets[/\/]images[/\/].+\.svg$/,
37+
test: /[/\\]assets[/\\]images[/\\].+\.svg$/,
3838
exclude: /node_modules/,
3939
loader: "file-loader",
4040
options: {

0 commit comments

Comments
 (0)