1
1
import React , { useCallback , useContext , useMemo } from "react"
2
2
import { clipboard , shell } from "electron"
3
3
import fs from "fs"
4
+ import os from "os"
5
+ import path from "path"
4
6
import debounce from "lodash.debounce"
5
7
import {
6
8
Header ,
@@ -12,7 +14,14 @@ import {
12
14
TimelineContext ,
13
15
RandomJoke ,
14
16
} from "reactotron-core-ui"
15
- import { MdSearch , MdDeleteSweep , MdFilterList , MdSwapVert , MdReorder } from "react-icons/md"
17
+ import {
18
+ MdSearch ,
19
+ MdDeleteSweep ,
20
+ MdFilterList ,
21
+ MdSwapVert ,
22
+ MdReorder ,
23
+ MdDownload ,
24
+ } from "react-icons/md"
16
25
import { FaTimes } from "react-icons/fa"
17
26
import styled from "styled-components"
18
27
@@ -110,6 +119,17 @@ function Timeline() {
110
119
shell . openExternal ( "https://docs.infinite.red/reactotron/quick-start/react-native/" )
111
120
}
112
121
122
+ function downloadLog ( ) {
123
+ const homeDir = os . homedir ( )
124
+ const downloadDir = path . join ( homeDir , "Downloads" )
125
+ fs . writeFileSync (
126
+ path . resolve ( downloadDir , `timeline-log-${ Date . now ( ) } .json` ) ,
127
+ JSON . stringify ( commands || [ ] ) ,
128
+ "utf8"
129
+ )
130
+ console . log ( `Exported timeline log to ${ downloadDir } ` )
131
+ }
132
+
113
133
const { searchString, handleInputChange } = useDebouncedSearchInput ( search , setSearch , 300 )
114
134
115
135
return (
@@ -118,6 +138,13 @@ function Timeline() {
118
138
title = "Timeline"
119
139
isDraggable
120
140
actions = { [
141
+ {
142
+ tip : "Export Log" ,
143
+ icon : MdDownload ,
144
+ onClick : ( ) => {
145
+ downloadLog ( )
146
+ } ,
147
+ } ,
121
148
{
122
149
tip : "Search" ,
123
150
icon : MdSearch ,
0 commit comments