UNPKG

@pagerduty/backstage-plugin

Version:
67 lines (64 loc) 1.99 kB
import { jsxs, Fragment, jsx } from 'react/jsx-runtime'; import { useState, useCallback } from 'react'; import { makeStyles, Typography } from '@material-ui/core'; import { TriggerDialog } from '../TriggerDialog/TriggerDialog.esm.js'; import AddAlert from '@material-ui/icons/AddAlert'; import { ButtonIcon } from '@backstage/ui'; function TriggerIncidentButton({ integrationKey, entityName, compact, handleRefresh }) { const useStyles = makeStyles(() => ({ containerStyle: { fontSize: compact !== true ? "12px" : "10px", width: compact !== true ? "80px" : "60px", display: "flex", flexDirection: "column", alignItems: "center" }, textStyle: { textAlign: "center", fontSize: "12px", minWidth: "30px" } })); const { containerStyle, 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__ */ jsxs("div", { className: containerStyle, children: [ /* @__PURE__ */ jsx( ButtonIcon, { variant: "tertiary", size: "medium", "aria-label": "create-incident", onClick: showDialog, isDisabled: disabled, icon: /* @__PURE__ */ jsx(AddAlert, {}) } ), /* @__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