1+ import { useConfig } from '@/components/ConfigProvider' ;
12import Stat from '@/components/Stat' ;
23import type { Response } from '@/lib/api/response' ;
34import { bytes } from '@/lib/bytes' ;
45import useLogin from '@/lib/hooks/useLogin' ;
5- import { Paper , ScrollArea , SimpleGrid , Skeleton , Table , Text , Title } from '@mantine/core' ;
6- import { IconDeviceSdCard , IconEyeFilled , IconFiles , IconLink , IconStarFilled } from '@tabler/icons-react' ;
6+ import { isAdministrator } from '@/lib/role' ;
7+ import { Button , Group , Paper , ScrollArea , SimpleGrid , Skeleton , Table , Text , Title } from '@mantine/core' ;
8+ import {
9+ IconDeviceSdCard ,
10+ IconEyeFilled ,
11+ IconFiles ,
12+ IconGraphFilled ,
13+ IconLink ,
14+ IconStarFilled ,
15+ } from '@tabler/icons-react' ;
716import { lazy , Suspense } from 'react' ;
17+ import { Link } from 'react-router-dom' ;
818import useSWR from 'swr' ;
919
1020const DashboardFile = lazy ( ( ) => import ( '@/components/file/DashboardFile' ) ) ;
@@ -13,6 +23,9 @@ export default function DashboardHome() {
1323 const { user } = useLogin ( ) ;
1424 const { data : recent , isLoading : recentLoading } = useSWR < Response [ '/api/user/recent' ] > ( '/api/user/recent' ) ;
1525 const { data : stats , isLoading : statsLoading } = useSWR < Response [ '/api/user/stats' ] > ( '/api/user/stats' ) ;
26+
27+ const config = useConfig ( ) ;
28+
1629 return (
1730 < >
1831 < Title >
@@ -47,9 +60,18 @@ export default function DashboardHome() {
4760 </ Text >
4861 ) : null }
4962
50- < Title order = { 2 } mt = 'md' mb = 'xs' >
51- Recent files
52- </ Title >
63+ < Group mt = 'md' mb = 'xs' style = { { alignItems : 'center' } } >
64+ < Title order = { 2 } > Recent files</ Title >
65+ < Button
66+ variant = 'outline'
67+ size = 'compact-xs'
68+ component = { Link }
69+ to = '/dashboard/files'
70+ leftSection = { < IconFiles size = '1rem' /> }
71+ >
72+ View all files
73+ </ Button >
74+ </ Group >
5375
5476 { recentLoading ? (
5577 < SimpleGrid cols = { { base : 1 , md : 2 , lg : 3 } } spacing = { { base : 'sm' , md : 'md' } } >
@@ -71,9 +93,21 @@ export default function DashboardHome() {
7193 </ Text >
7294 ) }
7395
74- < Title order = { 2 } mt = 'md' >
75- Stats
76- </ Title >
96+ < Group mt = 'md' style = { { alignItems : 'center' } } >
97+ < Title order = { 2 } > Stats</ Title >
98+ { ( ! config . features ?. metrics ?. adminOnly || isAdministrator ( user ?. role ) ) && (
99+ < Button
100+ variant = 'outline'
101+ size = 'compact-xs'
102+ component = { Link }
103+ to = '/dashboard/metrics'
104+ leftSection = { < IconGraphFilled size = '1rem' /> }
105+ >
106+ View instance metrics
107+ </ Button >
108+ ) }
109+ </ Group >
110+
77111 < Text size = 'sm' c = 'dimmed' mb = 'xs' >
78112 These statistics are based on your uploads only.
79113 </ Text >
0 commit comments