From bc2f5416c8a0f12f693e00f23a172476a467601d Mon Sep 17 00:00:00 2001 From: Ole Wieners Date: Mon, 3 Feb 2025 11:34:19 +0100 Subject: [PATCH] Change ordering of manage nav items --- frontend/src/layout/header/UserBox.tsx | 29 +++++----- frontend/src/routes/manage/index.tsx | 76 +++++++++++++------------- 2 files changed, 53 insertions(+), 52 deletions(-) diff --git a/frontend/src/layout/header/UserBox.tsx b/frontend/src/layout/header/UserBox.tsx index 623d92c5d..8f1e9e735 100644 --- a/frontend/src/layout/header/UserBox.tsx +++ b/frontend/src/layout/header/UserBox.tsx @@ -3,11 +3,11 @@ import { useTranslation } from "react-i18next"; import { LuAlertTriangle, LuLogIn, LuMoon, LuSun, LuFolder, LuFilm, LuUpload, LuVideo, LuLogOut, LuChevronDown, LuUserCheck, - LuFilePlus, + LuPlusCircle, } from "react-icons/lu"; import { HiOutlineFire, HiOutlineTranslate } from "react-icons/hi"; import { - match, ProtoButton, screenWidthAbove, screenWidthAtMost, + match, ProtoButton, screenWidthAbove, screenWidthAtMost, Spinner, HeaderMenuItemDef, HeaderMenuProps, WithHeaderMenu, checkboxMenuItem, useColorScheme, } from "@opencast/appkit"; @@ -17,7 +17,6 @@ import { Link } from "../../router"; import { User, useUser } from "../../User"; import { ActionIcon, ICON_STYLE } from "./ui"; import CONFIG from "../../config"; -import { Spinner } from "@opencast/appkit"; import { focusStyle } from "../../ui"; import { ExternalLink } from "../../relay/auth"; import { COLORS } from "../../color"; @@ -226,24 +225,12 @@ const LoggedIn: React.FC = ({ user }) => { children: t("manage.my-videos.title"), css: indent, }, - { - icon: , - wrapper: , - children: t("manage.my-series.title"), - css: indent, - }, ...user.canUpload ? [{ icon: , wrapper: , children: t("upload.title"), css: indent, }] : [], - { - icon: , - wrapper: , - children: t("manage.my-series.create.title"), - css: indent, - }, ...user.canUseStudio ? [{ icon: , wrapper: = ({ user }) => { children: t("manage.dashboard.studio-tile-title"), css: { ...indent, width: "100%" }, }] : [], + { + icon: , + wrapper: , + children: t("manage.my-series.title"), + css: indent, + }, + { + icon: , + wrapper: , + children: t("manage.my-series.create.title"), + css: indent, + }, // Logout button { diff --git a/frontend/src/routes/manage/index.tsx b/frontend/src/routes/manage/index.tsx index 6b5adf59e..b16de8c38 100644 --- a/frontend/src/routes/manage/index.tsx +++ b/frontend/src/routes/manage/index.tsx @@ -21,7 +21,6 @@ import { COLORS } from "../../color"; import { useMenu } from "../../layout/MenuState"; import CONFIG from "../../config"; import { translatedConfig } from "../../util"; -import i18n from "../../i18n"; import { UploadRoute } from "../Upload"; import { ManageVideosRoute } from "./Video"; import SeriesIcon from "../../icons/series.svg"; @@ -85,29 +84,57 @@ type ManageNavProps = { }; export const ManageNav: React.FC = ({ active }) => { - const { t } = useTranslation(); + const { t, i18n } = useTranslation(); const user = useUser(); const menu = useMenu(); const isDark = useColorScheme().scheme === "dark"; + const entries: [NonNullable, string, ReactElement][] = []; + /* eslint-disable react/jsx-key */ - const entries: [NonNullable, string, ReactElement][] = [ - [PATH, t("manage.dashboard.title"), ], - [ManageVideosRoute.url, t("manage.my-videos.title"), ], - [ManageSeriesRoute.url, t("manage.my-series.title"), ], - [CreateSeriesRoute.url, t("manage.my-series.create.title"), ], - ]; + entries.push([PATH, t("manage.dashboard.title"), ]); + if (isRealUser(user) && user.canCreateUserRealm) { - entries.splice( - 1, 0, [`/@${user.username}`, t("realm.user-realm.my-page"), ] - ); + entries.push([`/@${user.username}`, t("realm.user-realm.my-page"), ]); } + + entries.push([ManageVideosRoute.url, t("manage.my-videos.title"), ]); + if (isRealUser(user) && user.canUpload) { entries.push([UploadRoute.url, t("upload.title"), ]); } + + if (isRealUser(user) && user.canUseStudio) { + entries.push(["STUDIO", t("manage.dashboard.studio-tile-title"), ]); + } + + entries.push([ManageSeriesRoute.url, t("manage.my-series.title"), ]); + entries.push([CreateSeriesRoute.url, t("manage.my-series.create.title"), ]); /* eslint-enable react/jsx-key */ - const items = entries.map(([path, label, icon]) => ( + const items = entries.map(([path, label, icon]) => path === "STUDIO" ? ( + + {icon} + {label} + + ) : ( = ({ active }) => { )); - if (isRealUser(user) && user.canUseStudio) { - items.push( - - - {t("manage.dashboard.studio-tile-title")} - - ); - } - return ; };