Skip to content

Commit 8126503

Browse files
committed
changed the export endpoint address
1 parent 179f927 commit 8126503

7 files changed

Lines changed: 17 additions & 19 deletions

File tree

vis/js/components/ModalButtons.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const ModalButtons = ({
2323
onViperEditClick,
2424
showReloadButton,
2525
reloadLastUpdate,
26-
reloadApiProperties,
26+
apiProperties,
2727
isEmbedded,
2828
visTag,
2929
service,
@@ -46,7 +46,7 @@ const ModalButtons = ({
4646
{showReloadButton && (
4747
<ReloadButton
4848
lastUpdate={reloadLastUpdate}
49-
apiProperties={reloadApiProperties}
49+
apiProperties={apiProperties}
5050
/>
5151
)}
5252
{showCitationButton && <CitationButton />}
@@ -63,7 +63,7 @@ const mapStateToProps = (state) => ({
6363
showViperEditButton: state.modals.showViperEditButton,
6464
showReloadButton: state.modals.showReloadButton,
6565
reloadLastUpdate: state.modals.reloadLastUpdate,
66-
reloadApiProperties: state.modals.reloadApiProperties,
66+
apiProperties: state.modals.apiProperties,
6767
isEmbedded: state.misc.isEmbedded,
6868
visTag: state.misc.visTag,
6969
service: state.service,

vis/js/components/Modals.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const mapStateToProps = (state) => ({
7373
viperEditObjID: state.modals.viperEditObjID,
7474
showPDFPreview: state.modals.showPDFPreview,
7575
previewedPaper: state.modals.previewedPaper,
76-
serverUrl: state.modals.reloadApiProperties.headstartPath,
76+
serverUrl: state.modals.apiProperties.headstartPath,
7777
service: state.service,
7878
useViewer: state.modals.useViewer,
7979
localization: state.localization,

vis/js/reducers/modals.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const modals = (
2-
state = { reloadApiProperties: {}, infoParams: {} },
2+
state = { apiProperties: {}, infoParams: {} },
33
action
44
) => {
55
if (action.canceled) {
@@ -23,7 +23,7 @@ const modals = (
2323
: null,
2424
showReloadButton: action.contextObject.service === "gsheets",
2525
reloadLastUpdate: action.contextObject.last_update,
26-
reloadApiProperties: {
26+
apiProperties: {
2727
headstartPath: action.configObject.server_url,
2828
sheetID: getSheetID(action.configObject, action.contextObject),
2929
persistenceBackend: action.configObject.persistence_backend,

vis/js/templates/modals/ExportPaperModal.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import usePaperExport, {
1111
} from "../../utils/usePaperExport";
1212
import useMatomo from "../../utils/useMatomo";
1313

14-
const ExportPaperModal = ({ open, onClose, paper }) => {
14+
const ExportPaperModal = ({ open, onClose, paper, serverUrl }) => {
1515
const loc = useLocalizationContext();
1616
const { trackEvent } = useMatomo();
1717

18-
const exportContent = usePaperExport(paper);
18+
const exportContent = usePaperExport(paper, serverUrl);
1919

2020
const handleCopyClick = () => {
2121
trackEvent("List document", "Copy paper export", "Copy export button");
@@ -87,6 +87,7 @@ const ExportPaperModal = ({ open, onClose, paper }) => {
8787
const mapStateToProps = (state) => ({
8888
open: state.modals.exportedPaper !== null,
8989
paper: state.modals.exportedPaper,
90+
serverUrl: state.modals.apiProperties.headstartPath,
9091
});
9192

9293
const mapDispatchToProps = (dispatch) => ({

vis/js/utils/usePaperExport.js

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

3-
export const PAPER_EXPORT_ENDPOINT =
4-
process.env.NODE_ENV === "development"
5-
? "https://dev.openknowledgemaps.org/export-endpoint/headstart/server/services/exportMetadata?format=bibtex"
6-
: "https://openknowledgemaps.org/search_api/server/services/exportMetadata?format=bibtex";
3+
export const PAPER_EXPORT_ENDPOINT = "services/exportMetadata.php";
74

85
const DATA_FALLBACK = "No data available.";
96

10-
const usePaperExport = (paper) => {
7+
const usePaperExport = (paper, serverUrl) => {
118
const [exports, setExports] = useState({});
129

1310
useEffect(() => {
1411
if (!paper || !!exports[paper.safe_id]) {
1512
return;
1613
}
1714

18-
loadPaperExport(paper, setExports);
19-
}, [setExports, paper]);
15+
loadPaperExport(paper, serverUrl, setExports);
16+
}, [setExports, paper, serverUrl]);
2017

2118
if (!paper || !exports[paper.safe_id]) {
2219
return "";
@@ -27,8 +24,8 @@ const usePaperExport = (paper) => {
2724

2825
export default usePaperExport;
2926

30-
const loadPaperExport = (paper, callback) => {
31-
fetch(PAPER_EXPORT_ENDPOINT, {
27+
const loadPaperExport = (paper, serverUrl, callback) => {
28+
fetch(serverUrl + PAPER_EXPORT_ENDPOINT, {
3229
method: "POST",
3330
mode: "cors",
3431
headers: {

vis/test/component/modals.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const setup = (overrideModalsObject = {}, overrideStoreObject = {}) => {
4747
viperEditObjID: null,
4848
showReloadButton: false,
4949
reloadLastUpdate: null,
50-
reloadApiProperties: {
50+
apiProperties: {
5151
headstartPath: null,
5252
sheetID: null,
5353
persistenceBackend: null,

vis/test/store/modals.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe("modals state", () => {
2424
};
2525

2626
it("should return the initial state", () => {
27-
const EXPECTED_RESULT = { reloadApiProperties: {}, infoParams: {} };
27+
const EXPECTED_RESULT = { apiProperties: {}, infoParams: {} };
2828

2929
const result = reducer(undefined, {});
3030

0 commit comments

Comments
 (0)