@@ -2,7 +2,7 @@ import { useState } from 'react';
2
2
import intl from 'react-intl-universal' ;
3
3
import { useDispatch } from 'react-redux' ;
4
4
import { DownloadOutlined } from '@ant-design/icons' ;
5
- import { Button } from 'antd' ;
5
+ import { Button , Tooltip } from 'antd' ;
6
6
import { BaseButtonProps } from 'antd/lib/button/button' ;
7
7
import axios from 'axios' ;
8
8
import saveAs from 'file-saver' ;
@@ -11,58 +11,68 @@ import { getBlobFromResponse } from 'common/downloader';
11
11
import { ApiResponse } from 'services/api' ;
12
12
import { globalActions } from 'store/global' ;
13
13
14
+ import styles from './index.module.css' ;
15
+
14
16
type TDownloadTranscriptomics = BaseButtonProps & {
15
17
handleUrl : ( ) => Promise < ApiResponse < { url : string } > > ;
16
18
filename : string ;
17
19
displayNotification ?: boolean ;
20
+ tooltip : string ;
18
21
} ;
19
22
20
23
const DownloadTranscriptomics = ( {
21
24
handleUrl,
22
25
filename,
23
26
displayNotification = false ,
27
+ tooltip,
24
28
...props
25
29
} : TDownloadTranscriptomics ) => {
26
30
const [ loading , setLoading ] = useState < boolean > ( false ) ;
27
31
const dispatch = useDispatch ( ) ;
28
32
return (
29
- < Button
30
- loading = { loading }
31
- icon = { < DownloadOutlined /> }
32
- onClick = { async ( ) => {
33
- setLoading ( true ) ;
34
- const response = await handleUrl ( ) ;
33
+ < Tooltip
34
+ title = { tooltip }
35
+ overlayClassName = { styles . overlayTooltip }
36
+ overlayInnerStyle = { { textAlign : 'center' } }
37
+ >
38
+ < Button
39
+ loading = { loading }
40
+ icon = { < DownloadOutlined /> }
41
+ onClick = { async ( ) => {
42
+ setLoading ( true ) ;
43
+ const response = await handleUrl ( ) ;
35
44
36
- if ( displayNotification ) {
37
- dispatch (
38
- globalActions . displayMessage ( {
39
- type : 'loading' ,
40
- key : filename ,
41
- content : intl . get ( 'screen.analytics.transcriptomic.footer.notification' ) ,
42
- duration : 0 ,
43
- } ) ,
44
- ) ;
45
- }
45
+ if ( displayNotification ) {
46
+ dispatch (
47
+ globalActions . displayMessage ( {
48
+ type : 'loading' ,
49
+ key : filename ,
50
+ content : intl . get ( 'screen.analytics.transcriptomic.footer.notification' ) ,
51
+ duration : 0 ,
52
+ } ) ,
53
+ ) ;
54
+ }
46
55
47
- await axios ( {
48
- url : response . data ?. url ?? '' ,
49
- method : 'GET' ,
50
- responseType : 'blob' ,
51
- headers : {
52
- 'Content-Type' : 'application/json' ,
53
- Accept : '*/*' ,
54
- } ,
55
- } ) . then ( ( response ) => {
56
- const blob = getBlobFromResponse ( response , 'blob' ) ;
57
- saveAs ( blob , filename ) ;
58
- setLoading ( false ) ;
59
- dispatch ( globalActions . destroyMessages ( [ filename ] ) ) ;
60
- } ) ;
61
- } }
62
- { ...props }
63
- >
64
- { intl . get ( 'screen.analytics.transcriptomic.footer.download' ) }
65
- </ Button >
56
+ await axios ( {
57
+ url : response . data ?. url ?? '' ,
58
+ method : 'GET' ,
59
+ responseType : 'blob' ,
60
+ headers : {
61
+ 'Content-Type' : 'application/json' ,
62
+ Accept : '*/*' ,
63
+ } ,
64
+ } ) . then ( ( response ) => {
65
+ const blob = getBlobFromResponse ( response , 'blob' ) ;
66
+ saveAs ( blob , filename ) ;
67
+ setLoading ( false ) ;
68
+ dispatch ( globalActions . destroyMessages ( [ filename ] ) ) ;
69
+ } ) ;
70
+ } }
71
+ { ...props }
72
+ >
73
+ { intl . get ( 'screen.analytics.transcriptomic.footer.download' ) }
74
+ </ Button >
75
+ </ Tooltip >
66
76
) ;
67
77
} ;
68
78
0 commit comments