From dec9d721800ad8aa8fd1d8e9e1f5c856eb6a0c0c Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Thu, 21 Dec 2023 21:16:14 +0000 Subject: [PATCH 1/3] chore: no inline prop type definitions --- .../Dashboard/LicenseBanner/LicenseBanner.tsx | 9 ++- .../Dashboard/ServiceBanner/ServiceBanner.tsx | 23 +++--- .../DeploySettingsLayout/Header.tsx | 17 +++-- site/src/components/Dialogs/Dialog.tsx | 16 ++-- site/src/components/Resources/AgentStatus.tsx | 49 +++++-------- .../src/components/Resources/AgentVersion.tsx | 11 ++- .../components/Resources/AppLink/BaseIcon.tsx | 14 ++-- .../components/Resources/SensitiveValue.tsx | 47 +++++++----- .../RichParameterInput/RichParameterInput.tsx | 2 +- .../components/SignInLayout/SignInLayout.tsx | 73 ++++++++++--------- .../TemplateScheduleAutostart.tsx | 53 ++++++-------- .../BuildAuditDescription.tsx | 12 ++- .../AuditLogRow/AuditLogDiff/AuditLogDiff.tsx | 8 +- .../AuditPage/AuditLogRow/AuditLogRow.tsx | 4 +- .../CreateTemplatePage/VariableInput.tsx | 10 ++- .../ExternalAuthPage/ExternalAuthPageView.tsx | 9 ++- site/src/pages/GroupsPage/GroupPage.tsx | 15 +++- .../GroupsPage/SettingsGroupPageView.tsx | 12 ++- site/src/pages/SetupPage/SetupPageView.tsx | 15 ++-- .../TemplateEmbedPage/TemplateEmbedPage.tsx | 13 +++- .../src/pages/TemplatePage/TemplateLayout.tsx | 4 +- .../TemplatePermissionsPageView.tsx | 26 +++---- .../TemplateVersionEditorPage/FileDialog.tsx | 40 ++++++++-- .../TemplateVersionStatusBadge.tsx | 8 +- .../pages/TemplatesPage/EmptyTemplates.tsx | 9 ++- site/src/pages/UsersPage/UsersPage.tsx | 4 +- site/src/pages/WorkspacePage/BuildRow.tsx | 3 +- .../WorkspaceSettingsForm.tsx | 11 ++- 28 files changed, 299 insertions(+), 218 deletions(-) diff --git a/site/src/components/Dashboard/LicenseBanner/LicenseBanner.tsx b/site/src/components/Dashboard/LicenseBanner/LicenseBanner.tsx index 4f37638c9156b..6702c3c2bc8d4 100644 --- a/site/src/components/Dashboard/LicenseBanner/LicenseBanner.tsx +++ b/site/src/components/Dashboard/LicenseBanner/LicenseBanner.tsx @@ -1,13 +1,14 @@ +import { type FC } from "react"; import { useDashboard } from "components/Dashboard/DashboardProvider"; import { LicenseBannerView } from "./LicenseBannerView"; -export const LicenseBanner: React.FC = () => { +export const LicenseBanner: FC = () => { const { entitlements } = useDashboard(); const { errors, warnings } = entitlements; - if (errors.length > 0 || warnings.length > 0) { - return ; - } else { + if (errors.length === 0 && warnings.length === 0) { return null; } + + return ; }; diff --git a/site/src/components/Dashboard/ServiceBanner/ServiceBanner.tsx b/site/src/components/Dashboard/ServiceBanner/ServiceBanner.tsx index 239e6905ef523..d0dcfbcf1c09b 100644 --- a/site/src/components/Dashboard/ServiceBanner/ServiceBanner.tsx +++ b/site/src/components/Dashboard/ServiceBanner/ServiceBanner.tsx @@ -1,7 +1,8 @@ +import { type FC } from "react"; import { useDashboard } from "components/Dashboard/DashboardProvider"; import { ServiceBannerView } from "./ServiceBannerView"; -export const ServiceBanner: React.FC = () => { +export const ServiceBanner: FC = () => { const { appearance } = useDashboard(); const { message, background_color, enabled } = appearance.config.service_banner; @@ -10,15 +11,13 @@ export const ServiceBanner: React.FC = () => { return null; } - if (message !== undefined && background_color !== undefined) { - return ( - - ); - } else { - return null; - } + if (message === undefined || background_color === undefined) return null; + + return ( + + ); }; diff --git a/site/src/components/DeploySettingsLayout/Header.tsx b/site/src/components/DeploySettingsLayout/Header.tsx index 8be28d1e0d72e..2fbb31bd0261e 100644 --- a/site/src/components/DeploySettingsLayout/Header.tsx +++ b/site/src/components/DeploySettingsLayout/Header.tsx @@ -1,15 +1,22 @@ import Button from "@mui/material/Button"; import LaunchOutlined from "@mui/icons-material/LaunchOutlined"; -import type { FC } from "react"; +import type { FC, ReactNode } from "react"; import { useTheme } from "@emotion/react"; import { Stack } from "components/Stack/Stack"; -export const Header: FC<{ - title: string | JSX.Element; - description?: string | JSX.Element; +interface HeaderProps { + title: ReactNode; + description?: ReactNode; secondary?: boolean; docsHref?: string; -}> = ({ title, description, docsHref, secondary }) => { +} + +export const Header: FC = ({ + title, + description, + docsHref, + secondary, +}) => { const theme = useTheme(); return ( diff --git a/site/src/components/Dialogs/Dialog.tsx b/site/src/components/Dialogs/Dialog.tsx index 7e429752ddaa2..9ed588cf7a758 100644 --- a/site/src/components/Dialogs/Dialog.tsx +++ b/site/src/components/Dialogs/Dialog.tsx @@ -1,5 +1,5 @@ import MuiDialog, { DialogProps as MuiDialogProps } from "@mui/material/Dialog"; -import { type ReactNode } from "react"; +import { type FC, type ReactNode } from "react"; import { ConfirmDialogType } from "./types"; import { type Interpolation, type Theme } from "@emotion/react"; import LoadingButton, { LoadingButtonProps } from "@mui/lab/LoadingButton"; @@ -30,7 +30,7 @@ const typeToColor = (type: ConfirmDialogType): LoadingButtonProps["color"] => { /** * Quickly handles most modals actions, some combination of a cancel and confirm button */ -export const DialogActionButtons: React.FC = ({ +export const DialogActionButtons: FC = ({ cancelText = "Cancel", confirmText = "Confirm", confirmLoading = false, @@ -159,13 +159,7 @@ const styles = { export type DialogProps = MuiDialogProps; /** - * Wrapper around Material UI's Dialog component. Conveniently exports all of - * Dialog's components in one import, so for example `` becomes - * `` etc. Also contains some custom Dialog components listed below. - * - * See original component's Material UI documentation here: https://material-ui.com/components/dialogs/ + * Re-export of MUI's Dialog component, for convenience. + * @link See original documentation here: https://mui.com/material-ui/react-dialog/ */ -export const Dialog: React.FC = (props) => { - // Wrapped so we can add custom attributes below - return ; -}; +export { MuiDialog as Dialog }; diff --git a/site/src/components/Resources/AgentStatus.tsx b/site/src/components/Resources/AgentStatus.tsx index 706aa5edcdce7..0793377994b5c 100644 --- a/site/src/components/Resources/AgentStatus.tsx +++ b/site/src/components/Resources/AgentStatus.tsx @@ -1,15 +1,16 @@ import { type Interpolation, type Theme } from "@emotion/react"; import Tooltip from "@mui/material/Tooltip"; -import { WorkspaceAgent } from "api/typesGenerated"; -import { ChooseOne, Cond } from "components/Conditionals/ChooseOne"; import WarningRounded from "@mui/icons-material/WarningRounded"; +import Link from "@mui/material/Link"; +import { type FC } from "react"; +import type { WorkspaceAgent } from "api/typesGenerated"; +import { ChooseOne, Cond } from "components/Conditionals/ChooseOne"; import { HelpTooltip, HelpTooltipContent, HelpTooltipText, HelpTooltipTitle, } from "components/HelpTooltip/HelpTooltip"; -import Link from "@mui/material/Link"; import { PopoverTrigger } from "components/Popover/Popover"; // If we think in the agent status and lifecycle into a single enum/state I’d @@ -18,7 +19,7 @@ import { PopoverTrigger } from "components/Popover/Popover"; // connected:ready, connected:shutting_down, connected:shutdown_timeout, // connected:shutdown_error, connected:off. -const ReadyLifecycle = () => { +const ReadyLifecycle: FC = () => { return (
{ ); }; -const StartingLifecycle: React.FC = () => { +const StartingLifecycle: FC = () => { return (
{ ); }; -const StartTimeoutLifecycle: React.FC<{ +interface AgentStatusProps { agent: WorkspaceAgent; -}> = ({ agent }) => { +} + +const StartTimeoutLifecycle: FC = ({ agent }) => { return ( @@ -68,9 +71,7 @@ const StartTimeoutLifecycle: React.FC<{ ); }; -const StartErrorLifecycle: React.FC<{ - agent: WorkspaceAgent; -}> = ({ agent }) => { +const StartErrorLifecycle: FC = ({ agent }) => { return ( @@ -94,7 +95,7 @@ const StartErrorLifecycle: React.FC<{ ); }; -const ShuttingDownLifecycle: React.FC = () => { +const ShuttingDownLifecycle: FC = () => { return (
{ ); }; -const ShutdownTimeoutLifecycle: React.FC<{ - agent: WorkspaceAgent; -}> = ({ agent }) => { +const ShutdownTimeoutLifecycle: FC = ({ agent }) => { return ( @@ -132,9 +131,7 @@ const ShutdownTimeoutLifecycle: React.FC<{ ); }; -const ShutdownErrorLifecycle: React.FC<{ - agent: WorkspaceAgent; -}> = ({ agent }) => { +const ShutdownErrorLifecycle: FC = ({ agent }) => { return ( @@ -158,7 +155,7 @@ const ShutdownErrorLifecycle: React.FC<{ ); }; -const OffLifecycle: React.FC = () => { +const OffLifecycle: FC = () => { return (
{ ); }; -const ConnectedStatus: React.FC<{ - agent: WorkspaceAgent; -}> = ({ agent }) => { +const ConnectedStatus: FC = ({ agent }) => { // This is to support legacy agents that do not support // reporting the lifecycle_state field. if (agent.scripts.length === 0) { @@ -208,7 +203,7 @@ const ConnectedStatus: React.FC<{ ); }; -const DisconnectedStatus: React.FC = () => { +const DisconnectedStatus: FC = () => { return (
{ ); }; -const ConnectingStatus: React.FC = () => { +const ConnectingStatus: FC = () => { return (
{ ); }; -const TimeoutStatus: React.FC<{ - agent: WorkspaceAgent; -}> = ({ agent }) => { +const TimeoutStatus: FC = ({ agent }) => { return ( @@ -258,9 +251,7 @@ const TimeoutStatus: React.FC<{ ); }; -export const AgentStatus: React.FC<{ - agent: WorkspaceAgent; -}> = ({ agent }) => { +export const AgentStatus: FC = ({ agent }) => { return ( diff --git a/site/src/components/Resources/AgentVersion.tsx b/site/src/components/Resources/AgentVersion.tsx index ca4195965b57f..4b35ca6baec26 100644 --- a/site/src/components/Resources/AgentVersion.tsx +++ b/site/src/components/Resources/AgentVersion.tsx @@ -3,12 +3,19 @@ import type { WorkspaceAgent } from "api/typesGenerated"; import { agentVersionStatus, getDisplayVersionStatus } from "utils/workspace"; import { AgentOutdatedTooltip } from "./AgentOutdatedTooltip"; -export const AgentVersion: FC<{ +interface AgentVersionProps { agent: WorkspaceAgent; serverVersion: string; serverAPIVersion: string; onUpdate: () => void; -}> = ({ agent, serverVersion, serverAPIVersion, onUpdate }) => { +} + +export const AgentVersion: FC = ({ + agent, + serverVersion, + serverAPIVersion, + onUpdate, +}) => { const { status } = getDisplayVersionStatus( agent.version, serverVersion, diff --git a/site/src/components/Resources/AppLink/BaseIcon.tsx b/site/src/components/Resources/AppLink/BaseIcon.tsx index 72409249189ba..0d0738b22ac8d 100644 --- a/site/src/components/Resources/AppLink/BaseIcon.tsx +++ b/site/src/components/Resources/AppLink/BaseIcon.tsx @@ -1,15 +1,17 @@ -import { WorkspaceApp } from "api/typesGenerated"; -import { FC } from "react"; import ComputerIcon from "@mui/icons-material/Computer"; +import { type FC } from "react"; +import type { WorkspaceApp } from "api/typesGenerated"; -export const BaseIcon: FC<{ app: WorkspaceApp }> = ({ app }) => { +interface BaseIconProps { + app: WorkspaceApp; +} + +export const BaseIcon: FC = ({ app }) => { return app.icon ? ( {`${app.display_name} ) : ( diff --git a/site/src/components/Resources/SensitiveValue.tsx b/site/src/components/Resources/SensitiveValue.tsx index 7e9d62403a826..738b9a437ae72 100644 --- a/site/src/components/Resources/SensitiveValue.tsx +++ b/site/src/components/Resources/SensitiveValue.tsx @@ -3,7 +3,7 @@ import Tooltip from "@mui/material/Tooltip"; import VisibilityOffOutlined from "@mui/icons-material/VisibilityOffOutlined"; import VisibilityOutlined from "@mui/icons-material/VisibilityOutlined"; import { type FC, useState } from "react"; -import { css } from "@emotion/react"; +import { css, type Interpolation, type Theme } from "@emotion/react"; import { CopyableValue } from "components/CopyableValue/CopyableValue"; const Language = { @@ -11,7 +11,11 @@ const Language = { hideLabel: "Hide value", }; -export const SensitiveValue: FC<{ value: string }> = ({ value }) => { +interface SensitiveValueProps { + value: string; +} + +export const SensitiveValue: FC = ({ value }) => { const [shouldDisplay, setShouldDisplay] = useState(false); const displayValue = shouldDisplay ? value : "••••••••"; const buttonLabel = shouldDisplay ? Language.hideLabel : Language.showLabel; @@ -29,28 +33,12 @@ export const SensitiveValue: FC<{ value: string }> = ({ value }) => { gap: 4, }} > - + {displayValue} { setShouldDisplay((value) => !value); }} @@ -63,3 +51,22 @@ export const SensitiveValue: FC<{ value: string }> = ({ value }) => {
); }; + +const styles = { + value: { + // 22px is the button width + width: "calc(100% - 22px)", + overflow: "hidden", + whiteSpace: "nowrap", + textOverflow: "ellipsis", + }, + + button: css` + color: inherit; + + & .MuiSvgIcon-root { + width: 16px; + height: 16px; + } + `, +} satisfies Record>; diff --git a/site/src/components/RichParameterInput/RichParameterInput.tsx b/site/src/components/RichParameterInput/RichParameterInput.tsx index 4ce0d8555d403..ca8573a53241e 100644 --- a/site/src/components/RichParameterInput/RichParameterInput.tsx +++ b/site/src/components/RichParameterInput/RichParameterInput.tsx @@ -160,7 +160,7 @@ export const RichParameterInput: FC = ({ ); }; -const RichParameterField: React.FC = ({ +const RichParameterField: FC = ({ disabled, onChange, parameter, diff --git a/site/src/components/SignInLayout/SignInLayout.tsx b/site/src/components/SignInLayout/SignInLayout.tsx index f2c7f0973caf5..e033a2024a06c 100644 --- a/site/src/components/SignInLayout/SignInLayout.tsx +++ b/site/src/components/SignInLayout/SignInLayout.tsx @@ -1,43 +1,44 @@ -import { type FC, type ReactNode } from "react"; +import { type Interpolation, type Theme } from "@emotion/react"; +import { type FC, type PropsWithChildren } from "react"; -export const SignInLayout: FC<{ children: ReactNode }> = ({ children }) => { +export const SignInLayout: FC = ({ children }) => { return ( -
-
-
- {children} -
-
({ - fontSize: 12, - color: theme.palette.text.secondary, - marginTop: 24, - })} - > - {`\u00a9 ${new Date().getFullYear()} Coder Technologies, Inc.`} +
+
+
{children}
+
+ {"\u00a9"} {new Date().getFullYear()} Coder Technologies, Inc.
); }; + +const styles = { + container: { + flex: 1, + height: "-webkit-fill-available", + display: "flex", + justifyContent: "center", + alignItems: "center", + }, + + content: { + display: "flex", + flexDirection: "column", + alignItems: "center", + }, + + signIn: { + maxWidth: 385, + display: "flex", + flexDirection: "column", + alignItems: "center", + }, + + copyright: (theme) => ({ + fontSize: 12, + color: theme.palette.text.secondary, + marginTop: 24, + }), +} satisfies Record>; diff --git a/site/src/components/TemplateScheduleAutostart/TemplateScheduleAutostart.tsx b/site/src/components/TemplateScheduleAutostart/TemplateScheduleAutostart.tsx index 3fac410e1e206..21681dafdd56d 100644 --- a/site/src/components/TemplateScheduleAutostart/TemplateScheduleAutostart.tsx +++ b/site/src/components/TemplateScheduleAutostart/TemplateScheduleAutostart.tsx @@ -1,4 +1,4 @@ -import { FC } from "react"; +import { type FC } from "react"; import { TemplateAutostartRequirementDaysValue } from "utils/schedule"; import Button from "@mui/material/Button"; import { Stack } from "components/Stack/Stack"; @@ -11,9 +11,7 @@ export interface TemplateScheduleAutostartProps { onChange: (newDaysOfWeek: TemplateAutostartRequirementDaysValue[]) => void; } -export const TemplateScheduleAutostart: FC< - React.PropsWithChildren -> = ({ +export const TemplateScheduleAutostart: FC = ({ autostart_requirement_days_of_week, isSubmitting, allow_user_autostart, @@ -24,18 +22,14 @@ export const TemplateScheduleAutostart: FC< direction="column" width="100%" alignItems="center" - css={{ - marginBottom: "20px", - }} + css={{ marginBottom: "20px" }} > {( [ @@ -53,9 +47,7 @@ export const TemplateScheduleAutostart: FC< ).map((day) => (