Merge pull request #18880 from velocibear/cj-lattice-pd-change-events

Adding the ability to not render the change events tab for the PagerDuty Card
This commit is contained in:
Patrik Oldsberg
2023-08-12 15:15:13 +02:00
committed by GitHub
4 changed files with 27 additions and 9 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-pagerduty': patch
---
Add new `disableChangeEvents` prop to `EntityPagerDutyCard` to hide the Change Events tab and disable fetching of change events for the PagerDuty service.
+1
View File
@@ -22,6 +22,7 @@ export const EntityPagerDutyCard: (
// @public (undocumented)
export type EntityPagerDutyCardProps = {
readOnly?: boolean;
disableChangeEvents?: boolean;
};
// @public (undocumented)
@@ -30,12 +30,19 @@ export const isPluginApplicableToEntity = (entity: Entity) =>
/** @public */
export type EntityPagerDutyCardProps = {
readOnly?: boolean;
disableChangeEvents?: boolean;
};
/** @public */
export const EntityPagerDutyCard = (props: EntityPagerDutyCardProps) => {
const { readOnly } = props;
const { readOnly, disableChangeEvents } = props;
const { entity } = useEntity();
const pagerDutyEntity = getPagerDutyEntity(entity);
return <PagerDutyCard {...pagerDutyEntity} readOnly={readOnly} />;
return (
<PagerDutyCard
{...pagerDutyEntity}
readOnly={readOnly}
disableChangeEvents={disableChangeEvents}
/>
);
};
@@ -46,11 +46,12 @@ const BasicCard = ({ children }: { children: ReactNode }) => (
/** @public */
export type PagerDutyCardProps = PagerDutyEntity & {
readOnly?: boolean;
disableChangeEvents?: boolean;
};
/** @public */
export const PagerDutyCard = (props: PagerDutyCardProps) => {
const { readOnly, integrationKey, name } = props;
const { readOnly, disableChangeEvents, integrationKey, name } = props;
const api = useApi(pagerDutyApiRef);
const [refreshIncidents, setRefreshIncidents] = useState<boolean>(false);
const [refreshChangeEvents, setRefreshChangeEvents] =
@@ -169,12 +170,16 @@ export const PagerDutyCard = (props: PagerDutyCardProps) => {
refreshIncidents={refreshIncidents}
/>
</CardTab>
<CardTab label="Change Events">
<ChangeEvents
serviceId={service!.id}
refreshEvents={refreshChangeEvents}
/>
</CardTab>
<>
{disableChangeEvents !== true && (
<CardTab label="Change Events">
<ChangeEvents
serviceId={service!.id}
refreshEvents={refreshChangeEvents}
/>
</CardTab>
)}
</>
</TabbedCard>
<EscalationPolicy policyId={service!.policyId} />
</CardContent>