Skip to content

Commit 7b87b38

Browse files
authored
Merge pull request #794 from include-dcc/fix/SJIP-1124-tooltips
fix(transcriptomics): SJIP-1124 add tooltip
2 parents c98502f + 0b5b2e2 commit 7b87b38

File tree

4 files changed

+53
-36
lines changed

4 files changed

+53
-36
lines changed

src/locales/en.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1531,6 +1531,8 @@ const en = {
15311531
download: 'Download data',
15321532
notification:
15331533
'Please wait while we generate your report. This process may take a few moments.',
1534+
diffGeneTooltip: 'Download differential gene expression across all genes',
1535+
sampleTooltip: 'Download gene expression data across all genes',
15341536
},
15351537
about: {
15361538
title: 'About this dataset',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.overlayTooltip {
2+
max-width: 400px;
3+
}

src/views/Analytics/Transcriptomic/Footer/DownloadTranscriptomics/index.tsx

+46-36
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useState } from 'react';
22
import intl from 'react-intl-universal';
33
import { useDispatch } from 'react-redux';
44
import { DownloadOutlined } from '@ant-design/icons';
5-
import { Button } from 'antd';
5+
import { Button, Tooltip } from 'antd';
66
import { BaseButtonProps } from 'antd/lib/button/button';
77
import axios from 'axios';
88
import saveAs from 'file-saver';
@@ -11,58 +11,68 @@ import { getBlobFromResponse } from 'common/downloader';
1111
import { ApiResponse } from 'services/api';
1212
import { globalActions } from 'store/global';
1313

14+
import styles from './index.module.css';
15+
1416
type TDownloadTranscriptomics = BaseButtonProps & {
1517
handleUrl: () => Promise<ApiResponse<{ url: string }>>;
1618
filename: string;
1719
displayNotification?: boolean;
20+
tooltip: string;
1821
};
1922

2023
const DownloadTranscriptomics = ({
2124
handleUrl,
2225
filename,
2326
displayNotification = false,
27+
tooltip,
2428
...props
2529
}: TDownloadTranscriptomics) => {
2630
const [loading, setLoading] = useState<boolean>(false);
2731
const dispatch = useDispatch();
2832
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();
3544

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+
}
4655

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>
6676
);
6777
};
6878

src/views/Analytics/Transcriptomic/Footer/index.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,15 @@ const TranscriptomicFooter = ({
105105
<div className={styles.footer}>
106106
<div className={styles.gene}>
107107
<DownloadTranscriptomics
108+
tooltip={intl.get('screen.analytics.transcriptomic.footer.diffGeneTooltip')}
108109
filename="htp-dge-data"
109110
handleUrl={TranscriptomicsApi.fetchExportUrlDiffGeneExp}
110111
disabled={loading}
111112
/>
112113
</div>
113114
<div className={styles.sample}>
114115
<DownloadTranscriptomics
116+
tooltip={intl.get('screen.analytics.transcriptomic.footer.sampleTooltip')}
115117
filename="htp-rnaseq-data"
116118
displayNotification
117119
handleUrl={TranscriptomicsApi.fetchExportUrlSampleGeneExp}

0 commit comments

Comments
 (0)