mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-11 07:55:52 +01:00
✨ Make the Footer update a notification
This commit is contained in:
@@ -6,13 +6,11 @@ import {
|
|||||||
Group,
|
Group,
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
Footer as FooterComponent,
|
Footer as FooterComponent,
|
||||||
Alert,
|
|
||||||
useMantineTheme,
|
useMantineTheme,
|
||||||
} from '@mantine/core';
|
} from '@mantine/core';
|
||||||
import { AlertCircle, BrandGithub } from 'tabler-icons-react';
|
import { BrandGithub } from 'tabler-icons-react';
|
||||||
|
import { showNotification } from '@mantine/notifications';
|
||||||
import { CURRENT_VERSION, REPO_URL } from '../../../data/constants';
|
import { CURRENT_VERSION, REPO_URL } from '../../../data/constants';
|
||||||
import { ModuleWrapper } from '../modules/moduleWrapper';
|
|
||||||
import { DownloadsModule } from '../modules';
|
|
||||||
|
|
||||||
const useStyles = createStyles((theme) => ({
|
const useStyles = createStyles((theme) => ({
|
||||||
footer: {
|
footer: {
|
||||||
@@ -61,7 +59,7 @@ export function Footer({ links }: FooterCenteredProps) {
|
|||||||
</Anchor>
|
</Anchor>
|
||||||
));
|
));
|
||||||
|
|
||||||
const [latestVersion, setLatestVersion] = useState(CURRENT_VERSION);
|
const [latestVersion, setLatestVersion] = useState('0');
|
||||||
const [isOpen, setOpen] = useState(true);
|
const [isOpen, setOpen] = useState(true);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Fetch Data here when component first mounted
|
// Fetch Data here when component first mounted
|
||||||
@@ -74,71 +72,56 @@ export function Footer({ links }: FooterCenteredProps) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
if (update) {
|
||||||
|
showNotification({
|
||||||
|
color: 'yellow',
|
||||||
|
autoClose: false,
|
||||||
|
title: 'New version available',
|
||||||
|
message: `Version ${latestVersion} is available, update now! 😡`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FooterComponent
|
<FooterComponent
|
||||||
p={5}
|
p={5}
|
||||||
height="auto"
|
height="auto"
|
||||||
style={{
|
style={{
|
||||||
|
position: 'relative',
|
||||||
background: 'none',
|
background: 'none',
|
||||||
border: 'none',
|
border: 'none',
|
||||||
clear: 'both',
|
clear: 'both',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Group position="apart" direction="row" style={{ alignItems: 'end' }} mr="xs" mb="xs">
|
<Group position="right" direction="row" align="center" mr="xs">
|
||||||
<Group position="left">
|
<Group spacing={0}>
|
||||||
<Alert
|
<ActionIcon<'a'> component="a" href="https://github.com/ajnart/homarr" size="lg">
|
||||||
// onClick open latest release page
|
<BrandGithub size={18} />
|
||||||
onClose={() => setOpen(false)}
|
</ActionIcon>
|
||||||
icon={<AlertCircle size={16} />}
|
|
||||||
title={`Updated version: ${latestVersion} is available. Current version: ${CURRENT_VERSION}`}
|
|
||||||
withCloseButton
|
|
||||||
radius="lg"
|
|
||||||
hidden={CURRENT_VERSION === latestVersion || !isOpen}
|
|
||||||
variant="outline"
|
|
||||||
styles={{
|
|
||||||
root: {
|
|
||||||
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[6] : 'white',
|
|
||||||
},
|
|
||||||
|
|
||||||
closeButton: {
|
|
||||||
marginLeft: '5px',
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
children={undefined}
|
|
||||||
/>
|
|
||||||
</Group>
|
|
||||||
<Group position="right">
|
|
||||||
<Group spacing={0}>
|
|
||||||
<ActionIcon<'a'> component="a" href="https://github.com/ajnart/homarr" size="lg">
|
|
||||||
<BrandGithub size={18} />
|
|
||||||
</ActionIcon>
|
|
||||||
<Text
|
|
||||||
style={{
|
|
||||||
position: 'relative',
|
|
||||||
fontSize: '0.90rem',
|
|
||||||
color: 'gray',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{CURRENT_VERSION}
|
|
||||||
</Text>
|
|
||||||
</Group>
|
|
||||||
<Text
|
<Text
|
||||||
style={{
|
style={{
|
||||||
|
position: 'relative',
|
||||||
fontSize: '0.90rem',
|
fontSize: '0.90rem',
|
||||||
textAlign: 'center',
|
color: 'gray',
|
||||||
color: '#a0aec0',
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Made with ❤️ by @
|
{CURRENT_VERSION}
|
||||||
<Anchor
|
|
||||||
href="https://github.com/ajnart"
|
|
||||||
style={{ color: 'inherit', fontStyle: 'inherit', fontSize: 'inherit' }}
|
|
||||||
>
|
|
||||||
ajnart
|
|
||||||
</Anchor>
|
|
||||||
</Text>
|
</Text>
|
||||||
</Group>
|
</Group>
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
fontSize: '0.90rem',
|
||||||
|
textAlign: 'center',
|
||||||
|
color: '#a0aec0',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Made with ❤️ by @
|
||||||
|
<Anchor
|
||||||
|
href="https://github.com/ajnart"
|
||||||
|
style={{ color: 'inherit', fontStyle: 'inherit', fontSize: 'inherit' }}
|
||||||
|
>
|
||||||
|
ajnart
|
||||||
|
</Anchor>
|
||||||
|
</Text>
|
||||||
</Group>
|
</Group>
|
||||||
</FooterComponent>
|
</FooterComponent>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user