chore: Missing flow types
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import * as React from "react";
|
||||
import { observable, action } from "mobx";
|
||||
import { observer, inject } from "mobx-react";
|
||||
import type { RouterHistory } from "react-router-dom";
|
||||
import { type RouterHistory, type Match } from "react-router-dom";
|
||||
import styled from "styled-components";
|
||||
import { Waypoint } from "react-waypoint";
|
||||
import ArrowKeyNavigation from "boundless-arrow-key-navigation";
|
||||
@@ -17,7 +17,7 @@ import Revision from "./components/Revision";
|
||||
import { documentHistoryUrl } from "utils/routeHelpers";
|
||||
|
||||
type Props = {
|
||||
match: Object,
|
||||
match: Match,
|
||||
documents: DocumentsStore,
|
||||
revisions: RevisionsStore,
|
||||
history: RouterHistory,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import * as React from "react";
|
||||
import { observable } from "mobx";
|
||||
import { observer, inject } from "mobx-react";
|
||||
import { withRouter, type RouterHistory } from "react-router-dom";
|
||||
import { withRouter, type RouterHistory, type Match } from "react-router-dom";
|
||||
import { createGlobalStyle } from "styled-components";
|
||||
import invariant from "invariant";
|
||||
import importFile from "utils/importFile";
|
||||
@@ -22,7 +22,7 @@ type Props = {
|
||||
documents: DocumentsStore,
|
||||
disabled: boolean,
|
||||
location: Object,
|
||||
match: Object,
|
||||
match: Match,
|
||||
history: RouterHistory,
|
||||
staticContext: Object,
|
||||
};
|
||||
|
||||
@@ -29,9 +29,9 @@ function HoverPreview({ node, documents, onClose, event }: Props) {
|
||||
const slug = parseDocumentSlugFromUrl(node.href);
|
||||
|
||||
const [isVisible, setVisible] = React.useState(false);
|
||||
const timerClose = React.useRef(null);
|
||||
const timerOpen = React.useRef(null);
|
||||
const cardRef = React.useRef(null);
|
||||
const timerClose = React.useRef();
|
||||
const timerOpen = React.useRef();
|
||||
const cardRef = React.useRef();
|
||||
|
||||
const startCloseTimer = () => {
|
||||
stopOpenTimer();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// @flow
|
||||
import * as React from "react";
|
||||
import { Switch, Route, Redirect } from "react-router-dom";
|
||||
import { Switch, Route, Redirect, type Match } from "react-router-dom";
|
||||
import Login from "scenes/Login";
|
||||
import Dashboard from "scenes/Dashboard";
|
||||
import Starred from "scenes/Starred";
|
||||
@@ -32,8 +32,12 @@ import Authenticated from "components/Authenticated";
|
||||
import { matchDocumentSlug as slug } from "utils/routeHelpers";
|
||||
|
||||
const NotFound = () => <Search notFound />;
|
||||
const RedirectDocument = ({ match }: { match: Object }) => (
|
||||
<Redirect to={`/doc/${match.params.documentSlug}`} />
|
||||
const RedirectDocument = ({ match }: { match: Match }) => (
|
||||
<Redirect
|
||||
to={
|
||||
match.params.documentSlug ? `/doc/${match.params.documentSlug}` : "/home"
|
||||
}
|
||||
/>
|
||||
);
|
||||
|
||||
export default function Routes() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import * as React from "react";
|
||||
import { observable } from "mobx";
|
||||
import { observer, inject } from "mobx-react";
|
||||
import { Redirect, Link, Switch, Route } from "react-router-dom";
|
||||
import { Redirect, Link, Switch, Route, type Match } from "react-router-dom";
|
||||
|
||||
import styled, { withTheme } from "styled-components";
|
||||
import { NewDocumentIcon, PlusIcon, PinIcon } from "outline-icons";
|
||||
@@ -43,7 +43,7 @@ type Props = {
|
||||
documents: DocumentsStore,
|
||||
collections: CollectionsStore,
|
||||
policies: PoliciesStore,
|
||||
match: Object,
|
||||
match: Match,
|
||||
theme: Object,
|
||||
};
|
||||
|
||||
@@ -56,12 +56,17 @@ class CollectionScene extends React.Component<Props> {
|
||||
@observable redirectTo: ?string;
|
||||
|
||||
componentDidMount() {
|
||||
this.loadContent(this.props.match.params.id);
|
||||
const { id } = this.props.match.params;
|
||||
if (id) {
|
||||
this.loadContent(id);
|
||||
}
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (nextProps.match.params.id !== this.props.match.params.id) {
|
||||
this.loadContent(nextProps.match.params.id);
|
||||
const { id } = nextProps.match.params;
|
||||
|
||||
if (id && id !== this.props.match.params.id) {
|
||||
this.loadContent(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +116,7 @@ class CollectionScene extends React.Component<Props> {
|
||||
|
||||
renderActions() {
|
||||
const { match, policies } = this.props;
|
||||
const can = policies.abilities(match.params.id);
|
||||
const can = policies.abilities(match.params.id || "");
|
||||
|
||||
return (
|
||||
<Actions align="center" justify="flex-end">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import * as React from "react";
|
||||
import invariant from "invariant";
|
||||
import { withRouter } from "react-router-dom";
|
||||
import type { Location, RouterHistory } from "react-router-dom";
|
||||
import type { Location, RouterHistory, Match } from "react-router-dom";
|
||||
import { observable } from "mobx";
|
||||
import { observer, inject } from "mobx-react";
|
||||
import { matchDocumentEdit, updateDocumentUrl } from "utils/routeHelpers";
|
||||
@@ -22,7 +22,7 @@ import UiStore from "stores/UiStore";
|
||||
import { OfflineError } from "utils/errors";
|
||||
|
||||
type Props = {|
|
||||
match: Object,
|
||||
match: Match,
|
||||
location: Location,
|
||||
shares: SharesStore,
|
||||
documents: DocumentsStore,
|
||||
|
||||
@@ -6,7 +6,7 @@ import breakpoint from "styled-components-breakpoint";
|
||||
import { observable } from "mobx";
|
||||
import { observer, inject } from "mobx-react";
|
||||
import { Prompt, Route, withRouter } from "react-router-dom";
|
||||
import type { Location, RouterHistory } from "react-router-dom";
|
||||
import type { Location, RouterHistory, Match } from "react-router-dom";
|
||||
import keydown from "react-keydown";
|
||||
import { InputIcon } from "outline-icons";
|
||||
import Flex from "components/Flex";
|
||||
@@ -52,7 +52,7 @@ Are you sure you want to discard them?
|
||||
`;
|
||||
|
||||
type Props = {
|
||||
match: Object,
|
||||
match: Match,
|
||||
history: RouterHistory,
|
||||
location: Location,
|
||||
abilities: Object,
|
||||
@@ -322,10 +322,12 @@ class DocumentScene extends React.Component<Props> {
|
||||
let url;
|
||||
if (this.props.document.url) {
|
||||
url = this.props.document.url;
|
||||
} else {
|
||||
} else if (this.props.match.params.id) {
|
||||
url = collectionUrl(this.props.match.params.id);
|
||||
}
|
||||
this.props.history.push(url);
|
||||
if (url) {
|
||||
this.props.history.push(url);
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
import * as React from "react";
|
||||
import { inject } from "mobx-react";
|
||||
import queryString from "query-string";
|
||||
import type { RouterHistory, Location } from "react-router-dom";
|
||||
import {
|
||||
type RouterHistory,
|
||||
type Location,
|
||||
type Match,
|
||||
} from "react-router-dom";
|
||||
import Flex from "components/Flex";
|
||||
import CenteredContent from "components/CenteredContent";
|
||||
import LoadingPlaceholder from "components/LoadingPlaceholder";
|
||||
@@ -15,7 +19,7 @@ type Props = {
|
||||
location: Location,
|
||||
documents: DocumentsStore,
|
||||
ui: UiStore,
|
||||
match: Object,
|
||||
match: Match,
|
||||
};
|
||||
|
||||
class DocumentNew extends React.Component<Props> {
|
||||
|
||||
@@ -4,7 +4,7 @@ import ReactDOM from "react-dom";
|
||||
import keydown from "react-keydown";
|
||||
import { Waypoint } from "react-waypoint";
|
||||
import { withRouter, Link } from "react-router-dom";
|
||||
import type { Location, RouterHistory } from "react-router-dom";
|
||||
import type { Location, RouterHistory, Match } from "react-router-dom";
|
||||
import { PlusIcon } from "outline-icons";
|
||||
import { observable, action } from "mobx";
|
||||
import { observer, inject } from "mobx-react";
|
||||
@@ -37,7 +37,7 @@ import DateFilter from "./components/DateFilter";
|
||||
|
||||
type Props = {
|
||||
history: RouterHistory,
|
||||
match: Object,
|
||||
match: Match,
|
||||
location: Location,
|
||||
documents: DocumentsStore,
|
||||
users: UsersStore,
|
||||
|
||||
@@ -3,6 +3,7 @@ import * as React from "react";
|
||||
import { observable, action } from "mobx";
|
||||
import { observer, inject } from "mobx-react";
|
||||
import { Waypoint } from "react-waypoint";
|
||||
import { type Match } from "react-router-dom";
|
||||
|
||||
import { DEFAULT_PAGINATION_LIMIT } from "stores/BaseStore";
|
||||
import EventsStore from "stores/EventsStore";
|
||||
@@ -17,7 +18,7 @@ import EventListItem from "./components/EventListItem";
|
||||
|
||||
type Props = {
|
||||
events: EventsStore,
|
||||
match: Object,
|
||||
match: Match,
|
||||
};
|
||||
|
||||
@observer
|
||||
|
||||
@@ -4,6 +4,7 @@ import invariant from "invariant";
|
||||
import { observable } from "mobx";
|
||||
import { observer, inject } from "mobx-react";
|
||||
import { PlusIcon } from "outline-icons";
|
||||
import { type Match } from "react-router-dom";
|
||||
|
||||
import Empty from "components/Empty";
|
||||
import { ListPlaceholder } from "components/LoadingPlaceholder";
|
||||
@@ -27,7 +28,7 @@ type Props = {
|
||||
auth: AuthStore,
|
||||
groups: GroupsStore,
|
||||
policies: PoliciesStore,
|
||||
match: Object,
|
||||
match: Match,
|
||||
};
|
||||
|
||||
@observer
|
||||
|
||||
@@ -4,6 +4,7 @@ import invariant from "invariant";
|
||||
import { observable } from "mobx";
|
||||
import { observer, inject } from "mobx-react";
|
||||
import { PlusIcon } from "outline-icons";
|
||||
import { type Match } from "react-router-dom";
|
||||
|
||||
import Empty from "components/Empty";
|
||||
import Modal from "components/Modal";
|
||||
@@ -25,7 +26,7 @@ type Props = {
|
||||
auth: AuthStore,
|
||||
users: UsersStore,
|
||||
policies: PoliciesStore,
|
||||
match: Object,
|
||||
match: Match,
|
||||
};
|
||||
|
||||
@observer
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// @flow
|
||||
import * as React from "react";
|
||||
import { observer, inject } from "mobx-react";
|
||||
import { type Match } from "react-router-dom";
|
||||
|
||||
import CenteredContent from "components/CenteredContent";
|
||||
import Empty from "components/Empty";
|
||||
@@ -16,7 +17,7 @@ import DocumentsStore from "stores/DocumentsStore";
|
||||
|
||||
type Props = {
|
||||
documents: DocumentsStore,
|
||||
match: Object,
|
||||
match: Match,
|
||||
};
|
||||
|
||||
@observer
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// @flow
|
||||
import * as React from "react";
|
||||
import { observer, inject } from "mobx-react";
|
||||
import { type Match } from "react-router-dom";
|
||||
|
||||
import CenteredContent from "components/CenteredContent";
|
||||
import Empty from "components/Empty";
|
||||
@@ -15,7 +16,7 @@ import DocumentsStore from "stores/DocumentsStore";
|
||||
|
||||
type Props = {
|
||||
documents: DocumentsStore,
|
||||
match: Object,
|
||||
match: Match,
|
||||
};
|
||||
|
||||
@observer
|
||||
|
||||
Reference in New Issue
Block a user