hedgedoc/src/index.tsx

97 lines
3.6 KiB
TypeScript
Raw Normal View History

/*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import React from 'react'
import ReactDOM from 'react-dom'
import { Provider } from 'react-redux'
2020-05-29 13:44:45 +00:00
import { BrowserRouter as Router, Redirect, Route, Switch } from 'react-router-dom'
import { ApplicationLoader } from './components/application-loader/application-loader'
import { NotFoundErrorScreen } from './components/common/routing/not-found-error-screen'
import { Redirector } from './components/common/routing/redirector'
import { ErrorBoundary } from './components/error-boundary/error-boundary'
import { HistoryPage } from './components/history-page/history-page'
import { IntroPage } from './components/intro-page/intro-page'
import { LandingLayout } from './components/landing-layout/landing-layout'
import { LoginPage } from './components/login-page/login-page'
import { ProfilePage } from './components/profile-page/profile-page'
import { RegisterPage } from './components/register-page/register-page'
import { store } from './redux'
import * as serviceWorkerRegistration from './service-worker-registration'
2020-09-13 16:04:02 +00:00
import './style/dark.scss'
2020-09-26 07:54:17 +00:00
import './style/index.scss'
import { isTestMode } from './utils/test-modes'
2020-09-26 07:54:17 +00:00
const EditorPage = React.lazy(() => import(/* webpackPrefetch: true *//* webpackChunkName: "editor" */ './components/editor-page/editor-page'))
const RenderPage = React.lazy(() => import (/* webpackPrefetch: true *//* webpackChunkName: "renderPage" */ './components/render-page/render-page'))
const DocumentReadOnlyPage = React.lazy(() => import (/* webpackPrefetch: true *//* webpackChunkName: "documentReadOnly" */ './components/document-read-only-page/document-read-only-page'))
Restructures + New Evironment Variables (#1230) * Use document base uri for react router Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Rename getAndSetUser to fetchAndSetUser Getter should be reserved for simple get functions. Everything that does a bit more logic should use a more meaningful verb. Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Rename getFrontPageContent to fetchFrontPageContent Getter should be reserved for simple get functions. Everything that does a bit more logic should use a more meaningful verb. Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Reformat code Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Use PUBLIC_URL env var in index.html Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Introduce new environment variables For better testing (especially if you have multiple endpoints) this commit introduces REACT_APP_BACKEND_BASE_URL, REACT_APP_FRONTEND_ASSETS_URL and REACT_APP_CUSTOMIZE_ASSETS_URL Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Remove redundant license information Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Remove redundant license information Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Fix rebase issues Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Remove unused file Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Correct parameter Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Fix run tasks Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Force use of bash Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Fix link to cypress picture Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * revert change Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * fix url Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Remove license info Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Revert rebase issues Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Add missing banner code Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Fix test url Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Useless change to trigger github Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Don't set backend base url because this break the mock mode detection Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> Co-authored-by: Philip Molares <philip.molares@udo.edu>
2021-05-02 20:38:43 +00:00
const baseUrl = new URL(document.head.baseURI).pathname
Frontend config and Loader component (#12) * Add FrontendConfig and Loader Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Merge more setup into the application loader Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Rename config files Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Remove blank line Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Fix url Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Make strings more specific Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Restructure store use Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * split methods and actions Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * extract code Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * remove actions.ts Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * add reason and rename component Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * remove unused call Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Use redux store in api Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * activate email in backend config Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * add new line Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * reduce code Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Make error more specific Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Use expectedResponseCode Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Update src/redux/backend-config/types.ts Co-authored-by: Philip Molares <git@molar.es> * Update src/components/application-loader/application-loader.tsx Co-authored-by: Philip Molares <git@molar.es> * Update src/components/application-loader/application-loader.tsx Co-authored-by: Philip Molares <git@molar.es> * Update src/components/application-loader/application-loader.tsx Co-authored-by: Philip Molares <git@molar.es> * Use fragment Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> Co-authored-by: Philip Molares <git@molar.es>
2020-05-15 21:10:12 +00:00
ReactDOM.render(
<Provider store={ store }>
Restructures + New Evironment Variables (#1230) * Use document base uri for react router Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Rename getAndSetUser to fetchAndSetUser Getter should be reserved for simple get functions. Everything that does a bit more logic should use a more meaningful verb. Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Rename getFrontPageContent to fetchFrontPageContent Getter should be reserved for simple get functions. Everything that does a bit more logic should use a more meaningful verb. Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Reformat code Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Use PUBLIC_URL env var in index.html Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Introduce new environment variables For better testing (especially if you have multiple endpoints) this commit introduces REACT_APP_BACKEND_BASE_URL, REACT_APP_FRONTEND_ASSETS_URL and REACT_APP_CUSTOMIZE_ASSETS_URL Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Remove redundant license information Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Remove redundant license information Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Fix rebase issues Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Remove unused file Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Correct parameter Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Fix run tasks Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Force use of bash Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Fix link to cypress picture Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * revert change Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * fix url Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Remove license info Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Revert rebase issues Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Add missing banner code Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Fix test url Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Useless change to trigger github Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Don't set backend base url because this break the mock mode detection Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> Co-authored-by: Philip Molares <philip.molares@udo.edu>
2021-05-02 20:38:43 +00:00
<Router basename={ baseUrl }>
2020-05-29 13:44:45 +00:00
<ApplicationLoader>
<ErrorBoundary>
<Switch>
<Route path="/history">
<LandingLayout>
<HistoryPage/>
</LandingLayout>
</Route>
<Route path="/intro">
<LandingLayout>
<IntroPage/>
</LandingLayout>
</Route>
<Route path="/login">
<LandingLayout>
<LoginPage/>
</LandingLayout>
</Route>
<Route path="/register">
<LandingLayout>
<RegisterPage/>
</LandingLayout>
</Route>
<Route path="/profile">
<LandingLayout>
<ProfilePage/>
</LandingLayout>
</Route>
<Route path="/render">
<RenderPage/>
</Route>
<Route path="/n/:id">
<EditorPage/>
</Route>
<Route path="/s/:id">
<DocumentReadOnlyPage/>
</Route>
<Route path="/:id">
<Redirector/>
</Route>
<Route path="/">
<Redirect to="/intro"/>
</Route>
<Route>
<NotFoundErrorScreen/>
</Route>
</Switch>
</ErrorBoundary>
2020-05-29 13:44:45 +00:00
</ApplicationLoader>
</Router>
</Provider>
, document.getElementById('root')
)
if (isTestMode()) {
console.log('This build runs in test mode. This means:\n - no sandboxed iframe')
}
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorkerRegistration.unregister()