From 882f1262557049abfd504a747b40e599f33d22b5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Mar 2024 21:39:09 +0000 Subject: [PATCH 1/5] chore(deps): bump webpack-dev-middleware from 5.3.3 to 5.3.4 Bumps [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware) from 5.3.3 to 5.3.4. - [Release notes](https://github.com/webpack/webpack-dev-middleware/releases) - [Changelog](https://github.com/webpack/webpack-dev-middleware/blob/v5.3.4/CHANGELOG.md) - [Commits](https://github.com/webpack/webpack-dev-middleware/compare/v5.3.3...v5.3.4) --- updated-dependencies: - dependency-name: webpack-dev-middleware dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index f19fd49..4a56193 100644 --- a/yarn.lock +++ b/yarn.lock @@ -19019,8 +19019,8 @@ __metadata: linkType: hard "webpack-dev-middleware@npm:^5.3.1": - version: 5.3.3 - resolution: "webpack-dev-middleware@npm:5.3.3" + version: 5.3.4 + resolution: "webpack-dev-middleware@npm:5.3.4" dependencies: colorette: ^2.0.10 memfs: ^3.4.3 @@ -19029,7 +19029,7 @@ __metadata: schema-utils: ^4.0.0 peerDependencies: webpack: ^4.0.0 || ^5.0.0 - checksum: dd332cc6da61222c43d25e5a2155e23147b777ff32fdf1f1a0a8777020c072fbcef7756360ce2a13939c3f534c06b4992a4d659318c4a7fe2c0530b52a8a6621 + checksum: 90cf3e27d0714c1a745454a1794f491b7076434939340605b9ee8718ba2b85385b120939754e9fdbd6569811e749dee53eec319e0d600e70e0b0baffd8e3fb13 languageName: node linkType: hard From eba28543427550e7154bb3f08935b1792f4d5e1e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 29 Mar 2024 08:05:13 +0000 Subject: [PATCH 2/5] chore(deps): bump express from 4.18.2 to 4.19.2 Bumps [express](https://github.com/expressjs/express) from 4.18.2 to 4.19.2. - [Release notes](https://github.com/expressjs/express/releases) - [Changelog](https://github.com/expressjs/express/blob/master/History.md) - [Commits](https://github.com/expressjs/express/compare/4.18.2...4.19.2) --- updated-dependencies: - dependency-name: express dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/yarn.lock b/yarn.lock index f19fd49..36b8317 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6949,12 +6949,12 @@ __metadata: languageName: node linkType: hard -"body-parser@npm:1.20.1": - version: 1.20.1 - resolution: "body-parser@npm:1.20.1" +"body-parser@npm:1.20.2": + version: 1.20.2 + resolution: "body-parser@npm:1.20.2" dependencies: bytes: 3.1.2 - content-type: ~1.0.4 + content-type: ~1.0.5 debug: 2.6.9 depd: 2.0.0 destroy: 1.2.0 @@ -6962,10 +6962,10 @@ __metadata: iconv-lite: 0.4.24 on-finished: 2.4.1 qs: 6.11.0 - raw-body: 2.5.1 + raw-body: 2.5.2 type-is: ~1.6.18 unpipe: 1.0.0 - checksum: f1050dbac3bede6a78f0b87947a8d548ce43f91ccc718a50dd774f3c81f2d8b04693e52acf62659fad23101827dd318da1fb1363444ff9a8482b886a3e4a5266 + checksum: 14d37ec638ab5c93f6099ecaed7f28f890d222c650c69306872e00b9efa081ff6c596cd9afb9930656aae4d6c4e1c17537bea12bb73c87a217cb3cfea8896737 languageName: node linkType: hard @@ -7780,7 +7780,7 @@ __metadata: languageName: node linkType: hard -"content-type@npm:~1.0.4": +"content-type@npm:~1.0.4, content-type@npm:~1.0.5": version: 1.0.5 resolution: "content-type@npm:1.0.5" checksum: 566271e0a251642254cde0f845f9dd4f9856e52d988f4eb0d0dcffbb7a1f8ec98de7a5215fc628f3bce30fe2fb6fd2bc064b562d721658c59b544e2d34ea2766 @@ -7840,10 +7840,10 @@ __metadata: languageName: node linkType: hard -"cookie@npm:0.5.0": - version: 0.5.0 - resolution: "cookie@npm:0.5.0" - checksum: 1f4bd2ca5765f8c9689a7e8954183f5332139eb72b6ff783d8947032ec1fdf43109852c178e21a953a30c0dd42257828185be01b49d1eb1a67fd054ca588a180 +"cookie@npm:0.6.0": + version: 0.6.0 + resolution: "cookie@npm:0.6.0" + checksum: f56a7d32a07db5458e79c726b77e3c2eff655c36792f2b6c58d351fb5f61531e5b1ab7f46987150136e366c65213cbe31729e02a3eaed630c3bf7334635fb410 languageName: node linkType: hard @@ -9880,15 +9880,15 @@ __metadata: linkType: hard "express@npm:^4.17.1, express@npm:^4.17.3": - version: 4.18.2 - resolution: "express@npm:4.18.2" + version: 4.19.2 + resolution: "express@npm:4.19.2" dependencies: accepts: ~1.3.8 array-flatten: 1.1.1 - body-parser: 1.20.1 + body-parser: 1.20.2 content-disposition: 0.5.4 content-type: ~1.0.4 - cookie: 0.5.0 + cookie: 0.6.0 cookie-signature: 1.0.6 debug: 2.6.9 depd: 2.0.0 @@ -9914,7 +9914,7 @@ __metadata: type-is: ~1.6.18 utils-merge: 1.0.1 vary: ~1.1.2 - checksum: 3c4b9b076879442f6b968fe53d85d9f1eeacbb4f4c41e5f16cc36d77ce39a2b0d81b3f250514982110d815b2f7173f5561367f9110fcc541f9371948e8c8b037 + checksum: 212dbd6c2c222a96a61bc927639c95970a53b06257080bb9e2838adb3bffdb966856551fdad1ab5dd654a217c35db94f987d0aa88d48fb04d306340f5f34dca5 languageName: node linkType: hard @@ -15812,15 +15812,15 @@ __metadata: languageName: node linkType: hard -"raw-body@npm:2.5.1": - version: 2.5.1 - resolution: "raw-body@npm:2.5.1" +"raw-body@npm:2.5.2": + version: 2.5.2 + resolution: "raw-body@npm:2.5.2" dependencies: bytes: 3.1.2 http-errors: 2.0.0 iconv-lite: 0.4.24 unpipe: 1.0.0 - checksum: 5362adff1575d691bb3f75998803a0ffed8c64eabeaa06e54b4ada25a0cd1b2ae7f4f5ec46565d1bec337e08b5ac90c76eaa0758de6f72a633f025d754dec29e + checksum: ba1583c8d8a48e8fbb7a873fdbb2df66ea4ff83775421bfe21ee120140949ab048200668c47d9ae3880012f6e217052690628cf679ddfbd82c9fc9358d574676 languageName: node linkType: hard From c7fe30f578eeeaa1b038e75ecce7587ecc1e604f Mon Sep 17 00:00:00 2001 From: Tiago Barbosa Date: Wed, 3 Apr 2024 10:47:55 +0100 Subject: [PATCH 3/5] feat: hide trigger incident button when integration key is missing Signed-off-by: Tiago Barbosa --- src/components/EntityPagerDutyCard/index.test.tsx | 8 ++++---- src/components/PagerDutyCard/StatusCard.tsx | 2 +- src/components/PagerDutyCard/index.test.tsx | 6 +++--- src/components/PagerDutyCard/index.tsx | 9 ++++----- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/components/EntityPagerDutyCard/index.test.tsx b/src/components/EntityPagerDutyCard/index.test.tsx index 694cc64..ee4238b 100644 --- a/src/components/EntityPagerDutyCard/index.test.tsx +++ b/src/components/EntityPagerDutyCard/index.test.tsx @@ -282,7 +282,7 @@ describe("EntityPagerDutyCard", () => { ); await waitFor(() => !queryByTestId("progress")); expect(getByText("Open service in PagerDuty")).toBeInTheDocument(); - expect(getByText("Create new incident")).toBeInTheDocument(); + expect(queryByTestId("trigger-incident-button")).not.toBeInTheDocument(); expect(getByText("Nice! No incidents found!")).toBeInTheDocument(); expect( getByText("No one is on-call. Update the escalation policy.") @@ -349,12 +349,12 @@ describe("EntityPagerDutyCard", () => { ).toBeInTheDocument(); }); - it("disables the Create new incident button", async () => { + it("hides the Create new incident button", async () => { mockPagerDutyApi.getServiceByPagerDutyEntity = jest .fn() .mockImplementationOnce(async () => ({ service })); - const { queryByTestId, getByLabelText } = render( + const { queryByTestId } = render( wrapInTestApp( @@ -364,7 +364,7 @@ describe("EntityPagerDutyCard", () => { ) ); await waitFor(() => !queryByTestId("progress")); - expect(getByLabelText("create-incident").className).toMatch("disabled"); + expect(queryByTestId("trigger-incident-button")).not.toBeInTheDocument(); }); }); diff --git a/src/components/PagerDutyCard/StatusCard.tsx b/src/components/PagerDutyCard/StatusCard.tsx index 01397d9..0056b44 100644 --- a/src/components/PagerDutyCard/StatusCard.tsx +++ b/src/components/PagerDutyCard/StatusCard.tsx @@ -124,7 +124,7 @@ function StatusCard({ serviceId, refreshStatus }: Props) { {status !== undefined ? ( - {labelFromStatus(status!)} + {labelFromStatus(status)} ) : ( Unable to get status diff --git a/src/components/PagerDutyCard/index.test.tsx b/src/components/PagerDutyCard/index.test.tsx index c434c5e..1bfb538 100644 --- a/src/components/PagerDutyCard/index.test.tsx +++ b/src/components/PagerDutyCard/index.test.tsx @@ -265,12 +265,12 @@ describe("PagerDutyCard", () => { ).toBeInTheDocument(); }); - it("disables the Create new incident button", async () => { + it("hides the Create new incident button", async () => { mockPagerDutyApi.getServiceByPagerDutyEntity = jest .fn() .mockImplementationOnce(async () => ({ service })); - const { queryByTestId, getByLabelText } = render( + const { queryByTestId } = render( wrapInTestApp( @@ -278,7 +278,7 @@ describe("PagerDutyCard", () => { ) ); await waitFor(() => !queryByTestId("progress")); - expect(getByLabelText("create-incident").className).toMatch("disabled"); + expect(queryByTestId("trigger-incident-button")).not.toBeInTheDocument(); }); }); diff --git a/src/components/PagerDutyCard/index.tsx b/src/components/PagerDutyCard/index.tsx index c6b4bef..1730977 100644 --- a/src/components/PagerDutyCard/index.tsx +++ b/src/components/PagerDutyCard/index.tsx @@ -191,9 +191,10 @@ export const PagerDutyCard = (props: PagerDutyCardProps) => { ) } action={ - !readOnly ? ( + (!readOnly && props.integrationKey) ? (
{ 0 - ? service?.metrics![0].total_interruptions + ? service?.metrics[0].total_interruptions : undefined } label="interruptions" @@ -247,7 +248,7 @@ export const PagerDutyCard = (props: PagerDutyCardProps) => { 0 - ? service?.metrics![0].total_high_urgency_incidents + ? service?.metrics[0].total_high_urgency_incidents : undefined } label="high urgency" @@ -269,13 +270,11 @@ export const PagerDutyCard = (props: PagerDutyCardProps) => { Date: Wed, 3 Apr 2024 12:18:06 +0100 Subject: [PATCH 4/5] feat: add parameter to hide oncall information Signed-off-by: Tiago Barbosa --- .../EntityPagerDutyCard/index.test.tsx | 48 +++++++++++++++++++ src/components/EntityPagerDutyCard/index.tsx | 4 +- src/components/PagerDutyCard/index.tsx | 9 +++- 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/src/components/EntityPagerDutyCard/index.test.tsx b/src/components/EntityPagerDutyCard/index.test.tsx index ee4238b..7b18cff 100644 --- a/src/components/EntityPagerDutyCard/index.test.tsx +++ b/src/components/EntityPagerDutyCard/index.test.tsx @@ -393,6 +393,54 @@ describe("EntityPagerDutyCard", () => { }); }); + describe("when entity has all annotations but the plugin has been configured to disable change events", () => { + it("must hide change events tab", async () => { + mockPagerDutyApi.getServiceByPagerDutyEntity = jest + .fn() + .mockImplementationOnce(async () => ({ service })); + + const { getByText, queryByTestId } = render( + wrapInTestApp( + + + + + + ) + ); + await waitFor(() => !queryByTestId("progress")); + expect(getByText("Open service in PagerDuty")).toBeInTheDocument(); + expect(queryByTestId("change-events")).not.toBeInTheDocument(); + expect(getByText("Nice! No incidents found!")).toBeInTheDocument(); + expect( + getByText("No one is on-call. Update the escalation policy.") + ).toBeInTheDocument(); + }); + }); + + describe("when entity has all annotations but the plugin has been configured to disable on-call", () => { + it("must hide on-call component", async () => { + mockPagerDutyApi.getServiceByPagerDutyEntity = jest + .fn() + .mockImplementationOnce(async () => ({ service })); + + const { getByText, queryByTestId } = render( + wrapInTestApp( + + + + + + ) + ); + await waitFor(() => !queryByTestId("progress")); + expect(getByText("Open service in PagerDuty")).toBeInTheDocument(); + expect(getByText("Change Events")).toBeInTheDocument(); + expect(getByText("Nice! No incidents found!")).toBeInTheDocument(); + expect(queryByTestId("oncall-card")).not.toBeInTheDocument(); + }); + }); + describe('when entity has all annotations but the plugin has been configured to be "read only"', () => { it('queries by integration key but does not render the "Create new incident" button', async () => { mockPagerDutyApi.getServiceByPagerDutyEntity = jest diff --git a/src/components/EntityPagerDutyCard/index.tsx b/src/components/EntityPagerDutyCard/index.tsx index 167f779..af75793 100644 --- a/src/components/EntityPagerDutyCard/index.tsx +++ b/src/components/EntityPagerDutyCard/index.tsx @@ -32,11 +32,12 @@ export const isPluginApplicableToEntity = (entity: Entity) => export type EntityPagerDutyCardProps = { readOnly?: boolean; disableChangeEvents?: boolean; + disableOnCall?: boolean; }; /** @public */ export const EntityPagerDutyCard = (props: EntityPagerDutyCardProps) => { - const { readOnly, disableChangeEvents } = props; + const { readOnly, disableChangeEvents, disableOnCall } = props; const { entity } = useEntity(); const pagerDutyEntity = getPagerDutyEntity(entity); return ( @@ -44,6 +45,7 @@ export const EntityPagerDutyCard = (props: EntityPagerDutyCardProps) => { {...pagerDutyEntity} readOnly={readOnly} disableChangeEvents={disableChangeEvents} + disableOnCall={disableOnCall} /> ); }; diff --git a/src/components/PagerDutyCard/index.tsx b/src/components/PagerDutyCard/index.tsx index 1730977..08d75ee 100644 --- a/src/components/PagerDutyCard/index.tsx +++ b/src/components/PagerDutyCard/index.tsx @@ -100,6 +100,7 @@ const BasicCard = ({ children }: { children: ReactNode }) => ( export type PagerDutyCardProps = PagerDutyEntity & { readOnly?: boolean; disableChangeEvents?: boolean; + disableOnCall?: boolean; }; /** @public */ @@ -107,7 +108,7 @@ export const PagerDutyCard = (props: PagerDutyCardProps) => { const classes = useStyles(); const theme = useTheme(); - const { readOnly, disableChangeEvents } = props; + const { readOnly, disableChangeEvents, disableOnCall } = props; const api = useApi(pagerDutyApiRef); const [refreshIncidents, setRefreshIncidents] = useState(false); const [refreshChangeEvents, setRefreshChangeEvents] = @@ -300,6 +301,7 @@ export const PagerDutyCard = (props: PagerDutyCardProps) => { {disableChangeEvents !== true ? ( @@ -308,11 +310,16 @@ export const PagerDutyCard = (props: PagerDutyCardProps) => { <> )} + {disableOnCall !== true ? ( + ) : ( + <> + )} ); From 303c0e2abe69c32c7d8378b1c754e171599475cb Mon Sep 17 00:00:00 2001 From: Tiago Barbosa Date: Wed, 3 Apr 2024 13:03:31 +0100 Subject: [PATCH 5/5] style: adding correct spacing when change events do not include PD urls Signed-off-by: Tiago Barbosa --- .../ChangeEvents/ChangeEventListItem.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/ChangeEvents/ChangeEventListItem.tsx b/src/components/ChangeEvents/ChangeEventListItem.tsx index db7e0f1..4373c50 100644 --- a/src/components/ChangeEvents/ChangeEventListItem.tsx +++ b/src/components/ChangeEvents/ChangeEventListItem.tsx @@ -44,11 +44,15 @@ const useStyles = makeStyles((theme) => ({ fontWeight: "bold", }, smallExternalLinkIconStyle: { - color: theme.palette.text.primary + color: theme.palette.text.primary, + }, + smallExternalLinkWithoutMarginIconStyle: { + color: theme.palette.text.primary, + marginRight: "-20px", }, smallIconStyle: { color: theme.palette.text.primary, - marginRight: "-20px" + marginRight: "-20px", }, })); @@ -63,6 +67,7 @@ export const ChangeEventListItem = ({ changeEvent }: Props) => { const changedAt = DateTime.local() .minus(Duration.fromMillis(duration)) .toRelative({ locale: 'en' }); + let externalLinkElem: JSX.Element | undefined; if (changeEvent.links.length > 0) { const text: string = changeEvent.links[0].text; @@ -71,7 +76,11 @@ export const ChangeEventListItem = ({ changeEvent }: Props) => {