Skip to content
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

(feature) Add support for emitReportFileGenerationFailedToOne event #787

Merged
merged 38 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
3bad348
Merge pull request #783 from bitfinexcom/staging
prdn Mar 6, 2024
c1c9b2f
Actualize main method naming
alexstotsky Feb 27, 2024
bc3c2ad
Update deprecated export methods
alexstotsky Feb 27, 2024
7596ab7
Cleanup
alexstotsky Feb 27, 2024
8a9538e
Actualize localReportFolderPath and remoteReportUrn handling
alexstotsky Mar 6, 2024
5db2cc5
Actualize query constants
alexstotsky Mar 6, 2024
7c650f9
Unify export report saga naming
alexstotsky Mar 6, 2024
8ed6d1d
Update reducers handling cases and initial entries
alexstotsky Mar 6, 2024
7b7091e
Actualize export selectors
alexstotsky Mar 6, 2024
d74f595
Update export dialog mapped props
alexstotsky Mar 6, 2024
f694600
Actualize export method and prop-types
alexstotsky Mar 6, 2024
030c0c9
Actualize reports exporting actions
alexstotsky Mar 6, 2024
daee86b
Update mapped method
alexstotsky Mar 6, 2024
3bd3c03
Actualize is exporting constant naming
alexstotsky Mar 6, 2024
23712c0
Update set is exportting action
alexstotsky Mar 6, 2024
c43a75b
Actualize ws constants
alexstotsky Mar 6, 2024
61dbc3b
Update export report saga flow
alexstotsky Mar 6, 2024
e52f8bc
Actualize ws report generation sagas
alexstotsky Mar 6, 2024
9d842a9
Actualize ws constants
alexstotsky Mar 11, 2024
89ff14e
[wip]Export fail dialog
alexstotsky Mar 11, 2024
0c9591f
Add fail dialog handling ui constant
alexstotsky Mar 11, 2024
f14b1c5
Implement toggleExportFailDialog action
alexstotsky Mar 11, 2024
ea7ef88
Update ui reducers cases and init state entries
alexstotsky Mar 11, 2024
83697a7
Add getIsExportFailDialogOpen selector
alexstotsky Mar 11, 2024
de6bca2
Update styles imports
alexstotsky Mar 11, 2024
9681de8
Actualize fail dialog icon
alexstotsky Mar 11, 2024
4e7c370
Add export fail dialog to the main
alexstotsky Mar 11, 2024
f7b956b
Add export failing related keys and descriptions
alexstotsky Mar 11, 2024
af400ee
Actualize export fail dialog title and message
alexstotsky Mar 11, 2024
3d6ea74
Update dialog classes and cleanup
alexstotsky Mar 11, 2024
9a3b858
Adjust styling
alexstotsky Mar 11, 2024
0920ad1
Update prop-types
alexstotsky Mar 11, 2024
2bca11f
Cleanup
alexstotsky Mar 11, 2024
3d3a85f
Rework and optimize export fail dialog
alexstotsky Mar 12, 2024
0249fea
Update export and redundant code cleanup
alexstotsky Mar 12, 2024
cc8d7c3
Implement handleReportGenerationFailed ws saga
alexstotsky Mar 12, 2024
3224a2b
Cleanup
alexstotsky Mar 12, 2024
abef2e9
Actualize download status description
alexstotsky Mar 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion public/locales/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,11 @@
"remoteStorage": "Remote storage",
"status": {
"local": "Export generated, files are saved in: ",
"email": "Generating your CSV report, we'll send it to you via email as soon as it's ready..."
"email": "Generating your report, we'll send it to you via email as soon as it's ready...",
"failed": "Export generation failed. Please select a smaller date range or try again later."
},
"success": "Success",
"fail": "Fail",
"targets": "Data to Export",
"exportAsPdf": "Export as PDF"
},
Expand Down
8 changes: 4 additions & 4 deletions src/components/ExportDialog/ExportDialog.container.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { toggleExportDialog } from 'state/ui/actions'
import { getTimestamp } from 'state/wallets/selectors'
import { getTimeFrame } from 'state/timeRange/selectors'
import { getIsExportDialogOpen } from 'state/ui/selectors'
import { exportCsv, prepareExport } from 'state/query/actions'
import { exportReport, prepareExport } from 'state/query/actions'
import { getFullTime, getTimezone } from 'state/base/selectors'
import { getExportEmail, getIsCsvExporting } from 'state/query/selectors'
import { getExportEmail, getIsReportExporting } from 'state/query/selectors'

