review comments addressed
Signed-off-by: Brian Fletcher <brian@roadie.io>
This commit is contained in:
@@ -20,7 +20,19 @@ export const EntityPagerDutyCard: (
|
||||
) => JSX.Element;
|
||||
|
||||
// @public (undocumented)
|
||||
export type EntityPagerDutyCardProps = {
|
||||
type EntityPagerDutyCardProps = {
|
||||
readOnly?: boolean;
|
||||
};
|
||||
export { EntityPagerDutyCardProps };
|
||||
export { EntityPagerDutyCardProps as PagerDutyCardProps };
|
||||
|
||||
// @public (undocumented)
|
||||
export const HomePagePagerDutyCard: (
|
||||
props: CardExtensionProps<HomePagePagerDutyCardProps>,
|
||||
) => JSX.Element;
|
||||
|
||||
// @public (undocumented)
|
||||
export type HomePagePagerDutyCardProps = PagerDutyEntity & {
|
||||
readOnly?: boolean;
|
||||
};
|
||||
|
||||
@@ -55,6 +67,9 @@ export type PagerDutyAssignee = {
|
||||
html_url: string;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export const PagerDutyCard: (props: EntityPagerDutyCardProps) => JSX.Element;
|
||||
|
||||
// @public (undocumented)
|
||||
export type PagerDutyChangeEvent = {
|
||||
id: string;
|
||||
@@ -126,16 +141,6 @@ export type PagerDutyEntity = {
|
||||
name: string;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export const PagerDutyHomepageCard: (
|
||||
props: CardExtensionProps<PagerDutyHomepageCardProps>,
|
||||
) => JSX.Element;
|
||||
|
||||
// @public (undocumented)
|
||||
export type PagerDutyHomepageCardProps = PagerDutyEntity & {
|
||||
readOnly?: boolean;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export type PagerDutyIncident = {
|
||||
id: string;
|
||||
|
||||
@@ -15,159 +15,12 @@
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { EntityProvider } from '@backstage/plugin-catalog-react';
|
||||
import { createDevApp } from '@backstage/dev-utils';
|
||||
import { pagerDutyPlugin, EntityPagerDutyCard } from '../src/plugin';
|
||||
import { pagerDutyApiRef } from '../src/api';
|
||||
import { PagerDutyApi, PagerDutyTriggerAlarmRequest } from '../src/api/types';
|
||||
import {
|
||||
PagerDutyIncident,
|
||||
PagerDutyChangeEvent,
|
||||
} from '../src/components/types';
|
||||
import { PagerDutyEntity } from '../src';
|
||||
|
||||
const mockEntity: Entity = {
|
||||
apiVersion: 'backstage.io/v1alpha1',
|
||||
kind: 'Component',
|
||||
metadata: {
|
||||
name: 'backstage',
|
||||
description: 'backstage.io',
|
||||
annotations: {
|
||||
'github.com/project-slug': 'backstage/backstage',
|
||||
'pagerduty.com/service-id': 'foo',
|
||||
'pagerduty.com/integration-key': 'foo',
|
||||
},
|
||||
},
|
||||
spec: {
|
||||
lifecycle: 'production',
|
||||
type: 'website',
|
||||
owner: 'user:guest',
|
||||
},
|
||||
};
|
||||
|
||||
const mockPagerDutyApi: PagerDutyApi = {
|
||||
async getServiceByPagerDutyEntity(pagerDutyEntity: PagerDutyEntity) {
|
||||
return {
|
||||
service: {
|
||||
name: pagerDutyEntity.name,
|
||||
integrationKey: 'key',
|
||||
id: '123',
|
||||
html_url: 'http://service',
|
||||
escalation_policy: {
|
||||
id: '123',
|
||||
html_url: 'http://escalationpolicy',
|
||||
user: {
|
||||
id: '123',
|
||||
summary: 'summary',
|
||||
email: 'email@email.com',
|
||||
html_url: 'http://user',
|
||||
name: 'some-user',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
async getServiceByEntity(entity: Entity) {
|
||||
return {
|
||||
service: {
|
||||
name: entity.metadata.name,
|
||||
integrationKey: 'key',
|
||||
id: '123',
|
||||
html_url: 'http://service',
|
||||
escalation_policy: {
|
||||
id: '123',
|
||||
html_url: 'http://escalationpolicy',
|
||||
user: {
|
||||
id: '123',
|
||||
summary: 'summary',
|
||||
email: 'email@email.com',
|
||||
html_url: 'http://user',
|
||||
name: 'some-user',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
async getIncidentsByServiceId(serviceId: string) {
|
||||
const incident = (title: string) => {
|
||||
return {
|
||||
id: '123',
|
||||
title: title,
|
||||
status: 'acknowledged',
|
||||
html_url: 'http://incident',
|
||||
assignments: [
|
||||
{
|
||||
assignee: {
|
||||
id: '123',
|
||||
summary: 'Jane Doe',
|
||||
html_url: 'http://assignee',
|
||||
},
|
||||
},
|
||||
],
|
||||
serviceId: serviceId,
|
||||
created_at: '2015-10-06T21:30:42Z',
|
||||
} as PagerDutyIncident;
|
||||
};
|
||||
|
||||
return {
|
||||
incidents: [
|
||||
incident('Some Alerting Incident'),
|
||||
incident('Another Alerting Incident'),
|
||||
],
|
||||
};
|
||||
},
|
||||
|
||||
async getChangeEventsByServiceId(serviceId: string) {
|
||||
const changeEvent = (description: string) => {
|
||||
return {
|
||||
id: serviceId,
|
||||
source: 'some-source',
|
||||
html_url: 'http://changeevent',
|
||||
links: [
|
||||
{
|
||||
href: 'http://link',
|
||||
text: 'link text',
|
||||
},
|
||||
],
|
||||
summary: description,
|
||||
timestamp: '2018-10-06T21:30:42Z',
|
||||
} as PagerDutyChangeEvent;
|
||||
};
|
||||
|
||||
return {
|
||||
change_events: [
|
||||
changeEvent('us-east-1 deployment'),
|
||||
changeEvent('us-west-2 deployment'),
|
||||
],
|
||||
};
|
||||
},
|
||||
|
||||
async getOnCallByPolicyId() {
|
||||
const oncall = (name: string, escalation: number) => {
|
||||
return {
|
||||
user: {
|
||||
id: '123',
|
||||
name: name,
|
||||
html_url: 'http://assignee',
|
||||
summary: 'summary',
|
||||
email: 'email@email.com',
|
||||
},
|
||||
escalation_level: escalation,
|
||||
};
|
||||
};
|
||||
|
||||
return {
|
||||
oncalls: [oncall('Jane Doe', 1), oncall('John Doe', 2)],
|
||||
};
|
||||
},
|
||||
|
||||
async triggerAlarm(request: PagerDutyTriggerAlarmRequest) {
|
||||
return new Response(request.description);
|
||||
},
|
||||
};
|
||||
import { mockPagerDutyApi } from './mockPagerDutyApi';
|
||||
import { mockEntity } from './mockEntity';
|
||||
|
||||
createDevApp()
|
||||
.registerApi({
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2023 The Backstage Authors
|
||||
*
|
||||
* 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 { Entity } from '@backstage/catalog-model';
|
||||
|
||||
export const mockEntity: Entity = {
|
||||
apiVersion: 'backstage.io/v1alpha1',
|
||||
kind: 'Component',
|
||||
metadata: {
|
||||
name: 'backstage',
|
||||
description: 'backstage.io',
|
||||
annotations: {
|
||||
'github.com/project-slug': 'backstage/backstage',
|
||||
'pagerduty.com/service-id': 'foo',
|
||||
'pagerduty.com/integration-key': 'foo',
|
||||
},
|
||||
},
|
||||
spec: {
|
||||
lifecycle: 'production',
|
||||
type: 'website',
|
||||
owner: 'user:guest',
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright 2023 The Backstage Authors
|
||||
*
|
||||
* 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 {
|
||||
PagerDutyApi,
|
||||
PagerDutyChangeEvent,
|
||||
PagerDutyEntity,
|
||||
PagerDutyIncident,
|
||||
PagerDutyTriggerAlarmRequest,
|
||||
} from '../src';
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
|
||||
export const mockPagerDutyApi: PagerDutyApi = {
|
||||
async getServiceByPagerDutyEntity(pagerDutyEntity: PagerDutyEntity) {
|
||||
return {
|
||||
service: {
|
||||
name: pagerDutyEntity.name,
|
||||
integrationKey: 'key',
|
||||
id: '123',
|
||||
html_url: 'http://service',
|
||||
escalation_policy: {
|
||||
id: '123',
|
||||
html_url: 'http://escalationpolicy',
|
||||
user: {
|
||||
id: '123',
|
||||
summary: 'summary',
|
||||
email: 'email@email.com',
|
||||
html_url: 'http://user',
|
||||
name: 'some-user',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
async getServiceByEntity(entity: Entity) {
|
||||
return {
|
||||
service: {
|
||||
name: entity.metadata.name,
|
||||
integrationKey: 'key',
|
||||
id: '123',
|
||||
html_url: 'http://service',
|
||||
escalation_policy: {
|
||||
id: '123',
|
||||
html_url: 'http://escalationpolicy',
|
||||
user: {
|
||||
id: '123',
|
||||
summary: 'summary',
|
||||
email: 'email@email.com',
|
||||
html_url: 'http://user',
|
||||
name: 'some-user',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
async getIncidentsByServiceId(serviceId: string) {
|
||||
const incident = (title: string) => {
|
||||
return {
|
||||
id: '123',
|
||||
title: title,
|
||||
status: 'acknowledged',
|
||||
html_url: 'http://incident',
|
||||
assignments: [
|
||||
{
|
||||
assignee: {
|
||||
id: '123',
|
||||
summary: 'Jane Doe',
|
||||
html_url: 'http://assignee',
|
||||
},
|
||||
},
|
||||
],
|
||||
serviceId: serviceId,
|
||||
created_at: '2015-10-06T21:30:42Z',
|
||||
} as PagerDutyIncident;
|
||||
};
|
||||
|
||||
return {
|
||||
incidents: [
|
||||
incident('Some Alerting Incident'),
|
||||
incident('Another Alerting Incident'),
|
||||
],
|
||||
};
|
||||
},
|
||||
|
||||
async getChangeEventsByServiceId(serviceId: string) {
|
||||
const changeEvent = (description: string) => {
|
||||
return {
|
||||
id: serviceId,
|
||||
source: 'some-source',
|
||||
html_url: 'http://changeevent',
|
||||
links: [
|
||||
{
|
||||
href: 'http://link',
|
||||
text: 'link text',
|
||||
},
|
||||
],
|
||||
summary: description,
|
||||
timestamp: '2018-10-06T21:30:42Z',
|
||||
} as PagerDutyChangeEvent;
|
||||
};
|
||||
|
||||
return {
|
||||
change_events: [
|
||||
changeEvent('us-east-1 deployment'),
|
||||
changeEvent('us-west-2 deployment'),
|
||||
],
|
||||
};
|
||||
},
|
||||
|
||||
async getOnCallByPolicyId() {
|
||||
const oncall = (name: string, escalation: number) => {
|
||||
return {
|
||||
user: {
|
||||
id: '123',
|
||||
name: name,
|
||||
html_url: 'http://assignee',
|
||||
summary: 'summary',
|
||||
email: 'email@email.com',
|
||||
},
|
||||
escalation_level: escalation,
|
||||
};
|
||||
};
|
||||
|
||||
return {
|
||||
oncalls: [oncall('Jane Doe', 1), oncall('John Doe', 2)],
|
||||
};
|
||||
},
|
||||
|
||||
async triggerAlarm(request: PagerDutyTriggerAlarmRequest) {
|
||||
return new Response(request.description);
|
||||
},
|
||||
};
|
||||
+2
-2
@@ -19,11 +19,11 @@ import { PagerDutyEntity } from '../../types';
|
||||
import { PagerDutyCard } from '../PagerDutyCard';
|
||||
|
||||
/** @public */
|
||||
export type PagerDutyHomepageCardProps = PagerDutyEntity & {
|
||||
export type HomePagePagerDutyCardProps = PagerDutyEntity & {
|
||||
readOnly?: boolean;
|
||||
};
|
||||
|
||||
/** @public */
|
||||
export const Content = (props: PagerDutyHomepageCardProps) => {
|
||||
export const Content = (props: HomePagePagerDutyCardProps) => {
|
||||
return <PagerDutyCard {...props} />;
|
||||
};
|
||||
+1
-1
@@ -14,4 +14,4 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
export { Content } from './Content';
|
||||
export type { PagerDutyHomepageCardProps } from './Content';
|
||||
export type { HomePagePagerDutyCardProps } from './Content';
|
||||
@@ -24,7 +24,7 @@ export type {
|
||||
} from './types';
|
||||
|
||||
export type { EntityPagerDutyCardProps } from './EntityPagerDutyCard';
|
||||
export type { PagerDutyHomepageCardProps } from './PagerDutyHomepageCard';
|
||||
export type { HomePagePagerDutyCardProps } from './HomePagePagerDutyCard';
|
||||
|
||||
export {
|
||||
isPluginApplicableToEntity,
|
||||
|
||||
@@ -24,10 +24,15 @@ export {
|
||||
pagerDutyPlugin,
|
||||
pagerDutyPlugin as plugin,
|
||||
EntityPagerDutyCard,
|
||||
PagerDutyHomepageCard,
|
||||
HomePagePagerDutyCard,
|
||||
} from './plugin';
|
||||
|
||||
export * from './components';
|
||||
|
||||
// @deprecated Please use EntityPagerDutyCard
|
||||
export { EntityPagerDutyCard as PagerDutyCard } from './components';
|
||||
export type { EntityPagerDutyCardProps as PagerDutyCardProps } from './components';
|
||||
|
||||
export * from './api';
|
||||
|
||||
export type { PagerDutyEntity } from './types';
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
createComponentExtension,
|
||||
} from '@backstage/core-plugin-api';
|
||||
import { createCardExtension } from '@backstage/plugin-home';
|
||||
import { PagerDutyHomepageCardProps } from './components/PagerDutyHomepageCard/Content';
|
||||
import { HomePagePagerDutyCardProps } from './components/HomePagePagerDutyCard/Content';
|
||||
|
||||
export const rootRouteRef = createRouteRef({
|
||||
id: 'pagerduty',
|
||||
@@ -68,26 +68,26 @@ export const homePlugin = createPlugin({
|
||||
});
|
||||
|
||||
/** @public */
|
||||
export const PagerDutyHomepageCard = homePlugin.provide(
|
||||
createCardExtension<PagerDutyHomepageCardProps>({
|
||||
name: 'PagerDutyHomepageCard',
|
||||
title: 'Pager Duty Homepage Card',
|
||||
components: () => import('./components/PagerDutyHomepageCard'),
|
||||
export const HomePagePagerDutyCard = homePlugin.provide(
|
||||
createCardExtension<HomePagePagerDutyCardProps>({
|
||||
name: 'HomePagePagerDutyCard',
|
||||
title: 'PagerDuty Homepage Card',
|
||||
components: () => import('./components/HomePagePagerDutyCard'),
|
||||
settings: {
|
||||
schema: {
|
||||
title: 'Pagerduty',
|
||||
type: 'object',
|
||||
properties: {
|
||||
integrationKey: {
|
||||
title: 'Pager duty integration key',
|
||||
title: 'PagerDuty integration key',
|
||||
type: 'string',
|
||||
},
|
||||
serviceId: {
|
||||
title: 'Pager duty service id',
|
||||
title: 'PagerDuty service id',
|
||||
type: 'string',
|
||||
},
|
||||
name: {
|
||||
title: 'Pager duty service name',
|
||||
title: 'PagerDuty service name',
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user