From 02be8ca4f1a7095ea88a95642a4c4ee256c8b6b6 Mon Sep 17 00:00:00 2001 From: samiramkr Date: Fri, 4 Dec 2020 11:41:30 +0100 Subject: [PATCH] Delete PagerdutyCard.tsx --- .../src/components/PagerdutyCard.tsx | 169 ------------------ 1 file changed, 169 deletions(-) delete mode 100644 plugins/pagerduty/src/components/PagerdutyCard.tsx diff --git a/plugins/pagerduty/src/components/PagerdutyCard.tsx b/plugins/pagerduty/src/components/PagerdutyCard.tsx deleted file mode 100644 index ac309e8a95..0000000000 --- a/plugins/pagerduty/src/components/PagerdutyCard.tsx +++ /dev/null @@ -1,169 +0,0 @@ -/* - * 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. - */ -import React, { useState } from 'react'; -import { useApi, Progress } from '@backstage/core'; -import { Entity } from '@backstage/catalog-model'; -import { - Button, - Card, - CardContent, - CardHeader, - Divider, - makeStyles, -} from '@material-ui/core'; -import { Incidents } from './Incident'; -import { EscalationPolicy } from './Escalation'; -import { useAsync } from 'react-use'; -import { Alert } from '@material-ui/lab'; -import { pagerDutyApiRef, UnauthorizedError } from '../api'; -import { IconLinkVertical } from '@backstage/plugin-catalog'; -import { PagerDutyIcon } from './PagerDutyIcon'; -import AlarmAddIcon from '@material-ui/icons/AlarmAdd'; -import { TriggerDialog } from './TriggerDialog'; -import { MissingTokenError } from './MissingTokenError'; - -const useStyles = makeStyles(theme => ({ - links: { - margin: theme.spacing(2, 0), - display: 'grid', - gridAutoFlow: 'column', - gridAutoColumns: 'min-content', - gridGap: theme.spacing(3), - }, - triggerAlarm: { - paddingTop: 0, - paddingBottom: 0, - fontSize: '0.7rem', - textTransform: 'uppercase', - fontWeight: 600, - letterSpacing: 1.2, - lineHeight: 1.5, - '&:hover, &:focus, &.focus': { - backgroundColor: 'transparent', - textDecoration: 'none', - }, - }, -})); - -export const PAGERDUTY_INTEGRATION_KEY = 'pagerduty.com/integration-key'; - -export const isPluginApplicableToEntity = (entity: Entity) => - Boolean(entity.metadata.annotations?.[PAGERDUTY_INTEGRATION_KEY]); - -type Props = { - entity: Entity; -}; - -export const PagerDutyCard = ({ entity }: Props) => { - const classes = useStyles(); - const api = useApi(pagerDutyApiRef); - const [showDialog, setShowDialog] = useState(false); - const [refreshIncidents, setRefreshIncidents] = useState(false); - const integrationKey = entity.metadata.annotations![ - PAGERDUTY_INTEGRATION_KEY - ]; - - const { value: service, loading, error } = useAsync(async () => { - const services = await api.getServiceByIntegrationKey(integrationKey); - - return { - id: services[0].id, - name: services[0].name, - url: services[0].html_url, - policyId: services[0].escalation_policy.id, - }; - }); - - const handleDialog = () => { - setShowDialog(!showDialog); - }; - - if (error instanceof UnauthorizedError) { - return ; - } - - if (error) { - return ( - - Error encountered while fetching information. {error.message} - - ); - } - - if (loading) { - return ; - } - - const pagerdutyLink = { - title: 'View in PagerDuty', - href: service!.url, - }; - - const triggerAlarm = { - title: 'Trigger Alarm', - action: ( - - ), - }; - - const onTriggerRefresh = () => { - setRefreshIncidents(true); - }; - - return ( - - - } - /> - } - action={triggerAlarm.action} - /> - - } - /> - - - - - - - - ); -};