From 3a22bef9923645cb457c187c10125eb5e567d817 Mon Sep 17 00:00:00 2001 From: Bruno Quaresma Date: Tue, 17 Jan 2023 21:40:20 +0000 Subject: [PATCH 1/3] chore: Remove FE dead code --- site/e2e/constants.ts | 1 - site/package.json | 4 +- site/src/api/errors.ts | 2 +- site/src/components/AppLink/AppLink.tsx | 2 +- .../components/AppLink/AppLinkSkeleton.tsx | 2 +- .../src/components/AppLink/AppPreviewLink.tsx | 2 +- .../DeploySettingsLayout/Badges.tsx | 11 -- site/src/components/Dialogs/Dialog.tsx | 62 --------- .../FormDropdownField/FormDropdownField.tsx | 52 -------- .../components/FormSection/FormSection.tsx | 68 ---------- .../FormTextField/FormTextField.tsx | 2 +- site/src/components/FormTitle/FormTitle.tsx | 33 ----- site/src/components/Icons/DocsIcon.tsx | 12 -- site/src/components/Icons/Logo.tsx | 26 ---- site/src/components/Icons/LogoutIcon.tsx | 30 ----- site/src/components/Icons/SearchIcon.tsx | 7 - site/src/components/Icons/WorkspacesIcon.tsx | 11 -- .../Resources/ResourceAvatarData.tsx | 126 ------------------ site/src/components/TabPanel/TabPanel.tsx | 2 - .../components/TableHeaders/TableHeaders.tsx | 6 - .../components/Tooltips/AgentHelpTooltip.tsx | 20 --- .../Tooltips/AgentOutdatedTooltip.tsx | 25 ---- .../Tooltips/HelpTooltip/HelpTooltip.tsx | 4 +- .../Tooltips/ResourcesHelpTooltip.tsx | 28 ---- site/src/components/Tooltips/index.ts | 2 - site/src/hooks/useEntitlements.ts | 14 -- site/src/pages/index.tsx | 2 +- site/src/theme/constants.ts | 6 - site/src/util/events.ts | 17 --- site/src/util/filters.ts | 20 --- site/src/util/formUtils.ts | 2 +- site/src/util/index.ts | 1 - site/src/util/workspace.ts | 6 +- .../appearance/appearanceXService.ts | 5 - .../entitlements/entitlementsXService.ts | 4 - site/src/xServices/quotas/quotasXService.ts | 4 - .../workspaceScheduleBannerXService.ts | 4 - .../workspaceScheduleXService.ts | 4 - site/yarn.lock | 49 ++++++- 39 files changed, 62 insertions(+), 616 deletions(-) delete mode 100644 site/src/components/FormDropdownField/FormDropdownField.tsx delete mode 100644 site/src/components/FormSection/FormSection.tsx delete mode 100644 site/src/components/FormTitle/FormTitle.tsx delete mode 100644 site/src/components/Icons/DocsIcon.tsx delete mode 100644 site/src/components/Icons/Logo.tsx delete mode 100644 site/src/components/Icons/LogoutIcon.tsx delete mode 100644 site/src/components/Icons/SearchIcon.tsx delete mode 100644 site/src/components/Icons/WorkspacesIcon.tsx delete mode 100644 site/src/components/Resources/ResourceAvatarData.tsx delete mode 100644 site/src/components/TableHeaders/TableHeaders.tsx delete mode 100644 site/src/components/Tooltips/AgentHelpTooltip.tsx delete mode 100644 site/src/components/Tooltips/AgentOutdatedTooltip.tsx delete mode 100644 site/src/components/Tooltips/ResourcesHelpTooltip.tsx delete mode 100644 site/src/hooks/useEntitlements.ts delete mode 100644 site/src/util/index.ts diff --git a/site/e2e/constants.ts b/site/e2e/constants.ts index af78e67958883..a04fabce81ec6 100644 --- a/site/e2e/constants.ts +++ b/site/e2e/constants.ts @@ -5,5 +5,4 @@ export const basePort = 3000 // Credentials for the default user when running in dev mode. export const username = "developer" export const password = "password" -export const organization = "acme-corp" export const email = "admin@coder.com" diff --git a/site/package.json b/site/package.json index e2a4d01870f8c..ba3f920489ddb 100644 --- a/site/package.json +++ b/site/package.json @@ -23,7 +23,8 @@ "test": "jest --selectProjects test", "test:coverage": "jest --selectProjects test --collectCoverage", "test:watch": "jest --selectProjects test --watch", - "typegen": "xstate typegen 'src/**/*.ts'" + "typegen": "xstate typegen 'src/**/*.ts'", + "deadcode": "ts-prune | grep -v \".stories\\|.typegen\\|.config\\|e2e\\|__mocks__\\|used in module\\|testHelpers\\|typesGenerated\" || echo \"No deadcode found.\"" }, "dependencies": { "@emoji-mart/data": "1.0.5", @@ -68,6 +69,7 @@ "react-syntax-highlighter": "15.5.0", "remark-gfm": "3.0.1", "sourcemapped-stacktrace": "1.1.11", + "ts-prune": "0.10.3", "tzdata": "1.0.30", "ua-parser-js": "1.0.2", "uuid": "9.0.0", diff --git a/site/src/api/errors.ts b/site/src/api/errors.ts index 496bf493e98ef..b581526803986 100644 --- a/site/src/api/errors.ts +++ b/site/src/api/errors.ts @@ -1,6 +1,6 @@ import axios, { AxiosError, AxiosResponse } from "axios" -export const Language = { +const Language = { errorsByCode: { defaultErrorCode: "Invalid value", }, diff --git a/site/src/components/AppLink/AppLink.tsx b/site/src/components/AppLink/AppLink.tsx index 9c23757a36588..283843a28a38b 100644 --- a/site/src/components/AppLink/AppLink.tsx +++ b/site/src/components/AppLink/AppLink.tsx @@ -10,7 +10,7 @@ import { generateRandomString } from "../../util/random" import { BaseIcon } from "./BaseIcon" import { ShareIcon } from "./ShareIcon" -export const Language = { +const Language = { appTitle: (appName: string, identifier: string): string => `${appName} - ${identifier}`, } diff --git a/site/src/components/AppLink/AppLinkSkeleton.tsx b/site/src/components/AppLink/AppLinkSkeleton.tsx index d81630ac3eb55..4da189b44e0b3 100644 --- a/site/src/components/AppLink/AppLinkSkeleton.tsx +++ b/site/src/components/AppLink/AppLinkSkeleton.tsx @@ -15,7 +15,7 @@ export const AppLinkSkeleton: FC<{ width: number }> = ({ width }) => { ) } -export const useStyles = makeStyles(() => ({ +const useStyles = makeStyles(() => ({ skeleton: { borderRadius: borderRadiusSm, }, diff --git a/site/src/components/AppLink/AppPreviewLink.tsx b/site/src/components/AppLink/AppPreviewLink.tsx index ec6501b566a59..c218e8892d2a3 100644 --- a/site/src/components/AppLink/AppPreviewLink.tsx +++ b/site/src/components/AppLink/AppPreviewLink.tsx @@ -5,7 +5,7 @@ import * as TypesGen from "api/typesGenerated" import { BaseIcon } from "./BaseIcon" import { ShareIcon } from "./ShareIcon" -export interface AppPreviewProps { +interface AppPreviewProps { app: TypesGen.WorkspaceApp } diff --git a/site/src/components/DeploySettingsLayout/Badges.tsx b/site/src/components/DeploySettingsLayout/Badges.tsx index 747d8f5ab127f..3409cc165faf5 100644 --- a/site/src/components/DeploySettingsLayout/Badges.tsx +++ b/site/src/components/DeploySettingsLayout/Badges.tsx @@ -40,17 +40,6 @@ export const EnterpriseBadge: FC = () => { ) } -export const VersionBadge: FC<{ - version: string -}> = ({ version }) => { - const styles = useStyles() - return ( - - Version: {version} - - ) -} - export const Badges: FC = ({ children }) => { const styles = useStyles() return ( diff --git a/site/src/components/Dialogs/Dialog.tsx b/site/src/components/Dialogs/Dialog.tsx index 123fccfe499fd..81f18f69624a3 100644 --- a/site/src/components/Dialogs/Dialog.tsx +++ b/site/src/components/Dialogs/Dialog.tsx @@ -1,9 +1,7 @@ import MuiDialog, { DialogProps as MuiDialogProps, } from "@material-ui/core/Dialog" -import MuiDialogTitle from "@material-ui/core/DialogTitle" import { alpha, darken, lighten, makeStyles } from "@material-ui/core/styles" -import SvgIcon from "@material-ui/core/SvgIcon" import * as React from "react" import { combineClasses } from "../../util/combineClasses" import { @@ -12,66 +10,6 @@ import { } from "../LoadingButton/LoadingButton" import { ConfirmDialogType } from "./types" -export interface DialogTitleProps { - /** Title for display */ - title: React.ReactNode - /** Optional icon to display faded to the right of the title */ - icon?: typeof SvgIcon - /** Smaller text to display above the title */ - superTitle?: React.ReactNode -} - -/** - * Override of Material UI's DialogTitle that allows for a supertitle and background icon - */ -export const DialogTitle: React.FC = ({ - title, - icon: Icon, - superTitle, -}) => { - const styles = useTitleStyles() - return ( - -
- {superTitle &&
{superTitle}
} -
{title}
-
- {Icon && } -
- ) -} - -const useTitleStyles = makeStyles( - (theme) => ({ - title: { - position: "relative", - zIndex: 2, - fontSize: theme.typography.h3.fontSize, - fontWeight: theme.typography.h3.fontWeight, - lineHeight: "40px", - display: "flex", - alignItems: "center", - }, - superTitle: { - position: "relative", - zIndex: 2, - fontSize: theme.typography.body2.fontSize, - fontWeight: 500, - letterSpacing: 1.5, - textTransform: "uppercase", - }, - titleWrapper: { - padding: `${theme.spacing(2)}px 0`, - }, - icon: { - height: 84, - width: 84, - color: alpha(theme.palette.action.disabled, 0.4), - }, - }), - { name: "CdrDialogTitle" }, -) - export interface DialogActionButtonsProps { /** Text to display in the cancel button */ cancelText?: string diff --git a/site/src/components/FormDropdownField/FormDropdownField.tsx b/site/src/components/FormDropdownField/FormDropdownField.tsx deleted file mode 100644 index ca0b83aafa486..0000000000000 --- a/site/src/components/FormDropdownField/FormDropdownField.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import Box from "@material-ui/core/Box" -import MenuItem from "@material-ui/core/MenuItem" -import { makeStyles } from "@material-ui/core/styles" -import Typography from "@material-ui/core/Typography" -import { ReactElement } from "react" -import { - FormTextField, - FormTextFieldProps, -} from "../FormTextField/FormTextField" - -export interface FormDropdownItem { - value: string - name: string - description?: string -} - -export interface FormDropdownFieldProps extends FormTextFieldProps { - items: FormDropdownItem[] -} - -export const FormDropdownField = ({ - items, - ...props -}: FormDropdownFieldProps): ReactElement => { - const styles = useStyles() - return ( - - {items.map((item: FormDropdownItem) => ( - - - - {item.name} - - {item.description && ( - - - {item.description} - - - )} - - - ))} - - ) -} - -const useStyles = makeStyles({ - hintText: { - opacity: 0.75, - }, -}) diff --git a/site/src/components/FormSection/FormSection.tsx b/site/src/components/FormSection/FormSection.tsx deleted file mode 100644 index e61df29370935..0000000000000 --- a/site/src/components/FormSection/FormSection.tsx +++ /dev/null @@ -1,68 +0,0 @@ -import { makeStyles } from "@material-ui/core/styles" -import Typography from "@material-ui/core/Typography" -import { FC } from "react" - -export interface FormSectionProps { - title: string - description?: string -} - -export const useStyles = makeStyles((theme) => ({ - root: { - display: "flex", - flexDirection: "row", - // Borrowed from PaperForm styles - maxWidth: "852px", - width: "100%", - borderBottom: `1px solid ${theme.palette.divider}`, - }, - descriptionContainer: { - maxWidth: "200px", - flex: "0 0 200px", - display: "flex", - flexDirection: "column", - justifyContent: "flex-start", - alignItems: "flex-start", - marginTop: theme.spacing(5), - marginBottom: theme.spacing(2), - }, - descriptionText: { - fontSize: "0.9em", - lineHeight: "1em", - color: theme.palette.text.secondary, - marginTop: theme.spacing(1), - }, - contents: { - flex: 1, - marginTop: theme.spacing(4), - marginBottom: theme.spacing(4), - }, -})) - -export const FormSection: FC> = ({ - title, - description, - children, -}) => { - const styles = useStyles() - - return ( -
-
- - {title} - - {description && ( - - {description} - - )} -
-
{children}
-
- ) -} diff --git a/site/src/components/FormTextField/FormTextField.tsx b/site/src/components/FormTextField/FormTextField.tsx index 2e88f48cf4f2d..b73b723224b88 100644 --- a/site/src/components/FormTextField/FormTextField.tsx +++ b/site/src/components/FormTextField/FormTextField.tsx @@ -6,7 +6,7 @@ import { PasswordField } from "../PasswordField/PasswordField" /** * FormFieldProps are required props for creating form fields using a factory. */ -export interface FormFieldProps { +interface FormFieldProps { /** * form is a reference to a form or subform and is used to compute common * states such as error and helper text diff --git a/site/src/components/FormTitle/FormTitle.tsx b/site/src/components/FormTitle/FormTitle.tsx deleted file mode 100644 index de5aa7c15c976..0000000000000 --- a/site/src/components/FormTitle/FormTitle.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import { makeStyles } from "@material-ui/core/styles" -import Typography from "@material-ui/core/Typography" -import { FC, ReactNode } from "react" - -export interface FormTitleProps { - title: string - detail?: ReactNode -} - -const useStyles = makeStyles((theme) => ({ - title: { - marginTop: theme.spacing(6), - marginBottom: theme.spacing(4), - - "& h3": { - marginBottom: theme.spacing(1), - }, - }, -})) - -export const FormTitle: FC> = ({ - title, - detail, -}) => { - const styles = useStyles() - - return ( -
- {title} - {detail && {detail}} -
- ) -} diff --git a/site/src/components/Icons/DocsIcon.tsx b/site/src/components/Icons/DocsIcon.tsx deleted file mode 100644 index e6ce20fda7cb8..0000000000000 --- a/site/src/components/Icons/DocsIcon.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import SvgIcon, { SvgIconProps } from "@material-ui/core/SvgIcon" - -export const DocsIcon = (props: SvgIconProps): JSX.Element => ( - - - -) diff --git a/site/src/components/Icons/Logo.tsx b/site/src/components/Icons/Logo.tsx deleted file mode 100644 index e753d8cbadef9..0000000000000 --- a/site/src/components/Icons/Logo.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import * as React from "react" - -export const Logo = (props: React.SVGProps): JSX.Element => ( - - Codestin Search App - - - - - - - - - - - - -) diff --git a/site/src/components/Icons/LogoutIcon.tsx b/site/src/components/Icons/LogoutIcon.tsx deleted file mode 100644 index ba67e7680a51d..0000000000000 --- a/site/src/components/Icons/LogoutIcon.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import SvgIcon, { SvgIconProps } from "@material-ui/core/SvgIcon" - -export const LogoutIcon = (props: SvgIconProps): JSX.Element => ( - - - - - - -) diff --git a/site/src/components/Icons/SearchIcon.tsx b/site/src/components/Icons/SearchIcon.tsx deleted file mode 100644 index 7d83f82e57664..0000000000000 --- a/site/src/components/Icons/SearchIcon.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import SvgIcon, { SvgIconProps } from "@material-ui/core/SvgIcon" - -export const SearchIcon: typeof SvgIcon = (props: SvgIconProps) => ( - - - -) diff --git a/site/src/components/Icons/WorkspacesIcon.tsx b/site/src/components/Icons/WorkspacesIcon.tsx deleted file mode 100644 index c9374043d7149..0000000000000 --- a/site/src/components/Icons/WorkspacesIcon.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import SvgIcon, { SvgIconProps } from "@material-ui/core/SvgIcon" - -export const WorkspacesIcon: typeof SvgIcon = (props: SvgIconProps) => ( - - - - - - - -) diff --git a/site/src/components/Resources/ResourceAvatarData.tsx b/site/src/components/Resources/ResourceAvatarData.tsx deleted file mode 100644 index 2b540a2de0efe..0000000000000 --- a/site/src/components/Resources/ResourceAvatarData.tsx +++ /dev/null @@ -1,126 +0,0 @@ -import IconButton from "@material-ui/core/IconButton" -import { makeStyles } from "@material-ui/core/styles" -import Tooltip from "@material-ui/core/Tooltip" -import VisibilityOffOutlined from "@material-ui/icons/VisibilityOffOutlined" -import VisibilityOutlined from "@material-ui/icons/VisibilityOutlined" -import { WorkspaceResource } from "api/typesGenerated" -import { FC, useState } from "react" -import { - TableCellData, - TableCellDataPrimary, -} from "../TableCellData/TableCellData" -import { ResourceAvatar } from "./ResourceAvatar" - -const Language = { - showLabel: "Show value", - hideLabel: "Hide value", -} - -const SensitiveValue: React.FC<{ value: string }> = ({ value }) => { - const [shouldDisplay, setShouldDisplay] = useState(false) - const styles = useStyles() - const displayValue = shouldDisplay ? value : "••••••••" - const buttonLabel = shouldDisplay ? Language.hideLabel : Language.showLabel - const icon = shouldDisplay ? ( - - ) : ( - - ) - - return ( -
- {displayValue} - - { - setShouldDisplay((value) => !value) - }} - size="small" - aria-label={buttonLabel} - > - {icon} - - -
- ) -} - -export interface ResourceAvatarDataProps { - resource: WorkspaceResource -} - -export const ResourceAvatarData: FC = ({ - resource, -}) => { - const styles = useStyles() - - return ( -
-
- -
- - - {resource.name} -
- {resource.metadata?.map((metadata) => ( -
- {metadata.key}: - {metadata.sensitive ? ( - - ) : ( -
{metadata.value}
- )} -
- ))} -
-
-
- ) -} - -const useStyles = makeStyles((theme) => ({ - root: { - display: "flex", - }, - - avatarWrapper: { - marginRight: theme.spacing(3), - paddingTop: theme.spacing(0.5), - }, - - data: { - color: theme.palette.text.secondary, - fontSize: 14, - marginTop: theme.spacing(0.75), - display: "grid", - gridAutoFlow: "row", - whiteSpace: "nowrap", - gap: theme.spacing(0.75), - }, - - dataRow: { - display: "flex", - alignItems: "center", - - "& strong": { - marginRight: theme.spacing(1), - }, - }, - - sensitiveValue: { - display: "flex", - alignItems: "center", - }, - - button: { - marginLeft: theme.spacing(0.5), - color: "inherit", - - "& .MuiSvgIcon-root": { - width: 16, - height: 16, - }, - }, -})) diff --git a/site/src/components/TabPanel/TabPanel.tsx b/site/src/components/TabPanel/TabPanel.tsx index c60e02fea6352..ed90bcd35669f 100644 --- a/site/src/components/TabPanel/TabPanel.tsx +++ b/site/src/components/TabPanel/TabPanel.tsx @@ -3,8 +3,6 @@ import { alpha } from "@material-ui/core/styles/colorManipulator" import { FC } from "react" import { TabSidebar, TabSidebarItem } from "../TabSidebar/TabSidebar" -export type AdminMenuItemCallback = (menuItem: string) => void - export interface TabPanelProps { title: string menuItems: TabSidebarItem[] diff --git a/site/src/components/TableHeaders/TableHeaders.tsx b/site/src/components/TableHeaders/TableHeaders.tsx deleted file mode 100644 index 6adda32b33c40..0000000000000 --- a/site/src/components/TableHeaders/TableHeaders.tsx +++ /dev/null @@ -1,6 +0,0 @@ -import TableRow from "@material-ui/core/TableRow" -import { FC, ReactNode } from "react" - -export const TableHeaderRow: FC<{ children: ReactNode }> = ({ children }) => { - return {children} -} diff --git a/site/src/components/Tooltips/AgentHelpTooltip.tsx b/site/src/components/Tooltips/AgentHelpTooltip.tsx deleted file mode 100644 index 8bccc3e03127a..0000000000000 --- a/site/src/components/Tooltips/AgentHelpTooltip.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { - HelpTooltip, - HelpTooltipText, - HelpTooltipTitle, -} from "./HelpTooltip/HelpTooltip" - -export const Language = { - agentTooltipTitle: "What is an agent?", - agentTooltipText: - "The Coder agent runs inside your resource and gives you direct access to the shell via the UI or CLI.", -} - -export const AgentHelpTooltip: React.FC = () => { - return ( - - {Language.agentTooltipTitle} - {Language.agentTooltipText} - - ) -} diff --git a/site/src/components/Tooltips/AgentOutdatedTooltip.tsx b/site/src/components/Tooltips/AgentOutdatedTooltip.tsx deleted file mode 100644 index 9cbfe9e467fb6..0000000000000 --- a/site/src/components/Tooltips/AgentOutdatedTooltip.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import { FC } from "react" -import { HelpTooltip, HelpTooltipText, HelpTooltipTitle } from "./HelpTooltip" - -export const Language = { - label: "Agent Outdated", - text: "This agent is an older version than the Coder server. This can happen after you update Coder with running workspaces. To fix this, you can stop and start the workspace.", -} - -interface TooltipProps { - outdated: boolean -} - -export const AgentOutdatedTooltip: FC< - React.PropsWithChildren -> = ({ outdated }) => { - if (!outdated) { - return null - } - return ( - - {Language.label} - {Language.text} - - ) -} diff --git a/site/src/components/Tooltips/HelpTooltip/HelpTooltip.tsx b/site/src/components/Tooltips/HelpTooltip/HelpTooltip.tsx index 610a23db0bc3b..a9e58254848e4 100644 --- a/site/src/components/Tooltips/HelpTooltip/HelpTooltip.tsx +++ b/site/src/components/Tooltips/HelpTooltip/HelpTooltip.tsx @@ -17,7 +17,7 @@ import { Stack } from "../../Stack/Stack" type Icon = typeof HelpIcon type Size = "small" | "medium" -export interface HelpTooltipProps { +interface HelpTooltipProps { // Useful to test on storybook open?: boolean size?: Size @@ -26,7 +26,7 @@ export interface HelpTooltipProps { buttonClassName?: string } -export const Language = { +const Language = { ariaLabel: "tooltip", } diff --git a/site/src/components/Tooltips/ResourcesHelpTooltip.tsx b/site/src/components/Tooltips/ResourcesHelpTooltip.tsx deleted file mode 100644 index 102460d617def..0000000000000 --- a/site/src/components/Tooltips/ResourcesHelpTooltip.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { - HelpTooltip, - HelpTooltipLink, - HelpTooltipLinksGroup, - HelpTooltipText, - HelpTooltipTitle, -} from "./HelpTooltip/HelpTooltip" - -export const Language = { - resourceTooltipTitle: "What is a resource?", - resourceTooltipText: - "A resource is an infrastructure object that is created when the workspace is provisioned.", - resourceTooltipLink: "Persistent vs. ephemeral resources", -} - -export const ResourcesHelpTooltip: React.FC = () => { - return ( - - {Language.resourceTooltipTitle} - {Language.resourceTooltipText} - - - {Language.resourceTooltipLink} - - - - ) -} diff --git a/site/src/components/Tooltips/index.ts b/site/src/components/Tooltips/index.ts index e7b4f1bc5a2ff..a0f00ee3b8764 100644 --- a/site/src/components/Tooltips/index.ts +++ b/site/src/components/Tooltips/index.ts @@ -1,6 +1,4 @@ -export { AgentHelpTooltip } from "./AgentHelpTooltip" export { AuditHelpTooltip } from "./AuditHelpTooltip" export { OutdatedHelpTooltip } from "./OutdatedHelpTooltip" -export { ResourcesHelpTooltip } from "./ResourcesHelpTooltip" export { UserRoleHelpTooltip } from "./UserRoleHelpTooltip" export { WorkspaceHelpTooltip } from "./WorkspaceHelpTooltip" diff --git a/site/src/hooks/useEntitlements.ts b/site/src/hooks/useEntitlements.ts deleted file mode 100644 index 96780e2a0a050..0000000000000 --- a/site/src/hooks/useEntitlements.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { useSelector } from "@xstate/react" -import { Entitlements } from "api/typesGenerated" -import { useContext } from "react" -import { XServiceContext } from "xServices/StateContext" - -export const useEntitlements = (): Entitlements => { - const xServices = useContext(XServiceContext) - const entitlements = useSelector( - xServices.entitlementsXService, - (state) => state.context.entitlements, - ) - - return entitlements -} diff --git a/site/src/pages/index.tsx b/site/src/pages/index.tsx index 8417fdc3553b1..9759d739e0ca0 100644 --- a/site/src/pages/index.tsx +++ b/site/src/pages/index.tsx @@ -1,7 +1,7 @@ import { FC } from "react" import { Navigate } from "react-router-dom" -export const IndexPage: FC = () => { +const IndexPage: FC = () => { return } diff --git a/site/src/theme/constants.ts b/site/src/theme/constants.ts index c6ac2226fd63f..56421b9225d4c 100644 --- a/site/src/theme/constants.ts +++ b/site/src/theme/constants.ts @@ -1,16 +1,10 @@ -export const spacing = 8 export const borderRadius = 8 export const borderRadiusSm = 6 -export const buttonBorderWidth = 2 export const MONOSPACE_FONT_FAMILY = "'IBM Plex Mono', 'Lucida Console', 'Lucida Sans Typewriter', 'Liberation Mono', 'Monaco', 'Courier New', Courier, monospace" export const BODY_FONT_FAMILY = `"Inter", sans-serif` -export const lightButtonShadow = "0 2px 2px rgba(0, 23, 121, 0.08)" -export const emptyBoxShadow = "none" export const navHeight = 62 export const containerWidth = 1380 export const containerWidthMedium = 1080 export const sidePadding = 24 -export const TitleIconSize = 48 -export const CardRadius = 2 export const CardPadding = 20 diff --git a/site/src/util/events.ts b/site/src/util/events.ts index e0d03ecef1d13..7627c0626703e 100644 --- a/site/src/util/events.ts +++ b/site/src/util/events.ts @@ -19,23 +19,6 @@ export const dispatchCustomEvent = ( /** Annotates a custom event listener with descriptive type information. */ export type CustomEventListener = (event: CustomEvent) => void -/** - * An event listener is a function an Event-like object. - * - * Especially helpful when using `element.addEventListener` with a predeclared function. - * e.g. - * - * ```ts - * const handleClick = AnnotatedEventListener = (event) => { - * event.preventDefault() - * } - * - * window.addEventListener('click', handleClick) - * window.removeEventListener('click', handleClick) - * ``` - */ -export type AnnotatedEventListener = (event: E) => void - /** * Determines if an Event object is a CustomEvent. * diff --git a/site/src/util/filters.ts b/site/src/util/filters.ts index b1c7cc8d24717..a4e5cc04f90ff 100644 --- a/site/src/util/filters.ts +++ b/site/src/util/filters.ts @@ -1,4 +1,3 @@ -import { useSearchParams } from "react-router-dom" import * as TypesGen from "../api/typesGenerated" export const queryToFilter = ( @@ -20,22 +19,3 @@ export const userFilterQuery = { active: "status:active", all: "", } - -export const useFilter = ( - defaultFilter: string, -): { - filter: string - setFilter: (filter: string) => void -} => { - const [searchParams, setSearchParams] = useSearchParams() - const filter = searchParams.get("filter") ?? defaultFilter - - const setFilter = (filter: string) => { - setSearchParams({ filter }) - } - - return { - filter, - setFilter, - } -} diff --git a/site/src/util/formUtils.ts b/site/src/util/formUtils.ts index b750375961744..c0dc1aa53bac9 100644 --- a/site/src/util/formUtils.ts +++ b/site/src/util/formUtils.ts @@ -8,7 +8,7 @@ import { } from "react" import * as Yup from "yup" -export const Language = { +const Language = { nameRequired: (name: string): string => { return name ? `Please enter a ${name.toLowerCase()}.` : "Required" }, diff --git a/site/src/util/index.ts b/site/src/util/index.ts deleted file mode 100644 index c843a6a95d8e9..0000000000000 --- a/site/src/util/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./array" diff --git a/site/src/util/workspace.ts b/site/src/util/workspace.ts index 7d81e644d9d6d..e79ae365b7277 100644 --- a/site/src/util/workspace.ts +++ b/site/src/util/workspace.ts @@ -11,7 +11,7 @@ dayjs.extend(duration) dayjs.extend(utc) dayjs.extend(minMax) -export const DisplayWorkspaceBuildStatusLanguage = { +const DisplayWorkspaceBuildStatusLanguage = { succeeded: "Succeeded", pending: "Pending", running: "Running", @@ -20,7 +20,7 @@ export const DisplayWorkspaceBuildStatusLanguage = { failed: "Failed", } -export const DisplayAgentVersionLanguage = { +const DisplayAgentVersionLanguage = { unknown: "Unknown", } @@ -84,7 +84,7 @@ export const getDisplayWorkspaceBuildInitiatedBy = ( } } -export const getWorkspaceBuildDurationInSeconds = ( +const getWorkspaceBuildDurationInSeconds = ( build: TypesGen.WorkspaceBuild, ): number | undefined => { const isCompleted = build.job.started_at && build.job.completed_at diff --git a/site/src/xServices/appearance/appearanceXService.ts b/site/src/xServices/appearance/appearanceXService.ts index 1fa0b9c8235d7..ae843a5373ccd 100644 --- a/site/src/xServices/appearance/appearanceXService.ts +++ b/site/src/xServices/appearance/appearanceXService.ts @@ -3,11 +3,6 @@ import { assign, createMachine } from "xstate" import * as API from "../../api/api" import { AppearanceConfig } from "../../api/typesGenerated" -export const Language = { - getAppearanceError: "Error getting appearance.", - setAppearanceError: "Error setting appearance.", -} - export type AppearanceContext = { appearance: AppearanceConfig getAppearanceError?: Error | unknown diff --git a/site/src/xServices/entitlements/entitlementsXService.ts b/site/src/xServices/entitlements/entitlementsXService.ts index a1e8bb0d9b895..400104ab80e91 100644 --- a/site/src/xServices/entitlements/entitlementsXService.ts +++ b/site/src/xServices/entitlements/entitlementsXService.ts @@ -3,10 +3,6 @@ import { assign, createMachine } from "xstate" import * as API from "../../api/api" import { Entitlements } from "../../api/typesGenerated" -export const Language = { - getEntitlementsError: "Error getting license entitlements.", -} - export type EntitlementsContext = { entitlements: Entitlements getEntitlementsError?: Error | unknown diff --git a/site/src/xServices/quotas/quotasXService.ts b/site/src/xServices/quotas/quotasXService.ts index ae9a9652f54ee..84e22124f65e0 100644 --- a/site/src/xServices/quotas/quotasXService.ts +++ b/site/src/xServices/quotas/quotasXService.ts @@ -2,10 +2,6 @@ import { assign, createMachine } from "xstate" import * as API from "../../api/api" import { WorkspaceQuota } from "../../api/typesGenerated" -export const Language = { - getQuotaError: "Failed to get Quota", -} - export type QuotaContext = { quota?: WorkspaceQuota getQuotaError?: Error | unknown diff --git a/site/src/xServices/workspaceSchedule/workspaceScheduleBannerXService.ts b/site/src/xServices/workspaceSchedule/workspaceScheduleBannerXService.ts index 41c38f66da974..48c27f2ae7002 100644 --- a/site/src/xServices/workspaceSchedule/workspaceScheduleBannerXService.ts +++ b/site/src/xServices/workspaceSchedule/workspaceScheduleBannerXService.ts @@ -39,10 +39,6 @@ export type WorkspaceScheduleBannerEvent = workspace: Workspace } -export type WorkspaceScheduleBannerMachineRef = ActorRefFrom< - typeof workspaceScheduleBannerMachine -> - export const workspaceScheduleBannerMachine = createMachine( { id: "workspaceScheduleBannerState", diff --git a/site/src/xServices/workspaceSchedule/workspaceScheduleXService.ts b/site/src/xServices/workspaceSchedule/workspaceScheduleXService.ts index 65506a0f70e44..322b48d155792 100644 --- a/site/src/xServices/workspaceSchedule/workspaceScheduleXService.ts +++ b/site/src/xServices/workspaceSchedule/workspaceScheduleXService.ts @@ -6,10 +6,6 @@ import { assign, createMachine } from "xstate" import * as API from "../../api/api" import * as TypesGen from "../../api/typesGenerated" -export const Language = { - successMessage: "Successfully updated workspace schedule.", -} - type Permissions = Record, boolean> export interface WorkspaceScheduleContext { diff --git a/site/yarn.lock b/site/yarn.lock index 9e52d27cf7a54..bb0cce706ab02 100644 --- a/site/yarn.lock +++ b/site/yarn.lock @@ -2948,6 +2948,16 @@ resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82" integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw== +"@ts-morph/common@~0.12.3": + version "0.12.3" + resolved "https://registry.yarnpkg.com/@ts-morph/common/-/common-0.12.3.tgz#a96e250217cd30e480ab22ec6a0ebbe65fd784ff" + integrity sha512-4tUmeLyXJnJWvTFOKtcNJ1yh0a3SsTLi2MUoyj8iUNznFRN1ZquaNe7Oukqrnki2FzZkm0J9adCNLDZxUzvj+w== + dependencies: + fast-glob "^3.2.7" + minimatch "^3.0.4" + mkdirp "^1.0.4" + path-browserify "^1.0.1" + "@types/aria-query@^4.2.0": version "4.2.2" resolved "https://registry.yarnpkg.com/@types/aria-query/-/aria-query-4.2.2.tgz#ed4e0ad92306a704f9fb132a0cfcf77486dbe2bc" @@ -5223,6 +5233,11 @@ co@^4.6.0: resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" integrity sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ== +code-block-writer@^11.0.0: + version "11.0.3" + resolved "https://registry.yarnpkg.com/code-block-writer/-/code-block-writer-11.0.3.tgz#9eec2993edfb79bfae845fbc093758c0a0b73b76" + integrity sha512-NiujjUFB4SwScJq2bwbYUtXbZhBSlY6vYzm++3Q6oC+U+injTqfPYFK8wS9COOmb2lueqp0ZRB4nK1VYeHgNyw== + collapse-white-space@^1.0.2: version "1.0.6" resolved "https://registry.yarnpkg.com/collapse-white-space/-/collapse-white-space-1.0.6.tgz#e63629c0016665792060dbbeb79c42239d2c5287" @@ -5454,7 +5469,7 @@ cosmiconfig@^6.0.0: path-type "^4.0.0" yaml "^1.7.2" -cosmiconfig@^7.0.0: +cosmiconfig@^7.0.0, cosmiconfig@^7.0.1: version "7.1.0" resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-7.1.0.tgz#1443b9afa596b670082ea46cbd8f6a62b84635f6" integrity sha512-AdmX6xUzdNASswsFtmwSt7Vj8po9IuqXm0UXz7QKPuEUmPB4XyjGfaAr2PSuELMwkRMVH1EpIkX5bTZGRB3eCA== @@ -6912,7 +6927,7 @@ fast-glob@^2.2.6: merge2 "^1.2.3" micromatch "^3.1.10" -fast-glob@^3.2.11, fast-glob@^3.2.9: +fast-glob@^3.2.11, fast-glob@^3.2.7, fast-glob@^3.2.9: version "3.2.12" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.12.tgz#7f39ec99c2e6ab030337142da9e0c18f37afae80" integrity sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w== @@ -11032,6 +11047,11 @@ path-browserify@0.0.1: resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.1.tgz#e6c4ddd7ed3aa27c68a20cc4e50e1a4ee83bbc4a" integrity sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ== +path-browserify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-1.0.1.tgz#d98454a9c3753d5790860f16f68867b9e46be1fd" + integrity sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g== + path-dirname@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0" @@ -13310,6 +13330,11 @@ trough@^2.0.0: resolved "https://registry.yarnpkg.com/trough/-/trough-2.1.0.tgz#0f7b511a4fde65a46f18477ab38849b22c554876" integrity sha512-AqTiAOLcj85xS7vQ8QkAV41hPDIJ71XJB4RCUrzo/1GM2CQwhkJGaf9Hgr7BOugMRpgGUrqRg/DrBDl4H40+8g== +"true-myth@^4.1.0": + version "4.1.1" + resolved "https://registry.yarnpkg.com/true-myth/-/true-myth-4.1.1.tgz#ff4ac9d5130276e34aa338757e2416ec19248ba2" + integrity sha512-rqy30BSpxPznbbTcAcci90oZ1YR4DqvKcNXNerG5gQBU2v4jk0cygheiul5J6ExIMrgDVuanv/MkGfqZbKrNNg== + ts-dedent@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/ts-dedent/-/ts-dedent-2.2.0.tgz#39e4bd297cd036292ae2394eb3412be63f563bb5" @@ -13329,11 +13354,31 @@ ts-jest@27.1.4: semver "7.x" yargs-parser "20.x" +ts-morph@^13.0.1: + version "13.0.3" + resolved "https://registry.yarnpkg.com/ts-morph/-/ts-morph-13.0.3.tgz#c0c51d1273ae2edb46d76f65161eb9d763444c1d" + integrity sha512-pSOfUMx8Ld/WUreoSzvMFQG5i9uEiWIsBYjpU9+TTASOeUa89j5HykomeqVULm1oqWtBdleI3KEFRLrlA3zGIw== + dependencies: + "@ts-morph/common" "~0.12.3" + code-block-writer "^11.0.0" + ts-pnp@^1.1.6: version "1.2.0" resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.2.0.tgz#a500ad084b0798f1c3071af391e65912c86bca92" integrity sha512-csd+vJOb/gkzvcCHgTGSChYpy5f1/XKNsmvBGO4JXS+z1v2HobugDz4s1IeFXM3wZB44uczs+eazB5Q/ccdhQw== +ts-prune@0.10.3: + version "0.10.3" + resolved "https://registry.yarnpkg.com/ts-prune/-/ts-prune-0.10.3.tgz#b6c71a525543b38dcf947a7d3adfb7f9e8b91f38" + integrity sha512-iS47YTbdIcvN8Nh/1BFyziyUqmjXz7GVzWu02RaZXqb+e/3Qe1B7IQ4860krOeCGUeJmterAlaM2FRH0Ue0hjw== + dependencies: + commander "^6.2.1" + cosmiconfig "^7.0.1" + json5 "^2.1.3" + lodash "^4.17.21" + "true-myth" "^4.1.0" + ts-morph "^13.0.1" + tsconfig-paths@^3.14.1: version "3.14.1" resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz#ba0734599e8ea36c862798e920bcf163277b137a" From 23b478da88bab406459fee052f48aed307c14483 Mon Sep 17 00:00:00 2001 From: Bruno Quaresma Date: Tue, 17 Jan 2023 21:46:35 +0000 Subject: [PATCH 2/3] Remove unused deps --- .../workspaceSchedule/workspaceScheduleBannerXService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/src/xServices/workspaceSchedule/workspaceScheduleBannerXService.ts b/site/src/xServices/workspaceSchedule/workspaceScheduleBannerXService.ts index 48c27f2ae7002..4b20a92e94528 100644 --- a/site/src/xServices/workspaceSchedule/workspaceScheduleBannerXService.ts +++ b/site/src/xServices/workspaceSchedule/workspaceScheduleBannerXService.ts @@ -7,7 +7,7 @@ import { Workspace } from "api/typesGenerated" import dayjs from "dayjs" import minMax from "dayjs/plugin/minMax" import { getDeadline, getMaxDeadline, getMinDeadline } from "util/schedule" -import { ActorRefFrom, assign, createMachine } from "xstate" +import { assign, createMachine } from "xstate" import * as API from "../../api/api" import { displayError, From 626e04adf5c9a64c0bb41ff4f204d2d080e8efe6 Mon Sep 17 00:00:00 2001 From: Bruno Quaresma Date: Tue, 17 Jan 2023 22:50:24 +0000 Subject: [PATCH 3/3] Fix language --- site/src/components/Tooltips/HelpTooltip/HelpTooltip.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/src/components/Tooltips/HelpTooltip/HelpTooltip.tsx b/site/src/components/Tooltips/HelpTooltip/HelpTooltip.tsx index a9e58254848e4..0fdb0e36b565e 100644 --- a/site/src/components/Tooltips/HelpTooltip/HelpTooltip.tsx +++ b/site/src/components/Tooltips/HelpTooltip/HelpTooltip.tsx @@ -26,7 +26,7 @@ interface HelpTooltipProps { buttonClassName?: string } -const Language = { +export const Language = { ariaLabel: "tooltip", }