diff --git a/plugins/newrelic-dashboard/src/api/NewRelicDashboardClient.ts b/plugins/newrelic-dashboard/src/api/NewRelicDashboardClient.ts index d1626b481f..b79cceeeda 100644 --- a/plugins/newrelic-dashboard/src/api/NewRelicDashboardClient.ts +++ b/plugins/newrelic-dashboard/src/api/NewRelicDashboardClient.ts @@ -38,7 +38,7 @@ export class NewRelicDashboardClient implements NewRelicDashboardApi { private async callApi( query: string, - variables: { [key in string]: any }, + variables: { [key in string]: string | number }, ): Promise { const myHeaders = new Headers(); myHeaders.append('Content-Type', 'application/json'); diff --git a/plugins/newrelic-dashboard/src/components/NewRelicDashboard/DashboardEntityList.tsx b/plugins/newrelic-dashboard/src/components/NewRelicDashboard/DashboardEntityList.tsx index 082f4c8b0d..2626e7b345 100644 --- a/plugins/newrelic-dashboard/src/components/NewRelicDashboard/DashboardEntityList.tsx +++ b/plugins/newrelic-dashboard/src/components/NewRelicDashboard/DashboardEntityList.tsx @@ -19,11 +19,11 @@ import { newRelicDashboardApiRef } from '../../api'; import { useApi } from '@backstage/core-plugin-api'; import { useAsync } from 'react-use'; import { Progress, InfoCard, Link } from '@backstage/core-components'; - import Alert from '@material-ui/lab/Alert'; - import DesktopMac from '@material-ui/icons/DesktopMac'; import { useNewRelicDashboardEntity } from '../../hooks'; +import { DashboardEntitySummary } from '../../api/NewRelicDashboardApi'; +import { ResultEntity } from '../../types/DashboardEntity'; const useStyles = makeStyles({ svgIcon: { @@ -39,10 +39,13 @@ export const DashboardEntityList = () => { const DashboardEntity = useNewRelicDashboardEntity(); const classes = useStyles(); const newRelicDashboardAPI = useApi(newRelicDashboardApiRef); - const { value, loading, error } = useAsync(async (): Promise => { - const dashboardObject: any = newRelicDashboardAPI.getDashboardEntity( - String(DashboardEntity?.integrationKey), - ); + const { value, loading, error } = useAsync(async (): Promise< + DashboardEntitySummary | undefined + > => { + const dashboardObject: Promise = + newRelicDashboardAPI.getDashboardEntity( + String(DashboardEntity?.integrationKey), + ); return dashboardObject; }, []); if (loading) { @@ -55,12 +58,13 @@ export const DashboardEntityList = () => { {value?.getDashboardEntity === undefined && 'Unauthorized Request , please check API Key'} - {value?.getDashboardEntity?.data.actor.entitySearch.results.entities - .length <= 0 && ( - <>No Dashboard Pages found with the specified Dashboard GUID - )} + {value?.getDashboardEntity !== undefined && + value?.getDashboardEntity?.data.actor.entitySearch.results?.entities + ?.length <= 0 && ( + <>No Dashboard Pages found with the specified Dashboard GUID + )} {value?.getDashboardEntity?.data.actor.entitySearch.results.entities?.map( - (entity: any) => { + (entity: ResultEntity) => { return ( diff --git a/plugins/newrelic-dashboard/src/components/NewRelicDashboard/DashboardSnapshotList/DashboardSnapshot.tsx b/plugins/newrelic-dashboard/src/components/NewRelicDashboard/DashboardSnapshotList/DashboardSnapshot.tsx index 3794aeb688..72847792ec 100644 --- a/plugins/newrelic-dashboard/src/components/NewRelicDashboard/DashboardSnapshotList/DashboardSnapshot.tsx +++ b/plugins/newrelic-dashboard/src/components/NewRelicDashboard/DashboardSnapshotList/DashboardSnapshot.tsx @@ -20,6 +20,7 @@ import { useAsync } from 'react-use'; import { InfoCard, Progress } from '@backstage/core-components'; import { newRelicDashboardApiRef } from '../../../api'; import Alert from '@material-ui/lab/Alert'; +import { DashboardSnapshotSummary } from './../../../api/NewRelicDashboardApi'; type Props = { guid: string; @@ -35,11 +36,11 @@ export const DashboardSnapshot = ({ duration, }: Props) => { const newRelicDashboardAPI = useApi(newRelicDashboardApiRef); - const { value, loading, error } = useAsync(async (): Promise => { - const dashboardObject: any = newRelicDashboardAPI.getDashboardSnapshot( - guid, - duration, - ); + const { value, loading, error } = useAsync(async (): Promise< + DashboardSnapshotSummary | undefined + > => { + const dashboardObject: Promise = + newRelicDashboardAPI.getDashboardSnapshot(guid, duration); return dashboardObject; }, []); if (loading) { diff --git a/plugins/newrelic-dashboard/src/components/NewRelicDashboard/DashboardSnapshotList/DashboardSnapshotList.tsx b/plugins/newrelic-dashboard/src/components/NewRelicDashboard/DashboardSnapshotList/DashboardSnapshotList.tsx index 7fc29069d4..54faa7289d 100644 --- a/plugins/newrelic-dashboard/src/components/NewRelicDashboard/DashboardSnapshotList/DashboardSnapshotList.tsx +++ b/plugins/newrelic-dashboard/src/components/NewRelicDashboard/DashboardSnapshotList/DashboardSnapshotList.tsx @@ -21,6 +21,8 @@ import { useAsync } from 'react-use'; import { Progress } from '@backstage/core-components'; import Alert from '@material-ui/lab/Alert'; import { DashboardSnapshot } from './DashboardSnapshot'; +import { DashboardEntitySummary } from '../../../api/NewRelicDashboardApi'; +import { ResultEntity } from '../../../types/DashboardEntity'; interface TabPanelProps { children?: React.ReactNode; @@ -81,8 +83,11 @@ const useStyles = makeStyles( export const DashboardSnapshotList = ({ guid }: Props) => { const styles = useStyles(); const newRelicDashboardAPI = useApi(newRelicDashboardApiRef); - const { value, loading, error } = useAsync(async (): Promise => { - const dashboardObject: any = newRelicDashboardAPI.getDashboardEntity(guid); + const { value, loading, error } = useAsync(async (): Promise< + DashboardEntitySummary | undefined + > => { + const dashboardObject: Promise = + newRelicDashboardAPI.getDashboardEntity(guid); return dashboardObject; }, []); const [value1, setValue1] = useState(0); @@ -110,7 +115,7 @@ export const DashboardSnapshotList = ({ guid }: Props) => { style={{ width: '100%' }} > {value?.getDashboardEntity?.data?.actor.entitySearch.results.entities?.map( - (Entity: any, index: any) => { + (Entity: ResultEntity, index: number) => { return ( { )} {value?.getDashboardEntity?.data?.actor.entitySearch.results.entities?.map( - (Entity: any, index: any) => { + (Entity: ResultEntity, index: number) => { return (