fix typings

This commit is contained in:
Samira Mokaram
2020-11-05 10:49:11 +01:00
parent 361049d9c2
commit 122410f1ab
3 changed files with 88 additions and 31 deletions
@@ -30,7 +30,7 @@ import UserIcon from '@material-ui/icons/Person';
import EmailIcon from '@material-ui/icons/Email';
import { StatusWarning } from '@backstage/core';
import Pagerduty from '../assets/pd.svg';
import { PagerDutyUserData } from './types';
import { Oncall, PagerDutyEscalationPolicy } from './types';
const useStyles = makeStyles({
denseListIcon: {
@@ -45,11 +45,7 @@ const useStyles = makeStyles({
},
});
type EscalationUserProps = {
user: PagerDutyUserData;
};
const EscalationUser = ({ user }: EscalationUserProps) => {
const EscalationUser = ({ user }: PagerDutyEscalationPolicy) => {
const classes = useStyles();
return (
<ListItem>
@@ -65,7 +61,7 @@ const EscalationUser = ({ user }: EscalationUserProps) => {
</Tooltip>
<Tooltip title="View in PagerDuty" placement="left">
<IconButton
href={user.homepageUrl}
href={user.html_url}
target="_blank"
rel="noopener noreferrer"
>
@@ -96,7 +92,7 @@ const EscalationUsersEmptyState = () => {
};
type EscalationPolicyProps = {
escalation: PagerDutyUserData[];
escalation: Oncall[];
};
export const EscalationPolicy = ({ escalation }: EscalationPolicyProps) => (
@@ -29,6 +29,7 @@ import {
import { StatusError, StatusWarning, StatusOK } from '@backstage/core';
import Pagerduty from '../assets/pd.svg';
import moment from 'moment';
import { Incident } from '../components/types';
const useStyles = makeStyles({
denseListIcon: {
@@ -57,13 +58,13 @@ const IncidentsEmptyState = () => {
);
};
type IncidentListProps = {
incidents: any;
type IncidentListItemProps = {
incident: Incident;
};
const IncidentList = ({ incidents }: IncidentListProps) => {
const IncidentListItem = ({ incident }: IncidentListItemProps) => {
const classes = useStyles();
return incidents.map((incident: any) => (
return (
<ListItem key={incident.id}>
<ListItemIcon>
<Tooltip title={incident.status} placement="top">
@@ -103,17 +104,17 @@ const IncidentList = ({ incidents }: IncidentListProps) => {
</Tooltip>
</ListItemSecondaryAction>
</ListItem>
));
);
};
type IncidentsProps = {
incidents: Array<any>;
incidents: Incident[];
};
export const Incidents = ({ incidents }: IncidentsProps) => (
<List dense subheader={<ListSubheader>Incidents</ListSubheader>}>
{incidents.length ? (
<IncidentList incidents={incidents} />
incidents.map(incident => <IncidentListItem incident={incident} />)
) : (
<IncidentsEmptyState />
)}
+76 -16
View File
@@ -1,27 +1,87 @@
export type PagerDutyIncident = {
/*
* Copyright 2020 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export type Incident = {
id: string;
title: string;
status: string;
createdAt: string;
homepageUrl: string;
assignees: Partial<PagerDutyUserData>[];
assignments: [
{
assignee: User;
},
];
serviceId: string;
created_at: string;
};
export type PagerDutyUserData = {
export type Service = {
id: string;
name: string;
html_url: string;
integrationKey: string;
escalation_policy: PagerDutyEscalationPolicy;
};
export type ResponseService = {
services: Service[];
more: boolean;
};
export type ResponseOncall = {
id: string;
name: string;
email: string;
name: string;
homepageUrl: string;
id: string;
};
export type PagerDutyServicesData = {
activeIncidents: PagerDutyIncident[];
escalationPolicy: any; // PagerDutyUserData[];
id: string;
name: string;
homepageUrl: string;
};
export type PagerDutyData = {
pagerDutyServices: PagerDutyServicesData[];
export type Options = {
method: string;
headers: HeadersInit;
body?: BodyInit;
};
export type PagerDutyClientConfig = {
token?: string;
};
export type ServicesResponse = {
services: Service[];
};
export type IncidentResponse = {
incidents: Incident[];
};
export type OncallsResponse = {
oncalls: Oncall[];
};
export type PagerDutyEscalationPolicy = {
user: User;
};
export type User = {
id: string;
summary: string;
email: string;
html_url: string;
name: string;
};
export type Oncall = {
escalation_policy: PagerDutyEscalationPolicy;
user: User;
};