From 02e3b96384012679818c6b172039534a113334ef Mon Sep 17 00:00:00 2001 From: jeffvli Date: Wed, 26 Oct 2022 16:12:18 -0700 Subject: [PATCH] Update titlebar --- .../features/titlebar/components/Titlebar.tsx | 39 +++++------------- .../features/titlebar/components/app-menu.tsx | 36 ++++++++-------- .../titlebar/components/user-menu.tsx | 41 ------------------- src/renderer/features/titlebar/index.ts | 2 - 4 files changed, 27 insertions(+), 91 deletions(-) delete mode 100644 src/renderer/features/titlebar/components/user-menu.tsx delete mode 100644 src/renderer/features/titlebar/index.ts diff --git a/src/renderer/features/titlebar/components/Titlebar.tsx b/src/renderer/features/titlebar/components/Titlebar.tsx index 2a1b2fe10..48933e52f 100644 --- a/src/renderer/features/titlebar/components/Titlebar.tsx +++ b/src/renderer/features/titlebar/components/Titlebar.tsx @@ -2,11 +2,10 @@ import { ReactNode } from 'react'; import styled from '@emotion/styled'; import { Group } from '@mantine/core'; import { FiActivity } from 'react-icons/fi'; -import { RiArrowLeftSLine, RiArrowRightSLine } from 'react-icons/ri'; -import { useNavigate } from 'react-router-dom'; +import { Button, Text } from '@/renderer/components'; import { AppMenu } from '@/renderer/features/titlebar/components/app-menu'; import { useAuthStore } from '@/renderer/store'; -import { Button } from '../../../components'; +import { Font } from '@/renderer/styles'; import { WindowControls } from '../../window-controls'; interface TitlebarProps { @@ -32,57 +31,41 @@ const TitlebarContainer = styled.div` `; const Left = styled.div` + display: flex; flex: 1/3; + justify-content: center; height: 100%; + padding-left: 1rem; `; const Center = styled.div` + display: flex; flex: 1/3; + justify-content: center; height: 100%; `; const Right = styled.div` + display: flex; flex: 1/3; + justify-content: center; height: 100%; `; export const Titlebar = ({ children }: TitlebarProps) => { - const navigate = useNavigate(); const isAuthenticated = useAuthStore((state) => !!state.accessToken); return ( <> - - {isAuthenticated && ( - <> - - - - )} + + Feishin
{children} - {isAuthenticated && ( <> diff --git a/src/renderer/features/titlebar/components/app-menu.tsx b/src/renderer/features/titlebar/components/app-menu.tsx index 6a0711b27..7d4c2c966 100644 --- a/src/renderer/features/titlebar/components/app-menu.tsx +++ b/src/renderer/features/titlebar/components/app-menu.tsx @@ -1,5 +1,4 @@ import { openModal, closeAllModals } from '@mantine/modals'; -import { useTranslation } from 'react-i18next'; import { RiArrowLeftLine, RiLogoutBoxLine, RiMenu3Fill } from 'react-icons/ri'; import { useNavigate } from 'react-router'; import { Button, DropdownMenu } from '@/renderer/components'; @@ -8,23 +7,22 @@ import { ServerList, useServerList, } from '@/renderer/features/servers'; +import { usePermissions } from '@/renderer/features/shared'; import { useAuthStore } from '@/renderer/store'; export const AppMenu = () => { const navigate = useNavigate(); - const { t } = useTranslation(); const logout = useAuthStore((state) => state.logout); const currentServer = useAuthStore((state) => state.currentServer); const setCurrentServer = useAuthStore((state) => state.setCurrentServer); + const permissions = usePermissions(); const { data: servers } = useServerList(); const serverList = - servers?.data?.map((s) => ({ id: s.id, label: `${s.name} - ${s.url}` })) ?? - []; + servers?.data?.map((s) => ({ id: s.id, label: `${s.name}` })) ?? []; const handleLogout = () => { logout(); - localStorage.removeItem('authentication'); navigate('/login'); }; @@ -32,7 +30,7 @@ export const AppMenu = () => { openModal({ centered: true, children: , - title: t('modal.add_server.title'), + title: 'Add server', }); }; @@ -40,7 +38,7 @@ export const AppMenu = () => { openModal({ centered: true, children: , - title: t('modal.manage_servers.title'), + title: 'Manage servers', }); }; @@ -51,7 +49,7 @@ export const AppMenu = () => { }; return ( - + - - - } - onClick={() => addServerHandlers.open()} - > - Servers - - }>Settings - } onClick={handleLogout}> - Logout - - - - - ); -}; diff --git a/src/renderer/features/titlebar/index.ts b/src/renderer/features/titlebar/index.ts deleted file mode 100644 index 490eb5c35..000000000 --- a/src/renderer/features/titlebar/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './components/titlebar'; -export * from './components/user-menu';