Skip to content

Commit

Permalink
feature: activity export enhancements (#1836)
Browse files Browse the repository at this point in the history
* adds disable state to tx history component fixes default file name and location

* fixes linting errors

* removes commented out import
  • Loading branch information
comountainclimber committed Apr 11, 2019
1 parent 6c8ebcf commit be72a00
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions app/containers/TransactionHistory/TransactionHistory.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import ExportIcon from '../../assets/icons/export.svg'
import PanelHeaderButton from '../../components/PanelHeaderButton/PanelHeaderButton'
import { parseAbstractData } from '../../actions/transactionHistoryActions'

const { dialog } = require('electron').remote
const { dialog, app } = require('electron').remote

type Props = {
showSuccessNotification: ({ message: string }) => string,
Expand All @@ -26,13 +26,21 @@ type Props = {
address: string,
}

export default class TransactionHistory extends Component<Props> {
type State = {
isExporting: boolean,
}

export default class TransactionHistory extends Component<Props, State> {
state = {
isExporting: false,
}

render() {
return (
<div className={styles.transactionHistory}>
<HeaderBar
label="All Activity"
renderRightContent={this.renderPanelHeaderContent}
renderRightContent={() => this.renderPanelHeaderContent()}
/>
<TransactionHistoryPanel className={styles.transactionHistoryPanel} />
</div>
Expand All @@ -42,6 +50,7 @@ export default class TransactionHistory extends Component<Props> {
renderPanelHeaderContent = () => (
<div className={styles.panelHeaderButtons}>
<PanelHeaderButton
disabled={this.state.isExporting}
onClick={this.saveHistoryFile}
className={styles.exportButton}
renderIcon={() => <ExportIcon />}
Expand Down Expand Up @@ -75,6 +84,9 @@ export default class TransactionHistory extends Component<Props> {
}

saveHistoryFile = async () => {
this.setState({
isExporting: true,
})
const {
showErrorNotification,
showSuccessNotification,
Expand Down Expand Up @@ -110,6 +122,9 @@ export default class TransactionHistory extends Component<Props> {
hideNotification(infoNotification)
dialog.showSaveDialog(
{
defaultPath: `${app.getPath(
'documents',
)}/neon-wallet-activity-${moment().unix()}.csv`,
filters: [
{
name: 'CSV',
Expand All @@ -118,6 +133,9 @@ export default class TransactionHistory extends Component<Props> {
],
},
fileName => {
this.setState({
isExporting: false,
})
if (fileName === undefined) {
return
}
Expand All @@ -139,6 +157,9 @@ export default class TransactionHistory extends Component<Props> {
)
} catch (err) {
console.error(err)
this.setState({
isExporting: false,
})
showErrorNotification({
message: `An error occurred creating the file: ${err.message}`,
})
Expand Down

0 comments on commit be72a00

Please sign in to comment.