import React from "react" ; import ReactDOMServer from "react-dom/server" ; import { ToastContainer, toast } from "react-toastify" ; import "react-toastify/dist/ReactToastify.min.css" ; import SearchForm from "./SearchForm" ; import { SearchResults } from "./SearchResults" ; import { PublisherSearchResult } from "./PublisherSearchResult" ; import { PublicationSearchResult } from "./PublicationSearchResult" ; import { ArticleSearchResult } from "./ArticleSearchResult" ; import ModalForm from "./ModalForm"; import AskDialog from "./AskDialog" ; import "./App.css" ; const axios = require( "axios" ) ; const queryString = require( "query-string" ) ; // -------------------------------------------------------------------- export default class App extends React.Component { constructor( props ) { // initialize the App super( props ) ; this.state = { searchResults: [], searchSeqNo: 0, modalForm: null, askDialog: null, startupTasks: [ "caches.publishers", "caches.publications", "caches.authors", "caches.scenarios", "caches.tags" ], } ; // initialize this.args = queryString.parse( window.location.search ) ; this._storeMsgs = this.isTestMode() && this.args.store_msgs ; this._fakeUploads = this.isTestMode() && this.args.fake_uploads ; // figure out the base URL of the Flask backend server // NOTE: We allow the caller to do this since the test suite will usually spin up // it's own Flask server, but talks to an existing React server, so we need some way // for pytest to change which Flask server the React frontend code should tak to. this._flaskBaseUrl = this.isTestMode() ? this.args._flask : null ; if ( ! this._flaskBaseUrl ) this._flaskBaseUrl = process.env.REACT_APP_FLASK_URL ; } render() { let content ; if ( this.state.startupTasks.length > 0 ) { // we are still starting up content =
Loading...
; } else { // generate the main page content = (
) ; } return (
{content} { this.state.modalForm !== null && } { this.state.askDialog !== null && } { this._storeMsgs &&