mirror of
https://github.com/usatiuk/writer.git
synced 2025-10-29 00:17:48 +01:00
show a simple 404 page
This commit is contained in:
@@ -8,6 +8,7 @@ import { Dispatch } from "redux";
|
|||||||
import { IDocumentJSON } from "~../../src/entity/Document";
|
import { IDocumentJSON } from "~../../src/entity/Document";
|
||||||
import { showDeletionToast } from "~AppToaster";
|
import { showDeletionToast } from "~AppToaster";
|
||||||
import { LoadingStub } from "~LoadingStub";
|
import { LoadingStub } from "~LoadingStub";
|
||||||
|
import { NotFound } from "~NotFound";
|
||||||
import {
|
import {
|
||||||
deleteDocCancel,
|
deleteDocCancel,
|
||||||
deleteDocStart,
|
deleteDocStart,
|
||||||
@@ -59,7 +60,9 @@ export class DocumentEditComponent extends React.PureComponent<
|
|||||||
public render() {
|
public render() {
|
||||||
if (this.state.loaded) {
|
if (this.state.loaded) {
|
||||||
const doc = this.props.allDocs[this.state.id];
|
const doc = this.props.allDocs[this.state.id];
|
||||||
|
if (!doc) {
|
||||||
|
return <NotFound />;
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<div className="document">
|
<div className="document">
|
||||||
<div className="documentHeader">
|
<div className="documentHeader">
|
||||||
@@ -165,17 +168,11 @@ export class DocumentEditComponent extends React.PureComponent<
|
|||||||
this.props.fetchDocs();
|
this.props.fetchDocs();
|
||||||
} else {
|
} else {
|
||||||
const { id } = this.props.match.params as any;
|
const { id } = this.props.match.params as any;
|
||||||
if (
|
if (!this.state.loaded && this.props.allDocs) {
|
||||||
!this.state.loaded &&
|
|
||||||
this.props.allDocs &&
|
|
||||||
this.props.allDocs[id]
|
|
||||||
) {
|
|
||||||
const doc = this.props.allDocs[id];
|
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
...this.state,
|
...this.state,
|
||||||
loaded: true,
|
loaded: true,
|
||||||
id: doc.id,
|
id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { RouteComponentProps, withRouter } from "react-router";
|
|||||||
import { Dispatch } from "redux";
|
import { Dispatch } from "redux";
|
||||||
import { IDocumentJSON } from "~../../src/entity/Document";
|
import { IDocumentJSON } from "~../../src/entity/Document";
|
||||||
import { LoadingStub } from "~LoadingStub";
|
import { LoadingStub } from "~LoadingStub";
|
||||||
|
import { NotFound } from "~NotFound";
|
||||||
import { fetchDocsStart } from "~redux/docs/actions";
|
import { fetchDocsStart } from "~redux/docs/actions";
|
||||||
import { IAppState } from "~redux/reducers";
|
import { IAppState } from "~redux/reducers";
|
||||||
import { CodeBlock } from "./CodeBlock";
|
import { CodeBlock } from "./CodeBlock";
|
||||||
@@ -27,8 +28,12 @@ export class DocumentViewComponent extends React.PureComponent<
|
|||||||
> {
|
> {
|
||||||
public render() {
|
public render() {
|
||||||
const { id } = this.props.match.params as any;
|
const { id } = this.props.match.params as any;
|
||||||
if (this.props.allDocs && this.props.allDocs[id]) {
|
if (this.props.allDocs) {
|
||||||
const doc = this.props.allDocs[id];
|
const doc = this.props.allDocs[id];
|
||||||
|
if (!doc) {
|
||||||
|
return <NotFound />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="document">
|
<div className="document">
|
||||||
<div className="documentHeader">
|
<div className="documentHeader">
|
||||||
|
|||||||
@@ -58,11 +58,13 @@ export class HomeComponent extends React.PureComponent<IHomeProps> {
|
|||||||
|
|
||||||
if ((this.props.match.params as any).id && this.props.allDocs) {
|
if ((this.props.match.params as any).id && this.props.allDocs) {
|
||||||
const { id } = this.props.match.params as any;
|
const { id } = this.props.match.params as any;
|
||||||
breadcrumbs.push({
|
if (this.props.allDocs[id]) {
|
||||||
icon: "document",
|
breadcrumbs.push({
|
||||||
text: this.props.allDocs[id].name,
|
icon: "document",
|
||||||
onClick: () => this.props.history.push(`/docs/${id}`),
|
text: this.props.allDocs[id].name,
|
||||||
});
|
onClick: () => this.props.history.push(`/docs/${id}`),
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -82,8 +84,8 @@ export class HomeComponent extends React.PureComponent<IHomeProps> {
|
|||||||
{this.props.uploading || this.props.dirty ? (
|
{this.props.uploading || this.props.dirty ? (
|
||||||
<Spinner size={20} />
|
<Spinner size={20} />
|
||||||
) : (
|
) : (
|
||||||
<Icon icon="saved" />
|
<Icon icon="saved" />
|
||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
<Popover
|
<Popover
|
||||||
target={
|
target={
|
||||||
@@ -158,12 +160,12 @@ export class HomeComponent extends React.PureComponent<IHomeProps> {
|
|||||||
onClick={this.props.dispatchToggleDarkMode}
|
onClick={this.props.dispatchToggleDarkMode}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Menu.Item
|
<Menu.Item
|
||||||
icon="moon"
|
icon="moon"
|
||||||
text="Dark Mode"
|
text="Dark Mode"
|
||||||
onClick={this.props.dispatchToggleDarkMode}
|
onClick={this.props.dispatchToggleDarkMode}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Menu>
|
</Menu>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
5
frontend/src/NotFound.tsx
Normal file
5
frontend/src/NotFound.tsx
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import * as React from "react";
|
||||||
|
|
||||||
|
export function NotFound() {
|
||||||
|
return <div>404</div>;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user