@@ -3,17 +3,15 @@ import { ActivityLogFilters, useActivityLogs } from '@/api/account/activity';
33import { useFlashKey } from '@/plugins/useFlash' ;
44import PageContentBlock from '@/components/elements/PageContentBlock' ;
55import FlashMessageRender from '@/components/FlashMessageRender' ;
6- import { format , formatDistanceToNowStrict } from 'date-fns' ;
76import { Link } from 'react-router-dom' ;
87import PaginationFooter from '@/components/elements/table/PaginationFooter' ;
9- import { UserIcon } from '@heroicons/react/outline' ;
10- import Tooltip from '@/components/elements/tooltip/Tooltip' ;
118import { DesktopComputerIcon , XCircleIcon } from '@heroicons/react/solid' ;
129import { useLocation } from 'react-router' ;
1310import Spinner from '@/components/elements/Spinner' ;
1411import { styles as btnStyles } from '@/components/elements/button/index' ;
1512import classNames from 'classnames' ;
16- import Translate from '@/components/elements/Translate' ;
13+ import ActivityLogEntry from '@/components/elements/activity/ActivityLogEntry' ;
14+ import Tooltip from '@/components/elements/tooltip/Tooltip' ;
1715
1816export default ( ) => {
1917 const location = useLocation ( ) ;
@@ -35,15 +33,6 @@ export default () => {
3533 clearAndAddHttpError ( error ) ;
3634 } , [ error ] ) ;
3735
38- const queryTo = ( params : Record < string , string > ) : string => {
39- const current = new URLSearchParams ( location . search ) ;
40- Object . keys ( params ) . forEach ( key => {
41- current . set ( key , params [ key ] ) ;
42- } ) ;
43-
44- return current . toString ( ) ;
45- } ;
46-
4736 return (
4837 < PageContentBlock title = { 'Account Activity Log' } >
4938 < FlashMessageRender byKey = { 'account' } />
@@ -63,59 +52,13 @@ export default () => {
6352 :
6453 < div className = { 'bg-gray-700' } >
6554 { data ?. items . map ( ( activity ) => (
66- < div
67- key = { `${ activity . event } |${ activity . timestamp . toString ( ) } ` }
68- className = { 'grid grid-cols-10 py-4 border-b-2 border-gray-800 last:rounded-b last:border-0' }
69- >
70- < div className = { 'col-span-2 sm:col-span-1 flex items-center justify-center select-none' } >
71- < div className = { 'flex items-center w-8 h-8 rounded-full bg-gray-600 overflow-hidden' } >
72- { activity . relationships . actor ?
73- < img src = { activity . relationships . actor . image } alt = { 'User avatar' } />
74- :
75- < UserIcon className = { 'w-5 h-5 mx-auto' } />
76- }
77- </ div >
78- </ div >
79- < div className = { 'col-span-8 sm:col-span-9' } >
80- < div className = { 'flex items-center text-gray-50' } >
81- { activity . relationships . actor ?. username || 'system' }
82- < span className = { 'text-gray-400' } > — </ span >
83- < Link
84- to = { `?${ queryTo ( { event : activity . event } ) } ` }
85- className = { 'transition-colors duration-75 active:text-cyan-400 hover:text-cyan-400' }
86- >
87- { activity . event }
88- </ Link >
89- { typeof activity . properties . useragent === 'string' &&
90- < Tooltip content = { activity . properties . useragent } placement = { 'top' } >
91- < DesktopComputerIcon className = { 'ml-2 w-4 h-4 cursor-pointer' } />
92- </ Tooltip >
93- }
94- </ div >
95- < p className = { 'mt-1 text-sm break-words line-clamp-2 pr-4' } >
96- < Translate ns = { 'activity' } values = { activity . properties } >
97- { activity . event . replace ( ':' , '.' ) }
98- </ Translate >
99- </ p >
100- < div className = { 'mt-1 flex items-center text-sm' } >
101- < Link
102- to = { `?${ queryTo ( { ip : activity . ip } ) } ` }
103- className = { 'transition-colors duration-75 active:text-cyan-400 hover:text-cyan-400' }
104- >
105- { activity . ip }
106- </ Link >
107- < span className = { 'text-gray-400' } > | </ span >
108- < Tooltip
109- placement = { 'right' }
110- content = { format ( activity . timestamp , 'MMM do, yyyy h:mma' ) }
111- >
112- < span >
113- { formatDistanceToNowStrict ( activity . timestamp , { addSuffix : true } ) }
114- </ span >
115- </ Tooltip >
116- </ div >
117- </ div >
118- </ div >
55+ < ActivityLogEntry key = { activity . timestamp . toString ( ) + activity . event } activity = { activity } >
56+ { typeof activity . properties . useragent === 'string' &&
57+ < Tooltip content = { activity . properties . useragent } placement = { 'top' } >
58+ < DesktopComputerIcon className = { 'ml-2 w-4 h-4 cursor-pointer' } />
59+ </ Tooltip >
60+ }
61+ </ ActivityLogEntry >
11962 ) ) }
12063 </ div >
12164 }
0 commit comments