Files
gameyfin/app/src/main/frontend/views/MainLayout.tsx
T
Simon 717a423449 Release v2.2.0 (#741)
* Migrate to TailwindCSS v4 (#740)

* Remove "material-tailwind" dependencies due to incompatibility of Stepper component with Tailwind v4

* Clean up Tailwind configs before upgrade

* Run HeroUI upgrade

* Run TailwindCSS upgrade

* Replace PostCSS with Vite

* Migrate custom styles to v4

* Remove tailwind.config.ts

* Add heroui.ts
Add tailwind vite plugin

* Fix small UI color inconsistency

* Fix theming system
Rename purple theme to pink

* Re-implement stepper in HeroUI

* Fix RoleChip colors

* Migrate icon names (#743)

* Add migration script for phosphor-icons

* Migrate icon usages

* Update version to 2.2.0-preview

* Revert accidental rename of menu title

* Bump stefanzweifel/git-auto-commit-action from 6 to 7 (#750)

Bumps [stefanzweifel/git-auto-commit-action](https://github.com/stefanzweifel/git-auto-commit-action) from 6 to 7.
- [Release notes](https://github.com/stefanzweifel/git-auto-commit-action/releases)
- [Changelog](https://github.com/stefanzweifel/git-auto-commit-action/blob/master/CHANGELOG.md)
- [Commits](https://github.com/stefanzweifel/git-auto-commit-action/compare/v6...v7)

---
updated-dependencies:
- dependency-name: stefanzweifel/git-auto-commit-action
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Improve library scanning (#749)

* Update script to generate example libraries using SteamSpy API

* Refactor library scanning process

* Display Flyway startup log by default

* Fix race condition in CompanyService

* Fix race condition in ImageService
Remove obsolete table

* Fix SMTP config requiring an email as username (#755)

* Disable length limit for config values (#757)

* Deprecate DockerHub image (#759)

* Remove deprecation warning from web UI

* Reworked the CICD pipelines

* Optimize container image (#761)

* Fix Gradle warning

* Rework Docker image to improve layer caching

* Bump stefanzweifel/git-auto-commit-action from 6 to 7 (#765)

Bumps [stefanzweifel/git-auto-commit-action](https://github.com/stefanzweifel/git-auto-commit-action) from 6 to 7.
- [Release notes](https://github.com/stefanzweifel/git-auto-commit-action/releases)
- [Changelog](https://github.com/stefanzweifel/git-auto-commit-action/blob/master/CHANGELOG.md)
- [Commits](https://github.com/stefanzweifel/git-auto-commit-action/compare/v6...v7)

---
updated-dependencies:
- dependency-name: stefanzweifel/git-auto-commit-action
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Multi platform support (#764)

* Remove migrate-phosphor-icons.js since migration has been successful
* Refactor GameMetadata into separate files
* Add Platform enum
* Implement platform support in Plugin API
* Implement platform support in Steam Plugin
* Implement platform support in IGDB Plugin
* Add database migration for platform support
* Implement platform support in GameService
* Implement platform support on most endpoints and features, some are still missing
Implemented platform support in all bundled plugins (although not finished polishing yet)
* Implement platforms in UI
* Make GameRequest platform aware
* Return headerImages from IGDB
* Implement proper PlatformMapper for IGDB plugin
* Fix various smaller issues and inconsistencies

* Replace placeholder in LibraryOverviewCard (#767)

* Bump actions/download-artifact from 5 to 6 (#769)

* Bump actions/upload-artifact from 4 to 5 (#770)

* Multi platform support (#773)

* Fix bug in Plugin API related to state loading/saving

* Hide Flyway query logs by default

* Extend migration script for multi platform tables

* Plugins now store their data and state in ./plugindata

* Add "plugindata" directory to entrypoint scripts

* Improve download handling (#756)

* Process download in background thread to avoid session timeout affecting it

* Increase default session timeout to 24h

* Use virtual thread pool for download task in background

* Make KSP extensions.idx generation more robust

* Implement download bandwidth limiter
Implement SliderInput
Refactor NumberInput

* Implement download bandwidth throttling
Implement real-time download monitoring

* Improve UI for DownloadManagement
Track more stats in SessionStats

* Update Hilla
Use React 19

* Implement real-time graph to track bandwidth usage
Implement downloaded data sum over last day
Small bug fixes
Small refactorings

* Update docker-compose.example.yml

* Improve DownloadSessionCard (#784)

* Fix unit on y-axis of download graph

* Show game size and library in tooltip
Make game chips interactive in DownloadSessionCard (leads to game page when clicked)
Optimize graph settings

* Migrate torrent plugin to libtorrent (#775)

* Disable TorrentDownloadPlugin in Alpine based Docker image

* Improve test coverage (#785)

* Fix potential divide by zero bug

* Add mockk dependency

* Add tests for org.gameyfin.app.core.download

* Add tests for Filesytem package
Fix DownloadServiceTest

* Fix FilesystemServiceTest

* Add tests for "job" package

* Upgrade Gradle wrapper
Enable Gradle config cache

* Added more tests

* Added tests for the "security" package

* Add tests for "game" package

* Fix AsyncFileTailer not shutting down properly on Windows

* Fix GameServiceTest

* Added tests for "libraries" package

* Added tests for "media" package

* Fix warning in ImageService

* Add tests fpr "messages" package
Make sure transport is closed even in case an exception is thrown

* Add tests for "platforms" package

* Add tests for "requests" package

* Moved "token" package to "core" package (from "shared")

* Add tests for "token" package

* Fix issue in RoleEnum.safeValueOf() throwing Exception

* Fix potential issue in UserEndpoint.getUserInfo() when auth is null

* Added tests for "user" package

* Migrate package for "token" in FE

* Publish test report in CI

* Fix workflow permissions

* Remove test because of timing issue in CI

* Replaced "unmatched paths" with "ignored paths" (#791)

* Use new "AutoComplete" component (#793)

* Use ArrayInputAutocomplete in EditGameMetadataModal

* Add test for getEnumPropertyValues

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-11-17 08:45:39 +01:00

171 lines
7.5 KiB
TypeScript

import {useEffect, useState} from 'react';
import ProfileMenu from "Frontend/components/ProfileMenu";
import {Button, Divider, Link, Navbar, NavbarBrand, NavbarContent, NavbarItem, Tooltip} from "@heroui/react";
import GameyfinLogo from "Frontend/components/theming/GameyfinLogo";
import * as PackageJson from "../../../../package.json";
import {Outlet, useLocation, useNavigate} from "react-router";
import {useAuth} from "Frontend/util/auth";
import {
ArrowLeftIcon,
DiceSixIcon,
DiscIcon,
HeartIcon,
HouseIcon,
ListMagnifyingGlassIcon,
SignInIcon
} from "@phosphor-icons/react";
import Confetti, {ConfettiProps} from "react-confetti-boom";
import {useTheme} from "next-themes";
import {useUserPreferenceService} from "Frontend/util/user-preference-service";
import SearchBar from "Frontend/components/general/SearchBar";
import {useSnapshot} from "valtio/react";
import {gameState} from "Frontend/state/GameState";
import ScanProgressPopover from "Frontend/components/general/ScanProgressPopover";
import {isAdmin} from "Frontend/util/utils";
export default function MainLayout() {
const navigate = useNavigate();
const location = useLocation();
const auth = useAuth();
const userPreferenceService = useUserPreferenceService();
const {setTheme} = useTheme();
const isSearchPage = location.pathname.startsWith("/search");
const isHomePage = location.pathname === "/";
const [isExploding, setIsExploding] = useState(false);
const games = useSnapshot(gameState).games;
useEffect(() => {
userPreferenceService.sync()
.then(() => loadUserTheme().catch(console.error))
.catch(console.error);
}, [auth.state.user]);
const confettiProps: ConfettiProps = {
mode: 'boom',
x: 0.5,
y: 1,
particleCount: 1000,
spreadDeg: 90,
launchSpeed: 4,
effectInterval: 10000
}
async function loadUserTheme() {
let syncedTheme = await userPreferenceService.get("preferred-theme")
if (syncedTheme !== undefined) {
setTheme(syncedTheme);
}
}
function easterEgg() {
if (isExploding) return;
setIsExploding(true);
if (confettiProps.mode === "boom") {
setTimeout(() => setIsExploding(false), confettiProps.effectInterval);
}
}
function getRandomGameId() {
return games[Math.floor(Math.random() * games.length)].id;
}
return (
<div className="flex flex-col min-h-screen">
{isExploding ? <Confetti {...confettiProps}/> : <></>}
<Navbar maxWidth="full" className="2xl:px-[12.5%]">
<NavbarBrand>
{isHomePage ? <GameyfinLogo className="h-10 fill-foreground"/> :
<div className="flex flex-row gap-2">
<Button isIconOnly onPress={() => history.back()} variant="light">
<ArrowLeftIcon size={26} weight="bold"/>
</Button>
<Button isIconOnly onPress={() => navigate("/")} variant="light">
<HouseIcon size={26} weight="fill"/>
</Button>
</div>
}
</NavbarBrand>
{!isSearchPage && <NavbarContent justify="center" className="flex-1 max-w-96">
<Tooltip content="I'm feeling lucky" placement="bottom">
<Button isIconOnly variant="light"
onPress={() => navigate("/game/" + getRandomGameId())}
isDisabled={gameState.games.length === 0}>
<DiceSixIcon/>
</Button>
</Tooltip>
<SearchBar/>
<Tooltip content="Advanced search" placement="bottom">
<Button isIconOnly variant="light" onPress={() => navigate("/search")}>
<ListMagnifyingGlassIcon/>
</Button>
</Tooltip>
</NavbarContent>}
<NavbarContent justify="end" className="items-center">
<NavbarItem>
<Tooltip content="Request a game" placement="bottom">
<Button color="primary"
isDisabled={window.location.pathname.startsWith("/requests")}
onPress={() => navigate("/requests")}
startContent={<DiscIcon weight="fill"/>}>
Requests
</Button>
</Tooltip>
</NavbarItem>
{isAdmin(auth) &&
<div className="flex flex-row">
<NavbarItem>
<Tooltip content="View library scan results" placement="bottom">
<div>
<ScanProgressPopover/>
</div>
</Tooltip>
</NavbarItem>
</div>
}
{auth.state.user &&
<NavbarItem>
<ProfileMenu/>
</NavbarItem>
}
{!auth.state.user &&
<NavbarItem>
<Tooltip content="Sign in to your account" placement="bottom">
<Button color="primary"
radius="full"
isIconOnly
className="gradient-primary"
/* This is hacky but works since "/loginredirect" is not configured and returns 401 for not logged-in users.
This triggers Hilla to redirect to the correct login page (integrated or SSO) automatically.
Otherwise, SSO login would not be possible if we redirect to "/login" directly */
onPress={() => window.location.href = "/loginredirect"}>
<SignInIcon fill="text-background/80"/>
</Button>
</Tooltip>
</NavbarItem>
}
</NavbarContent>
</Navbar>
<div className="flex flex-col grow 2xl:px-[12.5%] overflow-x-hidden mt-4">
<Outlet/>
</div>
<Divider className="mt-8"/>
<div className="flex flex-col w-full 2xl:px-[12.5%]">
<footer className="flex flex-row items-center justify-between py-4">
<p>Gameyfin {PackageJson.version}</p>
<p className="flex flex-row gap-1 items-baseline">
Made with
<HeartIcon size={16} weight="fill" className="text-primary" onClick={easterEgg}/>
by
<Link href="https://github.com/grimsi" target="_blank">grimsi</Link> and
<Link href="https://github.com/gameyfin/gameyfin/graphs/contributors" target="_blank">
contributors
</Link>
</p>
</footer>
</div>
</div>
);
}