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

Commit c4582db

Browse files
PROD-1607 #comment make topnav links not clickable;
make the work login/out go to the correct urls #time 1h
1 parent fac6b63 commit c4582db

File tree

6 files changed

+57
-17
lines changed

6 files changed

+57
-17
lines changed

src-ts/profile-selector/ProfileSelector.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { UserProfile } from './user-profile.model'
88
interface ProfileSelectorProps {
99
initialized: boolean
1010
profile: UserProfile
11+
workPath: string
1112
}
1213

1314
const ProfileSelector: FC<ProfileSelectorProps> = (props: ProfileSelectorProps) => {
@@ -23,7 +24,12 @@ const ProfileSelector: FC<ProfileSelectorProps> = (props: ProfileSelectorProps)
2324
return (
2425
<div className={styles['profile-selector']}>
2526
{!isLoggedIn && <ProfileNotLoggedIn />}
26-
{isLoggedIn && <ProfileLoggedIn profile={profile} />}
27+
{isLoggedIn && (
28+
<ProfileLoggedIn
29+
profile={profile}
30+
workPath={props.workPath}
31+
/>
32+
)}
2733
</div>
2834
)
2935
}

src-ts/profile-selector/profile-logged-in/ProfileLoggedIn.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import styles from './ProfileLoggedIn.module.scss'
88

99
interface ProfileLoggedInProps {
1010
profile: UserProfile
11+
workPath: string
1112
}
1213

1314
const ProfileLoggedIn: FC<ProfileLoggedInProps> = (props: ProfileLoggedInProps) => {
@@ -61,6 +62,7 @@ const ProfileLoggedIn: FC<ProfileLoggedInProps> = (props: ProfileLoggedInProps)
6162
profile={profile}
6263
refObject={ref}
6364
toggleProfilePanel={toggleProfilePanel}
65+
workPath={props.workPath}
6466
/>
6567
)}
6668
</>

src-ts/profile-selector/profile-logged-in/profile-panel/ProfilePanel.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ interface ProfilePanelProps {
1010
profile: UserProfile
1111
refObject: MutableRefObject<any>
1212
toggleProfilePanel: () => void
13+
workPath: string
1314
}
1415

1516
const ProfilePanel: FC<ProfilePanelProps> = (props: ProfilePanelProps) => {
@@ -21,7 +22,7 @@ const ProfilePanel: FC<ProfilePanelProps> = (props: ProfilePanelProps) => {
2122
return <></>
2223
}
2324

24-
const authUrlLogout: string = `${config.URL.ACCOUNTS_APP_CONNECTOR}?logout=true&retUrl=${encodeURIComponent('https://' + window.location.host)}`
25+
const authUrlLogout: string = `${config.URL.ACCOUNTS_APP_CONNECTOR}?logout=true&retUrl=${encodeURIComponent(`https://${window.location.host}${props.workPath}`)}`
2526

2627
return (
2728
<div
@@ -34,7 +35,7 @@ const ProfilePanel: FC<ProfilePanelProps> = (props: ProfilePanelProps) => {
3435
<Link
3536
className={styles.profile}
3637
onClick={() => props.toggleProfilePanel()}
37-
to='/self-service/account'
38+
to={`'${props.workPath}/account'`}
3839
>
3940
Account
4041
</Link>

src-ts/profile-selector/profile-not-logged-in/ProfileNotLoggedIn.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import styles from './ProfileNotLoggedIn.module.scss'
77

88
const ProfileNotLoggedIn: FC<{}> = () => {
99

10-
const login: string = `${config.URL.ACCOUNTS_APP_CONNECTOR}?retUrl=${encodeURIComponent(window.location.href.match(/[^?]*/)?.[0] || fallback)}`
10+
const login: string = `${config.URL.ACCOUNTS_APP_CONNECTOR}?retUrl=${encodeURIComponent(window.location.href)}`
1111
const signup: string = `${login}&regSource=tcBusiness&mode=signUp`
1212

1313
return (

src/components/NavBar/index.jsx

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,16 @@ const NavBar = ({ hideSwitchTools, profileUrl }) => {
4747
const loginUrl = isSelfService ? getSelfServiceLoginUrl() : getLoginUrl();
4848
const signupUrl = isSelfService ? getSelfServiceSignupUrl() : "";
4949

50+
const workPath = '/self-service'
51+
5052
// Check app title with route activated
5153
useEffect(() => {
5254
const activeApp = apps.find(
5355
(f) => routerLocation.pathname.indexOf(f.path) !== -1
5456
);
5557
setActiveApp(activeApp);
5658

57-
setIsSelfService(routerLocation.pathname.indexOf("/self-service") !== -1);
59+
setIsSelfService(routerLocation.pathname.indexOf(workPath) !== -1);
5860
}, [routerLocation, apps]);
5961

6062
// Change micro-app callback
@@ -65,14 +67,43 @@ const NavBar = ({ hideSwitchTools, profileUrl }) => {
6567
[setActiveApp]
6668
);
6769

68-
const renderTopcoderLogo =
69-
hideSwitchTools && !isSelfService ? (
70-
<img src={TCLogo} alt="Topcoder Logo" />
71-
) : (
72-
<Link to={isSelfService ? "/self-service" : "/"}>
70+
71+
// if this is work app, we only want to show the link as clickable
72+
// if we're not on the page to which the link goes
73+
const isSelfServiceHome = [workPath, `${workPath}/dashboard`].includes(routerLocation.pathname)
74+
75+
// if the consuming app has requested that we disable the navigation
76+
// or we're on the work app home page,
77+
// don't make the logo a link
78+
let renderTopcoderLogo
79+
80+
if (hideSwitchTools && isSelfServiceHome) {
81+
82+
const linkClass = isSelfServiceHome ? 'logo-no-link' : ''
83+
renderTopcoderLogo = (
84+
<img
85+
className={linkClass}
86+
src={TCLogo} alt="Topcoder Logo" />
87+
)
88+
89+
} else {
90+
91+
renderTopcoderLogo = (
92+
<Link to={isSelfService ? workPath : "/"}>
7393
<img src={TCLogo} alt="Topcoder Logo" />
7494
</Link>
75-
);
95+
)
96+
}
97+
98+
// if this is not the self service app or it's the self service home,
99+
// make the title not clickable
100+
const renderTitle = !isSelfService || isSelfServiceHome
101+
? activeApp?.title || ""
102+
: (
103+
<Link to={workPath}>
104+
Work
105+
</Link>
106+
)
76107

77108
return (
78109
<div className="navbar">
@@ -86,10 +117,7 @@ const NavBar = ({ hideSwitchTools, profileUrl }) => {
86117
{renderTopcoderLogo}
87118
<div className="navbar-divider"></div>
88119
<div className="navbar-app-title">
89-
{isSelfService && (
90-
<Link to='/self-service'>Work</Link>
91-
)}
92-
{!isSelfService && (activeApp?.title || "")}
120+
{renderTitle}
93121
</div>
94122
</Fragment>
95123
)}
@@ -149,6 +177,7 @@ const NavBar = ({ hideSwitchTools, profileUrl }) => {
149177
<ProfileSelector
150178
initialized={auth.isInitialized}
151179
profile={auth.profile}
180+
workPath={workPath}
152181
/>
153182
)}
154183
</Fragment>

src/components/NavBar/styles.css

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
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
}
1715

16+
.navbar .logo-no-link {
17+
margin-top: -3px;
18+
}
19+
1820
.navbar-left {
1921
display: flex;
2022
flex-direction: row;

0 commit comments

Comments
 (0)