From af03a2b4772482b9f11fd5966e50a3bbbf9a196a Mon Sep 17 00:00:00 2001 From: Wes Date: Tue, 10 Oct 2023 10:29:51 -0700 Subject: [PATCH 1/4] chore: linting and style updates --- console/client/.eslintrc.cjs | 1 - .../src/features/modules/components/Panel.tsx | 14 +++++++++----- .../src/features/modules/graph/svg-zoom.ts | 2 +- console/client/src/layout/Page.tsx | 14 +++++++++----- console/client/tsconfig.json | 18 +++++++++++++----- 5 files changed, 32 insertions(+), 17 deletions(-) diff --git a/console/client/.eslintrc.cjs b/console/client/.eslintrc.cjs index f94f680b21..7b8ae2a15a 100644 --- a/console/client/.eslintrc.cjs +++ b/console/client/.eslintrc.cjs @@ -24,7 +24,6 @@ module.exports = { rules: { 'react/react-in-jsx-scope': 'off', 'react/jsx-uses-react': 'off', - 'react/prop-types': 'off', 'func-style': ['error', 'expression'], '@typescript-eslint/consistent-type-definitions': ['error', 'interface'], '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }], diff --git a/console/client/src/features/modules/components/Panel.tsx b/console/client/src/features/modules/components/Panel.tsx index 3b0f762977..c7752b51d0 100644 --- a/console/client/src/features/modules/components/Panel.tsx +++ b/console/client/src/features/modules/components/Panel.tsx @@ -26,14 +26,18 @@ const Body: React.FC<{ ) } -export const Panel: React.FC<{ +export const Panel: React.FC & { + Header: typeof Header + Body: typeof Body +} = ({ + className, + children, + style, +}: { className?: string children?: React.ReactNode style?: React.CSSProperties -}> & { - Header: typeof Header - Body: typeof Body -} = ({ className, children, style }) => { +}) => { return (
{children} diff --git a/console/client/src/features/modules/graph/svg-zoom.ts b/console/client/src/features/modules/graph/svg-zoom.ts index f0c27898f5..f77b2ecb9c 100644 --- a/console/client/src/features/modules/graph/svg-zoom.ts +++ b/console/client/src/features/modules/graph/svg-zoom.ts @@ -1,4 +1,4 @@ -import { SVG, Element, Svg } from '@svgdotjs/svg.js' +import { Element, SVG, Svg } from '@svgdotjs/svg.js' import '@svgdotjs/svg.panzoom.js/dist/svg.panzoom.esm.js' const centerGroup = ({ diff --git a/console/client/src/layout/Page.tsx b/console/client/src/layout/Page.tsx index fc994113c9..fe04f6353d 100644 --- a/console/client/src/layout/Page.tsx +++ b/console/client/src/layout/Page.tsx @@ -60,14 +60,18 @@ const Body: React.FC<{ ) } -export const Page: React.FC<{ +export const Page: React.FC & { + Header: typeof Header + Body: typeof Body +} = ({ + className, + style, + children, +}: { className?: string style?: React.CSSProperties children?: React.ReactNode -}> & { - Header: typeof Header - Body: typeof Body -} = ({ className, style, children }) => { +}) => { return (
{children} diff --git a/console/client/tsconfig.json b/console/client/tsconfig.json index 1d90f677e8..5b46fe6661 100644 --- a/console/client/tsconfig.json +++ b/console/client/tsconfig.json @@ -1,21 +1,29 @@ { "compilerOptions": { - "target": "es6", - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, + "target": "ES2021", + "useDefineForClassFields": true, + "lib": [ + "ES2021", + "DOM", + "DOM.Iterable" + ], "skipLibCheck": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "allowImportingTsExtensions": true, "strict": true, "forceConsistentCasingInFileNames": true, + "noUnusedLocals": true, + "noUnusedParameters": true, "noFallthroughCasesInSwitch": true, "module": "esnext", "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, - "jsx": "react-jsx" + "jsx": "react-jsx", }, - "include": ["src/**/*"] + "include": [ + "src/**/*" + ] } From a96c4188b4b4b1cc71b0cadcb05f24cbf22e22a6 Mon Sep 17 00:00:00 2001 From: Wes Date: Tue, 10 Oct 2023 10:52:42 -0700 Subject: [PATCH 2/4] Update react imports --- console/client/.eslintrc.cjs | 1 + .../client/src/features/calls/CallList.tsx | 6 ++-- .../features/deployments/DeploymentPage.tsx | 12 +++---- .../features/deployments/DeploymentsPage.tsx | 6 ++-- .../src/features/modules/ModulePage.tsx | 12 +++---- .../src/features/modules/ModulesGraph.tsx | 20 +++++------ .../src/features/modules/ModulesPage.tsx | 8 ++--- .../src/features/modules/ModulesRequests.tsx | 25 +++++++------- .../src/features/modules/ModulesSidebar.tsx | 10 +++--- .../src/features/modules/components/Panel.tsx | 14 +++----- .../features/modules/components/Select.tsx | 34 ------------------- .../src/features/modules/components/index.ts | 1 - .../client/src/features/timeline/Timeline.tsx | 14 ++++---- .../src/features/timeline/TimelinePage.tsx | 12 +++---- .../timeline/details/TimelineCallDetails.tsx | 4 +-- .../TimelineDeploymentCreatedDetails.tsx | 4 +-- .../TimelineDeploymentUpdatedDetails.tsx | 4 +-- .../timeline/details/TimelineLogDetails.tsx | 4 +-- .../timeline/details/TimelineTimestamp.tsx | 6 +--- .../timeline/filters/TimelineFilterPanel.tsx | 14 ++++---- .../timeline/filters/TimelineTimeControls.tsx | 12 +++---- .../client/src/features/verbs/VerbCalls.tsx | 8 ++--- .../client/src/features/verbs/VerbForm.tsx | 16 ++++----- .../client/src/features/verbs/VerbPage.tsx | 14 ++++---- console/client/src/features/verbs/VerbTab.tsx | 4 +-- console/client/src/hooks/use-local-storage.ts | 6 ++-- console/client/src/layout/Notification.tsx | 4 +-- console/client/src/layout/Page.tsx | 14 +++----- .../src/providers/dark-mode-provider.tsx | 4 +-- .../src/providers/notifications-provider.tsx | 8 ++--- .../src/providers/side-panel-provider.tsx | 8 ++--- 31 files changed, 130 insertions(+), 179 deletions(-) delete mode 100644 console/client/src/features/modules/components/Select.tsx diff --git a/console/client/.eslintrc.cjs b/console/client/.eslintrc.cjs index 7b8ae2a15a..ad545b8dd1 100644 --- a/console/client/.eslintrc.cjs +++ b/console/client/.eslintrc.cjs @@ -25,6 +25,7 @@ module.exports = { 'react/react-in-jsx-scope': 'off', 'react/jsx-uses-react': 'off', 'func-style': ['error', 'expression'], + 'react/prop-types': 'off', '@typescript-eslint/consistent-type-definitions': ['error', 'interface'], '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }], '@typescript-eslint/ban-ts-comment': [ diff --git a/console/client/src/features/calls/CallList.tsx b/console/client/src/features/calls/CallList.tsx index 0ce1f6ca68..0c3e4d95a5 100644 --- a/console/client/src/features/calls/CallList.tsx +++ b/console/client/src/features/calls/CallList.tsx @@ -1,4 +1,4 @@ -import React from 'react' +import { useContext, useState } from 'react' import { CallEvent } from '../../protos/xyz/block/ftl/v1/console/console_pb' import { SidePanelContext } from '../../providers/side-panel-provider' import { formatDuration, formatTimestampShort } from '../../utils' @@ -10,8 +10,8 @@ interface Props { } export const CallList = ({ calls }: Props) => { - const { openPanel, closePanel } = React.useContext(SidePanelContext) - const [selectedCall, setSelectedCall] = React.useState() + const { openPanel, closePanel } = useContext(SidePanelContext) + const [selectedCall, setSelectedCall] = useState() const handleCallClicked = (call: CallEvent) => { if (selectedCall?.equals(call)) { diff --git a/console/client/src/features/deployments/DeploymentPage.tsx b/console/client/src/features/deployments/DeploymentPage.tsx index 807e174831..31aa48528c 100644 --- a/console/client/src/features/deployments/DeploymentPage.tsx +++ b/console/client/src/features/deployments/DeploymentPage.tsx @@ -1,5 +1,5 @@ import { RocketLaunchIcon } from '@heroicons/react/24/outline' -import React from 'react' +import { useContext, useEffect, useState } from 'react' import { useNavigate, useParams } from 'react-router-dom' import { ButtonSmall } from '../../components/ButtonSmall' import { Card } from '../../components/Card' @@ -12,18 +12,18 @@ import { verbRefString } from '../verbs/verb.utils' export const DeploymentPage = () => { const navigate = useNavigate() const { deploymentName } = useParams() - const modules = React.useContext(modulesContext) - const [module, setModule] = React.useState() - const [calls, setCalls] = React.useState([]) + const modules = useContext(modulesContext) + const [module, setModule] = useState() + const [calls, setCalls] = useState([]) - React.useEffect(() => { + useEffect(() => { if (modules) { const module = modules.modules.find((module) => module.deploymentName === deploymentName) setModule(module) } }, [modules, deploymentName]) - React.useEffect(() => { + useEffect(() => { if (!module) return const verbCalls: VerbRef[] = [] diff --git a/console/client/src/features/deployments/DeploymentsPage.tsx b/console/client/src/features/deployments/DeploymentsPage.tsx index c854ef0760..a2faf449e9 100644 --- a/console/client/src/features/deployments/DeploymentsPage.tsx +++ b/console/client/src/features/deployments/DeploymentsPage.tsx @@ -1,12 +1,12 @@ import { RocketLaunchIcon } from '@heroicons/react/24/outline' -import React from 'react' +import { useContext } from 'react' import { useNavigate } from 'react-router-dom' import { Card } from '../../components/Card' -import { modulesContext } from '../../providers/modules-provider' import { Page } from '../../layout' +import { modulesContext } from '../../providers/modules-provider' export const DeploymentsPage = () => { - const modules = React.useContext(modulesContext) + const modules = useContext(modulesContext) const navigate = useNavigate() return ( diff --git a/console/client/src/features/modules/ModulePage.tsx b/console/client/src/features/modules/ModulePage.tsx index 51d2ec3088..39377fe0ef 100644 --- a/console/client/src/features/modules/ModulePage.tsx +++ b/console/client/src/features/modules/ModulePage.tsx @@ -1,5 +1,5 @@ import { Square3Stack3DIcon } from '@heroicons/react/24/outline' -import React from 'react' +import { useContext, useEffect, useState } from 'react' import { useNavigate, useParams } from 'react-router-dom' import { Card } from '../../components/Card' import { Page } from '../../layout' @@ -12,18 +12,18 @@ import { CallList } from '../calls/CallList' export const ModulePage = () => { const navigate = useNavigate() const { moduleName } = useParams() - const modules = React.useContext(modulesContext) - const [module, setModule] = React.useState() - const [calls, setCalls] = React.useState() + const modules = useContext(modulesContext) + const [module, setModule] = useState() + const [calls, setCalls] = useState() - React.useEffect(() => { + useEffect(() => { if (modules) { const module = modules.modules.find((module) => module.name === moduleName?.toLocaleLowerCase()) setModule(module) } }, [modules, moduleName]) - React.useEffect(() => { + useEffect(() => { const abortController = new AbortController() if (!module) return diff --git a/console/client/src/features/modules/ModulesGraph.tsx b/console/client/src/features/modules/ModulesGraph.tsx index 217e1241b1..900c971088 100644 --- a/console/client/src/features/modules/ModulesGraph.tsx +++ b/console/client/src/features/modules/ModulesGraph.tsx @@ -1,9 +1,9 @@ -import React from 'react' -import { PlusCircleIcon, MinusCircleIcon, ArrowPathIcon } from '@heroicons/react/24/outline' +import { ArrowPathIcon, MinusCircleIcon, PlusCircleIcon } from '@heroicons/react/24/outline' +import React, { useContext, useEffect, useRef, useState } from 'react' import { modulesContext } from '../../providers/modules-provider' -import { VerbId, ZoomCallbacks } from './modules.constants' import { Panel } from './components' -import { svgZoom, formatSVG, dotToSVG, generateDot } from './graph' +import { dotToSVG, formatSVG, generateDot, svgZoom } from './graph' +import { VerbId, ZoomCallbacks } from './modules.constants' export const ModulesGraph: React.FC<{ className?: string @@ -13,12 +13,12 @@ export const ModulesGraph: React.FC<{ setZoomCallbacks: React.Dispatch> zoomCallbacks?: ZoomCallbacks }> = ({ className, setZoomCallbacks, zoomCallbacks }) => { - const modules = React.useContext(modulesContext) - const canvasRef = React.useRef(null) - const [resizeCount, setResizeCount] = React.useState(0) - const previousDimensions = React.useRef({ width: 0, height: 0 }) // Store previous dimensions + const modules = useContext(modulesContext) + const canvasRef = useRef(null) + const [resizeCount, setResizeCount] = useState(0) + const previousDimensions = useRef({ width: 0, height: 0 }) // Store previous dimensions - React.useEffect(() => { + useEffect(() => { const canvasCur = canvasRef.current if (canvasCur) { const observer = new ResizeObserver((entries) => { @@ -39,7 +39,7 @@ export const ModulesGraph: React.FC<{ } }, [canvasRef]) - React.useEffect(() => { + useEffect(() => { const canvas = canvasRef.current const ready = canvas && Boolean(modules) let animationFrameId: number diff --git a/console/client/src/features/modules/ModulesPage.tsx b/console/client/src/features/modules/ModulesPage.tsx index e608e4abf3..7c04be3b00 100644 --- a/console/client/src/features/modules/ModulesPage.tsx +++ b/console/client/src/features/modules/ModulesPage.tsx @@ -1,5 +1,5 @@ import { Square3Stack3DIcon } from '@heroicons/react/24/outline' -import React from 'react' +import { useContext, useState } from 'react' import { Page } from '../../layout' import { modulesContext } from '../../providers/modules-provider' import { SidePanelProvider } from '../../providers/side-panel-provider' @@ -12,10 +12,10 @@ import type { ZoomCallbacks } from './modules.constants' import { VerbId } from './modules.constants' export const ModulesPage = () => { - const { modules } = React.useContext(modulesContext) - const [selectedVerbs, setSelectedVerbs] = React.useState([]) + const { modules } = useContext(modulesContext) + const [selectedVerbs, setSelectedVerbs] = useState([]) const hasVerbs = Boolean(selectedVerbs.length) - const [zoomCallbacks, setZoomCallbacks] = React.useState() + const [zoomCallbacks, setZoomCallbacks] = useState() return ( diff --git a/console/client/src/features/modules/ModulesRequests.tsx b/console/client/src/features/modules/ModulesRequests.tsx index 7f6ec8672d..6dcbddcb72 100644 --- a/console/client/src/features/modules/ModulesRequests.tsx +++ b/console/client/src/features/modules/ModulesRequests.tsx @@ -1,9 +1,11 @@ -import React from 'react' +import { Timestamp } from '@bufbuild/protobuf' +import React, { useContext, useEffect, useState } from 'react' import { useSearchParams } from 'react-router-dom' -import { Panel } from './components' -import { modulesFilter } from '../../services/console.service' -import { streamEvents } from '../../services/console.service' -import { Event, Module, EventsQuery_Filter } from '../../protos/xyz/block/ftl/v1/console/console_pb' +import { Event, EventsQuery_Filter, Module } from '../../protos/xyz/block/ftl/v1/console/console_pb' +import { SidePanelContext } from '../../providers/side-panel-provider.tsx' +import { modulesFilter, streamEvents } from '../../services/console.service' +import { formatTimestampShort } from '../../utils/date.utils.ts' +import { panelColor } from '../../utils/style.utils.ts' import { TimelineCall } from '../timeline/TimelineCall.tsx' import { TimelineDeploymentCreated } from '../timeline/TimelineDeploymentCreated.tsx' import { TimelineDeploymentUpdated } from '../timeline/TimelineDeploymentUpdated.tsx' @@ -13,10 +15,7 @@ import { TimelineCallDetails } from '../timeline/details/TimelineCallDetails.tsx import { TimelineDeploymentCreatedDetails } from '../timeline/details/TimelineDeploymentCreatedDetails.tsx' import { TimelineDeploymentUpdatedDetails } from '../timeline/details/TimelineDeploymentUpdatedDetails.tsx' import { TimelineLogDetails } from '../timeline/details/TimelineLogDetails.tsx' -import { SidePanelContext } from '../../providers/side-panel-provider.tsx' -import { formatTimestampShort } from '../../utils/date.utils.ts' -import { panelColor } from '../../utils/style.utils.ts' -import { Timestamp } from '@bufbuild/protobuf' +import { Panel } from './components' const maxTimelineEntries = 1000 @@ -25,9 +24,9 @@ export const ModulesRequests: React.FC<{ modules: Module[] }> = ({ className, modules }) => { const [searchParams, setSearchParams] = useSearchParams() - const [entries, setEntries] = React.useState([]) - const { openPanel, closePanel } = React.useContext(SidePanelContext) - const [selectedEntry, setSelectedEntry] = React.useState(null) + const [entries, setEntries] = useState([]) + const { openPanel, closePanel } = useContext(SidePanelContext) + const [selectedEntry, setSelectedEntry] = useState(null) const deployments = modules.map(({ deploymentName }) => deploymentName) const filters: EventsQuery_Filter[] = [] @@ -35,7 +34,7 @@ export const ModulesRequests: React.FC<{ filters.push(modulesFilter(deployments)) } - React.useEffect(() => { + useEffect(() => { setEntries([]) if (!filters.length) return const abortController = new AbortController() diff --git a/console/client/src/features/modules/ModulesSidebar.tsx b/console/client/src/features/modules/ModulesSidebar.tsx index dc0f4d9c02..42e777e894 100644 --- a/console/client/src/features/modules/ModulesSidebar.tsx +++ b/console/client/src/features/modules/ModulesSidebar.tsx @@ -1,11 +1,11 @@ -import React from 'react' import { Listbox } from '@headlessui/react' import { EyeIcon } from '@heroicons/react/20/solid' +import React, { useState } from 'react' import { Module } from '../../protos/xyz/block/ftl/v1/console/console_pb' -import { VerbId, ZoomCallbacks } from './modules.constants' -import { getNames } from './modules.utils' import { classNames } from '../../utils' import { backgrounds, borders, colors } from './components' +import { VerbId, ZoomCallbacks } from './modules.constants' +import { getNames } from './modules.utils' interface DeploymentVerbs { deploymentName: string @@ -73,10 +73,8 @@ export const ModulesSidebar: React.FC<{ selectedVerbs: VerbId[] zoomCallbacks?: ZoomCallbacks }> = ({ className, modules, setSelectedVerbs, selectedVerbs, zoomCallbacks }) => { - /** Setup hooks */ - const [query, setQuery] = React.useState('') + const [query, setQuery] = useState('') - /** Format data */ const map: Map = new Map() for (const { name: moduleName, verbs, deploymentName } of modules) { const value: DeploymentVerbs = { diff --git a/console/client/src/features/modules/components/Panel.tsx b/console/client/src/features/modules/components/Panel.tsx index c7752b51d0..3b0f762977 100644 --- a/console/client/src/features/modules/components/Panel.tsx +++ b/console/client/src/features/modules/components/Panel.tsx @@ -26,18 +26,14 @@ const Body: React.FC<{ ) } -export const Panel: React.FC & { - Header: typeof Header - Body: typeof Body -} = ({ - className, - children, - style, -}: { +export const Panel: React.FC<{ className?: string children?: React.ReactNode style?: React.CSSProperties -}) => { +}> & { + Header: typeof Header + Body: typeof Body +} = ({ className, children, style }) => { return (
{children} diff --git a/console/client/src/features/modules/components/Select.tsx b/console/client/src/features/modules/components/Select.tsx deleted file mode 100644 index 008514b743..0000000000 --- a/console/client/src/features/modules/components/Select.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import React from 'react' -import { Listbox } from '@headlessui/react' - -type OptionTypes = 'verb' | 'module' -interface Option { - key: string - value: string - type?: OptionTypes -} -const SelectIcon: React.FC<{ type: OptionTypes }> = ({ type }) => {type} - -export const Select: React.FC<{ - data: Option[] - onChange: (value: string) => void -}> = ({ data, onChange }) => { - const [selected, setSelected] = React.useState(data[0]) - const handleChange = (option: Option) => { - setSelected(option) - onChange(option.value) - } - return ( - - {selected.value} - - {data.map((item) => ( - - {item.type && } - {item.value} - - ))} - - - ) -} diff --git a/console/client/src/features/modules/components/index.ts b/console/client/src/features/modules/components/index.ts index a7d4722670..8c554565a1 100644 --- a/console/client/src/features/modules/components/index.ts +++ b/console/client/src/features/modules/components/index.ts @@ -1,3 +1,2 @@ -export * from './Select' export * from './Panel' export * from './components.constants' diff --git a/console/client/src/features/timeline/Timeline.tsx b/console/client/src/features/timeline/Timeline.tsx index c74fc7aad0..e63fe1a454 100644 --- a/console/client/src/features/timeline/Timeline.tsx +++ b/console/client/src/features/timeline/Timeline.tsx @@ -1,11 +1,12 @@ import { Timestamp } from '@bufbuild/protobuf' -import React from 'react' +import { useContext, useEffect, useState } from 'react' import { useSearchParams } from 'react-router-dom' import { Event, EventsQuery_Filter } from '../../protos/xyz/block/ftl/v1/console/console_pb.ts' import { SidePanelContext } from '../../providers/side-panel-provider.tsx' import { eventIdFilter, getEvents, streamEvents, timeFilter } from '../../services/console.service.ts' import { formatTimestampShort } from '../../utils/date.utils.ts' import { panelColor } from '../../utils/style.utils.ts' +import { DeploymentLabel } from './DeploymentLabel.tsx' import { TimelineCall } from './TimelineCall.tsx' import { TimelineDeploymentCreated } from './TimelineDeploymentCreated.tsx' import { TimelineDeploymentUpdated } from './TimelineDeploymentUpdated.tsx' @@ -16,7 +17,6 @@ import { TimelineDeploymentCreatedDetails } from './details/TimelineDeploymentCr import { TimelineDeploymentUpdatedDetails } from './details/TimelineDeploymentUpdatedDetails.tsx' import { TimelineLogDetails } from './details/TimelineLogDetails.tsx' import { TimeSettings } from './filters/TimelineTimeControls.tsx' -import { DeploymentLabel } from './DeploymentLabel.tsx' interface Props { timeSettings: TimeSettings @@ -27,11 +27,11 @@ const maxTimelineEntries = 1000 export const Timeline = ({ timeSettings, filters }: Props) => { const [searchParams, setSearchParams] = useSearchParams() - const { openPanel, closePanel, isOpen } = React.useContext(SidePanelContext) - const [entries, setEntries] = React.useState([]) - const [selectedEntry, setSelectedEntry] = React.useState(null) + const { openPanel, closePanel, isOpen } = useContext(SidePanelContext) + const [entries, setEntries] = useState([]) + const [selectedEntry, setSelectedEntry] = useState(null) - React.useEffect(() => { + useEffect(() => { const eventId = searchParams.get('id') const abortController = new AbortController() @@ -75,7 +75,7 @@ export const Timeline = ({ timeSettings, filters }: Props) => { } }, [filters, timeSettings]) - React.useEffect(() => { + useEffect(() => { if (!isOpen) { setSelectedEntry(null) } diff --git a/console/client/src/features/timeline/TimelinePage.tsx b/console/client/src/features/timeline/TimelinePage.tsx index ce107fdcae..b96ab0e06a 100644 --- a/console/client/src/features/timeline/TimelinePage.tsx +++ b/console/client/src/features/timeline/TimelinePage.tsx @@ -1,5 +1,5 @@ import { ListBulletIcon } from '@heroicons/react/24/outline' -import React from 'react' +import { useEffect, useState } from 'react' import { useSearchParams } from 'react-router-dom' import { Page } from '../../layout' import { EventsQuery_Filter } from '../../protos/xyz/block/ftl/v1/console/console_pb' @@ -10,13 +10,13 @@ import { TIME_RANGES, TimeSettings, TimelineTimeControls } from './filters/Timel export const TimelinePage = () => { const [searchParams] = useSearchParams() - const [timeSettings, setTimeSettings] = React.useState({ isTailing: true, isPaused: false }) - const [filters, setFilters] = React.useState([]) - const [selectedTimeRange, setSelectedTimeRange] = React.useState(TIME_RANGES['tail']) - const [isTimelinePaused, setIsTimelinePaused] = React.useState(false) + const [timeSettings, setTimeSettings] = useState({ isTailing: true, isPaused: false }) + const [filters, setFilters] = useState([]) + const [selectedTimeRange, setSelectedTimeRange] = useState(TIME_RANGES['tail']) + const [isTimelinePaused, setIsTimelinePaused] = useState(false) const initialEventId = searchParams.get('id') - React.useEffect(() => { + useEffect(() => { if (initialEventId) { // if we're loading a specific event, we don't want to tail. setSelectedTimeRange(TIME_RANGES['5m']) diff --git a/console/client/src/features/timeline/details/TimelineCallDetails.tsx b/console/client/src/features/timeline/details/TimelineCallDetails.tsx index b04ab6eebc..10c075d198 100644 --- a/console/client/src/features/timeline/details/TimelineCallDetails.tsx +++ b/console/client/src/features/timeline/details/TimelineCallDetails.tsx @@ -1,5 +1,5 @@ import { Timestamp } from '@bufbuild/protobuf' -import React, { useEffect, useState } from 'react' +import { useContext, useEffect, useState } from 'react' import { useNavigate } from 'react-router-dom' import { Card } from '../../../components' import { AttributeBadge } from '../../../components/AttributeBadge' @@ -23,7 +23,7 @@ interface Props { export const TimelineCallDetails = ({ timestamp, call }: Props) => { const client = useClient(ConsoleService) const navigate = useNavigate() - const { closePanel } = React.useContext(SidePanelContext) + const { closePanel } = useContext(SidePanelContext) const [requestCalls, setRequestCalls] = useState([]) const [selectedCall, setSelectedCall] = useState(call) diff --git a/console/client/src/features/timeline/details/TimelineDeploymentCreatedDetails.tsx b/console/client/src/features/timeline/details/TimelineDeploymentCreatedDetails.tsx index 0abdd6952a..ebc10210e6 100644 --- a/console/client/src/features/timeline/details/TimelineDeploymentCreatedDetails.tsx +++ b/console/client/src/features/timeline/details/TimelineDeploymentCreatedDetails.tsx @@ -1,5 +1,5 @@ import { Timestamp } from '@bufbuild/protobuf' -import React from 'react' +import { useContext } from 'react' import { useNavigate } from 'react-router-dom' import { AttributeBadge } from '../../../components/AttributeBadge' import { Card } from '../../../components/Card' @@ -14,7 +14,7 @@ interface Props { } export const TimelineDeploymentCreatedDetails = ({ event, deployment }: Props) => { - const { closePanel } = React.useContext(SidePanelContext) + const { closePanel } = useContext(SidePanelContext) const navigate = useNavigate() return ( diff --git a/console/client/src/features/timeline/details/TimelineDeploymentUpdatedDetails.tsx b/console/client/src/features/timeline/details/TimelineDeploymentUpdatedDetails.tsx index 282c39b74c..5d88256e1d 100644 --- a/console/client/src/features/timeline/details/TimelineDeploymentUpdatedDetails.tsx +++ b/console/client/src/features/timeline/details/TimelineDeploymentUpdatedDetails.tsx @@ -1,5 +1,5 @@ import { Timestamp } from '@bufbuild/protobuf' -import React from 'react' +import { useContext } from 'react' import { useNavigate } from 'react-router-dom' import { AttributeBadge } from '../../../components/AttributeBadge' import { Card } from '../../../components/Card' @@ -14,7 +14,7 @@ interface Props { } export const TimelineDeploymentUpdatedDetails = ({ event, deployment }: Props) => { - const { closePanel } = React.useContext(SidePanelContext) + const { closePanel } = useContext(SidePanelContext) const navigate = useNavigate() return ( diff --git a/console/client/src/features/timeline/details/TimelineLogDetails.tsx b/console/client/src/features/timeline/details/TimelineLogDetails.tsx index d5ecabb3d9..568790e4e4 100644 --- a/console/client/src/features/timeline/details/TimelineLogDetails.tsx +++ b/console/client/src/features/timeline/details/TimelineLogDetails.tsx @@ -1,5 +1,5 @@ import { Timestamp } from '@bufbuild/protobuf' -import React from 'react' +import { useContext } from 'react' import { useNavigate } from 'react-router-dom' import { AttributeBadge } from '../../../components/AttributeBadge' import { Card } from '../../../components/Card' @@ -18,7 +18,7 @@ interface Props { } export const TimelineLogDetails = ({ event, log }: Props) => { - const { closePanel } = React.useContext(SidePanelContext) + const { closePanel } = useContext(SidePanelContext) const navigate = useNavigate() return ( diff --git a/console/client/src/features/timeline/details/TimelineTimestamp.tsx b/console/client/src/features/timeline/details/TimelineTimestamp.tsx index e237e76d5b..ad108715cb 100644 --- a/console/client/src/features/timeline/details/TimelineTimestamp.tsx +++ b/console/client/src/features/timeline/details/TimelineTimestamp.tsx @@ -2,11 +2,7 @@ import { Timestamp } from '@bufbuild/protobuf' import { formatTimestampShort } from '../../../utils/date.utils' import { textColor } from '../../../utils/style.utils' -interface Props { - timestamp: Timestamp -} - -export const TimelineTimestamp = ({ timestamp }: Props) => { +export const TimelineTimestamp = ({ timestamp }: { timestamp: Timestamp }) => { return (