From 22b0500d76118aa07aca589a57d627f189facf7e Mon Sep 17 00:00:00 2001 From: Samira Mokaram Date: Wed, 18 Nov 2020 09:51:33 +0100 Subject: [PATCH] small fixes --- .../app/src/components/catalog/EntityPage.tsx | 3 +- plugins/pagerduty/src/api/client.ts | 10 +-- plugins/pagerduty/src/api/types.ts | 10 +++ plugins/pagerduty/src/assets/pd.svg | 13 ---- .../components/Escalation/EscalationUser.tsx | 4 +- .../components/Incident/IncidentListItem.tsx | 2 +- .../TriggerButton/TriggerButton.tsx | 2 +- .../TriggerDialog/TriggerDialog.tsx | 65 ++++++++++++------- 8 files changed, 60 insertions(+), 49 deletions(-) delete mode 100644 plugins/pagerduty/src/assets/pd.svg diff --git a/packages/app/src/components/catalog/EntityPage.tsx b/packages/app/src/components/catalog/EntityPage.tsx index 17231abb9a..6099b6ffe0 100644 --- a/packages/app/src/components/catalog/EntityPage.tsx +++ b/packages/app/src/components/catalog/EntityPage.tsx @@ -70,7 +70,8 @@ import { isPluginApplicableToEntity as isPagerDutyAvailable, PagerDutyCard, } from '@backstage/plugin-pagerduty'; -import { Router as BuildKiteRouter, +import { + Router as BuildKiteRouter, isPluginApplicableToEntity as isBuildKiteAvailable, } from '@roadiehq/backstage-plugin-buildkite'; diff --git a/plugins/pagerduty/src/api/client.ts b/plugins/pagerduty/src/api/client.ts index 985bb25e5a..c9d40a1694 100644 --- a/plugins/pagerduty/src/api/client.ts +++ b/plugins/pagerduty/src/api/client.ts @@ -27,13 +27,9 @@ import { } from '../components/types'; import { PagerDutyClient } from './types'; -export class UnauthorizedError extends Error { - constructor() { - super(); - } -} +export class UnauthorizedError extends Error {} -export const pagerDutyApiRef = createApiRef({ +export const pagerDutyApiRef = createApiRef({ id: 'plugin.pagerduty.api', description: 'Used to fetch data from PagerDuty API', }); @@ -65,7 +61,7 @@ export class PagerDutyClientApi implements PagerDutyClient { return oncalls; } - triggerPagerDutyAlarm( + triggerAlarm( integrationKey: string, source: string, description: string, diff --git a/plugins/pagerduty/src/api/types.ts b/plugins/pagerduty/src/api/types.ts index cb9d7fc5bc..c07834a213 100644 --- a/plugins/pagerduty/src/api/types.ts +++ b/plugins/pagerduty/src/api/types.ts @@ -34,4 +34,14 @@ export interface PagerDutyClient { * */ getOnCallByPolicyId(policyId: string): Promise; + + /** + * Triggers an incident to whoever is on-call. + */ + triggerAlarm( + integrationKey: string, + source: string, + description: string, + userName: string, + ): Promise; } diff --git a/plugins/pagerduty/src/assets/pd.svg b/plugins/pagerduty/src/assets/pd.svg deleted file mode 100644 index 237ffa2011..0000000000 --- a/plugins/pagerduty/src/assets/pd.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - pd_icon - Created with Sketch. - - - - - - - - diff --git a/plugins/pagerduty/src/components/Escalation/EscalationUser.tsx b/plugins/pagerduty/src/components/Escalation/EscalationUser.tsx index e20a5f7567..adc8d4e6d7 100644 --- a/plugins/pagerduty/src/components/Escalation/EscalationUser.tsx +++ b/plugins/pagerduty/src/components/Escalation/EscalationUser.tsx @@ -52,12 +52,12 @@ export const EscalationUser = ({ user }: { user: User }) => { secondary={user.email} /> - + - + { } /> - + { setDescription(event.target.value); }; - const [{ value, loading, error }, triggerAlarm] = useAsyncFn( + const [{ value, loading, error }, handleTriggerAlarm] = useAsyncFn( async (desc: string) => { - return await api.triggerPagerDutyAlarm( + return await api.triggerAlarm( integrationKey, window.location.toString(), desc, @@ -82,34 +91,41 @@ export const TriggerDialog = ({ name, integrationKey, onClose }: Props) => { }, [value, error, alertApi, onClose, userId]); return ( - + - This action will send PagerDuty alarms and notifications to on-call - people responsible for {name}. + This action will trigger an incident for "{name}". -

- Note: If the issue you are seeing does not need urgent attention, - please get in touch with the responsible team using their preferred - communications channel. For most views, you can find links to support - and information channels by clicking the support button in the top - right corner of the page. If the issue is urgent, please don't - hesitate to trigger the alert. -

-

+ + {/* "Note" */} + + If the issue you are seeing does not need urgent attention, please + get in touch with the responsible team using their preferred + communications channel. You can find information about the owner of + this entity in the "About" card. If the issue is urgent, please + don't hesitate to trigger the alert. + + + Please describe the problem you want to report. Be as descriptive as - possible. Your Spotify username and a reference to the current page - will automatically be sent amended to the alarm so that we can debug - the issue and reach out to you if necessary. -

+ possible. Your signed in user and a reference to the current page will + automatically be amended to the alarm so that the receiver can reach + out to you if necessary. +
@@ -119,15 +135,16 @@ export const TriggerDialog = ({ name, integrationKey, onClose }: Props) => { id="trigger" color="secondary" disabled={!description || loading} - onClick={() => triggerAlarm(description)} + variant="contained" + onClick={() => handleTriggerAlarm(description)} + endIcon={loading && } > - Trigger + Trigger Incident - - {loading && }
); };