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

Commit 9035527

Browse files
Merge pull request #113 from topcoder-platform/PROD-1551_header
PROD-1551 Hide Header for Customer Work App -> dev
2 parents 47aeb5c + 289ef43 commit 9035527

File tree

9 files changed

+392
-22939
lines changed

9 files changed

+392
-22939
lines changed

package-lock.json

Lines changed: 347 additions & 22633 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/App.jsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ const App = () => {
4343
);
4444
const location = useLocation();
4545

46+
// if this is the self-service app, don't display anything
47+
if (!!['/self-service', '/work', '/account'].find(path => location.pathname.startsWith(path))) {
48+
return <></>
49+
}
50+
4651
// set/remove class for the whole page, to know if sidebar is present or no
4752
useEffect(() => {
4853
if (isSideBarDisabled) {
@@ -58,11 +63,7 @@ const App = () => {
5863
<NavBar
5964
default
6065
noThrow
61-
profileUrl={
62-
location.pathname.includes("/self-service")
63-
? "/self-service/account/"
64-
: `/profile/${_.get(auth, "profile.handle", "")}`
65-
}
66+
profileUrl={`/profile/${_.get(auth, "profile.handle", "")}`}
6667
hideSwitchTools={isNavigationDisabled}
6768
path="/*"
6869
/>

src/components/NavBar/index.jsx

Lines changed: 38 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,13 @@ import { Link, useLocation } from "@reach/router";
1919
import TCLogo from "../../assets/images/tc-logo.svg";
2020
import {
2121
getLoginUrl,
22-
getSelfServiceLoginUrl,
23-
getSelfServiceSignupUrl,
2422
} from "../../utils";
25-
import { BUTTON_TYPE } from "constants/";
2623
import "./styles.css";
2724
import { useMediaQuery } from "react-responsive";
2825
import NotificationsMenu from "../NotificationsMenu";
29-
import Button from "../Button";
3026

3127
const NavBar = ({ hideSwitchTools, profileUrl }) => {
32-
const [isSelfService, setIsSelfService] = useState(false);
28+
3329
// all menu options
3430
const menu = useSelector((state) => state.menu.categories);
3531
// flat list of all apps
@@ -43,8 +39,7 @@ const NavBar = ({ hideSwitchTools, profileUrl }) => {
4339

4440
const routerLocation = useLocation();
4541

46-
const loginUrl = isSelfService ? getSelfServiceLoginUrl() : getLoginUrl();
47-
const signupUrl = isSelfService ? getSelfServiceSignupUrl() : "";
42+
const loginUrl = getLoginUrl();
4843

4944
// Check app title with route activated
5045
useEffect(() => {
@@ -53,7 +48,6 @@ const NavBar = ({ hideSwitchTools, profileUrl }) => {
5348
);
5449
setActiveApp(activeApp);
5550

56-
setIsSelfService(routerLocation.pathname.indexOf("/self-service") !== -1);
5751
}, [routerLocation, apps]);
5852

5953
// Change micro-app callback
@@ -64,14 +58,42 @@ const NavBar = ({ hideSwitchTools, profileUrl }) => {
6458
[setActiveApp]
6559
);
6660

67-
const renderTopcoderLogo =
68-
hideSwitchTools && !isSelfService ? (
61+
// if the consuming app has requested that we disable the navigation
62+
// don't make the logo a link
63+
let renderTopcoderLogo
64+
if (hideSwitchTools) {
65+
66+
renderTopcoderLogo = (
6967
<img src={TCLogo} alt="Topcoder Logo" />
70-
) : (
71-
<Link to={isSelfService ? "/self-service" : "/"}>
68+
)
69+
70+
} else {
71+
72+
renderTopcoderLogo = (
73+
<Link to={"/"}>
7274
<img src={TCLogo} alt="Topcoder Logo" />
7375
</Link>
74-
);
76+
)
77+
}
78+
79+
const renderTitle = activeApp?.title || ""
80+
81+
const renderProfile = (
82+
<>
83+
<NotificationsMenu />
84+
<UserMenu
85+
profileUrl={profileUrl}
86+
profile={auth.profile}
87+
hideSwitchTools={hideSwitchTools}
88+
/>
89+
</>
90+
)
91+
92+
const renderLogin = (
93+
<a href={loginUrl} className="navbar-login">
94+
Log in
95+
</a>
96+
)
7597

7698
return (
7799
<div className="navbar">
@@ -85,7 +107,7 @@ const NavBar = ({ hideSwitchTools, profileUrl }) => {
85107
{renderTopcoderLogo}
86108
<div className="navbar-divider"></div>
87109
<div className="navbar-app-title">
88-
{activeApp ? activeApp.title : ""}
110+
{renderTitle}
89111
</div>
90112
</Fragment>
91113
)}
@@ -102,22 +124,7 @@ const NavBar = ({ hideSwitchTools, profileUrl }) => {
102124
{isMobile ? (
103125
<Fragment>
104126
{auth.isInitialized &&
105-
(auth.tokenV3 ? (
106-
auth.profile && (
107-
<Fragment>
108-
<NotificationsMenu />
109-
<UserMenu
110-
profileUrl={profileUrl}
111-
profile={auth.profile}
112-
hideSwitchTools={hideSwitchTools}
113-
/>
114-
</Fragment>
115-
)
116-
) : (
117-
<a href={loginUrl} className="navbar-login">
118-
Login
119-
</a>
120-
))}
127+
(auth.tokenV3 ? (auth.profile && (renderProfile)) : (renderLogin))}
121128
</Fragment>
122129
) : (
123130
<Fragment>
@@ -128,33 +135,7 @@ const NavBar = ({ hideSwitchTools, profileUrl }) => {
128135
</Fragment>
129136
)}
130137
{auth.isInitialized &&
131-
(auth.tokenV3 ? (
132-
auth.profile && (
133-
<Fragment>
134-
{!isSelfService && <NotificationsMenu />}
135-
<UserMenu
136-
profileUrl={profileUrl}
137-
profile={auth.profile}
138-
hideSwitchTools={hideSwitchTools}
139-
/>
140-
</Fragment>
141-
)
142-
) : (
143-
<Fragment>
144-
<a href={loginUrl} className="navbar-login">
145-
Login
146-
</a>
147-
{isSelfService && (
148-
<Button
149-
href={signupUrl}
150-
className="navbar-signup"
151-
type={BUTTON_TYPE.SECONDARY}
152-
>
153-
SIGN UP
154-
</Button>
155-
)}
156-
</Fragment>
157-
))}
138+
(auth.tokenV3 ? (auth.profile && (renderProfile)) : (renderLogin))}
158139
</Fragment>
159140
)}
160141
</div>

src/components/NavBar/styles.css

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
position: relative;
1010
z-index: 1;
1111
font-family: "Roboto", Arial, Helvetica, sans-serif;
12-
}
13-
.navbar {
1412
padding: 0 24px;
1513
background-color: #0C0C0C;
1614
}

src/components/UserMenu/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const UserMenu = ({ profile, profileUrl }) => {
6969
to={`${profileUrl}`}
7070
onClick={closeMenu}
7171
>
72-
{profileUrl.startsWith('/self-service') ? 'Account' : 'Profile'}
72+
Profile
7373
</Link>
7474
</li>
7575
<li>

src/utils/index.js

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,6 @@ export const getBusinessLoginUrl = () =>
3636
window.location.href.match(/[^?]*/)[0]
3737
)}`;
3838

39-
/**
40-
* Returns login URL using which the user should be redirected to self service
41-
* dashboard page after login.
42-
*
43-
* @returns {string}
44-
*/
45-
export const getSelfServiceLoginUrl = () =>
46-
`${config.URL.AUTH}?retUrl=${encodeURIComponent(
47-
`${window.location.origin}/self-service`
48-
)}&regSource=selfService&mode=login`;
49-
50-
/**
51-
* Returns Sign up URL for self service app.
52-
*
53-
* @returns {string}
54-
*/
55-
export const getSelfServiceSignupUrl = () =>
56-
`${config.URL.AUTH}?retUrl=${encodeURIComponent(
57-
`${window.location.origin}/self-service`
58-
)}&regSource=selfService&mode=signUp`;
59-
6039
/**
6140
* Logout user from Topcoder
6241
*/

tsconfig.json

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +0,0 @@
1-
{
2-
"compilerOptions": {
3-
"target": "es5",
4-
"lib": [
5-
"dom",
6-
"dom.iterable",
7-
"esnext"
8-
],
9-
"allowJs": true,
10-
"skipLibCheck": true,
11-
"esModuleInterop": true,
12-
"allowSyntheticDefaultImports": true,
13-
"strict": true,
14-
"strictNullChecks": true,
15-
"forceConsistentCasingInFileNames": true,
16-
"noFallthroughCasesInSwitch": true,
17-
"module": "esnext",
18-
"moduleResolution": "node",
19-
"resolveJsonModule": true,
20-
"isolatedModules": true,
21-
"noEmit": true,
22-
"jsx": "react-jsx",
23-
"typeRoots": [
24-
"./types",
25-
"./node_modules/@types"
26-
]
27-
},
28-
"include": [
29-
"src"
30-
],
31-
"exclude": [
32-
"**/*.test.*"
33-
]
34-
}

0 commit comments

Comments
 (0)