2022-12-20 15:21:36 +09:00
|
|
|
import { Box, createStyles, Group, Header as MantineHeader, Indicator } from '@mantine/core';
|
2022-12-23 17:44:51 +01:00
|
|
|
import { useEffect, useState } from 'react';
|
|
|
|
|
import { CURRENT_VERSION, REPO_URL } from '../../../../data/constants';
|
2022-12-10 15:00:16 +01:00
|
|
|
import { useConfigContext } from '../../../config/provider';
|
2022-10-10 20:46:22 +02:00
|
|
|
import { Logo } from '../Logo';
|
2022-12-04 17:36:30 +01:00
|
|
|
import { useCardStyles } from '../useCardStyles';
|
2023-01-06 12:11:47 +09:00
|
|
|
import DockerMenuButton from '../../../modules/Docker/DockerModule';
|
2022-12-10 17:58:01 +01:00
|
|
|
import { ToggleEditModeAction } from './Actions/ToggleEditMode/ToggleEditMode';
|
2022-12-06 21:33:12 +01:00
|
|
|
import { Search } from './Search';
|
|
|
|
|
import { SettingsMenu } from './SettingsMenu';
|
2022-12-04 17:36:30 +01:00
|
|
|
|
|
|
|
|
export const HeaderHeight = 64;
|
2022-04-25 00:11:32 +02:00
|
|
|
|
2022-05-16 13:54:08 +02:00
|
|
|
export function Header(props: any) {
|
2022-12-04 17:36:30 +01:00
|
|
|
const { classes } = useStyles();
|
2022-12-30 17:58:12 +01:00
|
|
|
const { classes: cardClasses } = useCardStyles(false);
|
2022-04-25 00:11:32 +02:00
|
|
|
|
2022-12-10 15:00:16 +01:00
|
|
|
const { config } = useConfigContext();
|
|
|
|
|
|
2022-12-20 15:21:36 +09:00
|
|
|
const [newVersionAvailable, setNewVersionAvailable] = useState<string>('');
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
// Fetch Data here when component first mounted
|
|
|
|
|
fetch(`https://api.github.com/repos/${REPO_URL}/releases/latest`).then((res) => {
|
|
|
|
|
res.json().then((data) => {
|
|
|
|
|
if (data.tag_name > CURRENT_VERSION) {
|
|
|
|
|
setNewVersionAvailable(data.tag_name);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}, [CURRENT_VERSION]);
|
|
|
|
|
|
2022-04-25 00:11:32 +02:00
|
|
|
return (
|
2022-12-04 17:36:30 +01:00
|
|
|
<MantineHeader height={HeaderHeight} className={cardClasses.card}>
|
2022-11-29 20:30:53 +09:00
|
|
|
<Group p="xs" noWrap grow>
|
2022-12-04 17:36:30 +01:00
|
|
|
<Box className={classes.hide}>
|
|
|
|
|
<Logo />
|
|
|
|
|
</Box>
|
2022-12-10 22:50:34 +01:00
|
|
|
<Group position="right" style={{ maxWidth: 'none' }} noWrap>
|
2022-12-10 17:58:01 +01:00
|
|
|
<Search />
|
|
|
|
|
<ToggleEditModeAction />
|
2022-12-23 17:44:51 +01:00
|
|
|
<DockerMenuButton />
|
2022-12-20 15:21:36 +09:00
|
|
|
<Indicator size={15} color="blue" withBorder processing disabled={!newVersionAvailable}>
|
|
|
|
|
<SettingsMenu newVersionAvailable={newVersionAvailable} />
|
|
|
|
|
</Indicator>
|
2022-05-04 07:12:22 +02:00
|
|
|
</Group>
|
2022-05-14 21:41:30 +02:00
|
|
|
</Group>
|
2022-12-04 17:36:30 +01:00
|
|
|
</MantineHeader>
|
2022-04-25 00:11:32 +02:00
|
|
|
);
|
|
|
|
|
}
|
2022-12-04 17:36:30 +01:00
|
|
|
|
|
|
|
|
const useStyles = createStyles((theme) => ({
|
|
|
|
|
hide: {
|
|
|
|
|
[theme.fn.smallerThan('xs')]: {
|
|
|
|
|
display: 'none',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}));
|