Skip to content
Open
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
9 changes: 7 additions & 2 deletions ui/src/common/ConnectionErrorBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@ export const ConnectionErrorBanner = ({height, retry, message}: ConnectionErrorB
<div
style={{
backgroundColor: '#e74c3c',
height,
minHeight: height,
width: '100%',
zIndex: 1300,
position: 'relative',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
padding: '8px 16px',
boxSizing: 'border-box',
}}>
<Typography align="center" variant="h6" style={{lineHeight: `${height}px`}}>
<Typography align="center" variant="h6" style={{lineHeight: 1.4}}>
{message}{' '}
<Button variant="outlined" onClick={retry}>
Retry
Expand Down
5 changes: 2 additions & 3 deletions ui/src/common/ScrollUpButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ const ScrollUpButton = () => {
const currentScrollPos = Math.max(window.pageYOffset - 1000, 0);
const opacity = Math.min(currentScrollPos / 1000, 1);
const nextState = {display: currentScrollPos > 0 ? 'inherit' : 'none', opacity};
if (state.display !== nextState.display || state.opacity !== nextState.opacity) {
setState(nextState);
}
setState(nextState);
};
scrollHandler();
window.addEventListener('scroll', scrollHandler);
return () => window.removeEventListener('scroll', scrollHandler);
}, []);
Expand Down
129 changes: 72 additions & 57 deletions ui/src/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import SupervisorAccount from '@mui/icons-material/SupervisorAccount';
import React, {CSSProperties} from 'react';
import {Link} from 'react-router';
import {useMediaQuery} from '@mui/material';
import Tooltip from '@mui/material/Tooltip';
import {ThemeKey} from './theme';

