@backstage-community/plugin-splunk-on-call 0.20.0 → 0.21.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @backstage-community/plugin-splunk-on-call
2
2
 
3
+ ## 0.21.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 333f1ce: Backstage version bump to v1.49.2
8
+
3
9
  ## 0.20.0
4
10
 
5
11
  ### Minor Changes
package/dist/alpha.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import * as _backstage_plugin_catalog_react_alpha from '@backstage/plugin-catalog-react/alpha';
3
2
  import * as _backstage_catalog_model from '@backstage/catalog-model';
4
3
  import * as react from 'react';
@@ -18,9 +17,7 @@ declare const _default: _backstage_frontend_plugin_api.OverridableFrontendPlugin
18
17
  configInput: {};
19
18
  output: _backstage_frontend_plugin_api.ExtensionDataRef<_backstage_frontend_plugin_api.AnyApiFactory, "core.api.factory", {}>;
20
19
  inputs: {};
21
- params: <TApi, TImpl extends TApi, TDeps extends {
22
- [x: string]: unknown;
23
- }>(params: _backstage_frontend_plugin_api.ApiFactory<TApi, TImpl, TDeps>) => _backstage_frontend_plugin_api.ExtensionBlueprintParams<_backstage_frontend_plugin_api.AnyApiFactory>;
20
+ params: <TApi, TImpl extends TApi, TDeps extends { [name in string]: unknown; }>(params: _backstage_frontend_plugin_api.ApiFactory<TApi, TImpl, TDeps>) => _backstage_frontend_plugin_api.ExtensionBlueprintParams<_backstage_frontend_plugin_api.AnyApiFactory>;
24
21
  }>;
25
22
  "entity-card:splunk-on-call/splunk-on-call": _backstage_frontend_plugin_api.OverridableExtensionDefinition<{
26
23
  kind: "entity-card";
@@ -43,8 +40,8 @@ declare const _default: _backstage_frontend_plugin_api.OverridableFrontendPlugin
43
40
  inputs: {};
44
41
  params: {
45
42
  loader: () => Promise<JSX.Element>;
46
- filter?: _backstage_filter_predicates.FilterPredicate | ((entity: _backstage_catalog_model.Entity) => boolean) | undefined;
47
- type?: _backstage_plugin_catalog_react_alpha.EntityCardType | undefined;
43
+ filter?: string | _backstage_filter_predicates.FilterPredicate | ((entity: _backstage_catalog_model.Entity) => boolean);
44
+ type?: _backstage_plugin_catalog_react_alpha.EntityCardType;
48
45
  };
49
46
  }>;
50
47
  "page:splunk-on-call": _backstage_frontend_plugin_api.OverridableExtensionDefinition<{
@@ -79,13 +76,12 @@ declare const _default: _backstage_frontend_plugin_api.OverridableFrontendPlugin
79
76
  }>;
80
77
  };
81
78
  params: {
82
- defaultPath?: [Error: "Use the 'path' param instead"] | undefined;
83
79
  path: string;
84
- title?: string | undefined;
85
- icon?: _backstage_frontend_plugin_api.IconElement | undefined;
86
- loader?: (() => Promise<react.JSX.Element>) | undefined;
87
- routeRef?: _backstage_frontend_plugin_api.RouteRef<_backstage_frontend_plugin_api.AnyRouteRefParams> | undefined;
88
- noHeader?: boolean | undefined;
80
+ title?: string;
81
+ icon?: _backstage_frontend_plugin_api.IconElement;
82
+ loader?: () => Promise<react.JSX.Element>;
83
+ routeRef?: _backstage_frontend_plugin_api.RouteRef;
84
+ noHeader?: boolean;
89
85
  };
90
86
  }>;
91
87
  }>;
@@ -15,7 +15,8 @@ import OpenInBrowserIcon from '@material-ui/icons/OpenInBrowser';
15
15
  import { splunkOnCallApiRef } from '../../api/client.esm.js';
16
16
  import useAsyncFn from 'react-use/esm/useAsyncFn';
17
17
  import { StatusOK, StatusWarning, StatusError } from '@backstage/core-components';
18
- import { useApi, alertApiRef } from '@backstage/core-plugin-api';
18
+ import { useApi } from '@backstage/core-plugin-api';
19
+ import { toastApiRef } from '@backstage/frontend-plugin-api';
19
20
 
