11import React from 'react' ;
2- import { Box } from '@mui/material' ;
2+ import { Box , Button , Stack } from '@mui/material' ;
33import { styled } from '@mui/material/styles' ;
4+ import { FileDownload } from '@mui/icons-material' ;
45import { appColors } from '@root/src/theme/palette' ;
56import TreeDisplay from '@root/src/pages/sidepanel/components/TreeDisplay' ;
67
@@ -11,7 +12,7 @@ interface ProfileDetailTabProps {
1112const StyledPanel = styled ( Box ) ( ( { theme } ) => ( {
1213 width : '100%' ,
1314 backgroundColor : appColors . common . darkPanel ,
14- borderRadius : ` ${ theme . spacing ( 1 ) } ${ theme . spacing ( 1 ) } 0 0` , // 8px top corners, 0px bottom corners (top-left, top-right, bottom-right, bottom-left)
15+ borderRadius : theme . spacing ( 1 ) , // 8px all corners
1516 padding : '0.625rem' ,
1617 cursor : 'default' ,
1718 transition : 'none' ,
@@ -21,11 +22,42 @@ const StyledPanel = styled(Box)(({ theme }) => ({
2122 } ,
2223} ) ) ;
2324
25+ const ExportButton = styled ( Button ) ( ( { theme } ) => ( {
26+ width : '100%' ,
27+ padding : theme . spacing ( 1.5 ) ,
28+ backgroundColor : appColors . common . white ,
29+ color : appColors . neutral [ 900 ] ,
30+ fontWeight : appColors . common . fontWeight . semiBold ,
31+ fontSize : appColors . common . fontSize . base ,
32+ textTransform : 'none' ,
33+ borderRadius : theme . spacing ( 1 ) ,
34+ border : `1px solid ${ appColors . neutral [ 200 ] } ` ,
35+ '&:hover' : {
36+ backgroundColor : appColors . neutral [ 50 ] ,
37+ } ,
38+ } ) ) ;
39+
2440const ProfileDetail : React . FC < ProfileDetailTabProps > = ( { profile } ) => {
41+ const handleExport = ( ) => {
42+ const dataStr = JSON . stringify ( profile ?. data , null , 2 ) ;
43+ const dataBlob = new Blob ( [ dataStr ] , { type : 'application/json' } ) ;
44+ const url = URL . createObjectURL ( dataBlob ) ;
45+ const link = document . createElement ( 'a' ) ;
46+ link . href = url ;
47+ link . download = `profile-${ Date . now ( ) } .json` ;
48+ link . click ( ) ;
49+ URL . revokeObjectURL ( url ) ;
50+ } ;
51+
2552 return (
26- < StyledPanel >
27- < TreeDisplay data = { profile ?. data } collapsed = { 2 } />
28- </ StyledPanel >
53+ < Stack spacing = { 2 } width = "100%" >
54+ < StyledPanel >
55+ < TreeDisplay data = { profile ?. data } collapsed = { 2 } />
56+ </ StyledPanel >
57+ < ExportButton startIcon = { < FileDownload /> } onClick = { handleExport } >
58+ Export Profile JSON
59+ </ ExportButton >
60+ </ Stack >
2961 ) ;
3062} ;
3163
0 commit comments