refactor: flow typing (#1012)

* fix: padding

* fix: Minor button alignment issues

* feat: Add icon to invite people button

* WIP
This commit is contained in:
Tom Moor
2019-08-08 23:09:09 -07:00
committed by GitHub
parent 7b2eea0009
commit d024d31f66
64 changed files with 207 additions and 144 deletions

View File

@@ -2,7 +2,7 @@
import * as React from 'react';
import { observable } from 'mobx';
import { inject, observer } from 'mobx-react';
import { withRouter } from 'react-router-dom';
import { withRouter, type RouterHistory } from 'react-router-dom';
import styled from 'styled-components';
import { MoreIcon } from 'outline-icons';
import Modal from 'components/Modal';
@@ -22,7 +22,7 @@ type Props = {
ui: UiStore,
documents: DocumentsStore,
collection: Collection,
history: Object,
history: RouterHistory,
onOpen?: () => void,
onClose?: () => void,
};
@@ -33,20 +33,20 @@ class CollectionMenu extends React.Component<Props> {
@observable permissionsModalOpen: boolean = false;
@observable redirectTo: ?string;
onNewDocument = (ev: SyntheticEvent<*>) => {
onNewDocument = (ev: SyntheticEvent<>) => {
ev.preventDefault();
const { collection } = this.props;
this.props.history.push(newDocumentUrl(collection.id));
};
onImportDocument = (ev: SyntheticEvent<*>) => {
onImportDocument = (ev: SyntheticEvent<>) => {
ev.preventDefault();
// simulate a click on the file upload input element
if (this.file) this.file.click();
};
onFilePicked = async (ev: SyntheticEvent<*>) => {
onFilePicked = async (ev: SyntheticEvent<>) => {
const files = getDataTransferFiles(ev);
try {
@@ -61,25 +61,25 @@ class CollectionMenu extends React.Component<Props> {
}
};
onEdit = (ev: SyntheticEvent<*>) => {
onEdit = (ev: SyntheticEvent<>) => {
ev.preventDefault();
const { collection } = this.props;
this.props.ui.setActiveModal('collection-edit', { collection });
};
onDelete = (ev: SyntheticEvent<*>) => {
onDelete = (ev: SyntheticEvent<>) => {
ev.preventDefault();
const { collection } = this.props;
this.props.ui.setActiveModal('collection-delete', { collection });
};
onExport = (ev: SyntheticEvent<*>) => {
onExport = (ev: SyntheticEvent<>) => {
ev.preventDefault();
const { collection } = this.props;
this.props.ui.setActiveModal('collection-export', { collection });
};
onPermissions = (ev: SyntheticEvent<*>) => {
onPermissions = (ev: SyntheticEvent<>) => {
ev.preventDefault();
this.permissionsModalOpen = true;
};

View File

@@ -40,12 +40,12 @@ class DocumentMenu extends React.Component<Props> {
this.redirectTo = undefined;
}
handleNewChild = (ev: SyntheticEvent<*>) => {
handleNewChild = (ev: SyntheticEvent<>) => {
const { document } = this.props;
this.redirectTo = newDocumentUrl(document.collectionId, document.id);
};
handleDelete = (ev: SyntheticEvent<*>) => {
handleDelete = (ev: SyntheticEvent<>) => {
const { document } = this.props;
this.props.ui.setActiveModal('document-delete', { document });
};
@@ -54,15 +54,15 @@ class DocumentMenu extends React.Component<Props> {
this.redirectTo = documentHistoryUrl(this.props.document);
};
handleMove = (ev: SyntheticEvent<*>) => {
handleMove = (ev: SyntheticEvent<>) => {
this.redirectTo = documentMoveUrl(this.props.document);
};
handleEdit = (ev: SyntheticEvent<*>) => {
handleEdit = (ev: SyntheticEvent<>) => {
this.redirectTo = documentEditUrl(this.props.document);
};
handleDuplicate = async (ev: SyntheticEvent<*>) => {
handleDuplicate = async (ev: SyntheticEvent<>) => {
const duped = await this.props.document.duplicate();
// when duplicating, go straight to the duplicated document content
@@ -70,37 +70,37 @@ class DocumentMenu extends React.Component<Props> {
this.props.ui.showToast('Document duplicated');
};
handleArchive = async (ev: SyntheticEvent<*>) => {
handleArchive = async (ev: SyntheticEvent<>) => {
await this.props.document.archive();
this.props.ui.showToast('Document archived');
};
handleRestore = async (ev: SyntheticEvent<*>) => {
handleRestore = async (ev: SyntheticEvent<>) => {
await this.props.document.restore();
this.props.ui.showToast('Document restored');
};
handlePin = (ev: SyntheticEvent<*>) => {
handlePin = (ev: SyntheticEvent<>) => {
this.props.document.pin();
};
handleUnpin = (ev: SyntheticEvent<*>) => {
handleUnpin = (ev: SyntheticEvent<>) => {
this.props.document.unpin();
};
handleStar = (ev: SyntheticEvent<*>) => {
handleStar = (ev: SyntheticEvent<>) => {
this.props.document.star();
};
handleUnstar = (ev: SyntheticEvent<*>) => {
handleUnstar = (ev: SyntheticEvent<>) => {
this.props.document.unstar();
};
handleExport = (ev: SyntheticEvent<*>) => {
handleExport = (ev: SyntheticEvent<>) => {
this.props.document.download();
};
handleShareLink = async (ev: SyntheticEvent<*>) => {
handleShareLink = async (ev: SyntheticEvent<>) => {
const { document } = this.props;
if (!document.shareUrl) await document.share();

View File

@@ -1,6 +1,6 @@
// @flow
import * as React from 'react';
import { withRouter } from 'react-router-dom';
import { withRouter, type RouterHistory } from 'react-router-dom';
import { inject } from 'mobx-react';
import { MoreIcon } from 'outline-icons';
@@ -13,9 +13,9 @@ import UiStore from 'stores/UiStore';
type Props = {
label?: React.Node,
onOpen?: () => *,
onClose: () => *,
history: Object,
onOpen?: () => void,
onClose: () => void,
history: RouterHistory,
document: Document,
revision: Revision,
className?: string,
@@ -23,7 +23,7 @@ type Props = {
};
class RevisionMenu extends React.Component<Props> {
handleRestore = async (ev: SyntheticEvent<*>) => {
handleRestore = async (ev: SyntheticEvent<>) => {
ev.preventDefault();
await this.props.document.restore(this.props.revision);
this.props.ui.showToast('Document restored');

View File

@@ -13,8 +13,8 @@ import Share from 'models/Share';
type Props = {
label?: React.Node,
onOpen?: () => *,
onClose: () => *,
onOpen?: () => void,
onClose: () => void,
shares: SharesStore,
ui: UiStore,
share: Share,
@@ -28,12 +28,12 @@ class ShareMenu extends React.Component<Props> {
this.redirectTo = undefined;
}
handleGoToDocument = (ev: SyntheticEvent<*>) => {
handleGoToDocument = (ev: SyntheticEvent<>) => {
ev.preventDefault();
this.redirectTo = this.props.share.documentUrl;
};
handleRevoke = (ev: SyntheticEvent<*>) => {
handleRevoke = (ev: SyntheticEvent<>) => {
ev.preventDefault();
this.props.shares.revoke(this.props.share);
this.props.ui.showToast('Share link revoked');

View File

@@ -14,7 +14,7 @@ type Props = {
@observer
class UserMenu extends React.Component<Props> {
handlePromote = (ev: SyntheticEvent<*>) => {
handlePromote = (ev: SyntheticEvent<>) => {
ev.preventDefault();
const { user, users } = this.props;
if (
@@ -29,7 +29,7 @@ class UserMenu extends React.Component<Props> {
users.promote(user);
};
handleDemote = (ev: SyntheticEvent<*>) => {
handleDemote = (ev: SyntheticEvent<>) => {
ev.preventDefault();
const { user, users } = this.props;
if (!window.confirm(`Are you want to make ${user.name} a member?`)) {
@@ -38,7 +38,7 @@ class UserMenu extends React.Component<Props> {
users.demote(user);
};
handleSuspend = (ev: SyntheticEvent<*>) => {
handleSuspend = (ev: SyntheticEvent<>) => {
ev.preventDefault();
const { user, users } = this.props;
if (
@@ -51,7 +51,7 @@ class UserMenu extends React.Component<Props> {
users.suspend(user);
};
handleActivate = (ev: SyntheticEvent<*>) => {
handleActivate = (ev: SyntheticEvent<>) => {
ev.preventDefault();
const { user, users } = this.props;
users.activate(user);