Skip to content

Commit 0b30afb

Browse files
committed
export feature configurable by parameter
1 parent ca7bc15 commit 0b30afb

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

vis/js/reducers/list.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const list = (
1818
hideUnselectedKeywords: true,
1919
height: null,
2020
citePapers: false,
21+
exportPapers: false,
2122
},
2223
action
2324
) => {
@@ -49,6 +50,7 @@ const list = (
4950
disableClicks: !config.render_map,
5051
height: action.listHeight,
5152
citePapers: config.cite_papers,
53+
exportPapers: config.export_papers,
5254
};
5355
case "TOGGLE_LIST":
5456
return {

vis/js/templates/listentry/PaperButtons.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ const mapStateToProps = (state) => ({
6262
// state.service
6363
// ),
6464
showCiteButton: state.list.citePapers,
65-
showExportButton: ["base", "pubmed"].includes(state.service),
65+
// showExportButton: ["base", "pubmed"].includes(state.service),
66+
showExportButton: state.list.exportPapers,
6667
});
6768

6869
export default connect(

vis/js/utils/usePaperExport.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useState, useEffect } from "react";
22

3-
export const PAPER_EXPORT_ENDPOINT = "services/exportMetadata.php?format=bibtex";
3+
export const PAPER_EXPORT_ENDPOINT =
4+
"services/exportMetadata.php?format=bibtex";
45

56
const DATA_FALLBACK = "No data available.";
67

@@ -35,7 +36,12 @@ const loadPaperExport = (paper, serverUrl, callback) => {
3536
body: "paper=" + encodeURIComponent(JSON.stringify(paper)),
3637
})
3738
.then((response) => response.text())
38-
.then((data) => callback((prev) => ({ ...prev, [paper.safe_id]: data })))
39+
.then((data) =>
40+
callback((prev) => ({
41+
...prev,
42+
[paper.safe_id]: data ? data : DATA_FALLBACK,
43+
}))
44+
)
3945
.catch((error) => {
4046
console.error(error);
4147
callback((prev) => ({

0 commit comments

Comments
 (0)