@backstage-community/plugin-grafana 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/alpha/entityCards.esm.js +4 -4
- package/dist/alpha/entityCards.esm.js.map +1 -1
- package/dist/alpha.d.ts +38 -22
- package/dist/components/AlertsCard/AlertsCard.esm.js +16 -16
- package/dist/components/AlertsCard/AlertsCard.esm.js.map +1 -1
- package/dist/components/DashboardViewer/DashboardViewer.esm.js +4 -4
- package/dist/components/DashboardViewer/DashboardViewer.esm.js.map +1 -1
- package/dist/components/DashboardsCard/DashboardsCard.esm.js +13 -13
- package/dist/components/DashboardsCard/DashboardsCard.esm.js.map +1 -1
- package/dist/index.d.ts +7 -10
- package/package.json +14 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { EntityCardBlueprint } from '@backstage/plugin-catalog-react/alpha';
|
|
3
3
|
import { isDashboardSelectorAvailable, isAlertSelectorAvailable, isOverviewDashboardAvailable } from '../constants.esm.js';
|
|
4
4
|
|
|
@@ -6,21 +6,21 @@ const entityGrafanaDashboardsCard = EntityCardBlueprint.make({
|
|
|
6
6
|
name: "dashboards",
|
|
7
7
|
params: {
|
|
8
8
|
filter: (entity) => Boolean(isDashboardSelectorAvailable(entity)),
|
|
9
|
-
loader: () => import('../components/DashboardsCard/index.esm.js').then((m) => /* @__PURE__ */
|
|
9
|
+
loader: () => import('../components/DashboardsCard/index.esm.js').then((m) => /* @__PURE__ */ jsx(m.DashboardsCard, {}))
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
const entityGrafanaAlertsCard = EntityCardBlueprint.make({
|
|
13
13
|
name: "alerts",
|
|
14
14
|
params: {
|
|
15
15
|
filter: (entity) => Boolean(isDashboardSelectorAvailable(entity)) || isAlertSelectorAvailable(entity),
|
|
16
|
-
loader: () => import('../components/AlertsCard/index.esm.js').then((m) => /* @__PURE__ */
|
|
16
|
+
loader: () => import('../components/AlertsCard/index.esm.js').then((m) => /* @__PURE__ */ jsx(m.AlertsCard, {}))
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
const entityGrafanaOverviewDashboardViewer = EntityCardBlueprint.make({
|
|
20
20
|
name: "overview-dashboard",
|
|
21
21
|
params: {
|
|
22
22
|
filter: (entity) => isOverviewDashboardAvailable(entity),
|
|
23
|
-
loader: () => import('../components/DashboardViewer/index.esm.js').then((m) => /* @__PURE__ */
|
|
23
|
+
loader: () => import('../components/DashboardViewer/index.esm.js').then((m) => /* @__PURE__ */ jsx(m.EntityDashboardViewer, {}))
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
26
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entityCards.esm.js","sources":["../../src/alpha/entityCards.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport
|
|
1
|
+
{"version":3,"file":"entityCards.esm.js","sources":["../../src/alpha/entityCards.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { EntityCardBlueprint } from '@backstage/plugin-catalog-react/alpha';\nimport {\n isAlertSelectorAvailable,\n isDashboardSelectorAvailable,\n isOverviewDashboardAvailable,\n} from '../constants';\n\n/**\n * @alpha\n */\nexport const entityGrafanaDashboardsCard = EntityCardBlueprint.make({\n name: 'dashboards',\n params: {\n filter: entity => Boolean(isDashboardSelectorAvailable(entity)),\n loader: () =>\n import('../components/DashboardsCard').then(m => <m.DashboardsCard />),\n },\n});\n\n/**\n * @alpha\n */\nexport const entityGrafanaAlertsCard = EntityCardBlueprint.make({\n name: 'alerts',\n params: {\n filter: entity =>\n Boolean(isDashboardSelectorAvailable(entity)) ||\n isAlertSelectorAvailable(entity),\n loader: () =>\n import('../components/AlertsCard').then(m => <m.AlertsCard />),\n },\n});\n\n/**\n * @alpha\n */\nexport const entityGrafanaOverviewDashboardViewer = EntityCardBlueprint.make({\n name: 'overview-dashboard',\n params: {\n filter: entity => isOverviewDashboardAvailable(entity),\n loader: () =>\n import('../components/DashboardViewer').then(m => (\n <m.EntityDashboardViewer />\n )),\n },\n});\n"],"names":[],"mappings":";;;;AAyBa,MAAA,2BAAA,GAA8B,oBAAoB,IAAK,CAAA;AAAA,EAClE,IAAM,EAAA,YAAA;AAAA,EACN,MAAQ,EAAA;AAAA,IACN,MAAQ,EAAA,CAAA,MAAA,KAAU,OAAQ,CAAA,4BAAA,CAA6B,MAAM,CAAC,CAAA;AAAA,IAC9D,MAAA,EAAQ,MACN,OAAO,2CAA8B,CAAA,CAAE,IAAK,CAAA,CAAA,CAAA,qBAAM,GAAA,CAAA,CAAA,CAAE,cAAF,EAAA,EAAiB,CAAE;AAAA;AAE3E,CAAC;AAKY,MAAA,uBAAA,GAA0B,oBAAoB,IAAK,CAAA;AAAA,EAC9D,IAAM,EAAA,QAAA;AAAA,EACN,MAAQ,EAAA;AAAA,IACN,MAAA,EAAQ,YACN,OAAQ,CAAA,4BAAA,CAA6B,MAAM,CAAC,CAAA,IAC5C,yBAAyB,MAAM,CAAA;AAAA,IACjC,MAAA,EAAQ,MACN,OAAO,uCAA0B,CAAA,CAAE,IAAK,CAAA,CAAA,CAAA,qBAAM,GAAA,CAAA,CAAA,CAAE,UAAF,EAAA,EAAa,CAAE;AAAA;AAEnE,CAAC;AAKY,MAAA,oCAAA,GAAuC,oBAAoB,IAAK,CAAA;AAAA,EAC3E,IAAM,EAAA,oBAAA;AAAA,EACN,MAAQ,EAAA;AAAA,IACN,MAAA,EAAQ,CAAU,MAAA,KAAA,4BAAA,CAA6B,MAAM,CAAA;AAAA,IACrD,MAAA,EAAQ,MACN,OAAO,4CAA+B,CAAA,CAAE,IAAK,CAAA,CAAA,CAAA,qBAC1C,GAAA,CAAA,CAAA,CAAE,qBAAF,EAAA,EAAwB,CAC1B;AAAA;AAEP,CAAC;;;;"}
|
package/dist/alpha.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import * as
|
|
2
|
+
import * as _backstage_catalog_model from '@backstage/catalog-model';
|
|
3
3
|
import * as react from 'react';
|
|
4
|
+
import * as _backstage_plugin_catalog_react_alpha from '@backstage/plugin-catalog-react/alpha';
|
|
4
5
|
import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api';
|
|
5
|
-
import * as
|
|
6
|
+
import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* The Grafana backstage plugin.
|
|
@@ -10,75 +11,90 @@ import * as _backstage_core_plugin_api_index from '@backstage/core-plugin-api/in
|
|
|
10
11
|
* @alpha
|
|
11
12
|
*/
|
|
12
13
|
declare const _default: _backstage_frontend_plugin_api.FrontendPlugin<{}, {}, {
|
|
13
|
-
|
|
14
|
+
[x: `api:${string}`]: _backstage_frontend_plugin_api.ExtensionDefinition<{
|
|
14
15
|
kind: "api";
|
|
15
16
|
name: undefined;
|
|
16
17
|
config: {};
|
|
17
18
|
configInput: {};
|
|
18
|
-
output: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<
|
|
19
|
+
output: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<_backstage_core_plugin_api.AnyApiFactory, "core.api.factory", {}>;
|
|
19
20
|
inputs: {};
|
|
20
21
|
params: {
|
|
21
|
-
factory:
|
|
22
|
+
factory: _backstage_core_plugin_api.AnyApiFactory;
|
|
22
23
|
};
|
|
23
24
|
}>;
|
|
24
|
-
|
|
25
|
+
[x: `entity-card:${string}/alerts`]: _backstage_frontend_plugin_api.ExtensionDefinition<{
|
|
25
26
|
kind: "entity-card";
|
|
26
|
-
name: "
|
|
27
|
+
name: "alerts";
|
|
27
28
|
config: {
|
|
28
|
-
filter:
|
|
29
|
+
filter: _backstage_plugin_catalog_react_alpha.EntityPredicate | undefined;
|
|
30
|
+
type: "content" | "summary" | "info" | undefined;
|
|
29
31
|
};
|
|
30
32
|
configInput: {
|
|
31
|
-
filter?:
|
|
33
|
+
filter?: _backstage_plugin_catalog_react_alpha.EntityPredicate | undefined;
|
|
34
|
+
type?: "content" | "summary" | "info" | undefined;
|
|
32
35
|
};
|
|
33
|
-
output: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<react.JSX.Element, "core.reactElement", {}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<(entity:
|
|
36
|
+
output: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<react.JSX.Element, "core.reactElement", {}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<(entity: _backstage_catalog_model.Entity) => boolean, "catalog.entity-filter-function", {
|
|
34
37
|
optional: true;
|
|
35
38
|
}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<string, "catalog.entity-filter-expression", {
|
|
36
39
|
optional: true;
|
|
40
|
+
}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<_backstage_plugin_catalog_react_alpha.EntityCardType, "catalog.entity-card-type", {
|
|
41
|
+
optional: true;
|
|
37
42
|
}>;
|
|
38
43
|
inputs: {};
|
|
39
44
|
params: {
|
|
40
45
|
loader: () => Promise<JSX.Element>;
|
|
41
|
-
filter?:
|
|
46
|
+
filter?: _backstage_plugin_catalog_react_alpha.EntityPredicate | ((entity: _backstage_catalog_model.Entity) => boolean) | undefined;
|
|
47
|
+
type?: _backstage_plugin_catalog_react_alpha.EntityCardType | undefined;
|
|
42
48
|
};
|
|
43
49
|
}>;
|
|
44
|
-
|
|
50
|
+
[x: `entity-card:${string}/dashboards`]: _backstage_frontend_plugin_api.ExtensionDefinition<{
|
|
45
51
|
kind: "entity-card";
|
|
46
|
-
name: "
|
|
52
|
+
name: "dashboards";
|
|
47
53
|
config: {
|
|
48
|
-
filter:
|
|
54
|
+
filter: _backstage_plugin_catalog_react_alpha.EntityPredicate | undefined;
|
|
55
|
+
type: "content" | "summary" | "info" | undefined;
|
|
49
56
|
};
|
|
50
57
|
configInput: {
|
|
51
|
-
filter?:
|
|
58
|
+
filter?: _backstage_plugin_catalog_react_alpha.EntityPredicate | undefined;
|
|
59
|
+
type?: "content" | "summary" | "info" | undefined;
|
|
52
60
|
};
|
|
53
|
-
output: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<react.JSX.Element, "core.reactElement", {}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<(entity:
|
|
61
|
+
output: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<react.JSX.Element, "core.reactElement", {}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<(entity: _backstage_catalog_model.Entity) => boolean, "catalog.entity-filter-function", {
|
|
54
62
|
optional: true;
|
|
55
63
|
}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<string, "catalog.entity-filter-expression", {
|
|
56
64
|
optional: true;
|
|
65
|
+
}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<_backstage_plugin_catalog_react_alpha.EntityCardType, "catalog.entity-card-type", {
|
|
66
|
+
optional: true;
|
|
57
67
|
}>;
|
|
58
68
|
inputs: {};
|
|
59
69
|
params: {
|
|
60
70
|
loader: () => Promise<JSX.Element>;
|
|
61
|
-
filter?:
|
|
71
|
+
filter?: _backstage_plugin_catalog_react_alpha.EntityPredicate | ((entity: _backstage_catalog_model.Entity) => boolean) | undefined;
|
|
72
|
+
type?: _backstage_plugin_catalog_react_alpha.EntityCardType | undefined;
|
|
62
73
|
};
|
|
63
74
|
}>;
|
|
64
|
-
|
|
75
|
+
[x: `entity-card:${string}/overview-dashboard`]: _backstage_frontend_plugin_api.ExtensionDefinition<{
|
|
65
76
|
kind: "entity-card";
|
|
66
77
|
name: "overview-dashboard";
|
|
67
78
|
config: {
|
|
68
|
-
filter:
|
|
79
|
+
filter: _backstage_plugin_catalog_react_alpha.EntityPredicate | undefined;
|
|
80
|
+
type: "content" | "summary" | "info" | undefined;
|
|
69
81
|
};
|
|
70
82
|
configInput: {
|
|
71
|
-
filter?:
|
|
83
|
+
filter?: _backstage_plugin_catalog_react_alpha.EntityPredicate | undefined;
|
|
84
|
+
type?: "content" | "summary" | "info" | undefined;
|
|
72
85
|
};
|
|
73
|
-
output: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<react.JSX.Element, "core.reactElement", {}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<(entity:
|
|
86
|
+
output: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<react.JSX.Element, "core.reactElement", {}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<(entity: _backstage_catalog_model.Entity) => boolean, "catalog.entity-filter-function", {
|
|
74
87
|
optional: true;
|
|
75
88
|
}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<string, "catalog.entity-filter-expression", {
|
|
76
89
|
optional: true;
|
|
90
|
+
}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<_backstage_plugin_catalog_react_alpha.EntityCardType, "catalog.entity-card-type", {
|
|
91
|
+
optional: true;
|
|
77
92
|
}>;
|
|
78
93
|
inputs: {};
|
|
79
94
|
params: {
|
|
80
95
|
loader: () => Promise<JSX.Element>;
|
|
81
|
-
filter?:
|
|
96
|
+
filter?: _backstage_plugin_catalog_react_alpha.EntityPredicate | ((entity: _backstage_catalog_model.Entity) => boolean) | undefined;
|
|
97
|
+
type?: _backstage_plugin_catalog_react_alpha.EntityCardType | undefined;
|
|
82
98
|
};
|
|
83
99
|
}>;
|
|
84
100
|
}>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { Progress, Table, Link, StatusAborted, StatusError, StatusWarning, StatusPending, StatusOK } from '@backstage/core-components';
|
|
3
3
|
import { useEntity, MissingAnnotationEmptyState } from '@backstage/plugin-catalog-react';
|
|
4
4
|
import { useApi, configApiRef } from '@backstage/core-plugin-api';
|
|
@@ -12,26 +12,26 @@ const AlertStatusBadge = ({ alert }) => {
|
|
|
12
12
|
switch (alert.state) {
|
|
13
13
|
case "ok":
|
|
14
14
|
case "Normal":
|
|
15
|
-
statusElmt = /* @__PURE__ */
|
|
15
|
+
statusElmt = /* @__PURE__ */ jsx(StatusOK, {});
|
|
16
16
|
break;
|
|
17
17
|
case "paused":
|
|
18
18
|
case "Pending":
|
|
19
|
-
statusElmt = /* @__PURE__ */
|
|
19
|
+
statusElmt = /* @__PURE__ */ jsx(StatusPending, {});
|
|
20
20
|
break;
|
|
21
21
|
case "no_data":
|
|
22
22
|
case "pending":
|
|
23
23
|
case "NoData":
|
|
24
|
-
statusElmt = /* @__PURE__ */
|
|
24
|
+
statusElmt = /* @__PURE__ */ jsx(StatusWarning, {});
|
|
25
25
|
break;
|
|
26
26
|
case "alerting":
|
|
27
27
|
case "Alerting":
|
|
28
28
|
case "Error":
|
|
29
|
-
statusElmt = /* @__PURE__ */
|
|
29
|
+
statusElmt = /* @__PURE__ */ jsx(StatusError, {});
|
|
30
30
|
break;
|
|
31
31
|
default:
|
|
32
|
-
statusElmt = /* @__PURE__ */
|
|
32
|
+
statusElmt = /* @__PURE__ */ jsx(StatusAborted, {});
|
|
33
33
|
}
|
|
34
|
-
return /* @__PURE__ */
|
|
34
|
+
return /* @__PURE__ */ jsx("div", { children: statusElmt });
|
|
35
35
|
};
|
|
36
36
|
const AlertsTable = ({
|
|
37
37
|
alerts,
|
|
@@ -42,16 +42,16 @@ const AlertsTable = ({
|
|
|
42
42
|
title: "Name",
|
|
43
43
|
field: "name",
|
|
44
44
|
cellStyle: { width: "90%" },
|
|
45
|
-
render: (row) => /* @__PURE__ */
|
|
45
|
+
render: (row) => /* @__PURE__ */ jsx(Link, { to: row.url, target: "_blank", rel: "noopener", children: row.name })
|
|
46
46
|
}
|
|
47
47
|
];
|
|
48
48
|
if (opts.showState) {
|
|
49
49
|
columns.push({
|
|
50
50
|
title: "State",
|
|
51
|
-
render: (row) => /* @__PURE__ */
|
|
51
|
+
render: (row) => /* @__PURE__ */ jsx(AlertStatusBadge, { alert: row })
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
-
return /* @__PURE__ */
|
|
54
|
+
return /* @__PURE__ */ jsx(
|
|
55
55
|
Table,
|
|
56
56
|
{
|
|
57
57
|
title: opts.title || "Alerts",
|
|
@@ -78,18 +78,18 @@ const Alerts = ({ entity, opts }) => {
|
|
|
78
78
|
async () => await grafanaApi.alertsForSelector(alertSelector)
|
|
79
79
|
);
|
|
80
80
|
if (loading) {
|
|
81
|
-
return /* @__PURE__ */
|
|
81
|
+
return /* @__PURE__ */ jsx(Progress, {});
|
|
82
82
|
} else if (error) {
|
|
83
|
-
return /* @__PURE__ */
|
|
83
|
+
return /* @__PURE__ */ jsx(Alert, { severity: "error", children: error.message });
|
|
84
84
|
}
|
|
85
|
-
return /* @__PURE__ */
|
|
85
|
+
return /* @__PURE__ */ jsx(AlertsTable, { alerts: value || [], opts });
|
|
86
86
|
};
|
|
87
87
|
const AlertsCard = (opts) => {
|
|
88
88
|
const { entity } = useEntity();
|
|
89
89
|
const configApi = useApi(configApiRef);
|
|
90
90
|
const unifiedAlertingEnabled = configApi.getOptionalBoolean("grafana.unifiedAlerting") || false;
|
|
91
91
|
if (!unifiedAlertingEnabled && !isDashboardSelectorAvailable(entity)) {
|
|
92
|
-
return /* @__PURE__ */
|
|
92
|
+
return /* @__PURE__ */ jsx(
|
|
93
93
|
MissingAnnotationEmptyState,
|
|
94
94
|
{
|
|
95
95
|
annotation: GRAFANA_ANNOTATION_TAG_SELECTOR
|
|
@@ -97,7 +97,7 @@ const AlertsCard = (opts) => {
|
|
|
97
97
|
);
|
|
98
98
|
}
|
|
99
99
|
if (unifiedAlertingEnabled && !isAlertSelectorAvailable(entity)) {
|
|
100
|
-
return /* @__PURE__ */
|
|
100
|
+
return /* @__PURE__ */ jsx(
|
|
101
101
|
MissingAnnotationEmptyState,
|
|
102
102
|
{
|
|
103
103
|
annotation: GRAFANA_ANNOTATION_ALERT_LABEL_SELECTOR
|
|
@@ -105,7 +105,7 @@ const AlertsCard = (opts) => {
|
|
|
105
105
|
);
|
|
106
106
|
}
|
|
107
107
|
const finalOpts = { ...opts, ...{ showState: opts?.showState } };
|
|
108
|
-
return /* @__PURE__ */
|
|
108
|
+
return /* @__PURE__ */ jsx(Alerts, { entity, opts: finalOpts });
|
|
109
109
|
};
|
|
110
110
|
|
|
111
111
|
export { AlertsCard, AlertsTable };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlertsCard.esm.js","sources":["../../../src/components/AlertsCard/AlertsCard.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport
|
|
1
|
+
{"version":3,"file":"AlertsCard.esm.js","sources":["../../../src/components/AlertsCard/AlertsCard.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ReactElement, ReactNode } from 'react';\nimport {\n Progress,\n TableColumn,\n Table,\n StatusOK,\n StatusPending,\n StatusWarning,\n StatusError,\n StatusAborted,\n Link,\n} from '@backstage/core-components';\nimport { Entity } from '@backstage/catalog-model';\nimport {\n MissingAnnotationEmptyState,\n useEntity,\n} from '@backstage/plugin-catalog-react';\nimport { configApiRef, useApi } from '@backstage/core-plugin-api';\nimport { grafanaApiRef } from '../../api';\nimport useAsync from 'react-use/lib/useAsync';\nimport { Alert } from '@material-ui/lab';\nimport { AlertsCardOpts, Alert as GrafanaAlert } from '../../types';\nimport {\n GRAFANA_ANNOTATION_TAG_SELECTOR,\n GRAFANA_ANNOTATION_ALERT_LABEL_SELECTOR,\n isAlertSelectorAvailable,\n isDashboardSelectorAvailable,\n tagSelectorFromEntity,\n alertSelectorFromEntity,\n} from '../../constants';\n\nconst AlertStatusBadge = ({ alert }: { alert: GrafanaAlert }) => {\n let statusElmt: ReactElement;\n\n switch (alert.state) {\n case 'ok':\n case 'Normal':\n statusElmt = <StatusOK />;\n break;\n case 'paused':\n case 'Pending':\n statusElmt = <StatusPending />;\n break;\n case 'no_data':\n case 'pending':\n case 'NoData':\n statusElmt = <StatusWarning />;\n break;\n case 'alerting':\n case 'Alerting':\n case 'Error':\n statusElmt = <StatusError />;\n break;\n default:\n statusElmt = <StatusAborted />;\n }\n\n return <div>{statusElmt}</div>;\n};\n\nexport const AlertsTable = ({\n alerts,\n opts,\n}: {\n alerts: GrafanaAlert[];\n opts: AlertsCardOpts;\n}) => {\n const columns: TableColumn<GrafanaAlert>[] = [\n {\n title: 'Name',\n field: 'name',\n cellStyle: { width: '90%' },\n render: (row: GrafanaAlert): ReactNode => (\n <Link to={row.url} target=\"_blank\" rel=\"noopener\">\n {row.name}\n </Link>\n ),\n },\n ];\n\n if (opts.showState) {\n columns.push({\n title: 'State',\n render: (row: GrafanaAlert): ReactNode => (\n <AlertStatusBadge alert={row} />\n ),\n });\n }\n\n return (\n <Table\n title={opts.title || 'Alerts'}\n options={{\n paging: opts.paged ?? false,\n pageSize: opts.pageSize ?? 5,\n search: opts.searchable ?? false,\n emptyRowsWhenPaging: false,\n sorting: opts.sortable ?? false,\n draggable: false,\n padding: 'dense',\n }}\n data={alerts}\n columns={columns}\n />\n );\n};\n\nconst Alerts = ({ entity, opts }: { entity: Entity; opts: AlertsCardOpts }) => {\n const grafanaApi = useApi(grafanaApiRef);\n const configApi = useApi(configApiRef);\n const unifiedAlertingEnabled =\n configApi.getOptionalBoolean('grafana.unifiedAlerting') || false;\n const alertSelector = unifiedAlertingEnabled\n ? alertSelectorFromEntity(entity)\n : tagSelectorFromEntity(entity);\n\n const { value, loading, error } = useAsync(\n async () => await grafanaApi.alertsForSelector(alertSelector),\n );\n\n if (loading) {\n return <Progress />;\n } else if (error) {\n return <Alert severity=\"error\">{error.message}</Alert>;\n }\n\n return <AlertsTable alerts={value || []} opts={opts} />;\n};\n\nexport const AlertsCard = (opts?: AlertsCardOpts) => {\n const { entity } = useEntity();\n const configApi = useApi(configApiRef);\n const unifiedAlertingEnabled =\n configApi.getOptionalBoolean('grafana.unifiedAlerting') || false;\n\n if (!unifiedAlertingEnabled && !isDashboardSelectorAvailable(entity)) {\n return (\n <MissingAnnotationEmptyState\n annotation={GRAFANA_ANNOTATION_TAG_SELECTOR}\n />\n );\n }\n\n if (unifiedAlertingEnabled && !isAlertSelectorAvailable(entity)) {\n return (\n <MissingAnnotationEmptyState\n annotation={GRAFANA_ANNOTATION_ALERT_LABEL_SELECTOR}\n />\n );\n }\n\n const finalOpts = { ...opts, ...{ showState: opts?.showState } };\n\n return <Alerts entity={entity} opts={finalOpts} />;\n};\n"],"names":[],"mappings":";;;;;;;;;AA+CA,MAAM,gBAAmB,GAAA,CAAC,EAAE,KAAA,EAAqC,KAAA;AAC/D,EAAI,IAAA,UAAA;AAEJ,EAAA,QAAQ,MAAM,KAAO;AAAA,IACnB,KAAK,IAAA;AAAA,IACL,KAAK,QAAA;AACH,MAAA,UAAA,uBAAc,QAAS,EAAA,EAAA,CAAA;AACvB,MAAA;AAAA,IACF,KAAK,QAAA;AAAA,IACL,KAAK,SAAA;AACH,MAAA,UAAA,uBAAc,aAAc,EAAA,EAAA,CAAA;AAC5B,MAAA;AAAA,IACF,KAAK,SAAA;AAAA,IACL,KAAK,SAAA;AAAA,IACL,KAAK,QAAA;AACH,MAAA,UAAA,uBAAc,aAAc,EAAA,EAAA,CAAA;AAC5B,MAAA;AAAA,IACF,KAAK,UAAA;AAAA,IACL,KAAK,UAAA;AAAA,IACL,KAAK,OAAA;AACH,MAAA,UAAA,uBAAc,WAAY,EAAA,EAAA,CAAA;AAC1B,MAAA;AAAA,IACF;AACE,MAAA,UAAA,uBAAc,aAAc,EAAA,EAAA,CAAA;AAAA;AAGhC,EAAO,uBAAA,GAAA,CAAC,SAAK,QAAW,EAAA,UAAA,EAAA,CAAA;AAC1B,CAAA;AAEO,MAAM,cAAc,CAAC;AAAA,EAC1B,MAAA;AAAA,EACA;AACF,CAGM,KAAA;AACJ,EAAA,MAAM,OAAuC,GAAA;AAAA,IAC3C;AAAA,MACE,KAAO,EAAA,MAAA;AAAA,MACP,KAAO,EAAA,MAAA;AAAA,MACP,SAAA,EAAW,EAAE,KAAA,EAAO,KAAM,EAAA;AAAA,MAC1B,MAAQ,EAAA,CAAC,GACP,qBAAA,GAAA,CAAC,IAAK,EAAA,EAAA,EAAA,EAAI,GAAI,CAAA,GAAA,EAAK,MAAO,EAAA,QAAA,EAAS,GAAI,EAAA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og-react';
|
|
3
3
|
import { isOverviewDashboardAvailable, GRAFANA_ANNOTATION_OVERVIEW_DASHBOARD, overviewDashboardFromEntity } from '../../constants.esm.js';
|
|
4
4
|
|
|
5
5
|
const DashboardViewer = ({ embedUrl }) => {
|
|
6
|
-
return /* @__PURE__ */
|
|
6
|
+
return /* @__PURE__ */ jsx(
|
|
7
7
|
"iframe",
|
|
8
8
|
{
|
|
9
9
|
title: embedUrl,
|
|
@@ -17,14 +17,14 @@ const DashboardViewer = ({ embedUrl }) => {
|
|
|
17
17
|
const EntityDashboardViewer = () => {
|
|
18
18
|
const { entity } = useEntity();
|
|
19
19
|
if (!isOverviewDashboardAvailable(entity)) {
|
|
20
|
-
return /* @__PURE__ */
|
|
20
|
+
return /* @__PURE__ */ jsx(
|
|
21
21
|
MissingAnnotationEmptyState,
|
|
22
22
|
{
|
|
23
23
|
annotation: GRAFANA_ANNOTATION_OVERVIEW_DASHBOARD
|
|
24
24
|
}
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
|
-
return /* @__PURE__ */
|
|
27
|
+
return /* @__PURE__ */ jsx(DashboardViewer, { embedUrl: overviewDashboardFromEntity(entity) });
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
export { DashboardViewer, EntityDashboardViewer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardViewer.esm.js","sources":["../../../src/components/DashboardViewer/DashboardViewer.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport
|
|
1
|
+
{"version":3,"file":"DashboardViewer.esm.js","sources":["../../../src/components/DashboardViewer/DashboardViewer.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n MissingAnnotationEmptyState,\n useEntity,\n} from '@backstage/plugin-catalog-react';\nimport {\n GRAFANA_ANNOTATION_OVERVIEW_DASHBOARD,\n isOverviewDashboardAvailable,\n overviewDashboardFromEntity,\n} from '../../constants';\n\n/**\n * Component which embeds the defined URL contents\n * @public\n */\nexport const DashboardViewer = ({ embedUrl }: { embedUrl: string }) => {\n return (\n <iframe\n title={embedUrl}\n src={embedUrl}\n width=\"100%\"\n height=\"100%\"\n referrerPolicy=\"strict-origin-when-cross-origin\"\n />\n );\n};\n\n/**\n * Component which embeds the dashboard overview for an entity\n * @public\n */\nexport const EntityDashboardViewer = () => {\n const { entity } = useEntity();\n\n if (!isOverviewDashboardAvailable(entity)) {\n return (\n <MissingAnnotationEmptyState\n annotation={GRAFANA_ANNOTATION_OVERVIEW_DASHBOARD}\n />\n );\n }\n\n return <DashboardViewer embedUrl={overviewDashboardFromEntity(entity)} />;\n};\n"],"names":[],"mappings":";;;;AA8BO,MAAM,eAAkB,GAAA,CAAC,EAAE,QAAA,EAAqC,KAAA;AACrE,EACE,uBAAA,GAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,KAAO,EAAA,QAAA;AAAA,MACP,GAAK,EAAA,QAAA;AAAA,MACL,KAAM,EAAA,MAAA;AAAA,MACN,MAAO,EAAA,MAAA;AAAA,MACP,cAAe,EAAA;AAAA;AAAA,GACjB;AAEJ;AAMO,MAAM,wBAAwB,MAAM;AACzC,EAAM,MAAA,EAAE,MAAO,EAAA,GAAI,SAAU,EAAA;AAE7B,EAAI,IAAA,CAAC,4BAA6B,CAAA,MAAM,CAAG,EAAA;AACzC,IACE,uBAAA,GAAA;AAAA,MAAC,2BAAA;AAAA,MAAA;AAAA,QACC,UAAY,EAAA;AAAA;AAAA,KACd;AAAA;AAIJ,EAAA,uBAAQ,GAAA,CAAA,eAAA,EAAA,EAAgB,QAAU,EAAA,2BAAA,CAA4B,MAAM,CAAG,EAAA,CAAA;AACzE;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { Progress, Table, Link } from '@backstage/core-components';
|
|
3
3
|
import { useEntity, MissingAnnotationEmptyState } from '@backstage/plugin-catalog-react';
|
|
4
4
|
import { useApi } from '@backstage/core-plugin-api';
|
|
@@ -18,24 +18,24 @@ const DashboardsTable = ({
|
|
|
18
18
|
{
|
|
19
19
|
title: "Title",
|
|
20
20
|
field: "title",
|
|
21
|
-
render: (row) => /* @__PURE__ */
|
|
21
|
+
render: (row) => /* @__PURE__ */ jsx(Link, { to: row.url, target: "_blank", rel: "noopener", children: row.title })
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
24
|
title: "Folder",
|
|
25
25
|
field: "folderTitle",
|
|
26
|
-
render: (row) => /* @__PURE__ */
|
|
26
|
+
render: (row) => /* @__PURE__ */ jsx(Link, { to: row.folderUrl, target: "_blank", rel: "noopener", children: row.folderTitle })
|
|
27
27
|
}
|
|
28
28
|
];
|
|
29
|
-
const titleElm = /* @__PURE__ */
|
|
29
|
+
const titleElm = /* @__PURE__ */ jsx(
|
|
30
30
|
Tooltip,
|
|
31
31
|
{
|
|
32
32
|
title: `Note: only dashboard with the "${dashboardSelectorFromEntity(
|
|
33
33
|
entity
|
|
34
|
-
)}" selector are displayed
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
)}" selector are displayed.`,
|
|
35
|
+
children: /* @__PURE__ */ jsx(Typography, { children: opts.title || "Dashboards" })
|
|
36
|
+
}
|
|
37
37
|
);
|
|
38
|
-
return /* @__PURE__ */
|
|
38
|
+
return /* @__PURE__ */ jsx(
|
|
39
39
|
Table,
|
|
40
40
|
{
|
|
41
41
|
title: titleElm,
|
|
@@ -68,20 +68,20 @@ const Dashboards = ({
|
|
|
68
68
|
return dashboards;
|
|
69
69
|
});
|
|
70
70
|
if (loading) {
|
|
71
|
-
return /* @__PURE__ */
|
|
71
|
+
return /* @__PURE__ */ jsx(Progress, {});
|
|
72
72
|
} else if (error) {
|
|
73
|
-
return /* @__PURE__ */
|
|
73
|
+
return /* @__PURE__ */ jsx(Alert, { severity: "error", children: error.message });
|
|
74
74
|
}
|
|
75
|
-
return /* @__PURE__ */
|
|
75
|
+
return /* @__PURE__ */ jsx(DashboardsTable, { entity, dashboards: value || [], opts });
|
|
76
76
|
};
|
|
77
77
|
const DashboardsCard = (opts) => {
|
|
78
78
|
const { entity } = useEntity();
|
|
79
|
-
return !isDashboardSelectorAvailable(entity) ? /* @__PURE__ */
|
|
79
|
+
return !isDashboardSelectorAvailable(entity) ? /* @__PURE__ */ jsx(
|
|
80
80
|
MissingAnnotationEmptyState,
|
|
81
81
|
{
|
|
82
82
|
annotation: GRAFANA_ANNOTATION_DASHBOARD_SELECTOR
|
|
83
83
|
}
|
|
84
|
-
) : /* @__PURE__ */
|
|
84
|
+
) : /* @__PURE__ */ jsx(Dashboards, { entity, opts: opts || {} });
|
|
85
85
|
};
|
|
86
86
|
|
|
87
87
|
export { DashboardsCard, DashboardsTable };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardsCard.esm.js","sources":["../../../src/components/DashboardsCard/DashboardsCard.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport
|
|
1
|
+
{"version":3,"file":"DashboardsCard.esm.js","sources":["../../../src/components/DashboardsCard/DashboardsCard.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Progress, TableColumn, Table, Link } from '@backstage/core-components';\nimport { Entity } from '@backstage/catalog-model';\nimport {\n MissingAnnotationEmptyState,\n useEntity,\n} from '@backstage/plugin-catalog-react';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { grafanaApiRef } from '../../api';\nimport useAsync from 'react-use/lib/useAsync';\nimport Alert from '@material-ui/lab/Alert';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport Typography from '@material-ui/core/Typography';\nimport { Dashboard, DashboardCardOpts } from '../../types';\nimport {\n dashboardSelectorFromEntity,\n GRAFANA_ANNOTATION_DASHBOARD_SELECTOR,\n isDashboardSelectorAvailable,\n} from '../../constants';\n\nexport const DashboardsTable = ({\n entity,\n dashboards,\n opts,\n}: {\n entity: Entity;\n dashboards: Dashboard[];\n opts: DashboardCardOpts;\n}) => {\n const columns: TableColumn<Dashboard>[] = [\n {\n title: 'Title',\n field: 'title',\n render: (row: Dashboard) => (\n <Link to={row.url} target=\"_blank\" rel=\"noopener\">\n {row.title}\n </Link>\n ),\n },\n {\n title: 'Folder',\n field: 'folderTitle',\n render: (row: Dashboard) => (\n <Link to={row.folderUrl} target=\"_blank\" rel=\"noopener\">\n {row.folderTitle}\n </Link>\n ),\n },\n ];\n\n const titleElm = (\n <Tooltip\n title={`Note: only dashboard with the \"${dashboardSelectorFromEntity(\n entity,\n )}\" selector are displayed.`}\n >\n <Typography>{opts.title || 'Dashboards'}</Typography>\n </Tooltip>\n );\n\n return (\n <Table\n title={titleElm}\n options={{\n paging: opts.paged ?? false,\n pageSize: opts.pageSize ?? 5,\n search: opts.searchable ?? false,\n emptyRowsWhenPaging: false,\n sorting: opts.sortable ?? false,\n draggable: false,\n padding: 'dense',\n }}\n data={dashboards}\n columns={columns}\n />\n );\n};\n\nconst Dashboards = ({\n entity,\n opts,\n}: {\n entity: Entity;\n opts: DashboardCardOpts;\n}) => {\n const grafanaApi = useApi(grafanaApiRef);\n const { value, loading, error } = useAsync(async () => {\n const dashboards = await grafanaApi.listDashboards(\n dashboardSelectorFromEntity(entity),\n );\n if (opts?.additionalDashboards) {\n dashboards.push(...opts.additionalDashboards(entity));\n }\n return dashboards;\n });\n\n if (loading) {\n return <Progress />;\n } else if (error) {\n return <Alert severity=\"error\">{error.message}</Alert>;\n }\n\n return (\n <DashboardsTable entity={entity} dashboards={value || []} opts={opts} />\n );\n};\n\nexport const DashboardsCard = (opts?: DashboardCardOpts) => {\n const { entity } = useEntity();\n\n return !isDashboardSelectorAvailable(entity) ? (\n <MissingAnnotationEmptyState\n annotation={GRAFANA_ANNOTATION_DASHBOARD_SELECTOR}\n />\n ) : (\n <Dashboards entity={entity} opts={opts || {}} />\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAmCO,MAAM,kBAAkB,CAAC;AAAA,EAC9B,MAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF,CAIM,KAAA;AACJ,EAAA,MAAM,OAAoC,GAAA;AAAA,IACxC;AAAA,MACE,KAAO,EAAA,OAAA;AAAA,MACP,KAAO,EAAA,OAAA;AAAA,MACP,MAAQ,EAAA,CAAC,GACP,qBAAA,GAAA,CAAC,IAAK,EAAA,E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AAA;AACvC,EAAA,MAAM,EAAE,KAAO,EAAA,OAAA,EAAS,KAAM,EAAA,GAAI,SAAS,YAAY;AACrD,IAAM,MAAA,UAAA,GAAa,MAAM,UAAW,CAAA,cAAA;AAAA,MAClC,4BAA4B,MAAM;AAAA,KACpC;AACA,IAAA,IAAI,MAAM,oBAAsB,EAAA;AAC9B,MAAA,UAAA,CAAW,IAAK,CAAA,GAAG,IAAK,CAAA,oBAAA,CAAqB,MAAM,CAAC,CAAA;AAAA;AAEtD,IAAO,OAAA,UAAA;AAAA,GACR,CAAA;AAED,EAAA,IAAI,OAAS,EAAA;AACX,IAAA,2BAAQ,QAAS,EAAA,EAAA,CAAA;AAAA,aACR,KAAO,EAAA;AAChB,IAAA,uBAAQ,GAAA,CAAA,KAAA,EAAA,EAAM,QAAS,EAAA,OAAA,EAAS,gBAAM,OAAQ,EAAA,CAAA;AAAA;AAGhD,EAAA,2BACG,eAAgB,EAAA,EAAA,MAAA,EAAgB,YAAY,KAAS,IAAA,IAAI,IAAY,EAAA,CAAA;AAE1E,CAAA;AAEa,MAAA,cAAA,GAAiB,CAAC,IAA6B,KAAA;AAC1D,EAAM,MAAA,EAAE,MAAO,EAAA,GAAI,SAAU,EAAA;AAE7B,EAAO,OAAA,CAAC,4BAA6B,CAAA,MAAM,CACzC,mBAAA,GAAA;AAAA,IAAC,2BAAA;AAAA,IAAA;AAAA,MACC,UAAY,EAAA;AAAA;AAAA,sBAGb,GAAA,CAAA,UAAA,EAAA,EAAW,QAAgB,IAAM,EAAA,IAAA,IAAQ,EAAI,EAAA,CAAA;AAElD;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import * as react from 'react';
|
|
3
|
-
import react__default from 'react';
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
2
|
import { Entity } from '@backstage/catalog-model';
|
|
5
3
|
import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
|
|
6
|
-
import * as _backstage_core_plugin_api_index from '@backstage/core-plugin-api/index';
|
|
7
4
|
|
|
8
5
|
/**
|
|
9
6
|
* Component which embeds the defined URL contents
|
|
@@ -11,12 +8,12 @@ import * as _backstage_core_plugin_api_index from '@backstage/core-plugin-api/in
|
|
|
11
8
|
*/
|
|
12
9
|
declare const DashboardViewer: ({ embedUrl }: {
|
|
13
10
|
embedUrl: string;
|
|
14
|
-
}) =>
|
|
11
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
15
12
|
/**
|
|
16
13
|
* Component which embeds the dashboard overview for an entity
|
|
17
14
|
* @public
|
|
18
15
|
*/
|
|
19
|
-
declare const EntityDashboardViewer: () =>
|
|
16
|
+
declare const EntityDashboardViewer: () => react_jsx_runtime.JSX.Element;
|
|
20
17
|
|
|
21
18
|
/**
|
|
22
19
|
* Grafana daashboard parameters
|
|
@@ -109,17 +106,17 @@ declare const grafanaPlugin: _backstage_core_plugin_api.BackstagePlugin<{}, {},
|
|
|
109
106
|
* Component which displays the grafana dashboards found for an entity
|
|
110
107
|
* @public
|
|
111
108
|
*/
|
|
112
|
-
declare const EntityGrafanaDashboardsCard: (opts?: DashboardCardOpts | undefined) =>
|
|
109
|
+
declare const EntityGrafanaDashboardsCard: (opts?: DashboardCardOpts | undefined) => react_jsx_runtime.JSX.Element;
|
|
113
110
|
/**
|
|
114
111
|
* Component which displays the grafana alerts found for an entity
|
|
115
112
|
* @public
|
|
116
113
|
*/
|
|
117
|
-
declare const EntityGrafanaAlertsCard: (opts?: AlertsCardOpts | undefined) =>
|
|
114
|
+
declare const EntityGrafanaAlertsCard: (opts?: AlertsCardOpts | undefined) => react_jsx_runtime.JSX.Element;
|
|
118
115
|
/**
|
|
119
116
|
* Component which displays the defined grafana dashboard for an entity
|
|
120
117
|
* @public
|
|
121
118
|
*/
|
|
122
|
-
declare const EntityOverviewDashboardViewer: () =>
|
|
119
|
+
declare const EntityOverviewDashboardViewer: () => react_jsx_runtime.JSX.Element;
|
|
123
120
|
|
|
124
121
|
/**
|
|
125
122
|
* Grafana tag selector annotation
|
|
@@ -199,6 +196,6 @@ interface GrafanaApi {
|
|
|
199
196
|
* The grafana API reference
|
|
200
197
|
* @public
|
|
201
198
|
*/
|
|
202
|
-
declare const grafanaApiRef:
|
|
199
|
+
declare const grafanaApiRef: _backstage_core_plugin_api.ApiRef<GrafanaApi>;
|
|
203
200
|
|
|
204
201
|
export { type Alert, type AlertsCardOpts, type Dashboard, type DashboardCardOpts, DashboardViewer, EntityDashboardViewer, EntityGrafanaAlertsCard, EntityGrafanaDashboardsCard, EntityOverviewDashboardViewer, GRAFANA_ANNOTATION_ALERT_LABEL_SELECTOR, GRAFANA_ANNOTATION_DASHBOARD_SELECTOR, GRAFANA_ANNOTATION_OVERVIEW_DASHBOARD, GRAFANA_ANNOTATION_TAG_SELECTOR, type GrafanaApi, alertSelectorFromEntity, dashboardSelectorFromEntity, grafanaApiRef, grafanaPlugin, isAlertSelectorAvailable, isDashboardSelectorAvailable, isOverviewDashboardAvailable, overviewDashboardFromEntity, tagSelectorFromEntity };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage-community/plugin-grafana",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "A Backstage backend plugin that integrates towards Grafana",
|
|
5
5
|
"main": "./dist/index.esm.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
},
|
|
44
44
|
"typesVersions": {
|
|
45
45
|
"*": {
|
|
46
|
-
"index": [
|
|
47
|
-
"dist/index.d.ts"
|
|
48
|
-
],
|
|
49
46
|
"alpha": [
|
|
50
47
|
"dist/alpha.d.ts"
|
|
48
|
+
],
|
|
49
|
+
"package.json": [
|
|
50
|
+
"package.json"
|
|
51
51
|
]
|
|
52
52
|
}
|
|
53
53
|
},
|
|
@@ -62,11 +62,11 @@
|
|
|
62
62
|
"postpack": "backstage-cli package postpack"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@backstage/catalog-model": "^1.7.
|
|
66
|
-
"@backstage/core-components": "^0.
|
|
67
|
-
"@backstage/core-plugin-api": "^1.10.
|
|
68
|
-
"@backstage/frontend-plugin-api": "^0.
|
|
69
|
-
"@backstage/plugin-catalog-react": "^1.
|
|
65
|
+
"@backstage/catalog-model": "^1.7.4",
|
|
66
|
+
"@backstage/core-components": "^0.17.2",
|
|
67
|
+
"@backstage/core-plugin-api": "^1.10.7",
|
|
68
|
+
"@backstage/frontend-plugin-api": "^0.10.2",
|
|
69
|
+
"@backstage/plugin-catalog-react": "^1.18.0",
|
|
70
70
|
"@material-ui/core": "^4.12.2",
|
|
71
71
|
"@material-ui/lab": "4.0.0-alpha.61",
|
|
72
72
|
"cross-fetch": "^4.0.0",
|
|
@@ -79,11 +79,11 @@
|
|
|
79
79
|
"react-router-dom": "6.0.0-beta.0 || ^6.3.0"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@backstage/cli": "^0.
|
|
83
|
-
"@backstage/core-app-api": "^1.
|
|
84
|
-
"@backstage/dev-utils": "^1.1.
|
|
85
|
-
"@backstage/frontend-test-utils": "^0.2
|
|
86
|
-
"@backstage/test-utils": "^1.7.
|
|
82
|
+
"@backstage/cli": "^0.32.1",
|
|
83
|
+
"@backstage/core-app-api": "^1.17.0",
|
|
84
|
+
"@backstage/dev-utils": "^1.1.10",
|
|
85
|
+
"@backstage/frontend-test-utils": "^0.3.2",
|
|
86
|
+
"@backstage/test-utils": "^1.7.8",
|
|
87
87
|
"@testing-library/dom": "^10.0.0",
|
|
88
88
|
"@testing-library/jest-dom": "^6.0.0",
|
|
89
89
|
"@testing-library/react": "^15.0.0",
|