Skip to content

Commit

Permalink
dev: migrate from JSX.Element -> React.JSX.Element (part 1) (#4258)
Browse files Browse the repository at this point in the history
* refactor: update return types to React.JSX.Element in admin and alerts components

* refactor: update return types to React.JSX.Element across multiple components
  • Loading branch information
mastercactapus authored Feb 11, 2025
1 parent d45f234 commit 5d2b153
Show file tree
Hide file tree
Showing 119 changed files with 213 additions and 184 deletions.
2 changes: 1 addition & 1 deletion web/src/app/NewVersionCheck.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const fetchCurrentVersion = (): Promise<string> =>
.then((res) => res.text())
.then((docStr) => extractMetaTagValue(docStr, 'x-goalert-version'))

export default function NewVersionCheck(): JSX.Element {
export default function NewVersionCheck(): React.JSX.Element {
const [currentVersion, setCurrentVersion] = useState(GOALERT_VERSION)
const [firstSeen, setFirstSeen] = useState(DateTime.utc())
const [lastCheck, setLastCheck] = useState(DateTime.utc())
Expand Down
2 changes: 1 addition & 1 deletion web/src/app/admin/AdminAPIKeys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const useStyles = makeStyles((theme: Theme) => ({
},
}))

export default function AdminAPIKeys(): JSX.Element {
export default function AdminAPIKeys(): React.JSX.Element {
const classes = useStyles()
const [selectedAPIKey, setSelectedAPIKey] = useState<GQLAPIKey | null>(null)
const [createDialog, setCreateDialog] = useState<boolean>(false)
Expand Down
2 changes: 1 addition & 1 deletion web/src/app/admin/AdminConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function formatHeading(s = ''): string {
.replace(/R Ls\b/, 'RLs') // fix usages of `URLs`
}

export default function AdminConfig(): JSX.Element {
export default function AdminConfig(): React.JSX.Element {
const classes = useStyles()
const [confirm, setConfirm] = useState(false)
const [values, setValues] = useState({})
Expand Down
2 changes: 1 addition & 1 deletion web/src/app/admin/AdminDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface AdminDialogProps {
onComplete?: () => void
}

function AdminDialog(props: AdminDialogProps): JSX.Element {
function AdminDialog(props: AdminDialogProps): React.JSX.Element {
const [{ data, fetching, error: readError }] = useQuery({
query: props.query || query,
})
Expand Down
10 changes: 5 additions & 5 deletions web/src/app/admin/AdminFieldComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ interface InputProps {
autoComplete?: string
}

export function StringInput(props: InputProps): JSX.Element {
export function StringInput(props: InputProps): React.JSX.Element {
const [showPassword, setShowPassword] = useState(false)
const { onChange, password, type = 'text', ...rest } = props

const renderPasswordAdornment = (): JSX.Element | null => {
const renderPasswordAdornment = (): React.JSX.Element | null => {
if (!props.password) return null

return (
Expand Down Expand Up @@ -52,7 +52,7 @@ export function StringInput(props: InputProps): JSX.Element {
)
}

export const StringListInput = (props: InputProps): JSX.Element => {
export const StringListInput = (props: InputProps): React.JSX.Element => {
const value = props.value ? props.value.split('\n').concat('') : ['']
return (
<Grid container spacing={1}>
Expand Down Expand Up @@ -80,7 +80,7 @@ export const StringListInput = (props: InputProps): JSX.Element => {
)
}

export const IntegerInput = (props: InputProps): JSX.Element => (
export const IntegerInput = (props: InputProps): React.JSX.Element => (
<Input
name={props.name}
value={props.value}
Expand All @@ -95,7 +95,7 @@ export const IntegerInput = (props: InputProps): JSX.Element => (
/>
)

export const BoolInput = (props: InputProps): JSX.Element => (
export const BoolInput = (props: InputProps): React.JSX.Element => (
<Switch
name={props.name}
value={props.value}
Expand Down
2 changes: 1 addition & 1 deletion web/src/app/admin/AdminLimits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ interface LimitsValues {
[id: string]: string
}

export default function AdminLimits(): JSX.Element {
export default function AdminLimits(): React.JSX.Element {
const classes = useStyles()
const [confirm, setConfirm] = useState(false)
const [values, setValues] = useState({})
Expand Down
4 changes: 2 additions & 2 deletions web/src/app/admin/AdminNumberLookup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const numInfoQuery = gql`

const noSuspense = { suspense: false }

export default function AdminNumberLookup(): JSX.Element {
export default function AdminNumberLookup(): React.JSX.Element {
const [number, setNumber] = useState('')
const [staleCarrier, setStaleCarrier] = useState(true)

Expand All @@ -74,7 +74,7 @@ export default function AdminNumberLookup(): JSX.Element {
if (mutationError) setLastError(mutationError)
}, [mutationError])

function renderListItem(label: string, text = ''): JSX.Element {
function renderListItem(label: string, text = ''): React.JSX.Element {
return (
<React.Fragment>
<Divider />
Expand Down
2 changes: 1 addition & 1 deletion web/src/app/admin/AdminSMSSend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const useStyles = makeStyles({
},
})

export default function AdminSMSSend(): JSX.Element {
export default function AdminSMSSend(): React.JSX.Element {
const classes = useStyles()
const [cfgFromNumber, cfgSID] = useConfigValue(
'Twilio.FromNumber',
Expand Down
4 changes: 3 additions & 1 deletion web/src/app/admin/AdminSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ const useStyles = makeStyles((theme: Theme) => ({
},
}))

export default function AdminSection(props: AdminSectionProps): JSX.Element {
export default function AdminSection(
props: AdminSectionProps,
): React.JSX.Element {
// TODO: add 'reset to default' buttons
const classes = useStyles()
const { fields, value, headerNote } = props
Expand Down
2 changes: 1 addition & 1 deletion web/src/app/admin/AdminToolbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const useStyles = makeStyles((theme: Theme) => ({
},
}))

export default function AdminToolbox(): JSX.Element {
export default function AdminToolbox(): React.JSX.Element {
const classes = useStyles()

return (
Expand Down
4 changes: 2 additions & 2 deletions web/src/app/admin/SlackActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ const useStyles = makeStyles({
},
})

export default function SlackActions(): JSX.Element {
export default function SlackActions(): React.JSX.Element {
const classes = useStyles()
const [showManifest, setShowManifest] = useState(false)

const [{ fetching, error, data }] = useQuery({ query })
const manifest = data?.generateSlackAppManifest ?? ''

function renderContent(): JSX.Element {
function renderContent(): React.JSX.Element {
if (fetching) return <Spinner />
if (error) return <GenericError error={error.message} />

Expand Down
2 changes: 1 addition & 1 deletion web/src/app/admin/admin-alert-counts/AdminAlertCounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const units: Record<string, DateTimeUnit> = {
P1M: 'month',
}

export default function AdminAlertCounts(): JSX.Element {
export default function AdminAlertCounts(): React.JSX.Element {
const styles = useStyles()

const [graphData, setGraphData] = useState<AlertCountSeries[]>([])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { ISODateTimePicker } from '../../util/ISOPickers'
import { useURLParams, useResetURLParams } from '../../actions'
import { DateTime } from 'luxon'

export default function AlertCountControls(): JSX.Element {
export default function AlertCountControls(): React.JSX.Element {
const now = useMemo(() => DateTime.now(), [])
const [params, setParams] = useURLParams({
createdAfter: now.minus({ days: 1 }).toISO(),
Expand Down
4 changes: 2 additions & 2 deletions web/src/app/admin/admin-alert-counts/AlertCountLineGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ interface CustomDotProps extends DotProps {
}
}

function CustomDot(props: CustomDotProps): JSX.Element {
function CustomDot(props: CustomDotProps): React.JSX.Element {
const { cy, cx, fill, r, stroke, strokeWidth, name = '', payload } = props

return (
Expand All @@ -77,7 +77,7 @@ function CustomDot(props: CustomDotProps): JSX.Element {

export default function AlertCountLineGraph(
props: AlertCountLineGraphProps,
): JSX.Element {
): React.JSX.Element {
const [active, setActive] = useState('')
const classes = useStyles()
const theme = useTheme()
Expand Down
4 changes: 2 additions & 2 deletions web/src/app/admin/admin-alert-counts/AlertCountTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const columns = [

export default function AlertCountTable(
props: AlertCountTableProps,
): JSX.Element {
): React.JSX.Element {
const classes = useStyles()

const csvOpts = useMemo(
Expand All @@ -102,7 +102,7 @@ export default function AlertCountTable(
[csvData],
)

function CustomToolbar(): JSX.Element {
function CustomToolbar(): React.JSX.Element {
const apiRef = useGridApiContext()
const currentPage = gridPaginatedVisibleSortedGridRowEntriesSelector(
apiRef,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const query = gql`
export default function AdminAPIKeyDeleteDialog(props: {
apiKeyID: string
onClose: (yes: boolean) => void
}): JSX.Element {
}): React.JSX.Element {
const [{ fetching, data, error }] = useQuery({
query,
})
Expand Down
2 changes: 1 addition & 1 deletion web/src/app/admin/admin-api-keys/AdminAPIKeyDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function ActionBy(props: {
)
}

export default function AdminAPIKeyDrawer(props: Props): JSX.Element {
export default function AdminAPIKeyDrawer(props: Props): React.JSX.Element {
const { onClose, apiKeyID } = props
const classes = useStyles()
const isOpen = Boolean(apiKeyID)
Expand Down
2 changes: 1 addition & 1 deletion web/src/app/admin/admin-api-keys/AdminAPIKeyEditDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const query = gql`
export default function AdminAPIKeyEditDialog(props: {
onClose: (param: boolean) => void
apiKeyID: string
}): JSX.Element {
}): React.JSX.Element {
const { apiKeyID, onClose } = props
const [{ fetching, data, error }] = useQuery({
query,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const presets = [7, 15, 30, 60, 90]

export default function AdminAPIKeyExpirationField(
props: FieldProps,
): JSX.Element {
): React.JSX.Element {
const classes = useStyles()

const [selected, setSelected] = useState<number>(
Expand Down
2 changes: 1 addition & 1 deletion web/src/app/admin/admin-api-keys/AdminAPIKeyForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type AdminAPIKeyFormProps = {

export default function AdminAPIKeyForm(
props: AdminAPIKeyFormProps,
): JSX.Element {
): React.JSX.Element {
const queryError = props.errors.find((e) => e.field === 'query')?.message
return (
<FormContainer optionalLabels {...props}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const query = gql`
export default function AdminAPIKeyShowQueryDialog(props: {
apiKeyID: string
onClose: (yes: boolean) => void
}): JSX.Element {
}): React.JSX.Element {
const theme = useTheme()
const [{ fetching, data, error }] = useQuery({
query,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const useStyles = makeStyles((theme: Theme) => ({
},
}))

export default function AdminMessageLogDrawer(props: Props): JSX.Element {
export default function AdminMessageLogDrawer(props: Props): React.JSX.Element {
const { onClose, log } = props
const classes = useStyles()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ISODateTimePicker } from '../../util/ISOPickers'
import Search from '../../util/Search'
import { useMessageLogsParams } from './util'

export default function AdminMessageLogsControls(): JSX.Element {
export default function AdminMessageLogsControls(): React.JSX.Element {
const [params, setParams] = useMessageLogsParams()

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type Stats = Array<{

interface MessageLogGraphData {
date: string
label: JSX.Element
label: React.JSX.Element
count: number
}

Expand All @@ -60,7 +60,7 @@ const statsQuery = gql`
}
`

export default function AdminMessageLogsGraph(): JSX.Element {
export default function AdminMessageLogsGraph(): React.JSX.Element {
const theme = useTheme()

const [{ search, start, end, graphInterval }, setParams] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const useStyles = makeStyles((theme: Theme) => ({

const context = { suspense: false }

export default function AdminMessageLogsLayout(): JSX.Element {
export default function AdminMessageLogsLayout(): React.JSX.Element {
const classes = useStyles()
const [selectedLog, setSelectedLog] = useState<DebugMessage | null>(null)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { LabelKeySelect } from '../../selection'
import { LabelValueSelect } from '../../selection/LabelValueSelect'
import { useFeatures } from '../../util/RequireConfig'

function AdminServiceFilter(): JSX.Element {
function AdminServiceFilter(): React.JSX.Element {
const [open, setOpen] = useState<boolean>(false)

const [params, setParams] = useURLParams({
Expand Down Expand Up @@ -52,7 +52,7 @@ function AdminServiceFilter(): JSX.Element {
setParams({ ...params, [filterName]: [] })
}

function renderFilterChips(): JSX.Element {
function renderFilterChips(): React.JSX.Element {
return (
<Stack direction='row' spacing={1} sx={{ marginTop: '10px' }}>
{!!params.epStepTgts.length && (
Expand Down Expand Up @@ -89,7 +89,7 @@ function AdminServiceFilter(): JSX.Element {
)
}

function renderFilterDrawer(): JSX.Element {
function renderFilterDrawer(): React.JSX.Element {
return (
<ClickAwayListener
onClickAway={() => setOpen(false)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import AdminServiceTargetGraph from './AdminServiceTargetGraph'

const STALE_ALERT_LIMIT = 2

export default function AdminServiceMetrics(): JSX.Element {
export default function AdminServiceMetrics(): React.JSX.Element {
const now = useMemo(() => DateTime.now(), [])
const [params] = useURLParams({
epStepTgts: [] as string[],
Expand Down Expand Up @@ -95,7 +95,7 @@ export default function AdminServiceMetrics(): JSX.Element {
? 'Loading services... This may take a minute'
: `Metrics pulled from ${metrics.filteredServices.length} services`

function renderOverviewMetrics(): JSX.Element {
function renderOverviewMetrics(): React.JSX.Element {
return (
<React.Fragment>
<Grid item xs={4} sm={2.4}>
Expand Down Expand Up @@ -176,7 +176,7 @@ export default function AdminServiceMetrics(): JSX.Element {
)
}

function renderUsageGraphs(): JSX.Element {
function renderUsageGraphs(): React.JSX.Element {
return (
<React.Fragment>
<Grid item xs>
Expand Down Expand Up @@ -221,7 +221,7 @@ export default function AdminServiceMetrics(): JSX.Element {
)
}

function renderServiceTable(): JSX.Element {
function renderServiceTable(): React.JSX.Element {
return (
<Card sx={{ marginTop: (theme) => theme.spacing(1) }}>
<CardHeader title='Services' subheader={cardSubHeader} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ interface AdminServiceTableProps {

export default function AdminServiceTable(
props: AdminServiceTableProps,
): JSX.Element {
): React.JSX.Element {
const { services = [], loading, staleAlertServices } = props
// Community version of MUI DataGrid only supports sortModels with a single SortItem
const [sortModel, setSortModel] = useState<GridSortItem[]>([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface AdminServiceTargetGraphProps {

export default function AdminServiceTargetGraph(
props: AdminServiceTargetGraphProps,
): JSX.Element {
): React.JSX.Element {
const theme = useTheme()
const { metrics, loading } = props
let targetMetrics = [] as { type: string; count: number }[]
Expand Down
2 changes: 1 addition & 1 deletion web/src/app/admin/switchover/AdminSWOConfirmDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default function AdminSWOConfirmDialog(props: {
messages: string[]
onConfirm: () => void
onClose: () => void
}): JSX.Element {
}): React.JSX.Element {
return (
<FormDialog
title='Continue with switchover?'
Expand Down
Loading

0 comments on commit 5d2b153

Please sign in to comment.