Skip to content

Commit

Permalink
chore: Upgrade flow (outline#1854)
Browse files Browse the repository at this point in the history
* wip: upgrade flow

* chore: More sealed props improvements

* Final fixes
  • Loading branch information
tommoor authored Jan 30, 2021
1 parent ce2b246 commit 32f0589
Show file tree
Hide file tree
Showing 38 changed files with 191 additions and 96 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"javascript.validate.enable": false,
"javascript.format.enable": false,
"typescript.validate.enable": false,
"typescript.format.enable": false,
"editor.formatOnSave": true,
"typescript.format.enable": false
}
8 changes: 6 additions & 2 deletions app/components/Avatar/Avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ import { observable } from "mobx";
import { observer } from "mobx-react";
import * as React from "react";
import styled from "styled-components";
import User from "models/User";
import placeholder from "./placeholder.png";

type Props = {
type Props = {|
src: string,
size: number,
icon?: React.Node,
};
user?: User,
onClick?: () => void,
className?: string,
|};

@observer
class Avatar extends React.Component<Props> {
Expand Down
18 changes: 15 additions & 3 deletions app/components/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ export const Inner = styled.span`
${(props) => props.hasIcon && !props.hasText && "padding: 0 4px;"};
`;

export type Props = {
type?: string,
export type Props = {|
type?: "button" | "submit",
value?: string,
icon?: React.Node,
iconColor?: string,
Expand All @@ -118,9 +118,21 @@ export type Props = {
innerRef?: React.ElementRef<any>,
disclosure?: boolean,
neutral?: boolean,
danger?: boolean,
primary?: boolean,
disabled?: boolean,
fullwidth?: boolean,
autoFocus?: boolean,
style?: Object,
as?: React.ComponentType<any>,
to?: string,
onClick?: (event: SyntheticEvent<>) => mixed,
borderOnHover?: boolean,
};

"data-on"?: string,
"data-event-category"?: string,
"data-event-action"?: string,
|};

function Button({
type = "text",
Expand Down
7 changes: 5 additions & 2 deletions app/components/Checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ import { VisuallyHidden } from "reakit/VisuallyHidden";
import styled from "styled-components";
import HelpText from "components/HelpText";

export type Props = {
export type Props = {|
checked?: boolean,
label?: string,
labelHidden?: boolean,
className?: string,
name?: string,
disabled?: boolean,
onChange: (event: SyntheticInputEvent<HTMLInputElement>) => mixed,
note?: string,
short?: boolean,
small?: boolean,
};
|};

const LabelText = styled.span`
font-weight: 500;
Expand Down
7 changes: 5 additions & 2 deletions app/components/ContextMenu/MenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import * as React from "react";
import { MenuItem as BaseMenuItem } from "reakit/Menu";
import styled from "styled-components";

type Props = {
type Props = {|
onClick?: (SyntheticEvent<>) => void | Promise<void>,
children?: React.Node,
selected?: boolean,
disabled?: boolean,
to?: string,
href?: string,
target?: "_blank",
as?: string | React.ComponentType<*>,
};
|};

const MenuItem = ({
onClick,
Expand Down
9 changes: 7 additions & 2 deletions app/components/DocumentList.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ import * as React from "react";
import Document from "models/Document";
import DocumentListItem from "components/DocumentListItem";

type Props = {
type Props = {|
documents: Document[],
limit?: number,
};
showCollection?: boolean,
showPublished?: boolean,
showPin?: boolean,
showDraft?: boolean,
showTemplate?: boolean,
|};

export default function DocumentList({ limit, documents, ...rest }: Props) {
const items = limit ? documents.splice(0, limit) : documents;
Expand Down
4 changes: 2 additions & 2 deletions app/components/DocumentMeta.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ const Modified = styled.span`
font-weight: ${(props) => (props.highlight ? "600" : "400")};
`;

type Props = {
type Props = {|
showCollection?: boolean,
showPublished?: boolean,
showLastViewed?: boolean,
document: Document,
children: React.Node,
to?: string,
};
|};

function DocumentMeta({
showPublished,
Expand Down
21 changes: 19 additions & 2 deletions app/components/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,31 @@ const RichMarkdownEditor = React.lazy(() => import("rich-markdown-editor"));

const EMPTY_ARRAY = [];

type Props = {
export type Props = {|
id?: string,
value?: string,
defaultValue?: string,
readOnly?: boolean,
grow?: boolean,
disableEmbeds?: boolean,
ui?: UiStore,
};
autoFocus?: boolean,
template?: boolean,
placeholder?: string,
scrollTo?: string,
readOnlyWriteCheckboxes?: boolean,
onBlur?: (event: SyntheticEvent<>) => any,
onFocus?: (event: SyntheticEvent<>) => any,
onPublish?: (event: SyntheticEvent<>) => any,
onSave?: ({ done?: boolean, autosave?: boolean, publish?: boolean }) => any,
onCancel?: () => any,
onChange?: (getValue: () => string) => any,
onSearchLink?: (title: string) => any,
onHoverLink?: (event: MouseEvent) => any,
onCreateLink?: (title: string) => Promise<string>,
onImageUploadStart?: () => any,
onImageUploadStop?: () => any,
|};

type PropsWithRef = Props & {
forwardedRef: React.Ref<any>,
Expand Down
7 changes: 5 additions & 2 deletions app/components/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
import * as React from "react";
import { cdnPath } from "utils/urls";

type Props = {
type Props = {|
alt: string,
src: string,
};
title?: string,
width?: number,
height?: number,
|};

export default function Image({ src, alt, ...rest }: Props) {
return <img src={cdnPath(src)} alt={alt} {...rest} />;
Expand Down
15 changes: 12 additions & 3 deletions app/components/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ export const LabelText = styled.div`
display: inline-block;
`;

export type Props = {
type?: string,
export type Props = {|
type?: "text" | "email" | "checkbox" | "search",
value?: string,
label?: string,
className?: string,
Expand All @@ -85,9 +85,18 @@ export type Props = {
short?: boolean,
margin?: string | number,
icon?: React.Node,
name?: string,
minLength?: number,
maxLength?: number,
autoFocus?: boolean,
autoComplete?: boolean | string,
readOnly?: boolean,
required?: boolean,
placeholder?: string,
onChange?: (ev: SyntheticInputEvent<HTMLInputElement>) => mixed,
onFocus?: (ev: SyntheticEvent<>) => void,
onBlur?: (ev: SyntheticEvent<>) => void,
};
|};

@observer
class Input extends React.Component<Props> {
Expand Down
4 changes: 2 additions & 2 deletions app/components/InputRich.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import Editor from "components/Editor";
import HelpText from "components/HelpText";
import { LabelText, Outline } from "components/Input";

type Props = {
type Props = {|
label: string,
minHeight?: number,
maxHeight?: number,
readOnly?: boolean,
ui: UiStore,
};
|};

@observer
class InputRich extends React.Component<Props> {
Expand Down
2 changes: 2 additions & 0 deletions app/components/InputSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export type Props = {
className?: string,
labelHidden?: boolean,
options: Option[],
onBlur?: () => void,
onFocus?: () => void,
};

@observer
Expand Down
4 changes: 2 additions & 2 deletions app/components/Labeled.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import * as React from "react";
import styled from "styled-components";
import Flex from "components/Flex";

type Props = {
type Props = {|
label: React.Node | string,
children: React.Node,
};
|};

const Labeled = ({ label, children, ...props }: Props) => (
<Flex column {...props}>
Expand Down
6 changes: 3 additions & 3 deletions app/components/Mask.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { randomInteger } from "shared/random";
import { pulsate } from "shared/styles/animations";
import Flex from "components/Flex";

type Props = {
type Props = {|
header?: boolean,
height?: number,
};
|};

class Mask extends React.Component<Props> {
width: number;
Expand All @@ -23,7 +23,7 @@ class Mask extends React.Component<Props> {
}

render() {
return <Redacted width={this.width} {...this.props} />;
return <Redacted width={this.width} />;
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/components/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import Scrollable from "components/Scrollable";

ReactModal.setAppElement("#root");

type Props = {
type Props = {|
children?: React.Node,
isOpen: boolean,
title?: string,
onRequestClose: () => void,
};
|};

const GlobalStyles = createGlobalStyle`
.ReactModal__Overlay {
Expand Down
9 changes: 7 additions & 2 deletions app/components/PaginatedDocumentList.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ import Document from "models/Document";
import DocumentListItem from "components/DocumentListItem";
import PaginatedList from "components/PaginatedList";

type Props = {
type Props = {|
documents: Document[],
fetch: (options: ?Object) => Promise<void>,
options?: Object,
heading?: React.Node,
empty?: React.Node,
};
showCollection?: boolean,
showPublished?: boolean,
showPin?: boolean,
showDraft?: boolean,
showTemplate?: boolean,
|};

@observer
class PaginatedDocumentList extends React.Component<Props> {
Expand Down
5 changes: 3 additions & 2 deletions app/components/Sidebar/components/HeaderBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import styled from "styled-components";
import Flex from "components/Flex";
import TeamLogo from "components/TeamLogo";

type Props = {
type Props = {|
teamName: string,
subheading: React.Node,
showDisclosure?: boolean,
onClick: (event: SyntheticEvent<>) => void,
logoUrl: string,
};
|};

const HeaderBlock = React.forwardRef<Props, any>(
({ showDisclosure, teamName, subheading, logoUrl, ...rest }: Props, ref) => (
Expand Down
7 changes: 5 additions & 2 deletions app/components/Switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ import * as React from "react";
import styled from "styled-components";
import { LabelText } from "components/Input";

type Props = {
type Props = {|
width?: number,
height?: number,
label?: string,
checked?: boolean,
disabled?: boolean,
onChange: (event: SyntheticInputEvent<HTMLInputElement>) => mixed,
id?: string,
};
|};

function Switch({ width = 38, height = 20, label, ...props }: Props) {
const component = (
Expand Down
4 changes: 2 additions & 2 deletions app/components/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import Tippy from "@tippy.js/react";
import * as React from "react";
import styled from "styled-components";

type Props = {
type Props = {|
tooltip: React.Node,
shortcut?: React.Node,
placement?: "top" | "bottom" | "left" | "right",
children: React.Node,
delay?: number,
className?: string,
};
|};

class Tooltip extends React.Component<Props> {
render() {
Expand Down
1 change: 0 additions & 1 deletion app/menus/NewDocumentMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ function NewDocumentMenu() {
as={Link}
to={newDocumentUrl(collections.orderedData[0].id)}
icon={<PlusIcon />}
small
>
{t("New doc")}
</Button>
Expand Down
2 changes: 1 addition & 1 deletion app/models/BaseModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class BaseModel {
this.store = store;
}

save = async (params: ?Object) => {
save = async (params: Object = {}) => {
this.isSaving = true;

try {
Expand Down
Loading

0 comments on commit 32f0589

Please sign in to comment.