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

PROD-1551 header -> qa #137

Merged
merged 6 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
PROD-1551 #comment merge dev and remove all
references to the self service app and typescript #time 15m
  • Loading branch information
brooketopcoder committed May 3, 2022
commit eb793c7489bbee88c4cdf5b49a24054013c25280
22,980 changes: 347 additions & 22,633 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ const App = () => {
<NavBar
default
noThrow
profileUrl={
location.pathname.includes("/self-service")
? "/self-service/account/"
: `/profile/${_.get(auth, "profile.handle", "")}`
}
profileUrl={`/profile/${_.get(auth, "profile.handle", "")}`}
hideSwitchTools={isNavigationDisabled}
path="/*"
/>
Expand Down
95 changes: 38 additions & 57 deletions src/components/NavBar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,13 @@ import { Link, useLocation } from "@reach/router";
import TCLogo from "../../assets/images/tc-logo.svg";
import {
getLoginUrl,
getSelfServiceLoginUrl,
getSelfServiceSignupUrl,
} from "../../utils";
import { BUTTON_TYPE } from "constants/";
import "./styles.css";
import { useMediaQuery } from "react-responsive";
import NotificationsMenu from "../NotificationsMenu";
import Button from "../Button";

const NavBar = ({ hideSwitchTools, profileUrl }) => {
const [isSelfService, setIsSelfService] = useState(false);

// all menu options
const menu = useSelector((state) => state.menu.categories);
// flat list of all apps
Expand All @@ -43,8 +39,7 @@ const NavBar = ({ hideSwitchTools, profileUrl }) => {

const routerLocation = useLocation();

const loginUrl = isSelfService ? getSelfServiceLoginUrl() : getLoginUrl();
const signupUrl = isSelfService ? getSelfServiceSignupUrl() : "";
const loginUrl = getLoginUrl();

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

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

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

const renderTopcoderLogo =
hideSwitchTools && !isSelfService ? (
// if the consuming app has requested that we disable the navigation
// don't make the logo a link
let renderTopcoderLogo
if (hideSwitchTools) {

renderTopcoderLogo = (
<img src={TCLogo} alt="Topcoder Logo" />
) : (
<Link to={isSelfService ? "/self-service" : "/"}>
)

} else {

renderTopcoderLogo = (
<Link to={"/"}>
<img src={TCLogo} alt="Topcoder Logo" />
</Link>
);
)
}

const renderTitle = activeApp?.title || ""

const renderProfile = (
<>
<NotificationsMenu />
<UserMenu
profileUrl={profileUrl}
profile={auth.profile}
hideSwitchTools={hideSwitchTools}
/>
</>
)

const renderLogin = (
<a href={loginUrl} className="navbar-login">
Log in
</a>
)

return (
<div className="navbar">
Expand All @@ -85,7 +107,7 @@ const NavBar = ({ hideSwitchTools, profileUrl }) => {
{renderTopcoderLogo}
<div className="navbar-divider"></div>
<div className="navbar-app-title">
{activeApp ? activeApp.title : ""}
{renderTitle}
</div>
</Fragment>
)}
Expand All @@ -102,22 +124,7 @@ const NavBar = ({ hideSwitchTools, profileUrl }) => {
{isMobile ? (
<Fragment>
{auth.isInitialized &&
(auth.tokenV3 ? (
auth.profile && (
<Fragment>
<NotificationsMenu />
<UserMenu
profileUrl={profileUrl}
profile={auth.profile}
hideSwitchTools={hideSwitchTools}
/>
</Fragment>
)
) : (
<a href={loginUrl} className="navbar-login">
Login
</a>
))}
(auth.tokenV3 ? (auth.profile && (renderProfile)) : (renderLogin))}
</Fragment>
) : (
<Fragment>
Expand All @@ -128,33 +135,7 @@ const NavBar = ({ hideSwitchTools, profileUrl }) => {
</Fragment>
)}
{auth.isInitialized &&
(auth.tokenV3 ? (
auth.profile && (
<Fragment>
{!isSelfService && <NotificationsMenu />}
<UserMenu
profileUrl={profileUrl}
profile={auth.profile}
hideSwitchTools={hideSwitchTools}
/>
</Fragment>
)
) : (
<Fragment>
<a href={loginUrl} className="navbar-login">
Login
</a>
{isSelfService && (
<Button
href={signupUrl}
className="navbar-signup"
type={BUTTON_TYPE.SECONDARY}
>
SIGN UP
</Button>
)}
</Fragment>
))}
(auth.tokenV3 ? (auth.profile && (renderProfile)) : (renderLogin))}
</Fragment>
)}
</div>
Expand Down
12 changes: 10 additions & 2 deletions src/components/NavBar/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@
position: relative;
z-index: 1;
font-family: "Roboto", Arial, Helvetica, sans-serif;
}
.navbar {
padding: 0 24px;
background-color: #0C0C0C;
}

.navbar .logo-no-link {
margin-top: -3px;
}

@media (max-width: 1023px) {
.navbar .logo-no-link {
margin-top: 0;
}
}

.navbar-left {
display: flex;
flex-direction: row;
Expand Down
2 changes: 1 addition & 1 deletion src/components/UserMenu/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const UserMenu = ({ profile, profileUrl }) => {
to={`${profileUrl}`}
onClick={closeMenu}
>
{profileUrl.startsWith('/self-service') ? 'Account' : 'Profile'}
Account
</Link>
</li>
<li>
Expand Down
2 changes: 1 addition & 1 deletion src/constants/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const APP_CATEGORIES = [
apps: [
{
title: "Profile App",
path: "/profile/",
path: "/account/",
isExact: false,
menu: [],
},
Expand Down
21 changes: 0 additions & 21 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,6 @@ export const getBusinessLoginUrl = () =>
window.location.href.match(/[^?]*/)[0]
)}`;

/**
* Returns login URL using which the user should be redirected to self service
* dashboard page after login.
*
* @returns {string}
*/
export const getSelfServiceLoginUrl = () =>
`${config.URL.AUTH}?retUrl=${encodeURIComponent(
`${window.location.origin}/self-service`
)}&regSource=selfService&mode=login`;

/**
* Returns Sign up URL for self service app.
*
* @returns {string}
*/
export const getSelfServiceSignupUrl = () =>
`${config.URL.AUTH}?retUrl=${encodeURIComponent(
`${window.location.origin}/self-service`
)}&regSource=selfService&mode=signUp`;

/**
* Logout user from Topcoder
*/
Expand Down
34 changes: 0 additions & 34 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,34 +0,0 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"strictNullChecks": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"typeRoots": [
"./types",
"./node_modules/@types"
]
},
"include": [
"src"
],
"exclude": [
"**/*.test.*"
]
}
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.