removed all occurences of any

Signed-off-by: mufaddal motiwala <mufaddalmm.52@gmail.com>
This commit is contained in:
mufaddal motiwala
2021-12-20 13:56:57 +05:30
parent 996120684f
commit 11d4ee492d
5 changed files with 38 additions and 27 deletions
@@ -38,7 +38,7 @@ export class NewRelicDashboardClient implements NewRelicDashboardApi {
private async callApi<T>(
query: string,
variables: { [key in string]: any },
variables: { [key in string]: string | number },
): Promise<T | undefined> {
const myHeaders = new Headers();
myHeaders.append('Content-Type', 'application/json');
@@ -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<any> => {
const dashboardObject: any = newRelicDashboardAPI.getDashboardEntity(
String(DashboardEntity?.integrationKey),
);
const { value, loading, error } = useAsync(async (): Promise<
DashboardEntitySummary | undefined
> => {
const dashboardObject: Promise<DashboardEntitySummary | undefined> =
newRelicDashboardAPI.getDashboardEntity(
String(DashboardEntity?.integrationKey),
);
return dashboardObject;
}, []);
if (loading) {
@@ -55,12 +58,13 @@ export const DashboardEntityList = () => {
<InfoCard title="New Relic Dashboard Pages" variant="gridItem">
{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 (
<Box style={{ margin: '10px' }} display="flex">
<Box mr={1} className={classes.svgIcon}>
@@ -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<any> => {
const dashboardObject: any = newRelicDashboardAPI.getDashboardSnapshot(
guid,
duration,
);
const { value, loading, error } = useAsync(async (): Promise<
DashboardSnapshotSummary | undefined
> => {
const dashboardObject: Promise<DashboardSnapshotSummary | undefined> =
newRelicDashboardAPI.getDashboardSnapshot(guid, duration);
return dashboardObject;
}, []);
if (loading) {
@@ -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<any> => {
const dashboardObject: any = newRelicDashboardAPI.getDashboardEntity(guid);
const { value, loading, error } = useAsync(async (): Promise<
DashboardEntitySummary | undefined
> => {
const dashboardObject: Promise<DashboardEntitySummary | undefined> =
newRelicDashboardAPI.getDashboardEntity(guid);
return dashboardObject;
}, []);
const [value1, setValue1] = useState<number>(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 (
<Tab
label={Entity.name}
@@ -126,7 +131,7 @@ export const DashboardSnapshotList = ({ guid }: Props) => {
)}
</Tabs>
{value?.getDashboardEntity?.data?.actor.entitySearch.results.entities?.map(
(Entity: any, index: any) => {
(Entity: ResultEntity, index: number) => {
return (
<TabPanel value1={value1} index={index}>
<DashboardSnapshot
@@ -19,14 +19,15 @@ export type DashboardEntity = {
actor: {
entitySearch: {
results: {
entities: [
{
guid: string;
permalink: string;
},
];
entities: [ResultEntity];
};
};
};
};
};
export type ResultEntity = {
guid: string;
permalink: string;
name: string;
};