Upgrade /front version and display the version in settings navbar (#1207)

* Upgrade /front version and display the version in settings navbar

* fix

* fix version

* restore center

* add icon

* Fix styled components

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Weiko 2023-08-14 17:40:10 -07:00 committed by GitHub
parent e3dc3b3e4a
commit 239d036813
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 58 additions and 6 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "twenty", "name": "twenty",
"version": "0.1.0", "version": "0.1.2",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@air/react-drag-to-select": "^5.0.8", "@air/react-drag-to-select": "^5.0.8",

View File

@ -27,7 +27,7 @@ export function SettingsNavbar() {
}, [signOut, navigate]); }, [signOut, navigate]);
return ( return (
<SubMenuNavbar backButtonTitle="Settings"> <SubMenuNavbar backButtonTitle="Settings" displayVersion={true}>
<NavTitle label="User" /> <NavTitle label="User" />
<NavItem <NavItem
label="Profile" label="Profile"

View File

@ -55,3 +55,4 @@ export { IconHeart } from '@tabler/icons-react';
export { IconBrandX } from '@tabler/icons-react'; export { IconBrandX } from '@tabler/icons-react';
export { IconTag } from '@tabler/icons-react'; export { IconTag } from '@tabler/icons-react';
export { IconHelpCircle } from '@tabler/icons-react'; export { IconHelpCircle } from '@tabler/icons-react';
export { IconBrandGithub } from '@tabler/icons-react';

View File

@ -1,8 +1,11 @@
import { useTheme } from '@emotion/react';
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import { IconBrandGithub } from '@/ui/icon';
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile'; import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
import { leftNavbarWidth } from '../constants'; import packageJson from '../../../../../package.json';
import { githubLink, leftNavbarWidth } from '../constants';
import NavBackButton from './NavBackButton'; import NavBackButton from './NavBackButton';
import NavItemsContainer from './NavItemsContainer'; import NavItemsContainer from './NavItemsContainer';
@ -10,20 +13,66 @@ import NavItemsContainer from './NavItemsContainer';
type OwnProps = { type OwnProps = {
children: React.ReactNode; children: React.ReactNode;
backButtonTitle: string; backButtonTitle: string;
displayVersion?: boolean;
}; };
const StyledVersionContainer = styled.div`
font-size: ${({ theme }) => theme.font.size.sm};
font-weight: ${({ theme }) => theme.font.weight.medium};
margin-bottom: ${({ theme }) => theme.spacing(2)};
padding-left: ${({ theme }) => theme.spacing(1)};
`;
const StyledVersion = styled.span`
color: ${({ theme }) => theme.font.color.light};
:hover {
color: ${({ theme }) => theme.font.color.tertiary};
}
padding-left: ${({ theme }) => theme.spacing(1)};
`;
const StyledVersionLink = styled.a`
align-items: center;
color: ${({ theme }) => theme.font.color.light};
display: flex;
text-decoration: none;
:hover {
color: ${({ theme }) => theme.font.color.tertiary};
}
`;
const StyledContainer = styled.div` const StyledContainer = styled.div`
display: flex; display: flex;
flex-direction: column; flex-direction: column;
height: 100%;
justify-content: space-between;
padding-top: ${({ theme }) => theme.spacing(9)}; padding-top: ${({ theme }) => theme.spacing(9)};
width: ${() => (useIsMobile() ? '100%' : leftNavbarWidth.desktop)}; width: ${() => (useIsMobile() ? '100%' : leftNavbarWidth.desktop)};
`; `;
export default function SubMenuNavbar({ children, backButtonTitle }: OwnProps) { export default function SubMenuNavbar({
children,
backButtonTitle,
displayVersion,
}: OwnProps) {
const version = packageJson.version;
const theme = useTheme();
return ( return (
<StyledContainer> <StyledContainer>
<NavBackButton title={backButtonTitle} /> <div>
<NavItemsContainer>{children}</NavItemsContainer> <NavBackButton title={backButtonTitle} />
<NavItemsContainer>{children}</NavItemsContainer>
</div>
{displayVersion && (
<StyledVersionContainer>
<StyledVersionLink href={githubLink} target="_blank" rel="noreferrer">
<IconBrandGithub size={theme.icon.size.md} />
<StyledVersion>{version}</StyledVersion>
</StyledVersionLink>
</StyledVersionContainer>
)}
</StyledContainer> </StyledContainer>
); );
} }

View File

@ -12,3 +12,5 @@ export const navbarIconSize = {
mobile: 18, mobile: 18,
desktop: 16, desktop: 16,
}; };
export const githubLink = 'https://github.com/twentyhq/twenty';