diff --git a/.env.sample b/.env.sample index 154f991bf5..439c66d9f9 100644 --- a/.env.sample +++ b/.env.sample @@ -92,7 +92,7 @@ OIDC_USERNAME_CLAIM=preferred_username OIDC_DISPLAY_NAME=OpenID # Space separated auth scopes. -OIDC_SCOPES="openid profile email" +OIDC_SCOPES=openid profile email # –––––––––––––––– OPTIONAL –––––––––––––––– diff --git a/app/actions/index.ts b/app/actions/index.ts index b1b25bd04f..6985dc934f 100644 --- a/app/actions/index.ts +++ b/app/actions/index.ts @@ -101,9 +101,7 @@ export function actionToKBar( keywords: action.keywords ?? "", shortcut: action.shortcut || [], icon: resolvedIcon, - perform: action.perform - ? () => action.perform && action.perform(context) - : undefined, + perform: action.perform ? () => action?.perform?.(context) : undefined, }, // @ts-expect-error ts-migrate(2769) FIXME: No overload matches this call. ].concat(children.map((child) => ({ ...child, parent: action.id }))); diff --git a/app/components/Analytics.ts b/app/components/Analytics.ts index 1bf1e5d94c..044c6718f5 100644 --- a/app/components/Analytics.ts +++ b/app/components/Analytics.ts @@ -2,11 +2,7 @@ import * as React from "react"; import env from "~/env"; -type Props = { - children?: React.ReactNode; -}; - -export default class Analytics extends React.Component { +export default class Analytics extends React.Component { componentDidMount() { if (!env.GOOGLE_ANALYTICS_ID) { return; diff --git a/app/components/Authenticated.tsx b/app/components/Authenticated.tsx index 225791c663..976063b50e 100644 --- a/app/components/Authenticated.tsx +++ b/app/components/Authenticated.tsx @@ -15,7 +15,7 @@ type Props = { const Authenticated = ({ children }: Props) => { const { auth } = useStores(); const { i18n } = useTranslation(); - const language = auth.user && auth.user.language; + const language = auth.user?.language; // Watching for language changes here as this is the earliest point we have // the user available and means we can start loading translations faster diff --git a/app/components/AuthenticatedLayout.tsx b/app/components/AuthenticatedLayout.tsx index 11ad15b113..50d9c1c96d 100644 --- a/app/components/AuthenticatedLayout.tsx +++ b/app/components/AuthenticatedLayout.tsx @@ -34,10 +34,7 @@ const CommandBar = React.lazy( ) ); -type Props = WithTranslation & - RootStore & { - children?: React.ReactNode; - }; +type Props = WithTranslation & RootStore; @observer class AuthenticatedLayout extends React.Component { diff --git a/app/components/Breadcrumb.tsx b/app/components/Breadcrumb.tsx index 7ad14c4824..b0c3d205e2 100644 --- a/app/components/Breadcrumb.tsx +++ b/app/components/Breadcrumb.tsx @@ -9,11 +9,15 @@ import { MenuInternalLink } from "~/types"; type Props = { items: MenuInternalLink[]; max?: number; - children?: React.ReactNode; highlightFirstItem?: boolean; }; -function Breadcrumb({ items, highlightFirstItem, children, max = 2 }: Props) { +function Breadcrumb({ + items, + highlightFirstItem, + children, + max = 2, +}: React.PropsWithChildren) { const totalItems = items.length; const topLevelItems: MenuInternalLink[] = [...items]; let overflowItems; diff --git a/app/components/ButtonLink.tsx b/app/components/ButtonLink.tsx index 4c14c1664e..4d3463928f 100644 --- a/app/components/ButtonLink.tsx +++ b/app/components/ButtonLink.tsx @@ -3,10 +3,9 @@ import styled from "styled-components"; type Props = { onClick?: React.MouseEventHandler; - children: React.ReactNode; }; -const ButtonLink = React.forwardRef( +const ButtonLink: React.FC = React.forwardRef( (props: Props, ref: React.Ref) => { return ); -} +}; const Button = styled.button` display: inline-flex; diff --git a/app/components/Sidebar/components/NavLink.tsx b/app/components/Sidebar/components/NavLink.tsx index 7ba8010ece..2295e4c66d 100644 --- a/app/components/Sidebar/components/NavLink.tsx +++ b/app/components/Sidebar/components/NavLink.tsx @@ -70,7 +70,7 @@ const NavLink = ({ const { pathname: path } = toLocation; // Regex taken from: https://github.com/pillarjs/path-to-regexp/blob/master/index.js#L202 - const escapedPath = path && path.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1"); + const escapedPath = path?.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1"); const match = escapedPath ? matchPath(currentLocation.pathname, { path: escapedPath, diff --git a/app/components/Sidebar/components/SidebarAction.tsx b/app/components/Sidebar/components/SidebarAction.tsx index 82ecd7c56c..334d42e445 100644 --- a/app/components/Sidebar/components/SidebarAction.tsx +++ b/app/components/Sidebar/components/SidebarAction.tsx @@ -21,6 +21,10 @@ function SidebarAction({ action, ...rest }: Props) { const menuItem = actionToMenuItem(action, context); invariant(menuItem.type === "button", "passed action must be a button"); + if (!menuItem.visible) { + return null; + } + return ( ; }; -const SidebarButton = React.forwardRef( +const SidebarButton = React.forwardRef( ( { showDisclosure, @@ -22,7 +22,7 @@ const SidebarButton = React.forwardRef( title, minHeight = 0, ...rest - }: Props, + }: SidebarButtonProps, ref ) => ( { @@ -46,7 +44,7 @@ class SocketProvider extends React.Component { } checkConnection = () => { - if (this.socket && this.socket.disconnected && getPageVisible()) { + if (this.socket?.disconnected && getPageVisible()) { // null-ifying this reference is important, do not remove. Without it // references to old sockets are potentially held in context this.socket.close(); @@ -102,10 +100,9 @@ class SocketProvider extends React.Component { // connection may have failed (caused by proxy, firewall, browser, ...) this.socket.on("reconnect_attempt", () => { if (this.socket) { - this.socket.io.opts.transports = - auth.team && auth.team.domain - ? ["websocket"] - : ["websocket", "polling"]; + this.socket.io.opts.transports = auth?.team?.domain + ? ["websocket"] + : ["websocket", "polling"]; } }); @@ -210,10 +207,7 @@ class SocketProvider extends React.Component { // if we already have the latest version (it was us that performed // the change) then we don't need to update anything either. - if ( - collection && - collection.updatedAt === collectionDescriptor.updatedAt - ) { + if (collection?.updatedAt === collectionDescriptor.updatedAt) { continue; } diff --git a/app/components/Subheading.tsx b/app/components/Subheading.tsx index 85bd5e767b..d165fc6f8d 100644 --- a/app/components/Subheading.tsx +++ b/app/components/Subheading.tsx @@ -2,7 +2,6 @@ import * as React from "react"; import styled from "styled-components"; type Props = { - children: React.ReactNode; sticky?: boolean; }; @@ -34,7 +33,7 @@ const Background = styled.div<{ sticky?: boolean }>` z-index: 1; `; -const Subheading = ({ children, sticky, ...rest }: Props) => { +const Subheading: React.FC = ({ children, sticky, ...rest }) => { return (

