diff --git a/app-config.yaml b/app-config.yaml index d95553f12d..5919deb1ee 100644 --- a/app-config.yaml +++ b/app-config.yaml @@ -137,7 +137,7 @@ techdocs: type: 'local' # Alternatives - 'googleGcs' or 'awsS3' or 'azureBlobStorage' or 'openStackSwift'. Read documentation for using alternatives. dynatrace: - baseUrl: https://your-dynatrace-instance-here.dynatrace.com + baseUrl: https://your.dynatrace.instance.com sentry: organization: my-company diff --git a/plugins/dynatrace/config.d.ts b/plugins/dynatrace/config.d.ts index 2b9573e88b..b06d0c7362 100644 --- a/plugins/dynatrace/config.d.ts +++ b/plugins/dynatrace/config.d.ts @@ -23,6 +23,6 @@ export interface Config { * base url for links * @visibility frontend */ - baseUrl?: string; + baseUrl: string; }; } diff --git a/plugins/dynatrace/package.json b/plugins/dynatrace/package.json index c9c2180a53..267db810ce 100644 --- a/plugins/dynatrace/package.json +++ b/plugins/dynatrace/package.json @@ -43,14 +43,16 @@ "@backstage/test-utils": "^1.1.1-next.0", "@testing-library/jest-dom": "^5.10.1", "@testing-library/react": "^12.1.3", - "@testing-library/user-event": "^13.1.8", + "@testing-library/user-event": "^14.0.0", "@types/jest": "*", "@types/node": "*", "cross-fetch": "^3.1.5", "express": "^4.18.1", - "msw": "^0.35.0" + "msw": "^0.42.0" }, "files": [ - "dist" - ] + "dist", + "config.d.ts" + ], + "configSchema": "config.d.ts" } diff --git a/plugins/dynatrace/src/api/DynatraceClient.ts b/plugins/dynatrace/src/api/DynatraceClient.ts index 015ad4bc44..27476ddbac 100644 --- a/plugins/dynatrace/src/api/DynatraceClient.ts +++ b/plugins/dynatrace/src/api/DynatraceClient.ts @@ -47,14 +47,16 @@ export class DynatraceClient implements DynatraceApi { if (response.status === 200) { return (await response.json()) as T; } - return undefined; + throw new Error( + `Dynatrace API call failed: ${response.status}:${response.statusText}`, + ); } async getDynatraceProblems( dynatraceEntityId: string, ): Promise { if (!dynatraceEntityId) { - return undefined; + throw new Error('Dynatrace entity ID is required'); } return this.callApi('problems', { diff --git a/plugins/dynatrace/src/components/DynatraceTab/DynatraceTab.tsx b/plugins/dynatrace/src/components/DynatraceTab/DynatraceTab.tsx index 8068ad7ad9..c284eaba0f 100644 --- a/plugins/dynatrace/src/components/DynatraceTab/DynatraceTab.tsx +++ b/plugins/dynatrace/src/components/DynatraceTab/DynatraceTab.tsx @@ -29,12 +29,14 @@ import { DYNATRACE_ID_ANNOTATION } from '../../constants'; export const DynatraceTab = () => { const { entity } = useEntity(); - const dynatraceEntityId: string = - entity?.metadata.annotations?.[DYNATRACE_ID_ANNOTATION] ?? ''; if (!isDynatraceAvailable(entity)) { return ; } + + const dynatraceEntityId: string = + entity?.metadata.annotations?.[DYNATRACE_ID_ANNOTATION]!; + return ( @@ -45,7 +47,7 @@ export const DynatraceTab = () => { - + diff --git a/plugins/dynatrace/src/plugin.ts b/plugins/dynatrace/src/plugin.ts index 7ba3bef3a1..2c3fa0e936 100644 --- a/plugins/dynatrace/src/plugin.ts +++ b/plugins/dynatrace/src/plugin.ts @@ -25,13 +25,9 @@ import { import { Entity } from '@backstage/catalog-model'; import { DYNATRACE_ID_ANNOTATION } from './constants'; -import { rootRouteRef } from './routes'; - +// @public export const dynatracePlugin = createPlugin({ id: 'dynatrace', - routes: { - root: rootRouteRef, - }, apis: [ createApiFactory({ api: dynatraceApiRef, @@ -48,9 +44,11 @@ export const dynatracePlugin = createPlugin({ ], }); +// @public export const isDynatraceAvailable = (entity: Entity) => Boolean(entity.metadata.annotations?.[DYNATRACE_ID_ANNOTATION]); +// @public export const DynatraceTab = dynatracePlugin.provide( createRoutableExtension({ name: 'DynatraceTab', diff --git a/plugins/dynatrace/src/routes.ts b/plugins/dynatrace/src/routes.ts deleted file mode 100644 index 73f7b573b7..0000000000 --- a/plugins/dynatrace/src/routes.ts +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2022 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 { createRouteRef } from '@backstage/core-plugin-api'; - -export const rootRouteRef = createRouteRef({ - id: 'dynatrace', -}); diff --git a/yarn.lock b/yarn.lock index 8246a73ebb..630140b98c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5639,13 +5639,6 @@ "@testing-library/dom" "^8.0.0" "@types/react-dom" "<18.0.0" -"@testing-library/user-event@^13.1.8": - version "13.5.0" - resolved "https://registry.npmjs.org/@testing-library/user-event/-/user-event-13.5.0.tgz#69d77007f1e124d55314a2b73fd204b333b13295" - integrity sha512-5Kwtbo3Y/NowpkbRuSepbyMFkZmHgD+vPzYB/RJ4oxt5Gj/avFFBYjhw27cqSVPVw/3a67NK1PbiIr9k4Gwmdg== - dependencies: - "@babel/runtime" "^7.12.5" - "@testing-library/user-event@^14.0.0": version "14.2.0" resolved "https://registry.npmjs.org/@testing-library/user-event/-/user-event-14.2.0.tgz#8293560f8f80a00383d6c755ec3e0b918acb1683"