/*! Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one or more contributor license agreements. * Licensed under the Elastic License 2.0; you may not use this file except in compliance with the Elastic License 2.0. */ (window.infra_bundle_jsonpfunction=window.infra_bundle_jsonpfunction||[]).push([[20],{104:function(e,t,a){e.exports=a(65)(1466)},556:function(e,t,a){"use strict";a.r(t),a.d(t,"AlertDropdown",(function(){return w}));var n=a(104),l=a.n(n),i=a(2),r=a.n(i),s=a(1),o=a(35),c=a(75),u=a(38),d=a(56),g=a(13);const p=e=>{const{visible:t,setVisible:a}=e,{triggersActionsUI:n}=Object(i.useContext)(d.a),l=Object(i.useCallback)((()=>a(!1)),[a]),s=Object(i.useMemo)((()=>n&&n.getAddRuleFlyout({consumer:"logs",onClose:l,canChangeTrigger:!1,ruleTypeId:g.d,metadata:{isInternal:!0}})),[n,l]);return r.a.createElement(r.a.Fragment,null,t&&s)};var b=a(21);const m=s.i18n.translate("xpack.infra.logs.alertDropdown.readOnlyCreateAlertContent",{defaultMessage:"Creating alerts requires more permissions in this application."}),f=s.i18n.translate("xpack.infra.logs.alertDropdown.readOnlyCreateAlertTitle",{defaultMessage:"Read only"}),C=s.i18n.translate("xpack.infra.logs.alertDropdown.inlineLogViewCreateAlertTitle",{defaultMessage:"Inline Log View"}),k=s.i18n.translate("xpack.infra.logs.alertDropdown.inlineLogViewCreateAlertContent",{defaultMessage:"Creating alerts is not supported with inline Log Views"}),w=()=>{var e,t;const{services:{application:{capabilities:a},observability:n}}=Object(b.b)(),{isPersistedLogView:s}=Object(u.useLogViewContext)(),d=!(null!=a&&null!==(e=a.logs)&&void 0!==e&&e.save),g=null!==(t=!d&&s)&&void 0!==t&&t,[w,E]=Object(i.useState)(!1),[M,O]=Object(i.useState)(!1),v=n.useRulesLink({hrefOnly:!0}),x=Object(i.useCallback)((()=>{E(!1)}),[E]),j=Object(i.useCallback)((()=>{E(!0)}),[E]),y=Object(i.useCallback)((()=>{O(!0),x()}),[O,x]),A=Object(i.useMemo)((()=>[r.a.createElement(o.EuiContextMenuItem,{disabled:!g,icon:"bell",key:"createLink",onClick:y,toolTipContent:g?void 0:d?m:k,toolTipTitle:g?void 0:d?f:C},r.a.createElement(c.FormattedMessage,{id:"xpack.infra.alerting.logs.createAlertButton",defaultMessage:"Create rule"})),r.a.createElement(o.EuiContextMenuItem,l()({icon:"tableOfContents",key:"manageLink"},v),r.a.createElement(c.FormattedMessage,{id:"xpack.infra.alerting.logs.manageAlerts",defaultMessage:"Manage rules"}))]),[g,y,d,v]);return r.a.createElement(r.a.Fragment,null,r.a.createElement(o.EuiPopover,{panelPaddingSize:"none",button:r.a.createElement(o.EuiHeaderLink,{color:"text",iconSide:"right",iconType:"arrowDown",onClick:j},r.a.createElement(c.FormattedMessage,{id:"xpack.infra.alerting.logs.alertsButton",defaultMessage:"Alerts and rules"})),isOpen:w,closePopover:x},r.a.createElement(o.EuiContextMenuPanel,{items:A})),r.a.createElement(p,{setVisible:O,visible:M}))};t.default=w}}]);