kopia lustrzana https://github.com/fediversespace/fediverse.space
prep for react-router v6
rodzic
1ccb2a84a1
commit
4cdd03dd6c
13
README.md
13
README.md
|
@ -82,14 +82,19 @@ You don't have to follow these instructions, but it's one way to set up a contin
|
||||||
- `dokku elasticsearch:create fediverse`
|
- `dokku elasticsearch:create fediverse`
|
||||||
- `dokku elasticsearch:link fediverse phoenix`
|
- `dokku elasticsearch:link fediverse phoenix`
|
||||||
|
|
||||||
6. Update the backend configuration. In particular, change the `user_agent` in [config.exs](/backend/config/config.exs) to something descriptive.
|
6. Set the build dirs
|
||||||
7. Push the apps, e.g. `git push dokku@<DOMAIN>:phoenix` (note that the first push cannot be from the CD pipeline).
|
|
||||||
8. Set up SSL for the Phoenix app
|
- `dokku builder:set phoenix build-dir backend`
|
||||||
|
- `dokku builder:set gephi build-dir gephi`
|
||||||
|
|
||||||
|
7. Update the backend configuration. In particular, change the `user_agent` in [config.exs](/backend/config/config.exs) to something descriptive.
|
||||||
|
8. Push the apps, e.g. `git push dokku@<DOMAIN>:phoenix` (note that the first push cannot be from the CD pipeline).
|
||||||
|
9. Set up SSL for the Phoenix app
|
||||||
|
|
||||||
- `dokku letsencrypt:enable phoenix`
|
- `dokku letsencrypt:enable phoenix`
|
||||||
- `dokku letsencrypt:cron-job --add`
|
- `dokku letsencrypt:cron-job --add`
|
||||||
|
|
||||||
9. Set up a cron job for the graph layout (use the `dokku` user). E.g.
|
10. Set up a cron job for the graph layout (use the `dokku` user). E.g.
|
||||||
|
|
||||||
```
|
```
|
||||||
SHELL=/bin/bash
|
SHELL=/bin/bash
|
||||||
|
|
|
@ -3,7 +3,7 @@ import React from "react";
|
||||||
import { Classes } from "@blueprintjs/core";
|
import { Classes } from "@blueprintjs/core";
|
||||||
|
|
||||||
import { ConnectedRouter } from "connected-react-router";
|
import { ConnectedRouter } from "connected-react-router";
|
||||||
import { Route } from "react-router-dom";
|
import { Route, Switch } from "react-router-dom";
|
||||||
import { Nav } from "./components/organisms";
|
import { Nav } from "./components/organisms";
|
||||||
import {
|
import {
|
||||||
AboutScreen,
|
AboutScreen,
|
||||||
|
@ -20,11 +20,23 @@ const AppRouter: React.FC = () => (
|
||||||
<div className={`${Classes.DARK} App`}>
|
<div className={`${Classes.DARK} App`}>
|
||||||
<Nav />
|
<Nav />
|
||||||
<main role="main">
|
<main role="main">
|
||||||
<Route path="/instances" exact component={TableScreen} />
|
<Switch>
|
||||||
<Route path="/about" exact component={AboutScreen} />
|
<Route path="/instances" exact>
|
||||||
<Route path="/admin/login" exact component={LoginScreen} />
|
<TableScreen />
|
||||||
<Route path="/admin/verify" exact component={VerifyLoginScreen} />
|
</Route>
|
||||||
<Route path="/admin" exact component={AdminScreen} />
|
<Route path="/about" exact>
|
||||||
|
<AboutScreen />
|
||||||
|
</Route>
|
||||||
|
<Route path="/admin/login" exact>
|
||||||
|
<LoginScreen />
|
||||||
|
</Route>
|
||||||
|
<Route path="/admin/verify" exact>
|
||||||
|
<VerifyLoginScreen />
|
||||||
|
</Route>
|
||||||
|
<Route path="/admin" exact>
|
||||||
|
<AdminScreen />
|
||||||
|
</Route>
|
||||||
|
</Switch>
|
||||||
{/* We always want the GraphScreen to be rendered (since un- and re-mounting it is expensive */}
|
{/* We always want the GraphScreen to be rendered (since un- and re-mounting it is expensive */}
|
||||||
<GraphScreen />
|
<GraphScreen />
|
||||||
</main>
|
</main>
|
||||||
|
|
|
@ -3,13 +3,15 @@ import { connect } from "react-redux";
|
||||||
import { Dispatch } from "redux";
|
import { Dispatch } from "redux";
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
|
|
||||||
import { Route, RouteComponentProps, Switch, withRouter } from "react-router";
|
import { Route, Switch } from "react-router";
|
||||||
import { InstanceScreen, SearchScreen } from ".";
|
import { InstanceScreen, SearchScreen } from ".";
|
||||||
import { INSTANCE_DOMAIN_PATH } from "../../constants";
|
import { INSTANCE_DOMAIN_PATH } from "../../constants";
|
||||||
import { loadInstance } from "../../redux/actions";
|
import { loadInstance } from "../../redux/actions";
|
||||||
import { AppState } from "../../redux/types";
|
import { AppState } from "../../redux/types";
|
||||||
import { domainMatchSelector, isSmallScreen } from "../../util";
|
import { domainMatchSelector, isSmallScreen } from "../../util";
|
||||||
import { Graph, SidebarContainer } from "../organisms";
|
import { Graph, SidebarContainer } from "../organisms";
|
||||||
|
import { useLocation } from "react-router-dom";
|
||||||
|
import type { Location } from "history";
|
||||||
|
|
||||||
const GraphContainer = styled.div`
|
const GraphContainer = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -24,7 +26,8 @@ const FullDiv = styled.div`
|
||||||
right: 0;
|
right: 0;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
interface GraphScreenProps extends RouteComponentProps {
|
interface GraphScreenProps {
|
||||||
|
location: Location;
|
||||||
currentInstanceName: string | null;
|
currentInstanceName: string | null;
|
||||||
pathname: string;
|
pathname: string;
|
||||||
graphLoadError: boolean;
|
graphLoadError: boolean;
|
||||||
|
@ -79,8 +82,12 @@ class GraphScreenImpl extends React.Component<GraphScreenProps, GraphScreenState
|
||||||
{isSmallScreen || !this.state.hasBeenViewed || <Graph />}
|
{isSmallScreen || !this.state.hasBeenViewed || <Graph />}
|
||||||
<SidebarContainer>
|
<SidebarContainer>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path={INSTANCE_DOMAIN_PATH} component={InstanceScreen} />
|
<Route path={INSTANCE_DOMAIN_PATH}>
|
||||||
<Route exact path="/" component={SearchScreen} />
|
<InstanceScreen />
|
||||||
|
</Route>
|
||||||
|
<Route exact path="/">
|
||||||
|
<SearchScreen />
|
||||||
|
</Route>
|
||||||
</Switch>
|
</Switch>
|
||||||
</SidebarContainer>
|
</SidebarContainer>
|
||||||
</GraphContainer>
|
</GraphContainer>
|
||||||
|
@ -106,4 +113,9 @@ const mapDispatchToProps = (dispatch: Dispatch) => ({
|
||||||
loadInstance: (domain: string | null) => dispatch(loadInstance(domain) as any),
|
loadInstance: (domain: string | null) => dispatch(loadInstance(domain) as any),
|
||||||
});
|
});
|
||||||
const GraphScreen = connect(mapStateToProps, mapDispatchToProps)(GraphScreenImpl);
|
const GraphScreen = connect(mapStateToProps, mapDispatchToProps)(GraphScreenImpl);
|
||||||
export default withRouter(GraphScreen);
|
const Component = (props: Omit<React.ComponentProps<typeof GraphScreen>, "location">) => {
|
||||||
|
const location = useLocation();
|
||||||
|
return <GraphScreen {...props} location={location} />;
|
||||||
|
};
|
||||||
|
Component.displayName = "GraphScreen";
|
||||||
|
export default Component;
|
||||||
|
|
Ładowanie…
Reference in New Issue