diff --git a/components/common/UpdateNotice.js b/components/common/UpdateNotice.js index a98e3dca..732e6f52 100644 --- a/components/common/UpdateNotice.js +++ b/components/common/UpdateNotice.js @@ -1,13 +1,14 @@ import { useState, useEffect, useCallback } from 'react'; -import { FormattedMessage } from 'react-intl'; +import { useIntl } from 'react-intl'; +import { Button, Banner, Row, Column, Flexbox } from 'react-basics'; import { setItem } from 'next-basics'; -import ButtonLayout from 'components/layout/ButtonLayout'; import useStore, { checkVersion } from 'store/version'; import { REPO_URL, VERSION_CHECK } from 'lib/constants'; -import { Button } from 'react-basics'; +import { labels, messages } from 'components/messages'; import styles from './UpdateNotice.module.css'; export default function UpdateNotice() { + const { formatMessage } = useIntl(); const { latest, checked, hasUpdate, releaseUrl } = useStore(); const [dismissed, setDismissed] = useState(false); @@ -37,22 +38,16 @@ export default function UpdateNotice() { } return ( -
-
- -
- - - - -
+ + + ); } diff --git a/components/common/UpdateNotice.module.css b/components/common/UpdateNotice.module.css index 1837b4df..5962ec37 100644 --- a/components/common/UpdateNotice.module.css +++ b/components/common/UpdateNotice.module.css @@ -1,17 +1,33 @@ .notice { - display: flex; - justify-content: center; - align-items: center; - padding-top: 20px; + position: absolute; + max-width: 800px; + gap: 20px; + margin: 20px auto; + justify-self: center; + background: #fff; + padding: 20px; + border: 1px solid var(--base300); + border-radius: var(--border-radius); + z-index: 1000; } .message { + display: flex; + justify-content: center; + align-items: center; font-weight: 600; - flex: 1; - text-align: center; - margin-right: 20px; } .buttons { + display: flex; + flex-direction: row; + justify-content: flex-end; + gap: 10px; flex: 0; } + +@media only screen and (max-width: 992px) { + .message { + height: 80px; + } +} diff --git a/components/layout/AppLayout.js b/components/layout/AppLayout.js index ad744fab..58717e7e 100644 --- a/components/layout/AppLayout.js +++ b/components/layout/AppLayout.js @@ -1,6 +1,8 @@ import { Container } from 'react-basics'; import Head from 'next/head'; +import { useRouter } from 'next/router'; import NavBar from 'components/layout/NavBar'; +import UpdateNotice from 'components/common/UpdateNotice'; import useRequireLogin from 'hooks/useRequireLogin'; import useConfig from 'hooks/useConfig'; import { UI_LAYOUT_BODY } from 'lib/constants'; @@ -9,13 +11,17 @@ import styles from './AppLayout.module.css'; export default function AppLayout({ title, children }) { const { user } = useRequireLogin(); const config = useConfig(); + const { pathname } = useRouter(); if (!user || !config) { return null; } + const allowUpdate = user?.isAdmin && !config?.updatesDisabled && !pathname.includes('/share/'); + return (
+ {allowUpdate && } {title ? `${title} | umami` : 'umami'} diff --git a/components/layout/Header.js b/components/layout/Header.js index e5bf9417..88499768 100644 --- a/components/layout/Header.js +++ b/components/layout/Header.js @@ -1,15 +1,15 @@ +import { useRouter } from 'next/router'; +import { Column, Row } from 'react-basics'; +import classNames from 'classnames'; import HamburgerButton from 'components/common/HamburgerButton'; import UpdateNotice from 'components/common/UpdateNotice'; import LanguageButton from 'components/input/LanguageButton'; import ThemeButton from 'components/input/ThemeButton'; import UserButton from 'components/input/UserButton'; +import SettingsButton from 'components/input/SettingsButton'; import useConfig from 'hooks/useConfig'; import useUser from 'hooks/useUser'; -import { useRouter } from 'next/router'; -import { Column, Row } from 'react-basics'; -import SettingsButton from '../input/SettingsButton'; import styles from './Header.module.css'; -import classNames from 'classnames'; export default function Header({ className }) { const { user } = useUser(); diff --git a/components/layout/NavBar.js b/components/layout/NavBar.js index 80307568..723da5df 100644 --- a/components/layout/NavBar.js +++ b/components/layout/NavBar.js @@ -22,7 +22,6 @@ export default function NavBar() { const analytics = [ { label: formatMessage(labels.dashboard), url: '/dashboard', icon: }, { label: formatMessage(labels.realtime), url: '/realtime', icon: }, - { label: formatMessage(labels.queries), url: '/queries', icon: }, ]; const settings = [ diff --git a/components/messages.js b/components/messages.js index cc1d0e86..08548543 100644 --- a/components/messages.js +++ b/components/messages.js @@ -98,6 +98,7 @@ export const labels = defineMessages({ sessions: { id: 'label.sessions', defaultMessage: 'Sessions' }, pageNotFound: { id: 'message.page-not-found', defaultMessage: 'Page not found' }, logs: { id: 'label.activity-log', defaultMessage: 'Activity log' }, + dismiss: { id: 'label.dismiss', defaultMessage: 'Dismiss' }, }); export const messages = defineMessages({ @@ -177,6 +178,10 @@ export const messages = defineMessages({ id: 'message.event-log', defaultMessage: '{event} on {url}', }, + newVersionAvailable: { + id: 'new-version-available', + defaultMessage: 'A new version of Umami {version} is available!', + }, }); export const devices = defineMessages({