20
21
  const useStyles = makeStyles({
21
22
  denseListIcon: {
@@ -93,7 +94,7 @@ const IncidentListItem = ({
93
94
  const classes = useStyles();
94
95
  const duration = (/* @__PURE__ */ new Date()).getTime() - new Date(incident.startTime).getTime();
95
96
  const createdAt = DateTime.local().minus(Duration.fromMillis(duration)).toRelative({ locale: "en" });
96
- const alertApi = useApi(alertApiRef);
97
+ const toastApi = useApi(toastApiRef);
97
98
  const api = useApi(splunkOnCallApiRef);
98
99
  const hasBeenManuallyTriggered = incident.monitorName?.includes("vouser-");
99
100
  const source = () => {
@@ -124,29 +125,29 @@ const IncidentListItem = ({
124
125
  );
125
126
  useEffect(() => {
126
127
  if (acknowledgeValue) {
127
- alertApi.post({
128
- message: `Incident successfully acknowledged`
128
+ toastApi.post({
129
+ title: `Incident successfully acknowledged`
129
130
  });
130
131
  }
131
132
  if (resolveValue) {
132
- alertApi.post({
133
- message: `Incident successfully resolved`
133
+ toastApi.post({
134
+ title: `Incident successfully resolved`
134
135
  });
135
136
  }
136
137
  if (resolveValue || acknowledgeValue) {
137
138
  onIncidentAction();
138
139
  }
139
- }, [acknowledgeValue, resolveValue, alertApi, onIncidentAction]);
140
+ }, [acknowledgeValue, resolveValue, toastApi, onIncidentAction]);
140
141
  if (acknowledgeError) {
141
- alertApi.post({
142
- message: `Failed to acknowledge incident. ${acknowledgeError.message}`,
143
- severity: "error"
142
+ toastApi.post({
143
+ title: `Failed to acknowledge incident. ${acknowledgeError.message}`,
144
+ status: "danger"
144
145
  });
145
146
  }
146
147
  if (resolveError) {
147
- alertApi.post({
148
- message: `Failed to resolve incident. ${resolveError.message}`,
149
- severity: "error"
148
+ toastApi.post({
149
+ title: `Failed to resolve incident. ${resolveError.message}`,
150
+ status: "danger"
150
151
  });
151
152
  }
152
153
  return /* @__PURE__ */ jsxs(ListItem, { dense: true, children: [
@@ -1 +1 @@
1
- {"version":3,"file":"IncidentListItem.esm.js","sources":["../../../src/components/Incident/IncidentListItem.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 { useEffect } from 'react';\nimport ListItem from '@material-ui/core/ListItem';\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\nimport ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport IconButton from '@material-ui/core/IconButton';\nimport Typography from '@material-ui/core/Typography';\nimport { makeStyles } from '@material-ui/core/styles';\nimport DoneIcon from '@material-ui/icons/Done';\nimport DoneAllIcon from '@material-ui/icons/DoneAll';\nimport { DateTime, Duration } from 'luxon';\nimport { Incident, IncidentPhase } from '../types';\nimport OpenInBrowserIcon from '@material-ui/icons/OpenInBrowser';\nimport { splunkOnCallApiRef } from '../../api/client';\nimport useAsyncFn from 'react-use/esm/useAsyncFn';\nimport { TriggerAlarmRequest } from '../../api/types';\n\nimport {\n StatusError,\n StatusWarning,\n StatusOK,\n} from '@backstage/core-components';\nimport { useApi, alertApiRef } from '@backstage/core-plugin-api';\n\nconst useStyles = makeStyles({\n denseListIcon: {\n marginRight: 0,\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n },\n listItemPrimary: {\n fontWeight: 'bold',\n },\n listItemIcon: {\n minWidth: '1em',\n },\n secondaryAction: {\n paddingRight: 48,\n },\n});\n\ntype Props = {\n team: string;\n incident: Incident;\n onIncidentAction: () => void;\n readOnly: boolean;\n};\n\nconst IncidentPhaseStatus = ({\n currentPhase,\n}: {\n currentPhase: IncidentPhase;\n}) => {\n switch (currentPhase) {\n case 'UNACKED':\n return <StatusError />;\n case 'ACKED':\n return <StatusWarning />;\n default:\n return <StatusOK />;\n }\n};\n\nconst incidentPhaseTooltip = (currentPhase: IncidentPhase) => {\n switch (currentPhase) {\n case 'UNACKED':\n return 'Triggered';\n case 'ACKED':\n return 'Acknowledged';\n default:\n return 'Resolved';\n }\n};\n\nconst IncidentAction = ({\n currentPhase,\n incidentId,\n resolveAction,\n acknowledgeAction,\n}: {\n currentPhase: string;\n incidentId: string;\n resolveAction: (args: TriggerAlarmRequest) => void;\n acknowledgeAction: (args: TriggerAlarmRequest) => void;\n}) => {\n switch (currentPhase) {\n case 'UNACKED':\n return (\n <Tooltip title=\"Acknowledge\" placement=\"top\">\n <IconButton\n onClick={() =>\n acknowledgeAction({ incidentId, incidentType: 'ACKNOWLEDGEMENT' })\n }\n >\n <DoneIcon />\n </IconButton>\n </Tooltip>\n );\n case 'ACKED':\n return (\n <Tooltip title=\"Resolve\" placement=\"top\">\n <IconButton\n onClick={() =>\n resolveAction({ incidentId, incidentType: 'RECOVERY' })\n }\n >\n <DoneAllIcon />\n </IconButton>\n </Tooltip>\n );\n default:\n return <></>;\n }\n};\n\nexport const IncidentListItem = ({\n incident,\n readOnly,\n onIncidentAction,\n team,\n}: Props) => {\n const classes = useStyles();\n const duration =\n new Date().getTime() - new Date(incident.startTime!).getTime();\n const createdAt = DateTime.local()\n .minus(Duration.fromMillis(duration))\n .toRelative({ locale: 'en' });\n const alertApi = useApi(alertApiRef);\n const api = useApi(splunkOnCallApiRef);\n\n const hasBeenManuallyTriggered = incident.monitorName?.includes('vouser-');\n\n const source = () => {\n if (hasBeenManuallyTriggered) {\n return incident.monitorName?.replace('vouser-', '');\n }\n if (incident.monitorType === 'API') {\n return '{ REST }';\n }\n\n return incident.monitorName;\n };\n\n const [{ value: resolveValue, error: resolveError }, handleResolveIncident] =\n useAsyncFn(\n async ({ incidentId, incidentType }: TriggerAlarmRequest) =>\n await api.incidentAction({\n routingKey: team,\n incidentType,\n incidentId,\n }),\n );\n\n const [\n { value: acknowledgeValue, error: acknowledgeError },\n handleAcknowledgeIncident,\n ] = useAsyncFn(\n async ({ incidentId, incidentType }: TriggerAlarmRequest) =>\n await api.incidentAction({\n routingKey: team,\n incidentType,\n incidentId,\n }),\n );\n\n useEffect(() => {\n if (acknowledgeValue) {\n alertApi.post({\n message: `Incident successfully acknowledged`,\n });\n }\n\n if (resolveValue) {\n alertApi.post({\n message: `Incident successfully resolved`,\n });\n }\n if (resolveValue || acknowledgeValue) {\n onIncidentAction();\n }\n }, [acknowledgeValue, resolveValue, alertApi, onIncidentAction]);\n\n if (acknowledgeError) {\n alertApi.post({\n message: `Failed to acknowledge incident. ${acknowledgeError.message}`,\n severity: 'error',\n });\n }\n\n if (resolveError) {\n alertApi.post({\n message: `Failed to resolve incident. ${resolveError.message}`,\n severity: 'error',\n });\n }\n\n return (\n <ListItem dense key={incident.entityId}>\n <ListItemIcon className={classes.listItemIcon}>\n <Tooltip\n title={incidentPhaseTooltip(incident.currentPhase)}\n placement=\"top\"\n >\n <div className={classes.denseListIcon}>\n <IncidentPhaseStatus currentPhase={incident.currentPhase} />\n </div>\n </Tooltip>\n </ListItemIcon>\n <ListItemText\n primary={incident.entityDisplayName}\n primaryTypographyProps={{\n variant: 'body1',\n className: classes.listItemPrimary,\n }}\n secondary={\n <Typography noWrap variant=\"body2\" color=\"textSecondary\">\n #{incident.incidentNumber} - Created {createdAt}{' '}\n {source() && `by ${source()}`}\n </Typography>\n }\n />\n\n {incident.incidentLink && incident.incidentNumber && (\n <ListItemSecondaryAction>\n {!readOnly && (\n <IncidentAction\n currentPhase={incident.currentPhase || ''}\n incidentId={incident.entityId}\n resolveAction={handleResolveIncident}\n acknowledgeAction={handleAcknowledgeIncident}\n />\n )}\n <Tooltip title=\"View in Splunk On-Call\" placement=\"top\">\n <IconButton\n href={incident.incidentLink}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n color=\"primary\"\n >\n <OpenInBrowserIcon />\n </IconButton>\n </Tooltip>\n </ListItemSecondaryAction>\n )}\n </ListItem>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAyCA,MAAM,YAAY,UAAW,CAAA;AAAA,EAC3B,aAAe,EAAA;AAAA,IACb,WAAa,EAAA,CA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;AAAA,IAEC,QAAS,CAAA,YAAA,IAAgB,QAAS,CAAA,cAAA,yBAChC,uBACE,EAAA,EAAA,QAAA,EAAA;AAAA,MAAA,CAAC,QACA,oBAAA,GAAA;AAAA,QAAC,cAAA;AAAA,QAAA;AAAA,UACC,YAAA,EAAc,SAAS,YAAgB,IAAA,EAAA;AAAA,UACvC,YAAY,QAAS,CAAA,QAAA;AAAA,UACrB,aAAe,EAAA,qBAAA;AAAA,UACf,iBAAmB,EAAA;AAAA;AAAA,OACrB;AAAA,sBAED,GAAA,CAAA,OAAA,EAAA,EAAQ,KAAM,EAAA,wBAAA,EAAyB,WAAU,KAChD,EAAA,QAAA,kBAAA,GAAA;AAAA,QAAC,UAAA;AAAA,QAAA;AAAA,UACC,MAAM,QAAS,CAAA,YAAA;AAAA,UACf,MAAO,EAAA,QAAA;AAAA,UACP,GAAI,EAAA,qBAAA;AAAA,UACJ,KAAM,EAAA,SAAA;AAAA,UAEN,8BAAC,iBAAkB,EAAA,EAAA;AAAA;AAAA,OAEvB,EAAA;AAAA,KACF,EAAA;AAAA,GAAA,EAAA,EA7CiB,SAAS,QA+C9B,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"IncidentListItem.esm.js","sources":["../../../src/components/Incident/IncidentListItem.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 { useEffect } from 'react';\nimport ListItem from '@material-ui/core/ListItem';\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\nimport ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport IconButton from '@material-ui/core/IconButton';\nimport Typography from '@material-ui/core/Typography';\nimport { makeStyles } from '@material-ui/core/styles';\nimport DoneIcon from '@material-ui/icons/Done';\nimport DoneAllIcon from '@material-ui/icons/DoneAll';\nimport { DateTime, Duration } from 'luxon';\nimport { Incident, IncidentPhase } from '../types';\nimport OpenInBrowserIcon from '@material-ui/icons/OpenInBrowser';\nimport { splunkOnCallApiRef } from '../../api/client';\nimport useAsyncFn from 'react-use/esm/useAsyncFn';\nimport { TriggerAlarmRequest } from '../../api/types';\n\nimport {\n StatusError,\n StatusWarning,\n StatusOK,\n} from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { toastApiRef } from '@backstage/frontend-plugin-api';\n\nconst useStyles = makeStyles({\n denseListIcon: {\n marginRight: 0,\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n },\n listItemPrimary: {\n fontWeight: 'bold',\n },\n listItemIcon: {\n minWidth: '1em',\n },\n secondaryAction: {\n paddingRight: 48,\n },\n});\n\ntype Props = {\n team: string;\n incident: Incident;\n onIncidentAction: () => void;\n readOnly: boolean;\n};\n\nconst IncidentPhaseStatus = ({\n currentPhase,\n}: {\n currentPhase: IncidentPhase;\n}) => {\n switch (currentPhase) {\n case 'UNACKED':\n return <StatusError />;\n case 'ACKED':\n return <StatusWarning />;\n default:\n return <StatusOK />;\n }\n};\n\nconst incidentPhaseTooltip = (currentPhase: IncidentPhase) => {\n switch (currentPhase) {\n case 'UNACKED':\n return 'Triggered';\n case 'ACKED':\n return 'Acknowledged';\n default:\n return 'Resolved';\n }\n};\n\nconst IncidentAction = ({\n currentPhase,\n incidentId,\n resolveAction,\n acknowledgeAction,\n}: {\n currentPhase: string;\n incidentId: string;\n resolveAction: (args: TriggerAlarmRequest) => void;\n acknowledgeAction: (args: TriggerAlarmRequest) => void;\n}) => {\n switch (currentPhase) {\n case 'UNACKED':\n return (\n <Tooltip title=\"Acknowledge\" placement=\"top\">\n <IconButton\n onClick={() =>\n acknowledgeAction({ incidentId, incidentType: 'ACKNOWLEDGEMENT' })\n }\n >\n <DoneIcon />\n </IconButton>\n </Tooltip>\n );\n case 'ACKED':\n return (\n <Tooltip title=\"Resolve\" placement=\"top\">\n <IconButton\n onClick={() =>\n resolveAction({ incidentId, incidentType: 'RECOVERY' })\n }\n >\n <DoneAllIcon />\n </IconButton>\n </Tooltip>\n );\n default:\n return <></>;\n }\n};\n\nexport const IncidentListItem = ({\n incident,\n readOnly,\n onIncidentAction,\n team,\n}: Props) => {\n const classes = useStyles();\n const duration =\n new Date().getTime() - new Date(incident.startTime!).getTime();\n const createdAt = DateTime.local()\n .minus(Duration.fromMillis(duration))\n .toRelative({ locale: 'en' });\n const toastApi = useApi(toastApiRef);\n const api = useApi(splunkOnCallApiRef);\n\n const hasBeenManuallyTriggered = incident.monitorName?.includes('vouser-');\n\n const source = () => {\n if (hasBeenManuallyTriggered) {\n return incident.monitorName?.replace('vouser-', '');\n }\n if (incident.monitorType === 'API') {\n return '{ REST }';\n }\n\n return incident.monitorName;\n };\n\n const [{ value: resolveValue, error: resolveError }, handleResolveIncident] =\n useAsyncFn(\n async ({ incidentId, incidentType }: TriggerAlarmRequest) =>\n await api.incidentAction({\n routingKey: team,\n incidentType,\n incidentId,\n }),\n );\n\n const [\n { value: acknowledgeValue, error: acknowledgeError },\n handleAcknowledgeIncident,\n ] = useAsyncFn(\n async ({ incidentId, incidentType }: TriggerAlarmRequest) =>\n await api.incidentAction({\n routingKey: team,\n incidentType,\n incidentId,\n }),\n );\n\n useEffect(() => {\n if (acknowledgeValue) {\n toastApi.post({\n title: `Incident successfully acknowledged`,\n });\n }\n\n if (resolveValue) {\n toastApi.post({\n title: `Incident successfully resolved`,\n });\n }\n if (resolveValue || acknowledgeValue) {\n onIncidentAction();\n }\n }, [acknowledgeValue, resolveValue, toastApi, onIncidentAction]);\n\n if (acknowledgeError) {\n toastApi.post({\n title: `Failed to acknowledge incident. ${acknowledgeError.message}`,\n status: 'danger',\n });\n }\n\n if (resolveError) {\n toastApi.post({\n title: `Failed to resolve incident. ${resolveError.message}`,\n status: 'danger',\n });\n }\n\n return (\n <ListItem dense key={incident.entityId}>\n <ListItemIcon className={classes.listItemIcon}>\n <Tooltip\n title={incidentPhaseTooltip(incident.currentPhase)}\n placement=\"top\"\n >\n <div className={classes.denseListIcon}>\n <IncidentPhaseStatus currentPhase={incident.currentPhase} />\n </div>\n </Tooltip>\n </ListItemIcon>\n <ListItemText\n primary={incident.entityDisplayName}\n primaryTypographyProps={{\n variant: 'body1',\n className: classes.listItemPrimary,\n }}\n secondary={\n <Typography noWrap variant=\"body2\" color=\"textSecondary\">\n #{incident.incidentNumber} - Created {createdAt}{' '}\n {source() && `by ${source()}`}\n </Typography>\n }\n />\n\n {incident.incidentLink && incident.incidentNumber && (\n <ListItemSecondaryAction>\n {!readOnly && (\n <IncidentAction\n currentPhase={incident.currentPhase || ''}\n incidentId={incident.entityId}\n resolveAction={handleResolveIncident}\n acknowledgeAction={handleAcknowledgeIncident}\n />\n )}\n <Tooltip title=\"View in Splunk On-Call\" placement=\"top\">\n <IconButton\n href={incident.incidentLink}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n color=\"primary\"\n >\n <OpenInBrowserIcon />\n </IconButton>\n </Tooltip>\n </ListItemSecondaryAction>\n )}\n </ListItem>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AA0CA,MAAM,YAAY,UAAW,CAAA;AAAA,EAC3B,aAAe,EAAA;AAAA,IACb,WAAa,EAAA,CAAA;AAAA,IACb,OAAS,EAAA,MAAA;AAAA,IACT,aAAe,EAAA,QAAA;AAAA,IACf,UAAY,EAAA,QAAA;AAAA,IACZ,cAAgB,EAAA;AAAA,GAClB;AAAA,EACA,eAAiB,EAAA;AAAA,IACf,UAAY,EAAA;AAAA,GACd;AAAA,EACA,YAAc,EAAA;AAAA,IACZ,QAAU,EA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QAAS,CAAA,QAAA;AAAA,UACrB,aAAe,EAAA,qBAAA;AAAA,UACf,iBAAmB,EAAA;AAAA;AAAA,OACrB;AAAA,sBAED,GAAA,CAAA,OAAA,EAAA,EAAQ,KAAM,EAAA,wBAAA,EAAyB,WAAU,KAChD,EAAA,QAAA,kBAAA,GAAA;AAAA,QAAC,UAAA;AAAA,QAAA;AAAA,UACC,MAAM,QAAS,CAAA,YAAA;AAAA,UACf,MAAO,EAAA,QAAA;AAAA,UACP,GAAI,EAAA,qBAAA;AAAA,UACJ,KAAM,EAAA,SAAA;AAAA,UAEN,8BAAC,iBAAkB,EAAA,EAAA;AAAA;AAAA,OAEvB,EAAA;AAAA,KACF,EAAA;AAAA,GAAA,EAAA,EA7CiB,SAAS,QA+C9B,CAAA;AAEJ;;;;"}
@@ -16,7 +16,8 @@ import { makeStyles, createStyles } from '@material-ui/core/styles';
16
16
  import useAsyncFn from 'react-use/esm/useAsyncFn';
17
17
  import { splunkOnCallApiRef } from '../../api/client.esm.js';
18
18
  import Alert from '@material-ui/lab/Alert';
19
- import { useApi, alertApiRef } from '@backstage/core-plugin-api';
19
+ import { useApi } from '@backstage/core-plugin-api';
20
+ import { toastApiRef } from '@backstage/frontend-plugin-api';
20
21
 
21
22
  const useStyles = makeStyles(
22
23
  (theme) => createStyles({
@@ -53,7 +54,7 @@ const TriggerDialog = ({
53
54
  handleDialog,
54
55
  onIncidentCreated
55
56
  }) => {
56
- const alertApi = useApi(alertApiRef);
57
+ const toastApi = useApi(toastApiRef);
57
58
  const api = useApi(splunkOnCallApiRef);
58
59
  const classes = useStyles();
59
60
  const [incidentType, setIncidentType] = useState("");
@@ -86,17 +87,17 @@ const TriggerDialog = ({
86
87
  };
87
88
  useEffect(() => {
88
89
  if (value) {
89
- alertApi.post({
90
- message: `Alarm successfully triggered`
90
+ toastApi.post({
91
+ title: `Alarm successfully triggered`
91
92
  });
92
93
  onIncidentCreated();
93
94
  handleDialog();
94
95
  }
95
- }, [value, alertApi, handleDialog, onIncidentCreated]);
96
+ }, [value, toastApi, handleDialog, onIncidentCreated]);
96
97
  if (triggerError) {
97
- alertApi.post({
98
- message: `Failed to trigger alarm. ${triggerError.message}`,
99
- severity: "error"
98
+ toastApi.post({
99
+ title: `Failed to trigger alarm. ${triggerError.message}`,
100
+ status: "danger"
100
101
  });
101
102
  }
102
103
  return /* @__PURE__ */ jsxs(Dialog, { maxWidth: "md", open: showDialog, onClose: handleDialog, fullWidth: true, children: [
@@ -1 +1 @@
1
- {"version":3,"file":"TriggerDialog.esm.js","sources":["../../../src/components/TriggerDialog/TriggerDialog.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 { ChangeEvent } from 'react';\n\nimport { useState, useEffect } from 'react';\nimport Dialog from '@material-ui/core/Dialog';\nimport DialogTitle from '@material-ui/core/DialogTitle';\nimport TextField from '@material-ui/core/TextField';\nimport DialogActions from '@material-ui/core/DialogActions';\nimport Button from '@material-ui/core/Button';\nimport DialogContent from '@material-ui/core/DialogContent';\nimport Typography from '@material-ui/core/Typography';\nimport CircularProgress from '@material-ui/core/CircularProgress';\nimport Select from '@material-ui/core/Select';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport FormControl from '@material-ui/core/FormControl';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport { createStyles, makeStyles, Theme } from '@material-ui/core/styles';\nimport useAsyncFn from 'react-use/esm/useAsyncFn';\nimport { splunkOnCallApiRef } from '../../api';\nimport Alert from '@material-ui/lab/Alert';\nimport { TriggerAlarmRequest } from '../../api';\nimport { useApi, alertApiRef } from '@backstage/core-plugin-api';\n\ntype Props = {\n routingKey: string;\n showDialog: boolean;\n handleDialog: () => void;\n onIncidentCreated: () => void;\n};\n\nconst useStyles = makeStyles((theme: Theme) =>\n createStyles({\n chips: {\n display: 'flex',\n flexWrap: 'wrap',\n },\n chip: {\n margin: 2,\n },\n formControl: {\n margin: theme.spacing(1),\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n minWidth: `calc(100% - ${theme.spacing(2)}px)`,\n },\n formHeader: {\n width: '50%',\n },\n incidentType: {\n width: '90%',\n },\n targets: {\n display: 'flex',\n flexDirection: 'column',\n width: '100%',\n },\n }),\n);\n\nexport const TriggerDialog = ({\n routingKey,\n showDialog,\n handleDialog,\n onIncidentCreated: onIncidentCreated,\n}: Props) => {\n const alertApi = useApi(alertApiRef);\n const api = useApi(splunkOnCallApiRef);\n const classes = useStyles();\n\n const [incidentType, setIncidentType] = useState<string>('');\n const [incidentId, setIncidentId] = useState<string>();\n const [incidentDisplayName, setIncidentDisplayName] = useState<string>('');\n const [incidentMessage, setIncidentMessage] = useState<string>('');\n const [incidentStartTime, setIncidentStartTime] = useState<number>();\n\n const [\n { value, loading: triggerLoading, error: triggerError },\n handleTriggerAlarm,\n ] = useAsyncFn(\n async (params: TriggerAlarmRequest) => await api.incidentAction(params),\n );\n\n const handleIncidentType = (event: ChangeEvent<{ value: unknown }>) => {\n setIncidentType(event.target.value as string);\n };\n\n const handleIncidentId = (event: ChangeEvent<HTMLTextAreaElement>) => {\n setIncidentId(event.target.value as string);\n };\n\n const handleIncidentDisplayName = (\n event: ChangeEvent<HTMLTextAreaElement>,\n ) => {\n setIncidentDisplayName(event.target.value);\n };\n\n const handleIncidentMessage = (event: ChangeEvent<HTMLTextAreaElement>) => {\n setIncidentMessage(event.target.value);\n };\n\n const handleIncidentStartTime = (event: ChangeEvent<HTMLTextAreaElement>) => {\n const dateTime = new Date(event.target.value).getTime();\n const dateTimeInSeconds = Math.floor(dateTime / 1000);\n setIncidentStartTime(dateTimeInSeconds);\n };\n\n useEffect(() => {\n if (value) {\n alertApi.post({\n message: `Alarm successfully triggered`,\n });\n onIncidentCreated();\n handleDialog();\n }\n }, [value, alertApi, handleDialog, onIncidentCreated]);\n\n if (triggerError) {\n alertApi.post({\n message: `Failed to trigger alarm. ${triggerError.message}`,\n severity: 'error',\n });\n }\n\n return (\n <Dialog maxWidth=\"md\" open={showDialog} onClose={handleDialog} fullWidth>\n <DialogTitle>This action will trigger an incident</DialogTitle>\n <DialogContent>\n <Typography variant=\"subtitle1\" gutterBottom align=\"justify\">\n Created by: <b>{`{ REST } Endpoint`}</b>\n </Typography>\n <Alert severity=\"info\">\n <Typography variant=\"body1\" align=\"justify\">\n If the issue you are seeing does not need urgent attention, please\n get in touch with the responsible team using their preferred\n communications channel. You can find information about the owner of\n this entity in the \"About\" card. If the issue is urgent, please\n don't hesitate to trigger the alert.\n </Typography>\n </Alert>\n <Typography\n variant=\"body1\"\n style={{ marginTop: '1em' }}\n gutterBottom\n align=\"justify\"\n >\n Please describe the problem you want to report. Be as descriptive as\n possible. <br />\n Note that only the <b>Incident type</b>, <b>Incident display name</b>{' '}\n and the <b>Incident message</b> fields are <b>required</b>.\n </Typography>\n <FormControl className={classes.formControl}>\n <div className={classes.formHeader}>\n <InputLabel id=\"demo-simple-select-label\">Incident type</InputLabel>\n <Select\n id=\"incident-type\"\n className={classes.incidentType}\n value={incidentType}\n onChange={handleIncidentType}\n inputProps={{ 'data-testid': 'trigger-incident-type' }}\n >\n <MenuItem value=\"CRITICAL\">Critical</MenuItem>\n <MenuItem value=\"WARNING\">Warning</MenuItem>\n <MenuItem value=\"INFO\">Info</MenuItem>\n </Select>\n </div>\n <TextField\n className={classes.formHeader}\n id=\"datetime-local\"\n label=\"Incident start time\"\n type=\"datetime-local\"\n onChange={handleIncidentStartTime}\n InputLabelProps={{\n shrink: true,\n }}\n />\n </FormControl>\n <TextField\n inputProps={{ 'data-testid': 'trigger-incident-id' }}\n id=\"summary\"\n fullWidth\n margin=\"normal\"\n label=\"Incident id\"\n variant=\"outlined\"\n onChange={handleIncidentId}\n />\n <TextField\n required\n inputProps={{ 'data-testid': 'trigger-incident-displayName' }}\n id=\"summary\"\n fullWidth\n margin=\"normal\"\n label=\"Incident display name\"\n variant=\"outlined\"\n onChange={handleIncidentDisplayName}\n />\n <TextField\n required\n inputProps={{ 'data-testid': 'trigger-incident-message' }}\n id=\"details\"\n multiline\n fullWidth\n minRows=\"2\"\n margin=\"normal\"\n label=\"Incident message\"\n variant=\"outlined\"\n onChange={handleIncidentMessage}\n />\n </DialogContent>\n <DialogActions>\n <Button\n data-testid=\"trigger-button\"\n id=\"trigger\"\n color=\"secondary\"\n disabled={\n !incidentType.length ||\n !incidentDisplayName ||\n !incidentMessage ||\n triggerLoading\n }\n variant=\"contained\"\n onClick={() =>\n handleTriggerAlarm({\n routingKey,\n incidentType,\n incidentDisplayName,\n incidentMessage,\n ...(incidentId ? { incidentId } : {}),\n ...(incidentStartTime ? { incidentStartTime } : {}),\n } as TriggerAlarmRequest)\n }\n endIcon={triggerLoading && <CircularProgress size={16} />}\n >\n Trigger Incident\n </Button>\n <Button id=\"close\" color=\"primary\" onClick={handleDialog}>\n Close\n </Button>\n </DialogActions>\n </Dialog>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AA6CA,MAAM,SAAY,GAAA,UAAA;AAAA,EAAW,CAAC,UAC5B,YAAa,CAAA;AAAA,IACX,KAAO,EAAA;AAAA,MACL,OAAS,EAAA,MAAA;AAAA,MACT,QAAU,EAAA;AAAA,KACZ;AAAA,IACA,IAAM,EAAA;AAAA,MACJ,MAAQ,EAAA;AAAA,KACV;AAAA,IACA,WAAa,EAAA;AAAA,MACX,MAAA,EAAQ,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,MACvB,OAAS,EAAA,MAAA;AAAA,MACT,aAAe,EAAA,KAAA;AAAA,MACf,UAAY,EAAA,QAAA;AAAA,MACZ,QAAU,EAAA,CAAA,Y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,MACP,kBAAmB,CAAA;AAAA,YACjB,UAAA;AAAA,YACA,YAAA;AAAA,YACA,mBAAA;AAAA,YACA,eAAA;AAAA,YACA,GAAI,UAAA,GAAa,EAAE,UAAA,KAAe,EAAC;AAAA,YACnC,GAAI,iBAAA,GAAoB,EAAE,iBAAA,KAAsB;AAAC,WAC3B,CAAA;AAAA,UAE1B,OAAS,EAAA,cAAA,oBAAmB,GAAA,CAAA,gBAAA,EAAA,EAAiB,MAAM,EAAI,EAAA,CAAA;AAAA,UACxD,QAAA,EAAA;AAAA;AAAA,OAED;AAAA,sBACA,GAAA,CAAC,UAAO,EAAG,EAAA,OAAA,EAAQ,OAAM,SAAU,EAAA,OAAA,EAAS,cAAc,QAE1D,EAAA,OAAA,EAAA;AAAA,KACF,EAAA;AAAA,GACF,EAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"TriggerDialog.esm.js","sources":["../../../src/components/TriggerDialog/TriggerDialog.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 { ChangeEvent } from 'react';\n\nimport { useState, useEffect } from 'react';\nimport Dialog from '@material-ui/core/Dialog';\nimport DialogTitle from '@material-ui/core/DialogTitle';\nimport TextField from '@material-ui/core/TextField';\nimport DialogActions from '@material-ui/core/DialogActions';\nimport Button from '@material-ui/core/Button';\nimport DialogContent from '@material-ui/core/DialogContent';\nimport Typography from '@material-ui/core/Typography';\nimport CircularProgress from '@material-ui/core/CircularProgress';\nimport Select from '@material-ui/core/Select';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport FormControl from '@material-ui/core/FormControl';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport { createStyles, makeStyles, Theme } from '@material-ui/core/styles';\nimport useAsyncFn from 'react-use/esm/useAsyncFn';\nimport { splunkOnCallApiRef } from '../../api';\nimport Alert from '@material-ui/lab/Alert';\nimport { TriggerAlarmRequest } from '../../api';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { toastApiRef } from '@backstage/frontend-plugin-api';\n\ntype Props = {\n routingKey: string;\n showDialog: boolean;\n handleDialog: () => void;\n onIncidentCreated: () => void;\n};\n\nconst useStyles = makeStyles((theme: Theme) =>\n createStyles({\n chips: {\n display: 'flex',\n flexWrap: 'wrap',\n },\n chip: {\n margin: 2,\n },\n formControl: {\n margin: theme.spacing(1),\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n minWidth: `calc(100% - ${theme.spacing(2)}px)`,\n },\n formHeader: {\n width: '50%',\n },\n incidentType: {\n width: '90%',\n },\n targets: {\n display: 'flex',\n flexDirection: 'column',\n width: '100%',\n },\n }),\n);\n\nexport const TriggerDialog = ({\n routingKey,\n showDialog,\n handleDialog,\n onIncidentCreated: onIncidentCreated,\n}: Props) => {\n const toastApi = useApi(toastApiRef);\n const api = useApi(splunkOnCallApiRef);\n const classes = useStyles();\n\n const [incidentType, setIncidentType] = useState<string>('');\n const [incidentId, setIncidentId] = useState<string>();\n const [incidentDisplayName, setIncidentDisplayName] = useState<string>('');\n const [incidentMessage, setIncidentMessage] = useState<string>('');\n const [incidentStartTime, setIncidentStartTime] = useState<number>();\n\n const [\n { value, loading: triggerLoading, error: triggerError },\n handleTriggerAlarm,\n ] = useAsyncFn(\n async (params: TriggerAlarmRequest) => await api.incidentAction(params),\n );\n\n const handleIncidentType = (event: ChangeEvent<{ value: unknown }>) => {\n setIncidentType(event.target.value as string);\n };\n\n const handleIncidentId = (event: ChangeEvent<HTMLTextAreaElement>) => {\n setIncidentId(event.target.value as string);\n };\n\n const handleIncidentDisplayName = (\n event: ChangeEvent<HTMLTextAreaElement>,\n ) => {\n setIncidentDisplayName(event.target.value);\n };\n\n const handleIncidentMessage = (event: ChangeEvent<HTMLTextAreaElement>) => {\n setIncidentMessage(event.target.value);\n };\n\n const handleIncidentStartTime = (event: ChangeEvent<HTMLTextAreaElement>) => {\n const dateTime = new Date(event.target.value).getTime();\n const dateTimeInSeconds = Math.floor(dateTime / 1000);\n setIncidentStartTime(dateTimeInSeconds);\n };\n\n useEffect(() => {\n if (value) {\n toastApi.post({\n title: `Alarm successfully triggered`,\n });\n onIncidentCreated();\n handleDialog();\n }\n }, [value, toastApi, handleDialog, onIncidentCreated]);\n\n if (triggerError) {\n toastApi.post({\n title: `Failed to trigger alarm. ${triggerError.message}`,\n status: 'danger',\n });\n }\n\n return (\n <Dialog maxWidth=\"md\" open={showDialog} onClose={handleDialog} fullWidth>\n <DialogTitle>This action will trigger an incident</DialogTitle>\n <DialogContent>\n <Typography variant=\"subtitle1\" gutterBottom align=\"justify\">\n Created by: <b>{`{ REST } Endpoint`}</b>\n </Typography>\n <Alert severity=\"info\">\n <Typography variant=\"body1\" align=\"justify\">\n If the issue you are seeing does not need urgent attention, please\n get in touch with the responsible team using their preferred\n communications channel. You can find information about the owner of\n this entity in the \"About\" card. If the issue is urgent, please\n don't hesitate to trigger the alert.\n </Typography>\n </Alert>\n <Typography\n variant=\"body1\"\n style={{ marginTop: '1em' }}\n gutterBottom\n align=\"justify\"\n >\n Please describe the problem you want to report. Be as descriptive as\n possible. <br />\n Note that only the <b>Incident type</b>, <b>Incident display name</b>{' '}\n and the <b>Incident message</b> fields are <b>required</b>.\n </Typography>\n <FormControl className={classes.formControl}>\n <div className={classes.formHeader}>\n <InputLabel id=\"demo-simple-select-label\">Incident type</InputLabel>\n <Select\n id=\"incident-type\"\n className={classes.incidentType}\n value={incidentType}\n onChange={handleIncidentType}\n inputProps={{ 'data-testid': 'trigger-incident-type' }}\n >\n <MenuItem value=\"CRITICAL\">Critical</MenuItem>\n <MenuItem value=\"WARNING\">Warning</MenuItem>\n <MenuItem value=\"INFO\">Info</MenuItem>\n </Select>\n </div>\n <TextField\n className={classes.formHeader}\n id=\"datetime-local\"\n label=\"Incident start time\"\n type=\"datetime-local\"\n onChange={handleIncidentStartTime}\n InputLabelProps={{\n shrink: true,\n }}\n />\n </FormControl>\n <TextField\n inputProps={{ 'data-testid': 'trigger-incident-id' }}\n id=\"summary\"\n fullWidth\n margin=\"normal\"\n label=\"Incident id\"\n variant=\"outlined\"\n onChange={handleIncidentId}\n />\n <TextField\n required\n inputProps={{ 'data-testid': 'trigger-incident-displayName' }}\n id=\"summary\"\n fullWidth\n margin=\"normal\"\n label=\"Incident display name\"\n variant=\"outlined\"\n onChange={handleIncidentDisplayName}\n />\n <TextField\n required\n inputProps={{ 'data-testid': 'trigger-incident-message' }}\n id=\"details\"\n multiline\n fullWidth\n minRows=\"2\"\n margin=\"normal\"\n label=\"Incident message\"\n variant=\"outlined\"\n onChange={handleIncidentMessage}\n />\n </DialogContent>\n <DialogActions>\n <Button\n data-testid=\"trigger-button\"\n id=\"trigger\"\n color=\"secondary\"\n disabled={\n !incidentType.length ||\n !incidentDisplayName ||\n !incidentMessage ||\n triggerLoading\n }\n variant=\"contained\"\n onClick={() =>\n handleTriggerAlarm({\n routingKey,\n incidentType,\n incidentDisplayName,\n incidentMessage,\n ...(incidentId ? { incidentId } : {}),\n ...(incidentStartTime ? { incidentStartTime } : {}),\n } as TriggerAlarmRequest)\n }\n endIcon={triggerLoading && <CircularProgress size={16} />}\n >\n Trigger Incident\n </Button>\n <Button id=\"close\" color=\"primary\" onClick={handleDialog}>\n Close\n </Button>\n </DialogActions>\n </Dialog>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8CA,MAAM,SAAY,GAAA,UAAA;AAAA,EAAW,CAAC,UAC5B,YAAa,CAAA;AAAA,IACX,KAAO,EAAA;AAAA,MACL,OAAS,EAAA,MAAA;AAAA,MACT,QAAU,EAAA;AAAA,KACZ;AAAA,IACA,IAAM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A,QAAC,MAAA;AAAA,QAAA;AAAA,UACC,aAAY,EAAA,gBAAA;AAAA,UACZ,EAAG,EAAA,SAAA;AAAA,UACH,KAAM,EAAA,WAAA;AAAA,UACN,UACE,CAAC,YAAA,CAAa,UACd,CAAC,mBAAA,IACD,CAAC,eACD,IAAA,cAAA;AAAA,UAEF,OAAQ,EAAA,WAAA;AAAA,UACR,OAAA,EAAS,MACP,kBAAmB,CAAA;AAAA,YACjB,UAAA;AAAA,YACA,YAAA;AAAA,YACA,mBAAA;AAAA,YACA,eAAA;AAAA,YACA,GAAI,UAAA,GAAa,EAAE,UAAA,KAAe,EAAC;AAAA,YACnC,GAAI,iBAAA,GAAoB,EAAE,iBAAA,KAAsB;AAAC,WAC3B,CAAA;AAAA,UAE1B,OAAS,EAAA,cAAA,oBAAmB,GAAA,CAAA,gBAAA,EAAA,EAAiB,MAAM,EAAI,EAAA,CAAA;AAAA,UACxD,QAAA,EAAA;AAAA;AAAA,OAED;AAAA,sBACA,GAAA,CAAC,UAAO,EAAG,EAAA,OAAA,EAAQ,OAAM,SAAU,EAAA,OAAA,EAAS,cAAc,QAE1D,EAAA,OAAA,EAAA;AAAA,KACF,EAAA;AAAA,GACF,EAAA,CAAA;AAEJ;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,18 +1,10 @@
1
- /// <reference types="react" />
2
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
- import { Entity } from '@backstage/catalog-model';
4
2
  import * as react from 'react';
3
+ import { Entity } from '@backstage/catalog-model';
5
4
  import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
6
5
  import { DiscoveryApi, FetchApi, ConfigApi } from '@backstage/core-plugin-api';
7
6
  import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api';
8
7
 
9
- /** @public */
10
- declare const isSplunkOnCallAvailable: (entity: Entity) => boolean;
11
- /** @public */
12
- type EntitySplunkOnCallCardProps = {
13
- readOnly?: boolean;
14
- };
15
-
16
8
  /** @public */
17
9
  type SplunkOnCallPageProps = {
18
10
  title?: string;
@@ -21,20 +13,11 @@ type SplunkOnCallPageProps = {
21
13
  };
22
14
 
23
15
  /** @public */
24
- declare const splunkOnCallPlugin: _backstage_core_plugin_api.BackstagePlugin<{
25
- root: _backstage_core_plugin_api.RouteRef<undefined>;
26
- }, {}, {}>;
16
+ declare const isSplunkOnCallAvailable: (entity: Entity) => boolean;
27
17
  /** @public */
28
- declare const SplunkOnCallPage: {
29
- (props: SplunkOnCallPageProps): react.JSX.Element;
30
- defaultProps: {
31
- title: string;
32
- subtitle: string;
33
- pageTitle: string;
34
- };
18
+ type EntitySplunkOnCallCardProps = {
19
+ readOnly?: boolean;
35
20
  };
36
- /** @public */
37
- declare const EntitySplunkOnCallCard: (props: EntitySplunkOnCallCardProps) => react_jsx_runtime.JSX.Element;
38
21
 
39
22
  /** @public */
40
23
  type Team = {
@@ -153,6 +136,22 @@ type RoutingKeyTarget = {
153
136
  _teamUrl: string;
154
137
  };
155
138
 
139
+ /** @public */
140
+ declare const splunkOnCallPlugin: _backstage_core_plugin_api.BackstagePlugin<{
141
+ root: _backstage_core_plugin_api.RouteRef<undefined>;
142
+ }, {}, {}>;
143
+ /** @public */
144
+ declare const SplunkOnCallPage: {
145
+ (props: SplunkOnCallPageProps): react.JSX.Element;
146
+ defaultProps: {
147
+ title: string;
148
+ subtitle: string;
149
+ pageTitle: string;
150
+ };
151
+ };
152
+ /** @public */
153
+ declare const EntitySplunkOnCallCard: (props: EntitySplunkOnCallCardProps) => react_jsx_runtime.JSX.Element;
154
+
156
155
  /** @public */
157
156
  type MessageType = 'CRITICAL' | 'WARNING' | 'ACKNOWLEDGEMENT' | 'INFO' | 'RECOVERY';
158
157
  /** @public */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage-community/plugin-splunk-on-call",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "description": "A Backstage plugin that integrates towards Splunk On-Call",
5
5
  "backstage": {
6
6
  "role": "frontend-plugin",
@@ -67,12 +67,12 @@
67
67
  "test": "backstage-cli package test"
68
68
  },
69
69
  "dependencies": {
70
- "@backstage/catalog-model": "^1.7.6",
71
- "@backstage/core-compat-api": "^0.5.8",
72
- "@backstage/core-components": "^0.18.7",
73
- "@backstage/core-plugin-api": "^1.12.3",
74
- "@backstage/frontend-plugin-api": "^0.14.1",
75
- "@backstage/plugin-catalog-react": "^2.0.0",
70
+ "@backstage/catalog-model": "^1.7.7",
71
+ "@backstage/core-compat-api": "^0.5.9",
72
+ "@backstage/core-components": "^0.18.8",
73
+ "@backstage/core-plugin-api": "^1.12.4",
74
+ "@backstage/frontend-plugin-api": "^0.15.1",
75
+ "@backstage/plugin-catalog-react": "^2.1.0",
76
76
  "@material-ui/core": "^4.12.2",
77
77
  "@material-ui/icons": "^4.9.1",
78
78
  "@material-ui/lab": "4.0.0-alpha.61",
@@ -81,10 +81,10 @@
81
81
  "react-use": "^17.2.4"
82
82
  },
83
83
  "devDependencies": {
84
- "@backstage/cli": "^0.35.4",
85
- "@backstage/core-app-api": "^1.19.5",
86
- "@backstage/dev-utils": "^1.1.20",
87
- "@backstage/test-utils": "^1.7.15",
84
+ "@backstage/cli": "^0.36.0",
85
+ "@backstage/core-app-api": "^1.19.6",
86
+ "@backstage/dev-utils": "^1.1.21",
87
+ "@backstage/test-utils": "^1.7.16",
88
88
  "@testing-library/dom": "^10.0.0",
89
89
  "@testing-library/jest-dom": "^6.0.0",
90
90
  "@testing-library/react": "^15.0.0",