Skip to content

Commit 32f0589

Browse files
authored
chore: Upgrade flow (outline#1854)
* wip: upgrade flow * chore: More sealed props improvements * Final fixes
1 parent ce2b246 commit 32f0589

38 files changed

+191
-96
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"javascript.validate.enable": false,
3+
"javascript.format.enable": false,
34
"typescript.validate.enable": false,
5+
"typescript.format.enable": false,
46
"editor.formatOnSave": true,
5-
"typescript.format.enable": false
67
}

app/components/Avatar/Avatar.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@ import { observable } from "mobx";
33
import { observer } from "mobx-react";
44
import * as React from "react";
55
import styled from "styled-components";
6+
import User from "models/User";
67
import placeholder from "./placeholder.png";
78

8-
type Props = {
9+
type Props = {|
910
src: string,
1011
size: number,
1112
icon?: React.Node,
12-
};
13+
user?: User,
14+
onClick?: () => void,
15+
className?: string,
16+
|};
1317

1418
@observer
1519
class Avatar extends React.Component<Props> {

app/components/Button.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ export const Inner = styled.span`
108108
${(props) => props.hasIcon && !props.hasText && "padding: 0 4px;"};
109109
`;
110110

111-
export type Props = {
112-
type?: string,
111+
export type Props = {|
112+
type?: "button" | "submit",
113113
value?: string,
114114
icon?: React.Node,
115115
iconColor?: string,
@@ -118,9 +118,21 @@ export type Props = {
118118
innerRef?: React.ElementRef<any>,
119119
disclosure?: boolean,
120120
neutral?: boolean,
121+
danger?: boolean,
122+
primary?: boolean,
123+
disabled?: boolean,
121124
fullwidth?: boolean,
125+
autoFocus?: boolean,
126+
style?: Object,
127+
as?: React.ComponentType<any>,
128+
to?: string,
129+
onClick?: (event: SyntheticEvent<>) => mixed,
122130
borderOnHover?: boolean,
123-
};
131+
132+
"data-on"?: string,
133+
"data-event-category"?: string,
134+
"data-event-action"?: string,
135+
|};
124136

125137
function Button({
126138
type = "text",

app/components/Checkbox.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@ import { VisuallyHidden } from "reakit/VisuallyHidden";
44
import styled from "styled-components";
55
import HelpText from "components/HelpText";
66

7-
export type Props = {
7+
export type Props = {|
88
checked?: boolean,
99
label?: string,
1010
labelHidden?: boolean,
1111
className?: string,
12+
name?: string,
13+
disabled?: boolean,
14+
onChange: (event: SyntheticInputEvent<HTMLInputElement>) => mixed,
1215
note?: string,
1316
short?: boolean,
1417
small?: boolean,
15-
};
18+
|};
1619

1720
const LabelText = styled.span`
1821
font-weight: 500;

app/components/ContextMenu/MenuItem.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ import * as React from "react";
44
import { MenuItem as BaseMenuItem } from "reakit/Menu";
55
import styled from "styled-components";
66

7-
type Props = {
7+
type Props = {|
88
onClick?: (SyntheticEvent<>) => void | Promise<void>,
99
children?: React.Node,
1010
selected?: boolean,
1111
disabled?: boolean,
12+
to?: string,
13+
href?: string,
14+
target?: "_blank",
1215
as?: string | React.ComponentType<*>,
13-
};
16+
|};
1417

1518
const MenuItem = ({
1619
onClick,

app/components/DocumentList.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ import * as React from "react";
44
import Document from "models/Document";
55
import DocumentListItem from "components/DocumentListItem";
66

7-
type Props = {
7+
type Props = {|
88
documents: Document[],
99
limit?: number,
10-
};
10+
showCollection?: boolean,
11+
showPublished?: boolean,
12+
showPin?: boolean,
13+
showDraft?: boolean,
14+
showTemplate?: boolean,
15+
|};
1116

1217
export default function DocumentList({ limit, documents, ...rest }: Props) {
1318
const items = limit ? documents.splice(0, limit) : documents;

app/components/DocumentMeta.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ const Modified = styled.span`
2323
font-weight: ${(props) => (props.highlight ? "600" : "400")};
2424
`;
2525

26-
type Props = {
26+
type Props = {|
2727
showCollection?: boolean,
2828
showPublished?: boolean,
2929
showLastViewed?: boolean,
3030
document: Document,
3131
children: React.Node,
3232
to?: string,
33-
};
33+
|};
3434

3535
function DocumentMeta({
3636
showPublished,

app/components/Editor.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,31 @@ const RichMarkdownEditor = React.lazy(() => import("rich-markdown-editor"));
1616

1717
const EMPTY_ARRAY = [];
1818

19-
type Props = {
19+
export type Props = {|
2020
id?: string,
21+
value?: string,
2122
defaultValue?: string,
2223
readOnly?: boolean,
2324
grow?: boolean,
2425
disableEmbeds?: boolean,
2526
ui?: UiStore,
26-
};
27+
autoFocus?: boolean,
28+
template?: boolean,
29+
placeholder?: string,
30+
scrollTo?: string,
31+
readOnlyWriteCheckboxes?: boolean,
32+
onBlur?: (event: SyntheticEvent<>) => any,
33+
onFocus?: (event: SyntheticEvent<>) => any,
34+
onPublish?: (event: SyntheticEvent<>) => any,
35+
onSave?: ({ done?: boolean, autosave?: boolean, publish?: boolean }) => any,
36+
onCancel?: () => any,
37+
onChange?: (getValue: () => string) => any,
38+
onSearchLink?: (title: string) => any,
39+
onHoverLink?: (event: MouseEvent) => any,
40+
onCreateLink?: (title: string) => Promise<string>,
41+
onImageUploadStart?: () => any,
42+
onImageUploadStop?: () => any,
43+
|};
2744

2845
type PropsWithRef = Props & {
2946
forwardedRef: React.Ref<any>,

app/components/Image.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
import * as React from "react";
33
import { cdnPath } from "utils/urls";
44

5-
type Props = {
5+
type Props = {|
66
alt: string,
77
src: string,
8-
};
8+
title?: string,
9+
width?: number,
10+
height?: number,
11+
|};
912

1013
export default function Image({ src, alt, ...rest }: Props) {
1114
return <img src={cdnPath(src)} alt={alt} {...rest} />;

app/components/Input.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ export const LabelText = styled.div`
7575
display: inline-block;
7676
`;
7777

78-
export type Props = {
79-
type?: string,
78+
export type Props = {|
79+
type?: "text" | "email" | "checkbox" | "search",
8080
value?: string,
8181
label?: string,
8282
className?: string,
@@ -85,9 +85,18 @@ export type Props = {
8585
short?: boolean,
8686
margin?: string | number,
8787
icon?: React.Node,
88+
name?: string,
89+
minLength?: number,
90+
maxLength?: number,
91+
autoFocus?: boolean,
92+
autoComplete?: boolean | string,
93+
readOnly?: boolean,
94+
required?: boolean,
95+
placeholder?: string,
96+
onChange?: (ev: SyntheticInputEvent<HTMLInputElement>) => mixed,
8897
onFocus?: (ev: SyntheticEvent<>) => void,
8998
onBlur?: (ev: SyntheticEvent<>) => void,
90-
};
99+
|};
91100

92101
@observer
93102
class Input extends React.Component<Props> {

app/components/InputRich.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import Editor from "components/Editor";
88
import HelpText from "components/HelpText";
99
import { LabelText, Outline } from "components/Input";
1010

11-
type Props = {
11+
type Props = {|
1212
label: string,
1313
minHeight?: number,
1414
maxHeight?: number,
1515
readOnly?: boolean,
1616
ui: UiStore,
17-
};
17+
|};
1818

1919
@observer
2020
class InputRich extends React.Component<Props> {

app/components/InputSelect.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ export type Props = {
3636
className?: string,
3737
labelHidden?: boolean,
3838
options: Option[],
39+
onBlur?: () => void,
40+
onFocus?: () => void,
3941
};
4042

4143
@observer

app/components/Labeled.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import * as React from "react";
44
import styled from "styled-components";
55
import Flex from "components/Flex";
66

7-
type Props = {
7+
type Props = {|
88
label: React.Node | string,
99
children: React.Node,
10-
};
10+
|};
1111

1212
const Labeled = ({ label, children, ...props }: Props) => (
1313
<Flex column {...props}>

app/components/Mask.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import { randomInteger } from "shared/random";
55
import { pulsate } from "shared/styles/animations";
66
import Flex from "components/Flex";
77

8-
type Props = {
8+
type Props = {|
99
header?: boolean,
1010
height?: number,
11-
};
11+
|};
1212

1313
class Mask extends React.Component<Props> {
1414
width: number;
@@ -23,7 +23,7 @@ class Mask extends React.Component<Props> {
2323
}
2424

2525
render() {
26-
return <Redacted width={this.width} {...this.props} />;
26+
return <Redacted width={this.width} />;
2727
}
2828
}
2929

app/components/Modal.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import Scrollable from "components/Scrollable";
1313

1414
ReactModal.setAppElement("#root");
1515

16-
type Props = {
16+
type Props = {|
1717
children?: React.Node,
1818
isOpen: boolean,
1919
title?: string,
2020
onRequestClose: () => void,
21-
};
21+
|};
2222

2323
const GlobalStyles = createGlobalStyle`
2424
.ReactModal__Overlay {

app/components/PaginatedDocumentList.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@ import Document from "models/Document";
55
import DocumentListItem from "components/DocumentListItem";
66
import PaginatedList from "components/PaginatedList";
77

8-
type Props = {
8+
type Props = {|
99
documents: Document[],
1010
fetch: (options: ?Object) => Promise<void>,
1111
options?: Object,
1212
heading?: React.Node,
1313
empty?: React.Node,
14-
};
14+
showCollection?: boolean,
15+
showPublished?: boolean,
16+
showPin?: boolean,
17+
showDraft?: boolean,
18+
showTemplate?: boolean,
19+
|};
1520

1621
@observer
1722
class PaginatedDocumentList extends React.Component<Props> {

app/components/Sidebar/components/HeaderBlock.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import styled from "styled-components";
55
import Flex from "components/Flex";
66
import TeamLogo from "components/TeamLogo";
77

8-
type Props = {
8+
type Props = {|
99
teamName: string,
1010
subheading: React.Node,
1111
showDisclosure?: boolean,
12+
onClick: (event: SyntheticEvent<>) => void,
1213
logoUrl: string,
13-
};
14+
|};
1415

1516
const HeaderBlock = React.forwardRef<Props, any>(
1617
({ showDisclosure, teamName, subheading, logoUrl, ...rest }: Props, ref) => (

app/components/Switch.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ import * as React from "react";
33
import styled from "styled-components";
44
import { LabelText } from "components/Input";
55

6-
type Props = {
6+
type Props = {|
77
width?: number,
88
height?: number,
99
label?: string,
10+
checked?: boolean,
11+
disabled?: boolean,
12+
onChange: (event: SyntheticInputEvent<HTMLInputElement>) => mixed,
1013
id?: string,
11-
};
14+
|};
1215

1316
function Switch({ width = 38, height = 20, label, ...props }: Props) {
1417
const component = (

app/components/Tooltip.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import Tippy from "@tippy.js/react";
33
import * as React from "react";
44
import styled from "styled-components";
55

6-
type Props = {
6+
type Props = {|
77
tooltip: React.Node,
88
shortcut?: React.Node,
99
placement?: "top" | "bottom" | "left" | "right",
1010
children: React.Node,
1111
delay?: number,
1212
className?: string,
13-
};
13+
|};
1414

1515
class Tooltip extends React.Component<Props> {
1616
render() {

app/menus/NewDocumentMenu.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ function NewDocumentMenu() {
2727
as={Link}
2828
to={newDocumentUrl(collections.orderedData[0].id)}
2929
icon={<PlusIcon />}
30-
small
3130
>
3231
{t("New doc")}
3332
</Button>

app/models/BaseModel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default class BaseModel {
1111
this.store = store;
1212
}
1313

14-
save = async (params: ?Object) => {
14+
save = async (params: Object = {}) => {
1515
this.isSaving = true;
1616

1717
try {

0 commit comments

Comments
 (0)