From 6172147a7a526e24e777b24b373022c8f69741c6 Mon Sep 17 00:00:00 2001 From: Carey Gumaer Date: Fri, 14 Feb 2025 16:43:45 -0500 Subject: [PATCH] give the user menu a reasonable style and loading state --- base-theme/assets/css/header.scss | 7 ++ base-theme/assets/images/user.svg | 5 ++ base-theme/assets/js/components/UserMenu.tsx | 70 +++++++++----------- base-theme/layouts/partials/header.html | 8 ++- 4 files changed, 51 insertions(+), 39 deletions(-) create mode 100644 base-theme/assets/images/user.svg diff --git a/base-theme/assets/css/header.scss b/base-theme/assets/css/header.scss index d88c11bb3..4af86eaa9 100644 --- a/base-theme/assets/css/header.scss +++ b/base-theme/assets/css/header.scss @@ -86,6 +86,13 @@ } } } + + div#user-menu-container { + width: 40px; + img#user-menu-placeholder { + padding: 7px 13px; + } + } } } } diff --git a/base-theme/assets/images/user.svg b/base-theme/assets/images/user.svg new file mode 100644 index 000000000..10f4d49e1 --- /dev/null +++ b/base-theme/assets/images/user.svg @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/base-theme/assets/js/components/UserMenu.tsx b/base-theme/assets/js/components/UserMenu.tsx index e278088e4..d4431e703 100644 --- a/base-theme/assets/js/components/UserMenu.tsx +++ b/base-theme/assets/js/components/UserMenu.tsx @@ -5,12 +5,13 @@ import { RiAccountCircleFill } from "@remixicon/react" import { useUserMe } from "../user" export default function UserMenu() { - const { data: user } = useUserMe() + const { data: user, isLoading } = useUserMe() const learnBaseUrl = process.env.MIT_LEARN_BASEURL const apiBaseUrl = process.env.MIT_LEARN_API_BASEURL + const encodedLocation = encodeURI(window.location.href) const dashboardUrl = new URL("/dashboard", learnBaseUrl).toString() - const logoutUrl = new URL("/logout", apiBaseUrl).toString() - const loginUrl = new URL("/login/ol-oidc", apiBaseUrl).toString() + const logoutUrl = new URL(`/logout?redirect_uri=${encodedLocation}`, apiBaseUrl).toString() + const loginUrl = new URL(`/login/ol-oidc?redirect_uri=${encodedLocation}`, apiBaseUrl).toString() return (
@@ -23,46 +24,41 @@ export default function UserMenu() { > - + + ) : ( + + Login + + ) + ) : ( +
Loading...
+ )} +
) } diff --git a/base-theme/layouts/partials/header.html b/base-theme/layouts/partials/header.html index ee1a2286d..cc4675c4a 100644 --- a/base-theme/layouts/partials/header.html +++ b/base-theme/layouts/partials/header.html @@ -38,7 +38,9 @@ {{ partial "link.html" (dict "href" $contactUrl "class" "nav-link" "text" "Contact Us") }}
  • -
    +
    +
    +
  • @@ -64,7 +66,9 @@ {{ partial "link.html" (dict "href" $aboutUrl "class" "text-white text-decoration-none font-weight-bold pl-5 pr-3 py-2" "text" "about ocw") }} {{ partial "link.html" (dict "href" $zenDeskUrl "class" "text-white text-decoration-none font-weight-bold px-3 py-2" "text" "help & faqs" "target" "_blank") }} {{ partial "link.html" (dict "href" $contactUrl "class" "text-white text-decoration-none font-weight-bold px-3 py-2" "text" "contact us") }} -
    +
    + User Menu Loading... +