removed useNewRelicDashboardEntity hook
Signed-off-by: mufaddal motiwala <mufaddalmm.52@gmail.com>
This commit is contained in:
@@ -25,9 +25,10 @@ import {
|
||||
ErrorPanel,
|
||||
} from '@backstage/core-components';
|
||||
import DesktopMac from '@material-ui/icons/DesktopMac';
|
||||
import { useNewRelicDashboardEntity } from '../../hooks';
|
||||
import { DashboardEntitySummary } from '../../api/NewRelicDashboardApi';
|
||||
import { ResultEntity } from '../../types/DashboardEntity';
|
||||
import { useEntity } from '@backstage/plugin-catalog-react';
|
||||
import { NEWRELIC_GUID_ANNOTATION } from './../../constants';
|
||||
|
||||
const useStyles = makeStyles({
|
||||
svgIcon: {
|
||||
@@ -40,7 +41,7 @@ const useStyles = makeStyles({
|
||||
},
|
||||
});
|
||||
export const DashboardEntityList = () => {
|
||||
const DashboardEntity = useNewRelicDashboardEntity();
|
||||
const { entity } = useEntity();
|
||||
const classes = useStyles();
|
||||
const newRelicDashboardAPI = useApi(newRelicDashboardApiRef);
|
||||
const { value, loading, error } = useAsync(async (): Promise<
|
||||
@@ -48,10 +49,10 @@ export const DashboardEntityList = () => {
|
||||
> => {
|
||||
const dashboardObject: Promise<DashboardEntitySummary | undefined> =
|
||||
newRelicDashboardAPI.getDashboardEntity(
|
||||
String(DashboardEntity?.integrationKey),
|
||||
String(entity.metadata.annotations?.[NEWRELIC_GUID_ANNOTATION]),
|
||||
);
|
||||
return dashboardObject;
|
||||
}, [DashboardEntity?.integrationKey]);
|
||||
}, [entity.metadata.annotations?.[NEWRELIC_GUID_ANNOTATION]]);
|
||||
if (loading) {
|
||||
return <Progress />;
|
||||
}
|
||||
@@ -68,7 +69,7 @@ export const DashboardEntityList = () => {
|
||||
<>No Dashboard Pages found with the specified Dashboard GUID</>
|
||||
)}
|
||||
{value?.getDashboardEntity?.data.actor.entitySearch.results.entities?.map(
|
||||
(entity: ResultEntity) => {
|
||||
(entityResult: ResultEntity) => {
|
||||
return (
|
||||
<Box style={{ margin: '10px' }} display="flex">
|
||||
<Box mr={1} className={classes.svgIcon}>
|
||||
@@ -77,7 +78,7 @@ export const DashboardEntityList = () => {
|
||||
</Typography>
|
||||
</Box>
|
||||
<Box flexGrow="1">
|
||||
<Link to={entity.permalink}>{entity.name}</Link>
|
||||
<Link to={entityResult.permalink}>{entityResult.name}</Link>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
|
||||
@@ -16,12 +16,13 @@
|
||||
import React from 'react';
|
||||
import { Grid } from '@material-ui/core';
|
||||
import { Page, Content } from '@backstage/core-components';
|
||||
import { useNewRelicDashboardEntity } from '../../hooks';
|
||||
import { DashboardEntityList } from './DashboardEntityList';
|
||||
import { DashboardSnapshotList } from './DashboardSnapshotList';
|
||||
import { useEntity } from '@backstage/plugin-catalog-react';
|
||||
import { NEWRELIC_GUID_ANNOTATION } from '../../constants';
|
||||
|
||||
export const NewRelicDashboard = () => {
|
||||
const entity = useNewRelicDashboardEntity();
|
||||
const { entity } = useEntity();
|
||||
return (
|
||||
<Page themeId="home">
|
||||
<Content>
|
||||
@@ -30,7 +31,11 @@ export const NewRelicDashboard = () => {
|
||||
<DashboardEntityList />
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
<DashboardSnapshotList guid={String(entity.integrationKey)} />
|
||||
<DashboardSnapshotList
|
||||
guid={String(
|
||||
entity.metadata.annotations?.[NEWRELIC_GUID_ANNOTATION],
|
||||
)}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Content>
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright 2021 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 { useEntity } from '@backstage/plugin-catalog-react';
|
||||
|
||||
import { NEWRELIC_GUID_ANNOTATION } from '../constants';
|
||||
|
||||
export function useNewRelicDashboardEntity() {
|
||||
const { entity } = useEntity();
|
||||
const integrationKey: string | undefined =
|
||||
entity?.metadata?.annotations?.[NEWRELIC_GUID_ANNOTATION];
|
||||
const name: string | undefined = entity?.metadata?.name;
|
||||
|
||||
return { integrationKey, name };
|
||||
}
|
||||
Reference in New Issue
Block a user