const themeIcons: Record<ThemeKey, React.ReactElement> = {
Expand All @@ -36,9 +37,6 @@ const useStyles = makeStyles()((theme: Theme) => ({
},
toolbar: {
justifyContent: 'space-between',
[theme.breakpoints.down('sm')]: {
flexWrap: 'wrap',
},
},
menuButtons: {
display: 'flex',
Expand All @@ -47,12 +45,9 @@ const useStyles = makeStyles()((theme: Theme) => ({
},
justifyContent: 'center',
[theme.breakpoints.down('sm')]: {
flexBasis: '100%',
marginTop: 5,
order: 1,
height: 50,
justifyContent: 'space-between',
alignItems: 'center',
flex: 'none',
height: 'auto',
margin: 0,
},
},
title: {
Expand Down Expand Up @@ -81,6 +76,7 @@ interface IProps {
showSettings: VoidFunction;
logout: VoidFunction;
style: CSSProperties;
navOpen: boolean;
setNavOpen: (open: boolean) => void;
}

Expand All @@ -92,6 +88,7 @@ const Header = ({
toggleTheme,
logout,
style,
navOpen,
setNavOpen,
showSettings,
themeMode,
Expand Down Expand Up @@ -128,29 +125,34 @@ const Header = ({
admin={admin}
name={name}
logout={logout}
navOpen={navOpen}
setNavOpen={setNavOpen}
showSettings={showSettings}
/>
)}
<div>
<IconButton
onClick={toggleTheme}
color="inherit"
size="large"
title={themeLabel}
aria-label={themeLabel}>
{themeIcon}
</IconButton>

<a
href="https://github.com/gotify/server"
className={classes.link}
target="_blank"
rel="noopener noreferrer">
<IconButton color="inherit" size="large">
<GitHubIcon />
<Tooltip title={themeLabel} arrow>
<IconButton
onClick={toggleTheme}
color="inherit"
size="large"
aria-label={themeLabel}>
{themeIcon}
</IconButton>
</a>
</Tooltip>

<Tooltip title="Gotify on GitHub" arrow>
<a
href="https://github.com/gotify/server"
className={classes.link}
target="_blank"
rel="noopener noreferrer"
aria-label="Gotify on GitHub">
<IconButton color="inherit" size="large" aria-label="Gotify on GitHub">
<GitHubIcon />
</IconButton>
</a>
</Tooltip>
</div>
</Toolbar>
</AppBar>
Expand All @@ -162,53 +164,64 @@ const Buttons = ({
name,
admin,
logout,
navOpen,
setNavOpen,
}: {
name: string;
admin: boolean;
logout: VoidFunction;
navOpen: boolean;
setNavOpen: (open: boolean) => void;
showSettings: VoidFunction;
}) => {
const {classes} = useStyles();
const mobile = useMediaQuery('(max-width:600px)');

return (
<div className={classes.menuButtons}>
<ResponsiveButton
sx={{display: {sm: 'none', xs: 'block'}}}
icon={<MenuIcon />}
onClick={() => setNavOpen(true)}
onClick={() => setNavOpen(!navOpen)}
label="menu"
color="inherit"
/>
{admin && (
<Link className={classes.link} to="/users" id="navigate-users">
<ResponsiveButton icon={<SupervisorAccount />} label="users" color="inherit" />
</Link>
{!mobile && (
<>
{admin && (
<Link className={classes.link} to="/users" id="navigate-users">
<ResponsiveButton
icon={<SupervisorAccount />}
label="users"
color="inherit"
/>
</Link>
)}
<Link className={classes.link} to="/applications" id="navigate-apps">
<ResponsiveButton icon={<Chat />} label="apps" color="inherit" />
</Link>
<Link className={classes.link} to="/clients" id="navigate-clients">
<ResponsiveButton icon={<DevicesOther />} label="clients" color="inherit" />
</Link>
<Link className={classes.link} to="/plugins" id="navigate-plugins">
<ResponsiveButton icon={<Apps />} label="plugins" color="inherit" />
</Link>
<ResponsiveButton
icon={<AccountCircle />}
label={name}
onClick={showSettings}
id="changepw"
color="inherit"
/>
<ResponsiveButton
icon={<ExitToApp />}
label="Logout"
onClick={logout}
id="logout"
color="inherit"
/>
</>
)}
<Link className={classes.link} to="/applications" id="navigate-apps">
<ResponsiveButton icon={<Chat />} label="apps" color="inherit" />
</Link>
<Link className={classes.link} to="/clients" id="navigate-clients">
<ResponsiveButton icon={<DevicesOther />} label="clients" color="inherit" />
</Link>
<Link className={classes.link} to="/plugins" id="navigate-plugins">
<ResponsiveButton icon={<Apps />} label="plugins" color="inherit" />
</Link>
<ResponsiveButton
icon={<AccountCircle />}
label={name}
onClick={showSettings}
id="changepw"
color="inherit"
/>
<ResponsiveButton
icon={<ExitToApp />}
label="Logout"
onClick={logout}
id="logout"
color="inherit"
/>
</div>
);
};
Expand All @@ -224,9 +237,11 @@ const ResponsiveButton: React.FC<{
const matches = useMediaQuery('(max-width:1000px)');
if (matches) {
return (
<IconButton {...rest} size="large">
{icon}
</IconButton>
<Tooltip title={label} arrow>
<IconButton {...rest} size="large" aria-label={label}>
{icon}
</IconButton>
</Tooltip>
);
}
return (
Expand Down
28 changes: 25 additions & 3 deletions ui/src/layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,25 @@ const useStyles = makeStyles()((theme: Theme) => ({
marginTop: 64,
padding: theme.spacing(3),
width: '100%',
[theme.breakpoints.up('sm')]: {
marginLeft: 250,
width: 'calc(100% - 250px)',
},
[theme.breakpoints.down('sm')]: {
marginTop: 0,
padding: theme.spacing(1),
},
},
contentWithConnectionError: {
marginTop: 128,
[theme.breakpoints.down('sm')]: {
marginTop: 0,
},
},
}));

const localStorageThemeKey = 'gotify-theme';
const connectionBannerHeight = 64;

const Layout = observer(() => {
const {
Expand Down Expand Up @@ -106,7 +117,7 @@ const Layout = observer(() => {
<div key={refreshKey}>
{!connectionErrorMessage ? null : (
<ConnectionErrorBanner
height={64}
height={connectionBannerHeight}
retry={() => tryReconnect()}
message={connectionErrorMessage}
/>
Expand All @@ -116,22 +127,33 @@ const Layout = observer(() => {
<Header
admin={admin}
name={name}
style={{top: !connectionErrorMessage ? 0 : 64}}
style={{top: !connectionErrorMessage ? 0 : connectionBannerHeight}}
version={version}
loggedIn={loggedIn}
themeMode={currentTheme}
toggleTheme={toggleTheme}
showSettings={() => setShowSettings(true)}
logout={logout}
setNavOpen={setNavOpen}
navOpen={navOpen}
/>
<div style={{display: 'flex'}}>
<Navigation
loggedIn={loggedIn}
admin={admin}
name={name}
logout={logout}
showSettings={() => setShowSettings(true)}
bannerVisible={Boolean(connectionErrorMessage)}
navOpen={navOpen}
setNavOpen={setNavOpen}
/>
<main className={classes.content}>
<main
className={`${classes.content} ${
connectionErrorMessage
? classes.contentWithConnectionError
: ''
}`}>
<Routes>
<Route path="/login" element={<Login />} />
<Route path="/" element={authed(<Messages />)} />
Expand Down
Loading
Loading