mirror of
https://github.com/umami-software/umami.git
synced 2025-12-06 01:18:00 +01:00
New admin section.
This commit is contained in:
parent
cdf391d5c2
commit
b78ff3b477
28 changed files with 161 additions and 100 deletions
54
src/app/(main)/admin/AdminLayout.tsx
Normal file
54
src/app/(main)/admin/AdminLayout.tsx
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
'use client';
|
||||
import { ReactNode } from 'react';
|
||||
import { Grid, Column } from '@umami/react-zen';
|
||||
import { useLoginQuery, useMessages, useNavigation } from '@/components/hooks';
|
||||
import { SideMenu } from '@/components/common/SideMenu';
|
||||
import { PageHeader } from '@/components/common/PageHeader';
|
||||
import { Panel } from '@/components/common/Panel';
|
||||
import { PageBody } from '@/components/common/PageBody';
|
||||
|
||||
export function AdminLayout({ children }: { children: ReactNode }) {
|
||||
const { user } = useLoginQuery();
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const { pathname } = useNavigation();
|
||||
|
||||
if (!user.isAdmin) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const items = [
|
||||
{
|
||||
id: 'users',
|
||||
label: formatMessage(labels.users),
|
||||
url: '/admin/users',
|
||||
},
|
||||
{
|
||||
id: 'websites',
|
||||
label: formatMessage(labels.websites),
|
||||
url: '/admin/websites',
|
||||
},
|
||||
{
|
||||
id: 'teams',
|
||||
label: formatMessage(labels.teams),
|
||||
url: '/admin/teams',
|
||||
},
|
||||
];
|
||||
|
||||
const value = items.find(({ url }) => pathname.includes(url))?.id;
|
||||
|
||||
return (
|
||||
<PageBody>
|
||||
<Column gap="6">
|
||||
<PageHeader title={formatMessage(labels.admin)} />
|
||||
<Grid columns="160px 1fr" gap>
|
||||
<Column>
|
||||
<SideMenu items={items} selectedKey={value} />
|
||||
</Column>
|
||||
<Column>
|
||||
<Panel>{children}</Panel>
|
||||
</Column>
|
||||
</Grid>
|
||||
</Column>
|
||||
</PageBody>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue