From 29727e3070c9d98d3e5111caeb5a647c4166611a Mon Sep 17 00:00:00 2001 From: Gregor Zurowski Date: Thu, 26 Sep 2024 11:32:17 +0200 Subject: [PATCH 1/2] Remove client for `paper//additional_file` --- config/api.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/config/api.js b/config/api.js index 310c2fb09..f768b9bd8 100644 --- a/config/api.js +++ b/config/api.js @@ -1201,9 +1201,6 @@ const routes = (BASE_URL) => { DELETE_FIGURE: ({ figureId }) => { return BASE_URL + `figure/${figureId}/delete_figure`; }, - PAPER_FILES: ({ paperId }) => { - return BASE_URL + `paper/${paperId}/additional_file/`; - }, GATEKEEPER_CURRENT_USER: ({ type }) => BASE_URL + `gatekeeper/check_current_user/?type=${type}`, GOOGLE_ANALYTICS: ({ ignorePaper, ignoreUser, manual }) => { From 1417b8d6f3eee36f3f817b2c733b95dc741f9b27 Mon Sep 17 00:00:00 2001 From: Gregor Zurowski Date: Thu, 26 Sep 2024 11:32:35 +0200 Subject: [PATCH 2/2] Remove `FileTab` component --- components/Paper/Tabs/FileTab.js | 315 ------------------------------- 1 file changed, 315 deletions(-) delete mode 100644 components/Paper/Tabs/FileTab.js diff --git a/components/Paper/Tabs/FileTab.js b/components/Paper/Tabs/FileTab.js deleted file mode 100644 index 48ae90391..000000000 --- a/components/Paper/Tabs/FileTab.js +++ /dev/null @@ -1,315 +0,0 @@ -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { faPlusCircle } from "@fortawesome/pro-solid-svg-icons"; -/** - * Import the necessary modules, components, redux, config - * - * This needs to look like the citation card container - * - * Link the file upload modal - */ -import { Component } from "react"; -import { StyleSheet, css } from "aphrodite"; -import { connect } from "react-redux"; -import Ripples from "react-ripples"; -import ReactPlaceholder from "react-placeholder/lib"; - -// Components -import ComponentWrapper from "~/components/ComponentWrapper"; -import PreviewPlaceholder from "~/components/Placeholders/PreviewPlaceholder"; - -// Redux -import { MessageActions } from "~/redux/message"; -import { ModalActions } from "~/redux/modals"; - -// Config -import colors from "~/config/themes/colors"; -import API from "~/config/api"; -import { Helpers } from "@quantfive/js-web-config"; - -import { openExternalLink } from "~/config/utils/routing"; - -class FileTab extends Component { - constructor(props) { - super(props); - this.state = { - files: [], - page: 0, - count: null, - fetching: false, - }; - } - - componentDidMount() { - this.fetchFiles(); - } - - fetchFiles = () => { - let paperId = this.props.paperId; - this.setState({ fetching: true }, () => { - return fetch(API.PAPER_FILES({ paperId }), API.GET_CONFIG()) - .then(Helpers.checkStatus) - .then(Helpers.parseJSON) - .then((res) => { - this.setState({ - files: res.results, - count: null, - fetching: false, - }); - }); - }); - }; - - openDndModal = () => { - let props = { - title: "Add Files", - // fileAccept: "application/pdf", - onSubmit: this.addFile, - }; - this.props.openDndModal(true, props); - }; - - addFile = (newFiles, callback) => { - let paperId = this.props.paperId; - let { showMessage, setMessage } = this.props; - showMessage({ load: true, show: true }); - - let params = new FormData(); - newFiles.forEach((file) => { - params.append("file", file); - }); - - return fetch(API.PAPER_FILES({ paperId }), API.POST_FILE_CONFIG(params)) - .then(Helpers.checkStatus) - .then(Helpers.parseJSON) - .then((res) => { - showMessage({ show: false }); - setMessage("File uploaded successfully"); - let files = [...this.state.files, res]; - this.setState({ - files, - }); - callback(); - }) - .catch((err) => { - showMessage({ show: false }); - setMessage("Something went wrong"); - showMessage({ show: true, error: true }); - }); - }; - - navigateToFile = (link) => { - openExternalLink(link); - }; - - renderPreview = (file) => { - if (file.file) { - return ( -
this.navigateToFile(file.file)} - > -