UNPKG

@pagerduty/backstage-plugin

Version:

A Backstage plugin that integrates towards PagerDuty

72 lines (69 loc) 2.13 kB
import { jsxs, Fragment, jsx } from 'react/jsx-runtime'; import { useState, useCallback } from 'react'; import { makeStyles, IconButton, Typography } from '@material-ui/core'; import { TriggerDialog } from '../TriggerDialog/TriggerDialog.esm.js'; import AddAlert from '@material-ui/icons/AddAlert'; function TriggerIncidentButton({ integrationKey, entityName, compact, handleRefresh }) { const useStyles = makeStyles((theme) => ({ buttonStyle: { color: theme.palette.text.primary, "&:hover": { backgroundColor: "transparent", textDecoration: "underline" } }, containerStyle: { fontSize: compact !== true ? "12px" : "10px", width: compact !== true ? "80px" : "60px", marginRight: "-10px" }, iconStyle: { fontSize: "30px", marginBottom: "-10px" }, textStyle: { marginBottom: "-10px" } })); const { buttonStyle, containerStyle, iconStyle, textStyle } = useStyles(); const [dialogShown, setDialogShown] = useState(false); const showDialog = useCallback(() => { setDialogShown(true); }, [setDialogShown]); const hideDialog = useCallback(() => { setDialogShown(false); }, [setDialogShown]); const disabled = !integrationKey; return /* @__PURE__ */ jsxs(Fragment, { children: [ /* @__PURE__ */ jsx( IconButton, { "aria-label": "create-incident", onClick: showDialog, className: disabled ? "" : buttonStyle, disabled, children: /* @__PURE__ */ jsxs("div", { className: containerStyle, children: [ /* @__PURE__ */ jsx(AddAlert, { className: iconStyle }), /* @__PURE__ */ jsx(Typography, { className: textStyle, children: "Create new incident" }) ] }) } ), integrationKey && /* @__PURE__ */ jsx( TriggerDialog, { showDialog: dialogShown, handleDialog: hideDialog, integrationKey, serviceName: entityName, onIncidentCreated: handleRefresh } ) ] }); } export { TriggerIncidentButton }; //# sourceMappingURL=TriggerIncidentButton.esm.js.map