fix: address PR review comments from @freben

Signed-off-by: Isaiah Thiessen <isaiah.thiessen@telus.com>
This commit is contained in:
Isaiah Thiessen
2022-06-09 15:41:37 -07:00
parent 73353737d9
commit 6f475edfb6
8 changed files with 20 additions and 43 deletions
+1 -1
View File
@@ -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
+1 -1
View File
@@ -23,6 +23,6 @@ export interface Config {
* base url for links
* @visibility frontend
*/
baseUrl?: string;
baseUrl: string;
};
}
+6 -4
View File
@@ -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"
}
+4 -2
View File
@@ -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<DynatraceProblems | undefined> {
if (!dynatraceEntityId) {
return undefined;
throw new Error('Dynatrace entity ID is required');
}
return this.callApi('problems', {
@@ -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 <MissingAnnotationEmptyState annotation={DYNATRACE_ID_ANNOTATION} />;
}
const dynatraceEntityId: string =
entity?.metadata.annotations?.[DYNATRACE_ID_ANNOTATION]!;
return (
<Page themeId="tool">
<Content>
@@ -45,7 +47,7 @@ export const DynatraceTab = () => {
</ContentHeader>
<Grid container spacing={2}>
<Grid item xs={12} lg={12}>
<ProblemsList dynatraceEntityId={`${dynatraceEntityId}`} />
<ProblemsList dynatraceEntityId={dynatraceEntityId} />
</Grid>
</Grid>
</Content>
+3 -5
View File
@@ -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',
-20
View File
@@ -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',
});
-7
View File
@@ -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"