import ExportDialog from './ExportDialog'

Expand All @@ -20,11 +20,11 @@ const mapStateToProps = state => ({
timestamp: getTimestamp(state),
getFullTime: getFullTime(state),
isOpen: getIsExportDialogOpen(state),
isExporting: getIsCsvExporting(state),
isExporting: getIsReportExporting(state),
})

const mapDispatchToProps = {
exportCsv,
exportReport,
prepareExport,
toggleDialog: toggleExportDialog,
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/ExportDialog/ExportDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ExportDialog extends PureComponent {
end: PropTypes.number,
email: PropTypes.string,
toggleDialog: PropTypes.func.isRequired,
exportCsv: PropTypes.func.isRequired,
exportReport: PropTypes.func.isRequired,
location: PropTypes.shape({
pathname: PropTypes.string.isRequired,
}).isRequired,
Expand Down Expand Up @@ -78,15 +78,15 @@ class ExportDialog extends PureComponent {
}

startExport = () => {
const { exportCsv, location } = this.props
const { exportReport, location } = this.props
const { currentTargets } = this.state
tracker.trackEvent('Export')
const target = getTarget(location.pathname)
const targets = queryConstants.MENU_POSITIONS_AUDIT !== target
? currentTargets
: [queryConstants.MENU_POSITIONS_AUDIT]

exportCsv(targets)
exportReport(targets)
}

toggleTarget = (target) => {
Expand Down
52 changes: 52 additions & 0 deletions src/components/ExportFailDialog/ExportFailDialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { useTranslation } from 'react-i18next'
import {
Button,
Classes,
Dialog,
Intent,
} from '@blueprintjs/core'

import Icon from 'icons'
import { tracker } from 'utils/trackers'
import { toggleExportFailDialog } from 'state/ui/actions'
import { getIsExportFailDialogOpen } from 'state/ui/selectors'

const ExportFailDialog = () => {
const { t } = useTranslation()
const dispatch = useDispatch()
const isOpen = useSelector(getIsExportFailDialogOpen)

const onClose = () => {
tracker.trackEvent('Okay')
dispatch(toggleExportFailDialog())
}

return (
<Dialog
isOpen={isOpen}
onClose={onClose}
title={t('download.fail')}
isCloseButtonShown={false}
className='export-fail-dialog'
>
<div className={Classes.DIALOG_BODY}>
<Icon.WARNING />
<div className='export-fail-dialog-message'>
{t('download.status.failed')}
</div>
</div>
<div className={Classes.DIALOG_FOOTER}>
<Button
onClick={onClose}
intent={Intent.PRIMARY}
>
{t('download.okay')}
</Button>
</div>
</Dialog>
)
}

export default ExportFailDialog
25 changes: 25 additions & 0 deletions src/components/ExportFailDialog/_ExportFailDialog.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.export-fail-dialog {
.icon--warning {
display: block;
margin: 23px auto 28px auto;
}

&-message {
width: 283px;
text-align: center;
margin: 0 auto 10px auto;
}

.bp3-button {
display: block;
margin: 0 auto;
}
}

@media screen and (min-width: 2560px) {
.export-fail-dialog {
&-message {
line-height: 1.3;
}
}
}
1 change: 1 addition & 0 deletions src/components/ExportFailDialog/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './ExportFailDialog'
2 changes: 2 additions & 0 deletions src/components/Main/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import Preferences from 'components/Preferences'
import ExtraInfoDialog from 'components/ExtraInfoDialog'
import TimeFrameDialog from 'components/TimeFrameDialog'
import MaintenanceDialog from 'components/MaintenanceDialog'
import ExportFailDialog from 'components/ExportFailDialog'
import queryType from 'state/query/constants'
import { getPath } from 'state/query/utils'
import NavMenu from 'ui/NavMenu'
Expand Down Expand Up @@ -380,6 +381,7 @@ class Main extends PureComponent {
<GoToRangeDialog />
<NavMenuDrawer />
<ExtraInfoDialog />
<ExportFailDialog />
{showFrameworkMode && <MaintenanceDialog />}
</>
) : ''
Expand Down
20 changes: 10 additions & 10 deletions src/state/query/actions.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import types from './constants'

/**
* Create an action to export CSV.
* Create an action to export report.
* @param {string[]} targets array of export types
*/
export function exportCsv(targets) {
export function exportReport(targets) {
return {
type: types.EXPORT_CSV,
type: types.EXPORT_REPORT,
payload: targets,
}
}

/**
* Create an action to set path to local export CSV folder.
* Create an action to set path to local export folder.
* @param {string} path to local export folder
*/
export function setLocalExportPath(path) {
Expand All @@ -23,12 +23,12 @@ export function setLocalExportPath(path) {
}

/**
* Create an action to set remote CSV URN.
* Create an action to set remote report URN.
* @param {string} urn to generated report.
*/
export function setRemoteUrn(urn) {
return {
type: types.SET_REMOTE_CSV_URN,
type: types.SET_REMOTE_REPORT_URN,
payload: urn,
}
}
Expand All @@ -53,9 +53,9 @@ export function setExportEmail(email) {
}
}

export function setIsCsvExporting(isExporting) {
export function setIsReportExporting(isExporting) {
return {
type: types.SET_IS_CSV_EXPORTING,
type: types.SET_IS_REPORT_EXPORTING,
payload: isExporting,
}
}
Expand All @@ -68,11 +68,11 @@ export function setIsPdfRequired(isPdfRequired) {
}

export default {
exportCsv,
exportReport,
setRemoteUrn,
prepareExport,
setExportEmail,
setIsPdfRequired,
setIsCsvExporting,
setIsReportExporting,
setLocalExportPath,
}
8 changes: 4 additions & 4 deletions src/state/query/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ export default {
TIME_TYPE_LOCALTIME: 'local',
DEFAULT_QUERY_LIMIT: 500,
DEFAULT_RANGE: '2w',
EXPORT_CSV: 'BITFINEX/EXPORT/CSV',
SET_LOCAL_EXPORT_PATH: 'BITFINEX/EXPORT/CSV_FOLDER_PATH',
SET_REMOTE_CSV_URN: 'BITFINEX/EXPORT/CSV_REMOTE_URN',
SET_IS_CSV_EXPORTING: 'BITFINEX/EXPORT/IS_CSV_EXPORTING',
EXPORT_REPORT: 'BITFINEX/EXPORT/REPORT',
SET_LOCAL_EXPORT_PATH: 'BITFINEX/EXPORT/REPORT_FOLDER_PATH',
SET_REMOTE_REPORT_URN: 'BITFINEX/EXPORT/REPORT_REMOTE_URN',
SET_IS_REPORT_EXPORTING: 'BITFINEX/EXPORT/IS_REPORT_EXPORTING',
SET_IS_PDF_REQUIRED: 'BITFINEX/EXPORT/IS_PDF_REQUIRED',
PREPARE_EXPORT: 'BITFINEX/EXPORT/PREPARE',
SET_EXPORT_EMAIL: 'BITFINEX/EMAIL/EXPORT',
Expand Down
8 changes: 4 additions & 4 deletions src/state/query/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const initialState = {
exportEmail: '',
localExportPath: null,
remoteUrn: null,
isCsvExporting: false,
isReportExporting: false,
isPDFRequired: true,
}

Expand All @@ -23,15 +23,15 @@ export function queryReducer(state = initialState, action) {
...state,
localExportPath: payload || null,
}
case types.SET_REMOTE_CSV_URN:
case types.SET_REMOTE_REPORT_URN:
return {
...state,
remoteUrn: payload || null,
}
case types.SET_IS_CSV_EXPORTING:
case types.SET_IS_REPORT_EXPORTING:
return {
...state,
isCsvExporting: payload,
isReportExporting: payload,
}
case types.SET_IS_PDF_REQUIRED:
return {
Expand Down
Loading