=> {
+ const dashboardObject: any = NewRelicDashboardAPI.getDashboardSnapshot(
+ guid,
+ duration,
+ );
+ return dashboardObject;
+ }, []);
+ if (loading) {
+ return ;
+ }
+ if (error) {
+ return {error.message};
+ }
+ return (
+
+
+ {name}
+
+
+
+
+
+
+ {/* {JSON.stringify(
+ value.getDashboardSnapshot.data.dashboardCreateSnapshotUrl.replace(
+ /...$/,
+ 'png',
+ ),
+ )} */}
+
+
+ );
+};
diff --git a/plugins/new-relic-dashboard/src/components/NewRelicDashboard/DashboardSnapshot/DashboardSnapshotList.tsx b/plugins/new-relic-dashboard/src/components/NewRelicDashboard/DashboardSnapshot/DashboardSnapshotList.tsx
new file mode 100644
index 0000000000..78684f7a55
--- /dev/null
+++ b/plugins/new-relic-dashboard/src/components/NewRelicDashboard/DashboardSnapshot/DashboardSnapshotList.tsx
@@ -0,0 +1,157 @@
+/*
+ * 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 React from 'react';
+import { Grid, Tab, Tabs, makeStyles } from '@material-ui/core';
+import { NewRelicDashboardApiRef } from '../../../api';
+import { useApi } from '@backstage/core-plugin-api';
+import { useAsync } from 'react-use';
+import { Progress } from '@backstage/core-components';
+import Alert from '@material-ui/lab/Alert';
+import { DashboardSnapshot } from './DashboardSnapshot';
+
+interface TabPanelProps {
+ children?: React.ReactNode;
+ index: number;
+ value1: number;
+}
+function TabPanel(props: TabPanelProps) {
+ const { children, value1, index, ...other } = props;
+
+ return (
+
+ {value1 === index && children}
+
+ );
+}
+function a11yProps(index: number) {
+ return {
+ id: `simple-tab-${index}`,
+ 'aria-controls': `simple-tabpanel-${index}`,
+ };
+}
+type Props = {
+ guid: String;
+};
+const useStyles = makeStyles(
+ theme => ({
+ tabsWrapper: {
+ gridArea: 'pageSubheader',
+ backgroundColor: theme.palette.background.paper,
+ paddingLeft: theme.spacing(3),
+ },
+ defaultTab: {
+ padding: theme.spacing(3, 3),
+ ...theme.typography.caption,
+ textTransform: 'uppercase',
+ fontWeight: 'bold',
+ color: theme.palette.text.secondary,
+ },
+ selected: {
+ color: theme.palette.text.primary,
+ },
+ tabRoot: {
+ '&:hover': {
+ backgroundColor: theme.palette.background.default,
+ color: theme.palette.text.primary,
+ },
+ },
+ }),
+ { name: 'DashboardHeaderTabs' },
+);
+export const DashboardSnapshotList = ({ guid }: Props) => {
+ const styles = useStyles();
+ const NewRelicDashboardAPI = useApi(NewRelicDashboardApiRef);
+ const { value, loading, error } = useAsync(async (): Promise => {
+ const dashboardObject: any = NewRelicDashboardAPI.getDashboardEntity(guid);
+ return dashboardObject;
+ }, []);
+ const [value1, setValue1] = React.useState(0);
+ const handleChange = ({}: React.ChangeEvent<{}>, newValue: number) => {
+ setValue1(newValue);
+ };
+
+ if (loading) {
+ return ;
+ }
+ if (error) {
+ return {error.message};
+ }
+ return (
+ <>
+
+ {/*
+ {value.getDashboardEntity.data.actor.entitySearch.results.entities?.map(
+ (Entity: any) => {
+ return (
+
+ );
+ },
+ )}
+ */}
+
+
+ {value.getDashboardEntity.data.actor.entitySearch.results.entities?.map(
+ (Entity: any, index: any) => {
+ return (
+
+ );
+ },
+ )}
+
+ {value.getDashboardEntity.data.actor.entitySearch.results.entities?.map(
+ (Entity: any, index: any) => {
+ return (
+
+
+
+ );
+ },
+ )}
+ >
+ );
+};
diff --git a/plugins/new-relic-dashboard/src/components/NewRelicDashboard/DashboardSnapshot/index.ts b/plugins/new-relic-dashboard/src/components/NewRelicDashboard/DashboardSnapshot/index.ts
new file mode 100644
index 0000000000..6b17582515
--- /dev/null
+++ b/plugins/new-relic-dashboard/src/components/NewRelicDashboard/DashboardSnapshot/index.ts
@@ -0,0 +1,17 @@
+/*
+ * 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.
+ */
+export { DashboardSnapshot } from './DashboardSnapshot';
+export { DashboardSnapshotList } from './DashboardSnapshotList';
diff --git a/plugins/new-relic-dashboard/src/components/NewRelicDashboard/NewRelicDashboard.tsx b/plugins/new-relic-dashboard/src/components/NewRelicDashboard/NewRelicDashboard.tsx
new file mode 100644
index 0000000000..9cc1764b99
--- /dev/null
+++ b/plugins/new-relic-dashboard/src/components/NewRelicDashboard/NewRelicDashboard.tsx
@@ -0,0 +1,35 @@
+/*
+ * 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 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 './DashboardSnapshot';
+
+export const NewRelicDashboard = () => {
+ const entity = useNewRelicDashboardEntity();
+ return (
+
+
+
+
+
+
+
+
+ );
+};
diff --git a/plugins/new-relic-dashboard/src/components/NewRelicDashboard/index.ts b/plugins/new-relic-dashboard/src/components/NewRelicDashboard/index.ts
new file mode 100644
index 0000000000..668d76a059
--- /dev/null
+++ b/plugins/new-relic-dashboard/src/components/NewRelicDashboard/index.ts
@@ -0,0 +1,16 @@
+/*
+ * 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.
+ */
+export { NewRelicDashboard } from './NewRelicDashboard';
diff --git a/plugins/new-relic-dashboard/src/constants.ts b/plugins/new-relic-dashboard/src/constants.ts
new file mode 100644
index 0000000000..fd83a72132
--- /dev/null
+++ b/plugins/new-relic-dashboard/src/constants.ts
@@ -0,0 +1,16 @@
+/*
+ * 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.
+ */
+export const NEWRELIC_GUID = 'newrelic.com/dashboard-guid';
diff --git a/plugins/new-relic-dashboard/src/hooks/index.ts b/plugins/new-relic-dashboard/src/hooks/index.ts
new file mode 100644
index 0000000000..3739607b82
--- /dev/null
+++ b/plugins/new-relic-dashboard/src/hooks/index.ts
@@ -0,0 +1,27 @@
+/*
+ * 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 } from '../constants';
+
+export function useNewRelicDashboardEntity() {
+ const { entity } = useEntity();
+ const integrationKey: string | undefined =
+ entity.metadata.annotations?.[NEWRELIC_GUID];
+ const name: string | undefined = entity.metadata.name;
+
+ return { integrationKey, name };
+}
diff --git a/plugins/new-relic-dashboard/src/index.ts b/plugins/new-relic-dashboard/src/index.ts
new file mode 100644
index 0000000000..0c02a223d1
--- /dev/null
+++ b/plugins/new-relic-dashboard/src/index.ts
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+export {
+ newRelicDashboardPlugin,
+ NewRelicDashboardPage,
+ EntityNewRelicDashboard,
+ EntityPageNewRelicDashboard,
+} from './plugin';
+export { isNewRelicDashboardAvailable } from './Router';
diff --git a/plugins/new-relic-dashboard/src/plugin.test.ts b/plugins/new-relic-dashboard/src/plugin.test.ts
new file mode 100644
index 0000000000..e5eccd930b
--- /dev/null
+++ b/plugins/new-relic-dashboard/src/plugin.test.ts
@@ -0,0 +1,22 @@
+/*
+ * 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 { newRelicDashboardPlugin } from './plugin';
+
+describe('new-relic-dashboard', () => {
+ it('should export plugin', () => {
+ expect(newRelicDashboardPlugin).toBeDefined();
+ });
+});
diff --git a/plugins/new-relic-dashboard/src/plugin.ts b/plugins/new-relic-dashboard/src/plugin.ts
new file mode 100644
index 0000000000..cca9cbd7e1
--- /dev/null
+++ b/plugins/new-relic-dashboard/src/plugin.ts
@@ -0,0 +1,68 @@
+/*
+ * 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 {
+ createPlugin,
+ createRoutableExtension,
+ configApiRef,
+ createApiFactory,
+ discoveryApiRef,
+} from '@backstage/core-plugin-api';
+import { NewRelicDashboardApiRef, NewRelicDashboardClient } from './api';
+import { rootRouteRef } from './routes';
+
+export const newRelicDashboardPlugin = createPlugin({
+ id: 'new-relic-dashboard',
+ routes: {
+ root: rootRouteRef,
+ },
+ apis: [
+ createApiFactory({
+ api: NewRelicDashboardApiRef,
+ deps: { configApi: configApiRef, discoveryApi: discoveryApiRef },
+ factory: ({ configApi, discoveryApi }) =>
+ new NewRelicDashboardClient({
+ discoveryApi,
+ baseUrl: configApi.getOptionalString('newrelicdashboard.baseUrl'),
+ }),
+ }),
+ ],
+});
+
+export const NewRelicDashboardPage = newRelicDashboardPlugin.provide(
+ createRoutableExtension({
+ name: 'NewRelicDashboardPage',
+ component: () =>
+ import('./components/ExampleComponents').then(m => m.ExampleComponent),
+ mountPoint: rootRouteRef,
+ }),
+);
+
+export const EntityNewRelicDashboard = newRelicDashboardPlugin.provide(
+ createRoutableExtension({
+ component: () => import('./Router').then(m => m.Router),
+ mountPoint: rootRouteRef,
+ }),
+);
+
+export const EntityPageNewRelicDashboard = newRelicDashboardPlugin.provide(
+ createRoutableExtension({
+ component: () =>
+ import('./components/NewRelicDashboard/DashboardEntityList').then(
+ m => m.DashboardEntityList,
+ ),
+ mountPoint: rootRouteRef,
+ }),
+);
diff --git a/plugins/new-relic-dashboard/src/queries/getDashboardParentGuidQuery.ts b/plugins/new-relic-dashboard/src/queries/getDashboardParentGuidQuery.ts
new file mode 100644
index 0000000000..3a06384539
--- /dev/null
+++ b/plugins/new-relic-dashboard/src/queries/getDashboardParentGuidQuery.ts
@@ -0,0 +1,17 @@
+/*
+ * 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.
+ */
+export const getDashboardParentGuidQuery =
+ 'query ($query: String) {\n actor {\n entitySearch(query: $query) {\n results {\n entities {\n name\n ... on DashboardEntityOutline {\n name\n guid\n }\n permalink\n }\n }\n }\n }\n}\n';
diff --git a/plugins/new-relic-dashboard/src/queries/getDashboardSnapshotQuery.ts b/plugins/new-relic-dashboard/src/queries/getDashboardSnapshotQuery.ts
new file mode 100644
index 0000000000..7f96bf46ad
--- /dev/null
+++ b/plugins/new-relic-dashboard/src/queries/getDashboardSnapshotQuery.ts
@@ -0,0 +1,17 @@
+/*
+ * 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.
+ */
+export const getDashboardSnapshotQuery =
+ 'mutation($guid: EntityGuid!) {\n dashboardCreateSnapshotUrl(guid: $guid , params: {timeWindow: {duration: $duration}})\n}';
diff --git a/plugins/new-relic-dashboard/src/routes.ts b/plugins/new-relic-dashboard/src/routes.ts
new file mode 100644
index 0000000000..733cdfb571
--- /dev/null
+++ b/plugins/new-relic-dashboard/src/routes.ts
@@ -0,0 +1,20 @@
+/*
+ * 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 { createRouteRef } from '@backstage/core-plugin-api';
+
+export const rootRouteRef = createRouteRef({
+ title: 'new-relic-dashboard',
+});
diff --git a/plugins/new-relic-dashboard/src/setupTests.ts b/plugins/new-relic-dashboard/src/setupTests.ts
new file mode 100644
index 0000000000..fc6dbd98f8
--- /dev/null
+++ b/plugins/new-relic-dashboard/src/setupTests.ts
@@ -0,0 +1,17 @@
+/*
+ * 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 '@testing-library/jest-dom';
+import 'cross-fetch/polyfill';
diff --git a/plugins/new-relic-dashboard/src/types/DashboardEntity.ts b/plugins/new-relic-dashboard/src/types/DashboardEntity.ts
new file mode 100644
index 0000000000..93bcc24bd9
--- /dev/null
+++ b/plugins/new-relic-dashboard/src/types/DashboardEntity.ts
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+export type DashboardEntity = {
+ data: {
+ actor: {
+ entitySearch: {
+ results: {
+ entities: [
+ {
+ guid: string;
+ permalink: string;
+ },
+ ];
+ };
+ };
+ };
+ };
+};
diff --git a/plugins/new-relic-dashboard/src/types/DashboardSnapshot.ts b/plugins/new-relic-dashboard/src/types/DashboardSnapshot.ts
new file mode 100644
index 0000000000..6c11c6f6d7
--- /dev/null
+++ b/plugins/new-relic-dashboard/src/types/DashboardSnapshot.ts
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+export type DashboardSnapshot = {
+ data: {
+ dashboardCreateSnapshotUrl: string;
+ };
+};
diff --git a/plugins/new-relic-dashboard/src/types/SnapshotDetails.ts b/plugins/new-relic-dashboard/src/types/SnapshotDetails.ts
new file mode 100644
index 0000000000..e189ac52c4
--- /dev/null
+++ b/plugins/new-relic-dashboard/src/types/SnapshotDetails.ts
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+export type SnapshotDetails = {
+ dashboardSnapshotUrl: string;
+ permalink: string;
+};