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

Refactor user page #1110

Merged
merged 4 commits into from
Feb 25, 2024
Merged
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
30 changes: 10 additions & 20 deletions website/src/components/User/UserPage.astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { getKeycloakClient } from '../../middleware/authMiddleware';
import { routes } from '../../routes';
import { getAccessToken } from '../../utils/getAccessToken';
const session = Astro.locals.session;
const user = session.user!; // page only accessible if user is logged in
const username = user.username!; // all users must have a username
const name = user.name;

const accessToken = getAccessToken(Astro.locals.session)!;

Expand All @@ -17,13 +20,13 @@ const logoutUrl = new URL(Astro.request.url);
logoutUrl.pathname = routes.logout();

const keycloakLogoutUrl = (await getKeycloakClient()).endSessionUrl({
post_logout_redirect_uri: logoutUrl.href,
post_logout_redirect_uri: logoutUrl.href.replace('http://', 'https://'),
corneliusroemer marked this conversation as resolved.
Show resolved Hide resolved
});
---

<BaseLayout title='Login'>
<BaseLayout title='My account'>
<div class='flex items-center'>
<h1 class='title'>User {session.user?.name}</h1>
<h1 class='title'>{name} ({username})</h1>
</div>
<div class='my-2 mx-4'>
<a href={keycloakLogoutUrl}>Logout</a>
Expand All @@ -43,21 +46,8 @@ const keycloakLogoutUrl = (await getKeycloakClient()).endSessionUrl({
</>
)
}
{
session.user?.username !== undefined && (
<div class='my-2 mx-4'>
<a href={routes.datasetsPage(session.user.username)}>Datasets Overview</a>
</div>
)
}
{
session.user?.username !== undefined && (
<GroupManager
accessToken={accessToken}
clientConfig={clientConfig}
username={session.user.username}
client:load
/>
)
}
<div class='my-2 mx-4'>
<a href={routes.datasetsPage(username)}>Datasets Overview</a>
</div>
<GroupManager accessToken={accessToken} clientConfig={clientConfig} username={username} client:load />
</BaseLayout>
4 changes: 2 additions & 2 deletions website/tests/pages/navigation.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { baseUrl, dummyOrganism, test } from '../e2e.fixture';

const organismIndependentNavigationItems = [
{ link: 'User', title: 'Login' },
{ link: 'User', title: 'My account' },
{ link: 'About', title: 'About' },
{ link: 'Api documentation', title: 'Api Docs' },
{ link: 'Governance', title: 'Governance' },
Expand All @@ -11,7 +11,7 @@ const organismIndependentNavigationItems = [
const organismNavigationItems = [
{ link: 'Search', title: '[Organism] - Browse' },
{ link: 'Submit', title: 'Submit' },
{ link: 'User', title: 'Login' },
{ link: 'User', title: 'My account' },
{ link: 'Sequence Overview', title: 'Sequences' },
];

Expand Down
Loading