Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Add files here to ignore them from prettier formatting

.jj
/dist
/coverage
/templates

mockServiceWorker.js
mockServiceWorker.js
2 changes: 2 additions & 0 deletions app/components/CapacityBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* Copyright Oxide Computer Company
*/

import type { JSX } from 'react'

import { BigNum } from '~/ui/lib/BigNum'
import { percentage, splitDecimal } from '~/util/math'

Expand Down
1 change: 1 addition & 0 deletions app/components/DocsPopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import { Popover, PopoverButton, PopoverPanel } from '@headlessui/react'
import cn from 'classnames'
import type { JSX } from 'react'

import { Info16Icon, OpenLink12Icon } from '@oxide/design-system/icons/react'

Expand Down
1 change: 1 addition & 0 deletions app/components/TimeAgo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Copyright Oxide Computer Company
*/
import type { Placement } from '@floating-ui/react'
import type { JSX } from 'react'

import { Tooltip } from '~/ui/lib/Tooltip'
import { timeAgoAbbr, toLocaleDateTimeString } from '~/util/date'
Expand Down
4 changes: 3 additions & 1 deletion app/components/form/fields/DateTimeRangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ export function DateTimeRangePicker({
label="Choose a date range"
value={range}
onChange={(range) => {
setRange(range)
if (range) {
setRange(range)
}
setPreset('custom')
}}
minValue={minValue}
Expand Down
1 change: 1 addition & 0 deletions app/table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
import { flexRender, type Table as TableInstance } from '@tanstack/react-table'
import cn from 'classnames'
import type { JSX } from 'react'

import { Table as UITable } from '~/ui/lib/Table'

Expand Down
6 changes: 4 additions & 2 deletions app/ui/lib/DateRangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export function DateRangePicker(props: DateRangePickerProps) {
// because we always pass a value to this component and there is no way to
// unset the value through the UI.
if (!state.dateRange) return 'No range selected'
if (!state.dateRange.end) return 'No end date selected'
if (!state.dateRange.start) return 'No start date selected'

return formatter.formatRange(
state.dateRange.start.toDate(getLocalTimeZone()),
Expand Down Expand Up @@ -94,15 +96,15 @@ export function DateRangePicker(props: DateRangePickerProps) {
<TimeField
label="Start time"
value={state.timeRange?.start || null}
onChange={(v: TimeValue) => state.setTime('start', v)}
onChange={(v: TimeValue | null) => state.setTime('start', v)}
hourCycle={24}
className="shrink-0 grow basis-0"
/>
<div className="text-quaternary">–</div>
<TimeField
label="End time"
value={state.timeRange?.end || null}
onChange={(v: TimeValue) => state.setTime('end', v)}
onChange={(v: TimeValue | null) => state.setTime('end', v)}
hourCycle={24}
className="shrink-0 grow basis-0"
/>
Expand Down
2 changes: 1 addition & 1 deletion app/ui/lib/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Oxide Computer Company
*/
import cn from 'classnames'
import React, { useRef, type ReactElement } from 'react'
import React, { useRef, type JSX, type ReactElement } from 'react'
import SimpleBar from 'simplebar-react'

import { useIsOverflow } from '~/hooks/use-is-overflow'
Expand Down Expand Up @@ -71,7 +71,7 @@
Table.Body = ({ className, children, ...props }: TableBodyProps) => {
const rows = React.Children.toArray(children).map((c, i, siblings) => {
const child = c as ReactElement
const beforeSelected = (siblings[i - 1] as ReactElement | undefined)?.props.selected

Check failure on line 74 in app/ui/lib/Table.tsx

View workflow job for this annotation

GitHub Actions / ci

Object is of type 'unknown'.
const afterSelected = (siblings[i + 1] as ReactElement | undefined)?.props.selected
const className =
child.props.selected && (beforeSelected || afterSelected)
Expand Down
1 change: 1 addition & 0 deletions app/util/children.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*
* Copyright Oxide Computer Company
*/
import type { JSX } from 'react'
import { describe, expect, it } from 'vitest'

import { flattenChildren, isOneOf, pluckAllOfType, pluckFirstOfType } from './children'
Expand Down
2 changes: 1 addition & 1 deletion app/util/classed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright Oxide Computer Company
*/
import cn from 'classnames'
import React, { forwardRef } from 'react'
import React, { forwardRef, type JSX } from 'react'

// all the cuteness of tw.span`text-green-500 uppercase` with zero magic

Expand Down
7 changes: 7 additions & 0 deletions app/util/str.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ describe('extractText', () => {
</>
)
).toBe('This is my text')
expect(
extractText(
<>
Numbers like <em>9</em> are just strings
</>
)
).toBe('Numbers like 9 are just strings')
})
it('extracts strings from nested elements', () => {
expect(
Expand Down
2 changes: 1 addition & 1 deletion app/util/str.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const extractText = (children: React.ReactNode): string =>
typeof child === 'string'
? child
: React.isValidElement(child)
? extractText(child.props.children)
? extractText((child.props as { children?: React.ReactNode }).children)
: ''
)
.join(' ')
Expand Down
Loading
Loading