-
Notifications
You must be signed in to change notification settings - Fork 952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export timeline log feature #1533
Open
denis-remitly
wants to merge
6
commits into
infinitered:master
Choose a base branch
from
denis-remitly:feat-timeline-export
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9f55291
Ability to export
denis-remitly 4e1e1da
remove log
denis-remitly 081c245
Simplify
denis-remitly bd93a37
save as json instead of regular txt
denis-remitly e1a7a66
Merge branch 'master' into feat-timeline-export
jamonholmgren b8f1ee5
Merge branch 'master' into feat-timeline-export
denis-remitly File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import React, { useCallback, useContext, useMemo } from "react" | ||
import { clipboard, shell } from "electron" | ||
import fs from "fs" | ||
import os from "os" | ||
import path from "path" | ||
import debounce from "lodash.debounce" | ||
import { | ||
Header, | ||
|
@@ -12,7 +14,14 @@ import { | |
TimelineContext, | ||
RandomJoke, | ||
} from "reactotron-core-ui" | ||
import { MdSearch, MdDeleteSweep, MdFilterList, MdSwapVert, MdReorder } from "react-icons/md" | ||
import { | ||
MdSearch, | ||
MdDeleteSweep, | ||
MdFilterList, | ||
MdSwapVert, | ||
MdReorder, | ||
MdDownload, | ||
} from "react-icons/md" | ||
import { FaTimes } from "react-icons/fa" | ||
import styled from "styled-components" | ||
|
||
|
@@ -104,6 +113,21 @@ function Timeline() { | |
shell.openExternal("https://docs.infinite.red/reactotron/quick-start/react-native/") | ||
} | ||
|
||
function downloadLog() { | ||
if (commands.length > 0) { | ||
const homeDir = os.homedir() | ||
const downloadDir = path.join(homeDir, "Downloads") | ||
fs.writeFileSync( | ||
path.resolve(downloadDir, `timeline-log-${Date.now()}.json`), | ||
JSON.stringify(commands), | ||
"utf8" | ||
) | ||
console.log(`Exported timeline log to ${downloadDir}`) | ||
} else { | ||
console.error("There is nothing to export.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: @denis-remitly - what do you think about still exporting an empty array here instead? That would be my preference. |
||
} | ||
} | ||
|
||
const { searchString, handleInputChange } = useDebouncedSearchInput(search, setSearch, 300) | ||
|
||
return ( | ||
|
@@ -112,6 +136,13 @@ function Timeline() { | |
title="Timeline" | ||
isDraggable | ||
actions={[ | ||
{ | ||
tip: "Export Log", | ||
icon: MdDownload, | ||
onClick: () => { | ||
downloadLog() | ||
}, | ||
}, | ||
{ | ||
tip: "Search", | ||
icon: MdSearch, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: if
~/Downloads
doesn't exist, this fails silently. Can we either give the user an alert, or perhaps prompt them to set a download location instead of just assuming this path will exist for them?I don't think we need to block on this because it doesn't crash the app, but if we can add that to this PR or quickly follow up, that would be great.