;
-};
-export const Incidents = ({ incidents }: IncidentsProps) => (
- Incidents}>
- {incidents.length ? (
-
- ) : (
-
- )}
-
-);
-
-type EscalationProps = {
- escalation: PagerDutyUserData[];
-};
-
-const EscalationUsers = ({ escalation }: EscalationProps) => {
- const classes = useStyles();
- const escalations = escalation.map((user, index) => (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ));
- return {escalations}
;
-};
-
-const EscalationUsersEmptyState = () => {
- const classes = useStyles();
- return (
-
-
-
-
-
-
-
-
- );
-};
-
-const EscalationPolicy = ({ escalation }: EscalationProps) => (
- Escalation Policy}>
- {escalation.length ? (
-
- ) : (
-
- )}
-
-);
-
-type CardBodyProps = {
- entity: Entity;
- data: PagerDutyData;
-};
-
-const CardBody = ({ entity, data }: CardBodyProps) => {
- const { pagerDutyServices } = data;
- const classes = useStyles();
-
- if (!pagerDutyServices.length) {
- return (
-
- 'The specified PagerDuty integration key does not match any PagerDuty
- service.'
-
- );
- }
-
- const { activeIncidents, escalationPolicy } = pagerDutyServices[0];
-
- return (
- <>
-
-
-
- {/* */}
-
- >
- );
-};
-
-type PagerDutyIncident = {
- id: string;
- title: string;
- status: string;
- createdAt: string;
- homepageUrl: string;
- assignees: Partial[];
-};
-
-type PagerDutyUserData = {
- email: string;
- name: string;
- homepageUrl: string;
- id: string;
-};
-
-type PagerDutyServicesData = {
- activeIncidents: PagerDutyIncident[];
- escalationPolicy: PagerDutyUserData[];
- id: string;
- name: string;
- homepageUrl: string;
-};
-
-type PagerDutyData = {
- pagerDutyServices: PagerDutyServicesData[];
-};
+export const isPluginApplicableToEntity = (entity: Entity) =>
+ Boolean(entity.metadata.annotations?.[PAGERDUTY_INTEGRATION_KEY]);
type Props = {
entity: Entity;
@@ -284,11 +64,20 @@ export const PagerDutyServiceCard = ({ entity }: Props) => {
],
};
- return (
+ const { activeIncidents, escalationPolicy } = mockData.pagerDutyServices[0];
+
+ return isPluginApplicableToEntity(entity) ? (
+
+ ) : (
-
+
+
+
+ {/* */}
+
+
);
};
-
-export const isPluginApplicableToEntity = (entity: Entity) => true;
diff --git a/plugins/pagerduty/src/components/types.tsx b/plugins/pagerduty/src/components/types.tsx
new file mode 100644
index 0000000000..b3b94f0200
--- /dev/null
+++ b/plugins/pagerduty/src/components/types.tsx
@@ -0,0 +1,27 @@
+export type PagerDutyIncident = {
+ id: string;
+ title: string;
+ status: string;
+ createdAt: string;
+ homepageUrl: string;
+ assignees: Partial[];
+};
+
+export type PagerDutyUserData = {
+ 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[];
+};