Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Upgrade frontend to React 18#3353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ammario merged 20 commits intomainfromreact-18
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
20 commits
Select commitHold shift + click to select a range
d889b18
Upgrade to React 18
ammarioAug 2, 2022
7c5c2a1
Update react-dom
ammarioAug 2, 2022
54d5cce
Replace react-helmet with react-helmet-async
ammarioAug 2, 2022
6676cb3
Chase down errors
ammarioAug 2, 2022
8a0a73f
Simplify FC defs
ammarioAug 2, 2022
4928cf7
Run prettier
ammarioAug 2, 2022
8358053
Pin all new deps
ammarioAug 2, 2022
25d747d
Import PropsWithChildren in a few components
ammarioAug 2, 2022
5495f83
Fix remaining errors and most tests
ammarioAug 15, 2022
78448c4
Resolve more tests
ammarioAug 15, 2022
fafff02
Things are borked
ammarioAug 16, 2022
dab2f24
removing act; cleaning up tests
Kira-PilotAug 17, 2022
df998c2
fixed UsersPage tests
Kira-PilotAug 17, 2022
876e740
fixed CreateWorkspacePage tests
Kira-PilotAug 17, 2022
a5dc090
Wait for permissions too be loaded as well
BrunoQuaresmaAug 19, 2022
5fa1c0e
added cancelation test back
Kira-PilotAug 19, 2022
8cb1cd3
fixed workspacebuild test
Kira-PilotAug 19, 2022
087ebc2
disable floating promises in test file
Kira-PilotAug 22, 2022
29aedc6
fixing up lint
Kira-PilotAug 22, 2022
bc8a14d
resolving conflicts
Kira-PilotAug 22, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletionssite/package.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,16 +39,17 @@
"cron-parser": "4.5.0",
"cronstrue": "2.11.0",
"dayjs": "1.11.4",
"formik": "2.2.9",
"formik": "^2.2.9",
"front-matter": "4.0.2",
"history": "5.3.0",
"just-debounce-it": "3.0.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-helmet": "6.1.0",
"react": "^18.2.0",
"react-dom": "18.2.0",
"react-helmet-async": "1.3.0",
"react-markdown": "8.0.3",
"react-router-dom": "6.3.0",
"sourcemapped-stacktrace": "1.1.11",
"swr": "1.3.0",
"tzdata": "1.0.30",
"uuid": "8.3.2",
"xstate": "4.32.1",
Expand All@@ -70,13 +71,13 @@
"@storybook/addon-links": "6.5.9",
"@storybook/react": "6.4.22",
"@testing-library/jest-dom": "5.16.4",
"@testing-library/react": "12.1.5",
"@testing-library/user-event": "14.3.0",
"@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^14.4.3",
"@types/express": "4.17.13",
"@types/jest": "27.4.1",
"@types/node": "14.18.22",
"@types/react": "17.0.44",
"@types/react-dom": "17.0.16",
"@types/react": "18.0.15",
"@types/react-dom": "18.0.6",
"@types/react-helmet": "6.1.5",
"@types/superagent": "4.1.15",
"@types/uuid": "8.3.4",
Expand DownExpand Up@@ -105,7 +106,7 @@
"jest-runner-eslint": "1.0.0",
"jest-websocket-mock": "2.3.0",
"mini-css-extract-plugin": "2.6.1",
"msw": "0.42.0",
"msw": "^0.44.2",
"prettier": "2.7.1",
"prettier-plugin-organize-imports": "3.0.0",
"react-hot-loader": "4.13.0",
Expand Down
1 change: 0 additions & 1 deletionsite/src/AppRouter.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,7 +35,6 @@ const AuditPage = lazy(() => import("./pages/AuditPage/AuditPage"))
export const AppRouter: FC = () => {
const xServices = useContext(XServiceContext)
const permissions = useSelector(xServices.authXService, selectPermissions)

return (
<Suspense fallback={<></>}>
<Routes>
Expand Down
8 changes: 6 additions & 2 deletionssite/src/Main.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
import { inspect } from "@xstate/inspect"
importReactDOMfrom "react-dom"
import{ createRoot }from "react-dom/client"
import { Interpreter } from "xstate"
import { App } from "./app"

Expand All@@ -25,7 +25,11 @@ const main = () => {
██████▀▄█ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀▀ ▀▀▀▀ ▀
`)
const element = document.getElementById("root")
ReactDOM.render(<App />, element)
if (element === null) {
throw new Error("root element is null")
}
const root = createRoot(element)
root.render(<App />)
}

main()
4 changes: 2 additions & 2 deletionssite/src/__mocks__/react-markdown.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { FC } from "react"
import { FC, PropsWithChildren } from "react"

const ReactMarkdown: FC = ({ children }) => {
const ReactMarkdown: FC<PropsWithChildren<unknown>> = ({ children }) => {
return <div data-testid="markdown">{children}</div>
}

Expand Down
21 changes: 12 additions & 9 deletionssite/src/app.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
import CssBaseline from "@material-ui/core/CssBaseline"
import ThemeProvider from "@material-ui/styles/ThemeProvider"
import { FC } from "react"
import { HelmetProvider } from "react-helmet-async"
import { BrowserRouter as Router } from "react-router-dom"
import { AppRouter } from "./AppRouter"
import { ErrorBoundary } from "./components/ErrorBoundary/ErrorBoundary"
Expand All@@ -12,15 +13,17 @@ import { XServiceProvider } from "./xServices/StateContext"
export const App: FC = () => {
return (
<Router>
<ThemeProvider theme={dark}>
<CssBaseline />
<ErrorBoundary>
<XServiceProvider>
<AppRouter />
<GlobalSnackbar />
</XServiceProvider>
</ErrorBoundary>
</ThemeProvider>
<HelmetProvider>
<ThemeProvider theme={dark}>
<CssBaseline />
<ErrorBoundary>
<XServiceProvider>
<AppRouter />
<GlobalSnackbar />
</XServiceProvider>
</ErrorBoundary>
</ThemeProvider>
</HelmetProvider>
</Router>
)
}
9 changes: 7 additions & 2 deletionssite/src/components/AppLink/AppLink.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,7 @@ import Button from "@material-ui/core/Button"
import Link from "@material-ui/core/Link"
import { makeStyles } from "@material-ui/core/styles"
import ComputerIcon from "@material-ui/icons/Computer"
import { FC } from "react"
import { FC, PropsWithChildren } from "react"
import * as TypesGen from "../../api/typesGenerated"
import { generateRandomString } from "../../util/random"

Expand All@@ -17,7 +17,12 @@ export interface AppLinkProps {
appIcon?: TypesGen.WorkspaceApp["icon"]
}

export const AppLink: FC<AppLinkProps> = ({ userName, workspaceName, appName, appIcon }) => {
export const AppLink: FC<PropsWithChildren<AppLinkProps>> = ({
userName,
workspaceName,
appName,
appIcon,
}) => {
const styles = useStyles()
const href = `/@${userName}/${workspaceName}/apps/${appName}`

Expand Down
4 changes: 2 additions & 2 deletionssite/src/components/AvatarData/AvatarData.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
import Avatar from "@material-ui/core/Avatar"
import Link from "@material-ui/core/Link"
import { makeStyles } from "@material-ui/core/styles"
import { FC } from "react"
import { FC, PropsWithChildren } from "react"
import { Link as RouterLink } from "react-router-dom"
import { firstLetter } from "../../util/firstLetter"
import {
Expand All@@ -18,7 +18,7 @@ export interface AvatarDataProps {
avatar?: React.ReactNode
}

export const AvatarData: FC<AvatarDataProps> = ({
export const AvatarData: FC<PropsWithChildren<AvatarDataProps>> = ({
title,
subtitle,
link,
Expand Down
8 changes: 6 additions & 2 deletionssite/src/components/BorderedMenu/BorderedMenu.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
import Popover, { PopoverProps } from "@material-ui/core/Popover"
import { fade, makeStyles } from "@material-ui/core/styles"
import { FC } from "react"
import { FC, PropsWithChildren } from "react"

type BorderedMenuVariant = "admin-dropdown" | "user-dropdown"

export type BorderedMenuProps = Omit<PopoverProps, "variant"> & {
variant?: BorderedMenuVariant
}

export const BorderedMenu: FC<BorderedMenuProps> = ({ children, variant, ...rest }) => {
export const BorderedMenu: FC<PropsWithChildren<BorderedMenuProps>> = ({
children,
variant,
...rest
}) => {
const styles = useStyles()

return (
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,7 +26,7 @@ interface BorderedMenuRowProps {
onClick?: () => void
}

export const BorderedMenuRow: FC<BorderedMenuRowProps> = ({
export const BorderedMenuRow: FC<React.PropsWithChildren<BorderedMenuRowProps>> = ({
active,
description,
Icon,
Expand Down
5 changes: 4 additions & 1 deletionsite/src/components/BuildsTable/BuildsTable.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,10 @@ export interface BuildsTableProps {
className?: string
}

export const BuildsTable: FC<BuildsTableProps> = ({ builds, className }) => {
export const BuildsTable: FC<React.PropsWithChildren<BuildsTableProps>> = ({
builds,
className,
}) => {
const { username, workspace: workspaceName } = useParams()
const isLoading = !builds
const theme: Theme = useTheme()
Expand Down
2 changes: 1 addition & 1 deletionsite/src/components/CliAuthToken/CliAuthToken.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,7 @@ export interface CliAuthTokenProps {
sessionToken: string
}

export const CliAuthToken: FC<CliAuthTokenProps> = ({ sessionToken }) => {
export const CliAuthToken: FC<React.PropsWithChildren<CliAuthTokenProps>> = ({ sessionToken }) => {
const styles = useStyles()
return (
<Paper className={styles.container}>
Expand Down
6 changes: 5 additions & 1 deletionsite/src/components/CodeBlock/CodeBlock.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,11 @@ export interface CodeBlockProps {
className?: string
}

export const CodeBlock: FC<CodeBlockProps> = ({ lines, ctas, className = "" }) => {
export const CodeBlock: FC<React.PropsWithChildren<CodeBlockProps>> = ({
lines,
ctas,
className = "",
}) => {
const styles = useStyles()

return (
Expand Down
2 changes: 1 addition & 1 deletionsite/src/components/CodeExample/CodeExample.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,7 +14,7 @@ export interface CodeExampleProps {
/**
* Component to show single-line code examples, with a copy button
*/
export const CodeExample: FC<CodeExampleProps> = ({
export const CodeExample: FC<React.PropsWithChildren<CodeExampleProps>> = ({
code,
className,
buttonClassName,
Expand Down
13 changes: 5 additions & 8 deletionssite/src/components/ConfirmDialog/ConfirmDialog.test.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
import { fireEvent, render } from "@testing-library/react"
import { FC } from "react"
import { act } from "react-dom/test-utils"
import { WrapperComponent } from "../../testHelpers/renderHelpers"
import { ConfirmDialog, ConfirmDialogProps } from "./ConfirmDialog"

namespace Helpers {
export const Component: FC<ConfirmDialogProps> = (props: ConfirmDialogProps) => {
export const Component: FC<React.PropsWithChildren<ConfirmDialogProps>> = (
props: ConfirmDialogProps,
) => {
return (
<WrapperComponent>
<ConfirmDialog {...props} />
Expand DownExpand Up@@ -116,9 +117,7 @@ describe("ConfirmDialog", () => {

// When
const { getByText } = render(<Helpers.Component {...props} />)
act(() => {
fireEvent.click(getByText("CANCEL"))
})
fireEvent.click(getByText("CANCEL"))

// Then
expect(onCloseMock).toBeCalledTimes(1)
Expand All@@ -140,9 +139,7 @@ describe("ConfirmDialog", () => {

// When
const { getByText } = render(<Helpers.Component {...props} />)
act(() => {
fireEvent.click(getByText("CONFIRM"))
})
fireEvent.click(getByText("CONFIRM"))

// Then
expect(onCloseMock).toBeCalledTimes(0)
Expand Down
2 changes: 1 addition & 1 deletionsite/src/components/ConfirmDialog/ConfirmDialog.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -78,7 +78,7 @@ const useStyles = makeStyles((theme) => ({
* Quick-use version of the Dialog component with slightly alternative styles,
* great to use for dialogs that don't have any interaction beyond yes / no.
*/
export const ConfirmDialog: React.FC<ConfirmDialogProps> = ({
export const ConfirmDialog: React.FC<React.PropsWithChildren<ConfirmDialogProps>> = ({
cancelText,
confirmLoading,
confirmText,
Expand Down
2 changes: 1 addition & 1 deletionsite/src/components/CopyButton/CopyButton.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,7 +22,7 @@ export const Language = {
/**
* Copy button used inside the CodeBlock component internally
*/
export const CopyButton: React.FC<CopyButtonProps> = ({
export const CopyButton: React.FC<React.PropsWithChildren<CopyButtonProps>> = ({
text,
ctaCopy,
wrapperClassName = "",
Expand Down
2 changes: 1 addition & 1 deletionsite/src/components/CreateUserForm/CreateUserForm.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,7 +35,7 @@ const validationSchema = Yup.object({
username: nameValidator(Language.usernameLabel),
})

export const CreateUserForm: FC<CreateUserFormProps> = ({
export const CreateUserForm: FC<React.PropsWithChildren<CreateUserFormProps>> = ({
onSubmit,
onCancel,
formErrors,
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,11 +12,9 @@ export interface DeleteWorkspaceDialogProps {
handleCancel: () => void
}

export const DeleteWorkspaceDialog: React.FC<DeleteWorkspaceDialogProps> = ({
isOpen,
handleCancel,
handleConfirm,
}) => (
export const DeleteWorkspaceDialog: React.FC<
React.PropsWithChildren<DeleteWorkspaceDialogProps>
> = ({ isOpen, handleCancel, handleConfirm }) => (
<ConfirmDialog
type="delete"
hideCancel={false}
Expand Down
2 changes: 1 addition & 1 deletionsite/src/components/EmptyState/EmptyState.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,7 @@ export interface EmptyStateProps {
* EmptyState's props extend the [Material UI Box component](https://material-ui.com/components/box/)
* that you can directly pass props through to to customize the shape and layout of it.
*/
export const EmptyState: FC<EmptyStateProps> = (props) => {
export const EmptyState: FC<React.PropsWithChildren<EmptyStateProps>> = (props) => {
const { message, description, cta, descriptionClassName, className, ...boxProps } = props
const styles = useStyles()

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,7 +25,7 @@ export interface EnterpriseSnackbarProps extends MuiSnackbarProps {
*
* See original component's Material UI documentation here: https://material-ui.com/components/snackbars/
*/
export const EnterpriseSnackbar: FC<EnterpriseSnackbarProps> = ({
export const EnterpriseSnackbar: FC<React.PropsWithChildren<EnterpriseSnackbarProps>> = ({
onClose,
variant = "info",
ContentProps = {},
Expand Down
4 changes: 2 additions & 2 deletionssite/src/components/ErrorBoundary/ErrorBoundary.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
import { Component, ReactNode } from "react"
importReact,{ Component, ReactNode } from "react"
import { RuntimeErrorState } from "../RuntimeErrorState/RuntimeErrorState"

type ErrorBoundaryProps =Record<string,unknown>
type ErrorBoundaryProps =React.PropsWithChildren<unknown>

interface ErrorBoundaryState {
error: Error | null
Expand Down
2 changes: 1 addition & 1 deletionsite/src/components/ErrorSummary/ErrorSummary.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,7 @@ export interface ErrorSummaryProps {
defaultMessage?: string
}

export const ErrorSummary: FC<ErrorSummaryProps> = ({
export const ErrorSummary: FC<React.PropsWithChildren<ErrorSummaryProps>> = ({
error,
retry,
dismissible,
Expand Down
2 changes: 1 addition & 1 deletionsite/src/components/Footer/Footer.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,7 +18,7 @@ export interface FooterProps {
buildInfo?: TypesGen.BuildInfoResponse
}

export const Footer: React.FC<FooterProps> = ({ buildInfo }) => {
export const Footer: React.FC<React.PropsWithChildren<FooterProps>> = ({ buildInfo }) => {
const styles = useFooterStyles()

const githubUrl = `https://github.com/coder/coder/issues/new?labels=needs+grooming&body=${encodeURIComponent(`Version: [\`${buildInfo?.version}\`](${buildInfo?.external_url})
Expand Down
4 changes: 3 additions & 1 deletionsite/src/components/FormCloseButton/FormCloseButton.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,9 @@ export interface FormCloseButtonProps {
onClose: () => void
}

export const FormCloseButton: React.FC<FormCloseButtonProps> = ({ onClose }) => {
export const FormCloseButton: React.FC<React.PropsWithChildren<FormCloseButtonProps>> = ({
onClose,
}) => {
const styles = useStyles()

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletionsite/src/components/FormFooter/FormFooter.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ const useStyles = makeStyles((theme) => ({
},
}))

export const FormFooter: FC<FormFooterProps> = ({
export const FormFooter: FC<React.PropsWithChildren<FormFooterProps>> = ({
onCancel,
isLoading,
submitLabel = Language.defaultSubmitLabel,
Expand Down
6 changes: 5 additions & 1 deletionsite/src/components/FormSection/FormSection.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,7 +39,11 @@ export const useStyles = makeStyles((theme) => ({
},
}))

export const FormSection: FC<FormSectionProps> = ({ title, description, children }) => {
export const FormSection: FC<React.PropsWithChildren<FormSectionProps>> = ({
title,
description,
children,
}) => {
const styles = useStyles()

return (
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp