diff --git a/web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertConfirm.js b/web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertConfirm.tsx similarity index 85% rename from web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertConfirm.js rename to web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertConfirm.tsx index 5a5dc22389..949a7400d2 100644 --- a/web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertConfirm.js +++ b/web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertConfirm.tsx @@ -14,10 +14,20 @@ const useStyles = makeStyles({ }, }) -export function CreateAlertConfirm() { +export function CreateAlertConfirm(): JSX.Element { const classes = useStyles() - const renderItem = ({ name, label, value, children }) => ( + const renderItem = ({ + name, + label, + value, + children, + }: { + name: string + label: string + value: string + children: JSX.Element + }): JSX.Element => ( ( + children: value.map((id: string) => ( diff --git a/web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertListItem.js b/web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertListItem.tsx similarity index 89% rename from web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertListItem.js rename to web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertListItem.tsx index f89b97f7df..6b91d86294 100644 --- a/web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertListItem.js +++ b/web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertListItem.tsx @@ -1,5 +1,4 @@ import React from 'react' -import p from 'prop-types' import { ListItem, ListItemText, Typography } from '@mui/material' import makeStyles from '@mui/styles/makeStyles' import OpenInNewIcon from '@mui/icons-material/OpenInNew' @@ -21,7 +20,9 @@ const useStyles = makeStyles({ }, }) -export default function CreateAlertListItem(props) { +export default function CreateAlertListItem(props: { + id: string +}): JSX.Element { const { id } = props const classes = useStyles() @@ -49,7 +50,3 @@ export default function CreateAlertListItem(props) { ) } - -CreateAlertListItem.propTypes = { - id: p.string.isRequired, -} diff --git a/web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertReview.js b/web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertReview.tsx similarity index 77% rename from web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertReview.js rename to web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertReview.tsx index 7c26f42688..c78d312f58 100644 --- a/web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertReview.js +++ b/web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertReview.tsx @@ -1,10 +1,19 @@ import React from 'react' -import p from 'prop-types' import { Grid, List } from '@mui/material' import CreateAlertListItem from './CreateAlertListItem' import CreateAlertServiceListItem from './CreateAlertServiceListItem' -export function CreateAlertReview(props) { +interface FailedService { + id: string + message: string +} + +interface CreateAlertReviewProps { + createdAlertIDs?: string[] + failedServices?: FailedService[] +} + +export function CreateAlertReview(props: CreateAlertReviewProps): JSX.Element { const { createdAlertIDs = [], failedServices = [] } = props return ( @@ -12,7 +21,7 @@ export function CreateAlertReview(props) { {createdAlertIDs.length > 0 && ( - {createdAlertIDs.map((id) => ( + {createdAlertIDs.map((id: string) => ( ))} @@ -37,13 +46,3 @@ export function CreateAlertReview(props) { ) } - -CreateAlertReview.propTypes = { - createdAlertIDs: p.arrayOf(p.string), - failedServices: p.arrayOf( - p.shape({ - id: p.string, - message: p.string, - }), - ), -} diff --git a/web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertServiceListItem.js b/web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertServiceListItem.tsx similarity index 82% rename from web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertServiceListItem.js rename to web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertServiceListItem.tsx index 99cce783a5..26a4a41e24 100644 --- a/web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertServiceListItem.js +++ b/web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertServiceListItem.tsx @@ -1,6 +1,5 @@ import React from 'react' import { gql, useQuery } from '@apollo/client' -import p from 'prop-types' import { ListItem, ListItemText, Typography } from '@mui/material' @@ -26,7 +25,14 @@ const useStyles = makeStyles({ }, }) -export default function CreateAlertServiceListItem(props) { +interface CreateAlertServiceListItemProps { + id: string + err?: string +} + +export default function CreateAlertServiceListItem( + props: CreateAlertServiceListItemProps, +): JSX.Element { const { id, err } = props const classes = useStyles() @@ -43,8 +49,8 @@ export default function CreateAlertServiceListItem(props) { const { service } = data || {} - if (!data && loading) return 'Loading...' - if (queryError) return 'Error fetching data.' + if (!data && loading) return
Loading...
+ if (queryError) return
Error fetching data.
const serviceURL = '/services/' + id + '/alerts' @@ -69,8 +75,3 @@ export default function CreateAlertServiceListItem(props) { ) } - -CreateAlertServiceListItem.propTypes = { - id: p.string.isRequired, - err: p.string, -} diff --git a/web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertServiceSelect.js b/web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertServiceSelect.tsx similarity index 88% rename from web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertServiceSelect.js rename to web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertServiceSelect.tsx index 84a677f0ac..c62ee79080 100644 --- a/web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertServiceSelect.js +++ b/web/src/app/alerts/CreateAlertDialog/StepContent/CreateAlertServiceSelect.tsx @@ -1,6 +1,5 @@ -import React, { useRef, useState, useEffect } from 'react' +import React, { useRef, useState, useEffect, MouseEvent } from 'react' import { gql, useQuery } from '@apollo/client' -import p from 'prop-types' import { TextField, InputAdornment, @@ -15,6 +14,7 @@ import { FormLabel, FormControl, Box, + Theme, } from '@mui/material' import makeStyles from '@mui/styles/makeStyles' import ServiceLabelFilterContainer from '../../../services/ServiceFilterContainer' @@ -27,6 +27,7 @@ import getServiceFilters from '../../../util/getServiceFilters' import { CREATE_ALERT_LIMIT, DEBOUNCE_DELAY } from '../../../config' import { allErrors } from '../../../util/errutil' +import { Service } from '../../../../schema' const query = gql` query ($input: ServiceSearchOptions) { @@ -40,7 +41,7 @@ const query = gql` } ` -const useStyles = makeStyles((theme) => ({ +const useStyles = makeStyles((theme: Theme) => ({ addAll: { marginRight: '0.25em', }, @@ -68,8 +69,17 @@ const useStyles = makeStyles((theme) => ({ }, })) -export function CreateAlertServiceSelect(props) { +interface CreateAlertServiceSelectProps { + value: string[] + onChange: (val: string[]) => void + error?: Error +} + +export function CreateAlertServiceSelect( + props: CreateAlertServiceSelectProps, +): JSX.Element { const { value, onChange } = props + const [searchQueryInput, setSearchQueryInput] = useState('') const [searchUserInput, setSearchUserInput] = useState('') @@ -88,10 +98,10 @@ export function CreateAlertServiceSelect(props) { }, }) - const fieldRef = useRef() + const fieldRef = useRef(null) const classes = useStyles() const searchResults = _.get(data, 'services.nodes', []).filter( - ({ id }) => !value.includes(id), + ({ id }: { id: string }) => !value.includes(id), ) const queryErrorMsg = allErrors(queryError) @@ -118,10 +128,10 @@ export function CreateAlertServiceSelect(props) { const { labelKey, labelValue } = getServiceFilters(searchUserInput) - const addAll = (e) => { + const addAll = (e: MouseEvent): void => { e.stopPropagation() e.preventDefault() - const resultIDs = searchResults.map((s) => s.id) + const resultIDs = searchResults.map((s: { id: string }) => s.id) props.onChange( _.uniq([...value, ...resultIDs]).slice(0, CREATE_ALERT_LIMIT), @@ -168,7 +178,7 @@ export function CreateAlertServiceSelect(props) { {Boolean(props.error) && ( - {props.error.message.replace(/^./, (str) => str.toUpperCase())} + {props.error?.message.replace(/^./, (str) => str.toUpperCase())} )} @@ -223,8 +233,7 @@ export function CreateAlertServiceSelect(props) { {queryErrorMsg} )} - - {searchResults.map((service) => ( + {searchResults.map((service: Service) => ( = CREATE_ALERT_LIMIT} onClick={() => onChange([ - ...value.filter((id) => id !== service.id), + ...value.filter((id: string) => id !== service.id), service.id, ]) } @@ -257,8 +266,3 @@ export function CreateAlertServiceSelect(props) { ) } - -CreateAlertServiceSelect.propTypes = { - onChange: p.func.isRequired, - error: p.object, -} diff --git a/web/src/app/forms/FormField.js b/web/src/app/forms/FormField.js index 862050a027..541dbf9eaa 100644 --- a/web/src/app/forms/FormField.js +++ b/web/src/app/forms/FormField.js @@ -246,7 +246,7 @@ FormField.propTypes = { disabled: p.bool, multiline: p.bool, - rows: p.string, + rows: p.number, autoComplete: p.string, charCount: p.number, diff --git a/web/src/app/services/ServiceFilterContainer.tsx b/web/src/app/services/ServiceFilterContainer.tsx index 91cf2165e6..04a4db1b4d 100644 --- a/web/src/app/services/ServiceFilterContainer.tsx +++ b/web/src/app/services/ServiceFilterContainer.tsx @@ -11,7 +11,7 @@ import FilterContainer from '../util/FilterContainer' interface Value { labelKey: string labelValue: string - integrationKey: string + integrationKey?: string } interface ServiceFilterContainerProps { diff --git a/web/src/app/services/ServiceForm.tsx b/web/src/app/services/ServiceForm.tsx index 8c10aa080b..1c73470dd4 100644 --- a/web/src/app/services/ServiceForm.tsx +++ b/web/src/app/services/ServiceForm.tsx @@ -45,7 +45,7 @@ export default function ServiceForm(props: ServiceFormProps): JSX.Element { label='Description' name='description' multiline - rows='4' + rows={4} component={TextField} charCount={MaxDetailsLength} hint='Markdown Supported'