Skip to content
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

Mergeback Rc/0.4.0 (#51) #54

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts

# generic name for files that shouldn't be checked in (handy for mock data)
*.temp*
25 changes: 23 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rdpc-ui",
"version": "0.3.0",
"version": "0.4.0",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down Expand Up @@ -46,6 +46,7 @@
"husky": "^8.0.3",
"lint-staged": "^13.2.2",
"prettier": "2.8.8",
"prettier-plugin-organize-imports": "^3.2.2",
"typescript": "^5.1.3"
},
"lint-staged": {
Expand Down
75 changes: 55 additions & 20 deletions src/app/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,43 @@
*/
'use client';

import { AppBar, css, DnaLoader, UserBadge } from '@icgc-argo/uikit';
import Link from 'next/link';
import Image from 'next/image';
import argoLogo from '/public/argo-logo.svg';
import { useAuthContext } from '@/global/utils/auth';
import { css, useTheme } from '@/lib/emotion';
import { AppBar, AppBarMenuItem, DnaLoader, Link, NavElement } from '@icgc-argo/uikit';
import Image from 'next/image';
import { usePathname } from 'next/navigation';
import { useState } from 'react';
import LoginButton from './LoginButton';
import ProfileMenu from './ProfileMenu';
import argoLogo from '/public/argo-logo.svg';

const Header = () => {
const { egoJwt, loggingIn } = useAuthContext();
const [isDropdownOpen, setDropdownOpen] = useState(false);
const { egoJwt, authLoading, logOut } = useAuthContext();
const path = usePathname();
const theme = useTheme();
const onProfilePage = path === '/landing-page';
const profileActive = onProfilePage && !!egoJwt.length && !authLoading;

const profileNavDetails: Array<NavElement> = [
{
active: profileActive,
href: '/landing-page',
name: 'Profile & Token',
LinkComp: Link,
},
{
isLink: false,
onClick: () => {
setDropdownOpen(false);
logOut();
},
name: 'Logout',
active: false,
href: '',
LinkComp: Link,
},
];

return (
<header>
Expand All @@ -43,21 +71,28 @@ const Header = () => {

{/** keep this div. header will have more items, will be "right-aligned" */}
<div>
{egoJwt ? (
<UserBadge
showGreeting={true}
firstName={'Test'}
lastName={'User'}
title={'DCC Member'}
css={css`
color: white;
`}
/>
) : loggingIn ? (
<DnaLoader />
) : (
<LoginButton />
)}
<AppBarMenuItem
active={profileActive}
css={css`
border-bottom: ${profileActive ? `solid 3px ${theme.colors.accent1}` : ''};
`}
>
{egoJwt ? (
<ProfileMenu
isDropdownOpen={isDropdownOpen}
onProfilePage={onProfilePage}
onClick={() => {
setDropdownOpen(!isDropdownOpen);
}}
profileNavDetails={profileNavDetails}
theme={theme}
/>
) : authLoading ? (
<DnaLoader />
) : (
<LoginButton />
)}
</AppBarMenuItem>
</div>
</AppBar>
</header>
Expand Down
62 changes: 62 additions & 0 deletions src/app/components/ProfileMenu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2023 The Ontario Institute for Cancer Research. All rights reserved
*
* This program and the accompanying materials are made available under the terms of
* the GNU Affero General Public License v3.0. You should have received a copy of the
* GNU Affero General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
'use client';

import { css } from '@/lib/emotion';
import { DropdownMenu, FocusWrapper, NavBarElement, NavElement, UserBadge } from '@icgc-argo/uikit';
import { Theme } from '@icgc-argo/uikit/ThemeProvider';

const ProfileMenu = ({
isDropdownOpen,
onProfilePage,
onClick,
profileNavDetails,
theme,
}: {
isDropdownOpen: boolean;
onProfilePage: boolean;
onClick: () => void;
profileNavDetails: NavElement[];
theme: Theme;
}) => (
<FocusWrapper onClick={onClick}>
{isDropdownOpen && (
<DropdownMenu>
{profileNavDetails.map((element, idx) => (
<NavBarElement key={`profileNavDetail_${idx}`} {...element} isDropdown={true} />
))}
</DropdownMenu>
)}
<UserBadge
showGreeting={true}
firstName={'Test'}
lastName={'User'}
title={'DCC Member'}
className={onProfilePage ? 'active' : ''}
css={css`
color: ${onProfilePage ? theme.colors.accent1 : theme.colors.white};
&:hover {
color: ${theme.colors.accent1};
}
`}
/>
</FocusWrapper>
);

export default ProfileMenu;
7 changes: 1 addition & 6 deletions src/app/landing-page/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
'use client';

import { getAppConfig } from '@/global/config';
import { logOut } from '@/global/utils/auth';

export default function LandingPage() {
const { EGO_CLIENT_ID } = getAppConfig();

return (
<main>
<div>
Expand All @@ -32,11 +32,6 @@ export default function LandingPage() {
</p>
</div>
<h1>Welcome! {EGO_CLIENT_ID}</h1>
<div>
<a href={`/`}>
<button onClick={logOut}>Logout</button>
</a>
</div>
</main>
);
}
3 changes: 1 addition & 2 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@
*/
'use client';

import { Work_Sans } from 'next/font/google';
import { AuthProvider } from '@/global/utils/auth';
import { ReactNode } from 'react';
import { QueryClient, QueryClientProvider } from 'react-query';
import { AuthProvider } from '@/global/utils/auth';
import Header from './components/Header';
import ThemeProvider from './components/ThemeProvider';
import { css } from '@/lib/emotion';
Expand Down
12 changes: 5 additions & 7 deletions src/app/logging-in/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ import { useRouter } from 'next/navigation';
import { useQuery } from 'react-query';
import urlJoin from 'url-join';

import { css, DnaLoader, useTheme } from '@icgc-argo/uikit';
import { getAppConfig } from '@/global/config';
import { storeToken, useAuthContext } from '@/global/utils/auth';
import { useAuthContext } from '@/global/utils/auth';
import { DnaLoader, css, useTheme } from '@icgc-argo/uikit';

export default async function LoggingIn() {
const { EGO_API_ROOT, EGO_CLIENT_ID } = getAppConfig();
const router = useRouter();
const theme = useTheme();
const { egoJwt, setEgoJwt, loggingIn, setLoggingIn } = useAuthContext();
const { egoJwt, authLoading, setAuthLoading, logIn } = useAuthContext();
const egoLoginUrl = urlJoin(EGO_API_ROOT, `/api/oauth/ego-token?client_id=${EGO_CLIENT_ID}`);

if (egoJwt) router.push('/landing-page');

if (!loggingIn && !egoJwt) setLoggingIn(true);
if (!authLoading && !egoJwt) setAuthLoading(true);

useQuery('egoJwt', () => {
fetch(egoLoginUrl, {
Expand All @@ -47,9 +47,7 @@ export default async function LoggingIn() {
})
.then(async (res) => {
const newToken = await res.text();
storeToken(newToken);
setEgoJwt(newToken);
setLoggingIn(false);
logIn(newToken);
})
.catch(console.error);
});
Expand Down
9 changes: 4 additions & 5 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
*/
'use client';

import { ComponentType } from 'react';
import Image from 'next/image';
import urlJoin from 'url-join';
import { DataCallout, Link, Typography, overtureLogo } from '@icgc-argo/uikit';
import { getAppConfig } from '@/global/config';
import { css, useTheme } from '@/lib/emotion';
import Footer from './components/Footer';
import { DataCallout, Link, Typography, overtureLogo } from '@icgc-argo/uikit';
import Image from 'next/image';
import { ComponentType } from 'react';
import urlJoin from 'url-join';
import Hero from './components/Hero';

const { DOCS_URL_ROOT } = getAppConfig();
Expand Down
24 changes: 24 additions & 0 deletions src/app/submission/[shortName]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2023 The Ontario Institute for Cancer Research. All rights reserved
*
* This program and the accompanying materials are made available under the terms of
* the GNU Affero General Public License v3.0. You should have received a copy of the
* GNU Affero General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

'use client';

export default function Program() {
return <div>Program</div>;
}
Loading