From c79a22b8570b22c5032f94a5bdfdaabc3927a9cc Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 21 Oct 2021 21:23:58 -0700 Subject: [PATCH] flow --- app/components/PaginatedList.js | 2 +- app/components/PaginatedList.test.js | 13 +++++++++++-- app/components/Sidebar/components/Collections.js | 1 - app/components/Sidebar/components/NavLink.js | 2 +- app/components/Sidebar/components/SidebarLink.js | 7 +++---- shared/i18n/locales/en_US/translation.json | 2 ++ 6 files changed, 18 insertions(+), 9 deletions(-) diff --git a/app/components/PaginatedList.js b/app/components/PaginatedList.js index ce876259..3784f606 100644 --- a/app/components/PaginatedList.js +++ b/app/components/PaginatedList.js @@ -13,7 +13,7 @@ import PlaceholderList from "components/List/Placeholder"; import { dateToHeading } from "utils/dates"; type Props = { - fetch?: (options: ?Object) => Promise, + fetch?: (options: ?Object) => Promise, options?: Object, heading?: React.Node, empty?: React.Node, diff --git a/app/components/PaginatedList.test.js b/app/components/PaginatedList.test.js index 438f65ac..22608e6a 100644 --- a/app/components/PaginatedList.test.js +++ b/app/components/PaginatedList.test.js @@ -2,15 +2,21 @@ import "../stores"; import { shallow } from "enzyme"; import * as React from "react"; +import AuthStore from "stores/AuthStore"; import { DEFAULT_PAGINATION_LIMIT } from "stores/BaseStore"; +import RootStore from "stores/RootStore"; import { runAllPromises } from "../test/support"; import { Component as PaginatedList } from "./PaginatedList"; describe("PaginatedList", () => { const render = () => null; + const rootStore = new RootStore(); + const props = { auth: new AuthStore(rootStore), t: (string) => "test" }; it("with no items renders nothing", () => { - const list = shallow(); + const list = shallow( + + ); expect(list).toEqual({}); }); @@ -20,6 +26,7 @@ describe("PaginatedList", () => { items={[]} empty={

Sorry, no results

} renderItem={render} + {...props} /> ); expect(list.text()).toEqual("Sorry, no results"); @@ -35,6 +42,7 @@ describe("PaginatedList", () => { fetch={fetch} options={options} renderItem={render} + {...props} /> ); expect(fetch).toHaveBeenCalledWith({ @@ -46,7 +54,7 @@ describe("PaginatedList", () => { it("calls fetch when options prop changes", async () => { const fetchedItems = Array(DEFAULT_PAGINATION_LIMIT).fill(); - const fetch = jest.fn().mockReturnValue(fetchedItems); + const fetch = jest.fn().mockReturnValue(Promise.resolve(fetchedItems)); const list = shallow( { fetch={fetch} options={{ id: "one" }} renderItem={render} + {...props} /> ); diff --git a/app/components/Sidebar/components/Collections.js b/app/components/Sidebar/components/Collections.js index 36f92588..2f49ec36 100644 --- a/app/components/Sidebar/components/Collections.js +++ b/app/components/Sidebar/components/Collections.js @@ -112,7 +112,6 @@ function Collections({ onCreateCollection }: Props) { } - disabled /> diff --git a/app/components/Sidebar/components/NavLink.js b/app/components/Sidebar/components/NavLink.js index 0c2967e0..1411fa7a 100644 --- a/app/components/Sidebar/components/NavLink.js +++ b/app/components/Sidebar/components/NavLink.js @@ -27,7 +27,7 @@ const joinClassnames = (...classnames) => { return classnames.filter((i) => i).join(" "); }; -type Props = {| +export type Props = {| activeClassName?: String, activeStyle?: Object, className?: string, diff --git a/app/components/Sidebar/components/SidebarLink.js b/app/components/Sidebar/components/SidebarLink.js index d95bbfec..22ee1cdd 100644 --- a/app/components/Sidebar/components/SidebarLink.js +++ b/app/components/Sidebar/components/SidebarLink.js @@ -4,15 +4,15 @@ import * as React from "react"; import styled, { useTheme } from "styled-components"; import breakpoint from "styled-components-breakpoint"; import EventBoundary from "components/EventBoundary"; -import NavLink from "./NavLink"; +import NavLink, { type Props as NavLinkProps } from "./NavLink"; type Props = {| + ...NavLinkProps, to?: string | Object, href?: string | Object, innerRef?: (?HTMLElement) => void, - onClick?: (SyntheticEvent<>) => void, + onClick?: (SyntheticEvent<>) => mixed, onMouseEnter?: (SyntheticEvent<>) => void, - className?: string, children?: React.Node, icon?: React.Node, label?: React.Node, @@ -20,7 +20,6 @@ type Props = {| showActions?: boolean, active?: boolean, isActiveDrop?: boolean, - exact?: boolean, depth?: number, scrollIntoViewIfNeeded?: boolean, |}; diff --git a/shared/i18n/locales/en_US/translation.json b/shared/i18n/locales/en_US/translation.json index 5a3e47fa..0a22a768 100644 --- a/shared/i18n/locales/en_US/translation.json +++ b/shared/i18n/locales/en_US/translation.json @@ -152,6 +152,7 @@ "Starred": "Starred", "Show more": "Show more", "Show less": "Show less", + "Toggle sidebar": "Toggle sidebar", "Delete {{ documentName }}": "Delete {{ documentName }}", "Home": "Home", "Settings": "Settings", @@ -597,6 +598,7 @@ "Are you sure? Deleting your account will destroy identifying data associated with your user and cannot be undone. You will be immediately logged out of Outline and all your API tokens will be revoked.": "Are you sure? Deleting your account will destroy identifying data associated with your user and cannot be undone. You will be immediately logged out of Outline and all your API tokens will be revoked.", "Note: Signing back in will cause a new account to be automatically reprovisioned.": "Note: Signing back in will cause a new account to be automatically reprovisioned.", "Delete My Account": "Delete My Account", + "Profile picture": "Profile picture", "You joined": "You joined", "Joined": "Joined", "{{ time }} ago.": "{{ time }} ago.",