diff --git a/app/components/Tab.tsx b/app/components/Tab.tsx index 8f8dac6f82..4d12f6a496 100644 --- a/app/components/Tab.tsx +++ b/app/components/Tab.tsx @@ -9,7 +9,6 @@ type Props = Omit< > & { to: string; exact?: boolean; - children: React.ReactNode; }; const TabLink = styled(NavLinkWithChildrenFunc)` @@ -45,7 +44,7 @@ const transition = { damping: 30, }; -export default function Tab({ children, ...rest }: Props) { +const Tab: React.FC = ({ children, ...rest }) => { const theme = useTheme(); const activeStyle = { color: theme.textSecondary, @@ -67,4 +66,6 @@ export default function Tab({ children, ...rest }: Props) { )} ); -} +}; + +export default Tab; diff --git a/app/components/Tabs.tsx b/app/components/Tabs.tsx index 0805d12d6a..e4939e58ed 100644 --- a/app/components/Tabs.tsx +++ b/app/components/Tabs.tsx @@ -56,7 +56,7 @@ export const Separator = styled.span` margin-top: 6px; `; -const Tabs = ({ children }: { children: React.ReactNode }) => { +const Tabs: React.FC = ({ children }) => { const ref = React.useRef(); const [shadowVisible, setShadow] = React.useState(false); const { width } = useWindowSize(); diff --git a/app/components/Theme.tsx b/app/components/Theme.tsx index eb85af31bf..c434e1ee57 100644 --- a/app/components/Theme.tsx +++ b/app/components/Theme.tsx @@ -6,11 +6,7 @@ import useMediaQuery from "~/hooks/useMediaQuery"; import useStores from "~/hooks/useStores"; import GlobalStyles from "~/styles/globals"; -type Props = { - children: React.ReactNode; -}; - -function Theme({ children }: Props) { +const Theme: React.FC = ({ children }) => { const { ui } = useStores(); const resolvedTheme = ui.resolvedTheme === "dark" ? dark : light; const resolvedMobileTheme = @@ -37,6 +33,6 @@ function Theme({ children }: Props) { ); -} +}; export default observer(Theme); diff --git a/app/editor/components/CommandMenu.tsx b/app/editor/components/CommandMenu.tsx index 0d87a0b898..2ace5b25e4 100644 --- a/app/editor/components/CommandMenu.tsx +++ b/app/editor/components/CommandMenu.tsx @@ -139,7 +139,7 @@ class CommandMenu extends React.Component, State> { this.setState({ selectedIndex: Math.max( 0, - prev && prev.name === "separator" ? prevIndex - 1 : prevIndex + prev?.name === "separator" ? prevIndex - 1 : prevIndex ), }); } else { @@ -162,7 +162,7 @@ class CommandMenu extends React.Component, State> { this.setState({ selectedIndex: Math.min( - next && next.name === "separator" ? nextIndex + 1 : nextIndex, + next?.name === "separator" ? nextIndex + 1 : nextIndex, total ), }); diff --git a/app/editor/components/SelectionToolbar.tsx b/app/editor/components/SelectionToolbar.tsx index f71f14a092..55e1ec598c 100644 --- a/app/editor/components/SelectionToolbar.tsx +++ b/app/editor/components/SelectionToolbar.tsx @@ -191,8 +191,7 @@ export default class SelectionToolbar extends React.Component { const isTableSelection = colIndex !== undefined && rowIndex !== undefined; const link = isMarkActive(state.schema.marks.link)(state); const range = getMarkRange(selection.$from, state.schema.marks.link); - const isImageSelection = - selection.node && selection.node.type.name === "image"; + const isImageSelection = selection.node?.type?.name === "image"; let isTextSelection = false; let items: MenuItem[] = []; diff --git a/app/editor/components/Tooltip.tsx b/app/editor/components/Tooltip.tsx index 6dc9fc3080..670a8eabe2 100644 --- a/app/editor/components/Tooltip.tsx +++ b/app/editor/components/Tooltip.tsx @@ -3,11 +3,10 @@ import styled from "styled-components"; import Tooltip from "~/components/Tooltip"; type Props = { - children: React.ReactNode; tooltip?: string; }; -const WrappedTooltip = ({ children, tooltip }: Props) => ( +const WrappedTooltip: React.FC = ({ children, tooltip }) => ( {children} diff --git a/app/hooks/useAuthorizedSettingsConfig.ts b/app/hooks/useAuthorizedSettingsConfig.ts index fe96f56481..016af6ff94 100644 --- a/app/hooks/useAuthorizedSettingsConfig.ts +++ b/app/hooks/useAuthorizedSettingsConfig.ts @@ -29,6 +29,7 @@ import Zapier from "~/scenes/Settings/Zapier"; import SlackIcon from "~/components/SlackIcon"; import ZapierIcon from "~/components/ZapierIcon"; import env from "~/env"; +import isHosted from "~/utils/isHosted"; import useCurrentTeam from "./useCurrentTeam"; import usePolicy from "./usePolicy"; @@ -61,8 +62,6 @@ type ConfigType = { [key in SettingsPage]: ConfigItem; }; -const isHosted = env.DEPLOYMENT === "hosted"; - const useAuthorizedSettingsConfig = () => { const team = useCurrentTeam(); const can = usePolicy(team.id); diff --git a/app/index.tsx b/app/index.tsx index cdf525f266..9a65d2d409 100644 --- a/app/index.tsx +++ b/app/index.tsx @@ -37,7 +37,7 @@ if ("serviceWorker" in window.navigator) { } ); - if (maybePromise && maybePromise.then) { + if (maybePromise?.then) { maybePromise .then((registration) => { console.log("SW registered: ", registration); diff --git a/app/menus/AccountMenu.tsx b/app/menus/AccountMenu.tsx index 2c6eb30c90..1c63b5aa3d 100644 --- a/app/menus/AccountMenu.tsx +++ b/app/menus/AccountMenu.tsx @@ -18,11 +18,7 @@ import usePrevious from "~/hooks/usePrevious"; import useStores from "~/hooks/useStores"; import separator from "~/menus/separator"; -type Props = { - children: (props: any) => React.ReactNode; -}; - -function AccountMenu(props: Props) { +const AccountMenu: React.FC = ({ children }) => { const menu = useMenuState({ placement: "bottom-end", modal: true, @@ -55,12 +51,12 @@ function AccountMenu(props: Props) { return ( <> - {props.children} + {children}