"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[6618],{29507:(e,t,n)=>{n.d(t,{x:()=>r});var a=n(68404),i=n(18745),s=n(45193);function r(e){const t=(0,i.useDispatch)(),n=(0,a.useRef)(e);n.current=e,(0,a.useEffect)((()=>()=>{t((0,s.e)({stateSelector:n.current}))}),[t])}},93970:(e,t,n)=>{n.d(t,{q:()=>s});var a=n(18745),i=n(8674);const s=e=>{const t=(0,a.useSelector)((e=>e.navIndex));return(0,i.h)(t,e)}},80892:(e,t,n)=>{n.r(t),n.d(t,{default:()=>x});var a,i,s,r,l=n(68404),o=n(42147),c=n(90923),d=n(69783),u=n(28436),p=n(33801),m=n(98163),h=n(93970),g=n(21169),f=n(45916);const x=()=>{const e=(0,h.q)("channels"),[t,n]=(0,l.useState)([]),[x,v]=(0,o.Z)((async()=>await(0,c.getBackendSrv)().get("/api/alert-notifications")));(0,l.useEffect)((()=>{v().then((e=>{n(e)}))}),[v]);const y=async e=>{await(0,c.getBackendSrv)().delete(`/api/alert-notifications/${e}`);const t=await v();n(t)};return(0,f.jsx)(p.Z,{navModel:e,children:(0,f.jsxs)(p.Z.Contents,{children:[x.error&&(0,f.jsx)("p",{children:x.error}),!!t.length&&(0,f.jsxs)(f.Fragment,{children:[a||(a=(0,f.jsxs)("div",{className:"page-action-bar",children:[(0,f.jsx)("div",{className:"page-action-bar__spacer"}),(0,f.jsx)(d.LinkButton,{icon:"channel-add",href:"alerting/notification/new",children:"New channel"})]})),(0,f.jsxs)("table",{className:"filter-table filter-table--hover",children:[(0,f.jsx)("thead",{children:(0,f.jsxs)("tr",{children:[(0,f.jsx)("th",{style:{minWidth:"200px"},children:i||(i=(0,f.jsx)("strong",{children:"Name"}))}),(0,f.jsx)("th",{style:{minWidth:"100px"},children:"Type"}),(0,f.jsx)("th",{style:{width:"1%"}})]})}),(0,f.jsx)("tbody",{children:t.map((e=>(0,f.jsxs)("tr",{children:[(0,f.jsx)("td",{className:"link-td",children:(0,f.jsx)("a",{href:`alerting/notification/${e.id}/edit`,children:e.name})}),(0,f.jsx)("td",{className:"link-td",children:(0,f.jsx)("a",{href:`alerting/notification/${e.id}/edit`,children:e.type})}),(0,f.jsx)("td",{className:"text-right",children:(0,f.jsxs)(d.HorizontalGroup,{justify:"flex-end",children:[e.isDefault&&(s||(s=(0,f.jsx)(d.Button,{disabled:!0,variant:"secondary",size:"sm",children:"default"}))),(0,f.jsx)(d.Button,{variant:"destructive",icon:"times",size:"sm",onClick:()=>{var t;t=e.id,m.h$.publish(new g.VJ({title:"Delete",text:"Do you want to delete this notification channel?",text2:"Deleting this notification channel will not delete from alerts any references to it",icon:"trash-alt",confirmText:"Delete",yesText:"Delete",onConfirm:async()=>{y(t)}}))}})]})})]},e.id)))})]})]}),!(t.length||x.loading)&&(r||(r=(0,f.jsx)(u.Z,{title:"There are no notification channels defined yet",buttonIcon:"channel-add",buttonLink:"alerting/notification/new",buttonTitle:"Add channel",proTip:"You can include images in your alert notifications.",proTipLink:"http://docs.grafana.org/alerting/notifications/",proTipLinkTitle:"Learn more",proTipTarget:"_blank"})))]})})}},91517:(e,t,n)=>{n.r(t),n.d(t,{default:()=>Mt});var a=n(68404),i=n(18745),s=n(42326),r=n(69783),l=n(50489),o=n(40256),c=n(71308),d=n(19462),u=n(83809);function p(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return Object.assign({propertyName:e,label:t,description:n,element:"input",inputType:"",required:!1,secure:!1,placeholder:"",validationRule:"",showWhen:{field:"",is:""},dependsOn:""},a)}const m=p("basic_auth","Basic auth","Sets the `Authorization` header with the configured username and password. Password and password_file are mutually exclusive.",{element:"subform",subformOptions:[p("username","Username",""),p("password","Password",""),p("password_file","Password file","")]}),h=p("tls_config","TLS config","Configures the TLS settings.",{element:"subform",subformOptions:[p("ca_file","CA file","CA certificate to validate the server certificate with."),p("cert_file","Cert file","Certificate for client cert authentication to the server."),p("key_file","Key file","Key file for client cert authentication to the server."),p("server_name","Server name","ServerName extension to indicate the name of the server."),p("insecure_skip_verify","Skip verify","Disable validation of the server certificate.",{element:"checkbox"})]}),g=p("http_config","HTTP Config","Note that `basic_auth`, `bearer_token` and `bearer_token_file` options are mutually exclusive.",{element:"subform",subformOptions:[p("bearer_token","Bearer token","Sets the `Authorization` header with the configured bearer token."),p("bearer_token_file","Bearer token file","Sets the `Authorization` header with the bearer token read from the configured file."),p("proxy_url","Proxy URL","Optional proxy URL."),m,h]}),f=[{name:"Email",description:"Send notification over SMTP",type:"email",info:"",heading:"Email settings",options:[p("to","To","The email address to send notifications to.",{required:!0}),p("from","From","The sender address."),p("smarthost","SMTP host","The SMTP host through which emails are sent."),p("hello","Hello","The hostname to identify to the SMTP server."),p("auth_username","Username","SMTP authentication information"),p("auth_password","Password","SMTP authentication information"),p("auth_secret","Secret","SMTP authentication information"),p("auth_identity","Identity","SMTP authentication information"),p("require_tls","Require TLS","The SMTP TLS requirement",{element:"checkbox"}),p("html","Email HTML body","The HTML body of the email notification.",{placeholder:'{{ template "email.default.html" . }}',element:"textarea"}),p("text","Email text body","The text body of the email notification.",{element:"textarea"}),p("headers","Headers","Further headers email header key/value pairs. Overrides any headers previously set by the notification implementation.",{element:"key_value_map"}),h]},{name:"PagerDuty",description:"Send notifications to PagerDuty",type:"pagerduty",info:"",heading:"PagerDuty settings",options:[p("routing_key","Routing key","The PagerDuty integration key (when using PagerDuty integration type `Events API v2`)"),p("service_key","Service key","The PagerDuty integration key (when using PagerDuty integration type `Prometheus`)."),p("url","URL","The URL to send API requests to"),p("client","Client","The client identification of the Alertmanager.",{placeholder:'{{ template "pagerduty.default.client" . }}'}),p("client_url","Client URL","A backlink to the sender of the notification.",{placeholder:'{{ template "pagerduty.default.clientURL" . }}'}),p("description","Description","A description of the incident.",{placeholder:'{{ template "pagerduty.default.description" .}}'}),p("severity","Severity","Severity of the incident.",{placeholder:"error"}),p("details","Details","A set of arbitrary key/value pairs that provide further detail about the incident.",{element:"key_value_map"}),p("images","Images","Images to attach to the incident.",{element:"subform_array",subformOptions:[p("href","URL","",{required:!0}),p("source","Source","",{required:!0}),p("alt","Alt","",{required:!0})]}),p("links","Links","Links to attach to the incident.",{element:"subform_array",subformOptions:[p("href","URL","",{required:!0}),p("text","Text","",{required:!0})]}),g]},{name:"Pushover",description:"Send notifications to Pushover",type:"pushover",info:"",heading:"Pushover settings",options:[p("user_key","User key","The recipient user’s user key.",{required:!0}),p("token","Token","Your registered application’s API token, see https://pushover.net/app",{required:!0}),p("title","Title","Notification title.",{placeholder:'{{ template "pushover.default.title" . }}'}),p("message","Message","Notification message.",{placeholder:'{{ template "pushover.default.message" . }}'}),p("url","URL","A supplementary URL shown alongside the message.",{placeholder:'{{ template "pushover.default.url" . }}'}),p("priority","Priority","Priority, see https://pushover.net/api#priority",{placeholder:'{{ if eq .Status "firing" }}2{{ else }}0{{ end }}'}),p("retry","Retry","How often the Pushover servers will send the same notification to the user. Must be at least 30 seconds.",{placeholder:"1m"}),p("expire","Expire","How long your notification will continue to be retried for, unless the user acknowledges the notification.",{placeholder:"1h"}),g]},{name:"Slack",description:"Send notifications to Slack",type:"slack",info:"",heading:"Slack settings",options:[p("api_url","Webhook URL","The Slack webhook URL."),p("channel","Channel","The #channel or @user to send notifications to.",{required:!0}),p("icon_emoji","Emoji icon",""),p("icon_url","Icon URL",""),p("link_names","Names link","",{element:"checkbox"}),p("username","Username","",{placeholder:'{{ template "slack.default.username" . }}'}),p("callback_id","Callback ID","",{placeholder:'{{ template "slack.default.callbackid" . }}'}),p("color","Color","",{placeholder:'{{ if eq .Status "firing" }}danger{{ else }}good{{ end }}'}),p("fallback","Fallback","",{placeholder:'{{ template "slack.default.fallback" . }}'}),p("footer","Footer","",{placeholder:'{{ template "slack.default.footer" . }}'}),p("mrkdwn_in","Mrkdwn fields","An array of field names that should be formatted by mrkdwn syntax.",{element:"string_array"}),p("pretext","Pre-text","",{placeholder:'{{ template "slack.default.pretext" . }}'}),p("short_fields","Short fields","",{element:"checkbox"}),p("text","Message body","",{element:"textarea",placeholder:'{{ template "slack.default.text" . }}'}),p("title","Title","",{placeholder:'{{ template "slack.default.title" . }}'}),p("title_link","Title link","",{placeholder:'{{ template "slack.default.titlelink" . }}'}),p("image_url","Image URL",""),p("thumb_url","Thumbnail URL",""),p("actions","Actions","",{element:"subform_array",subformOptions:[p("text","Text","",{required:!0}),p("type","Type","",{required:!0}),p("url","URL","Either url or name and value are mandatory."),p("name","Name",""),p("value","Value",""),p("confirm","Confirm","",{element:"subform",subformOptions:[p("text","Text","",{required:!0}),p("dismiss_text","Dismiss text",""),p("ok_text","OK text",""),p("title","Title","")]}),p("style","Style","")]}),p("fields","Fields","",{element:"subform_array",subformOptions:[p("title","Title","",{required:!0}),p("value","Value","",{required:!0}),p("short","Short","",{element:"checkbox"})]}),g]},{name:"OpsGenie",description:"Send notifications to OpsGenie",type:"opsgenie",info:"",heading:"OpsGenie settings",options:[p("api_key","API key","The API key to use when talking to the OpsGenie API."),p("api_url","API URL","The host to send OpsGenie API requests to."),p("message","Message","Alert text limited to 130 characters."),p("description","Description","A description of the incident.",{placeholder:'{{ template "opsgenie.default.description" . }}'}),p("source","Source","A backlink to the sender of the notification.",{placeholder:'{{ template "opsgenie.default.source" . }}'}),p("details","Details","A set of arbitrary key/value pairs that provide further detail about the incident.",{element:"key_value_map"}),p("tags","Tags","Comma separated list of tags attached to the notifications."),p("note","Note","Additional alert note."),p("priority","Priority","Priority level of alert. Possible values are P1, P2, P3, P4, and P5."),p("responders","Responders","List of responders responsible for notifications.",{element:"subform_array",subformOptions:[p("type","Type",'"team", "user", "escalation" or schedule".',{required:!0}),p("id","ID","Exactly one of these fields should be defined."),p("name","Name","Exactly one of these fields should be defined."),p("username","Username","Exactly one of these fields should be defined.")]}),g]},{name:"VictorOps",description:"Send notifications to VictorOps",type:"victorops",info:"",heading:"VictorOps settings",options:[p("api_key","API key","The API key to use when talking to the VictorOps API."),p("api_url","API URL","The VictorOps API URL."),p("routing_key","Routing key","A key used to map the alert to a team.",{required:!0}),p("message_type","Message type","Describes the behavior of the alert (CRITICAL, WARNING, INFO)."),p("entity_display_name","Entity display name","Contains summary of the alerted problem.",{placeholder:'{{ template "victorops.default.entity_display_name" . }}'}),p("state_message","State message","Contains long explanation of the alerted problem.",{placeholder:'{{ template "victorops.default.state_message" . }}'}),p("monitoring_tool","Monitoring tool","The monitoring tool the state message is from.",{placeholder:'{{ template "victorops.default.monitoring_tool" . }}'}),g]},{name:"Webhook",description:"Send notifications to a webhook",type:"webhook",info:"",heading:"Webhook settings",options:[p("url","URL","The endpoint to send HTTP POST requests to.",{required:!0}),p("max_alerts","Max alerts","The maximum number of alerts to include in a single webhook message. Alerts above this threshold are truncated. When leaving this at its default value of 0, all alerts are included.",{placeholder:"0",validationRule:"(^\\d+$|^$)"}),g]}],x=[p("smtp_from","SMTP from","The default SMTP From header field."),p("smtp_smarthost","SMTP smarthost","The default SMTP smarthost used for sending emails, including port number. Port number usually is 25, or 587 for SMTP over TLS (sometimes referred to as STARTTLS). Example: smtp.example.org:587"),p("smtp_hello","SMTP hello","The default hostname to identify to the SMTP server.",{placeholder:"localhost"}),p("smtp_auth_username","SMTP auth username","SMTP Auth using CRAM-MD5, LOGIN and PLAIN. If empty, Alertmanager doesn't authenticate to the SMTP server."),p("smtp_auth_password","SMTP auth password","SMTP Auth using LOGIN and PLAIN."),p("smtp_auth_identity","SMTP auth identity","SMTP Auth using PLAIN."),p("smtp_auth_secret","SMTP auth secret","SMTP Auth using CRAM-MD5."),p("smtp_require_tls","SMTP require TLS","The default SMTP TLS requirement. Note that Go does not support unencrypted connections to remote SMTP endpoints.",{element:"checkbox"}),p("slack_api_url","Slack API URL",""),p("victorops_api_key","VictorOps API key",""),p("victorops_api_url","VictorOps API URL","",{placeholder:"https://alert.victorops.com/integrations/generic/20131114/alert/"}),p("pagerduty_url","PagerDuty URL","https://events.pagerduty.com/v2/enqueue"),p("opsgenie_api_key","OpsGenie API key",""),p("opsgenie_api_url","OpsGenie API URL","",{placeholder:"https://api.opsgenie.com/"}),p("wechat_api_url","WeChat API URL","",{placeholder:"https://qyapi.weixin.qq.com/cgi-bin/"}),p("wechat_api_secret","WeChat API secret",""),p("wechat_api_corp_id","WeChat API corp id",""),g,p("resolve_timeout","Resolve timeout","ResolveTimeout is the default value used by alertmanager if the alert does not include EndsAt, after this time passes it can declare the alert as resolved if it has not been updated. This has no impact on alerts from Prometheus, as they always include EndsAt.",{placeholder:"5m"})];var v=n(82897);function y(e,t){var n,a;const i={};let s=1;return[{name:e.name,items:null!==(n=null===(a=e.grafana_managed_receiver_configs)||void 0===a?void 0:a.map((e=>{const n=String(s++);i[n]=e;const a=t.find((t=>{let{type:n}=t;return n===e.type}));return function(e,t,n){const a={__id:e,type:t.type,secureSettings:{},settings:Object.assign({},t.settings),secureFields:Object.assign({},t.secureFields),disableResolveMessage:t.disableResolveMessage};return null==n||n.options.forEach((e=>{e.secure&&a.settings[e.propertyName]&&(delete a.settings[e.propertyName],a.secureFields[e.propertyName]=!0)})),a}(n,e,a)})))&&void 0!==n?n:[]},i]}function b(e,t){const n={};let a=1;const i=Object.entries(e).filter((e=>{let[t]=e;return t.endsWith("_configs")&&"grafana_managed_receiver_configs"!==t})).map((e=>{let[t,n]=e;return[t.replace("_configs",""),n]})).map((e=>{let[i,s]=e;return s.map((e=>{const s=String(a++);n[s]={type:i,config:e};if(!t.find((e=>e.type===i)))throw new Error(`unknown cloud notifier: ${i}`);return function(e,t,n){return{__id:e,type:t,settings:Object.assign({},n),secureFields:{},secureSettings:{},sendResolved:n.send_resolved}}(s,i,e)}))})).flat();return[{name:e.name,items:i},n]}function j(e,t,n){var a;const i=null!==(a=e.alertmanager_config.receivers)&&void 0!==a?a:[];if(t.name!==n&&i.find((e=>{let{name:n}=e;return n===t.name})))throw new Error(`Duplicate receiver name ${t.name}`);if(n&&!i.find((e=>{let{name:t}=e;return t===n})))throw new Error(`Expected receiver ${n} to exist, but did not find it in the config`);const s=Object.assign({},e,{alertmanager_config:Object.assign({},e.alertmanager_config,{receivers:n?i.map((e=>e.name===n?t:e)):[...i,t]})});return s.alertmanager_config.route&&n&&t.name!==n&&(s.alertmanager_config.route=_(s.alertmanager_config.route,n,t.name)),s}function _(e,t,n){const a=Object.assign({},e);return a.receiver===t&&(a.receiver=n),a.routes&&(a.routes=a.routes.map((e=>_(e,t,n)))),a}function k(e,t,n,a){var i,s,r,l,o;const c={settings:S(Object.assign({},a&&a.type===e.type&&null!==(i=a.settings)&&void 0!==i?i:{},null!==(s=e.settings)&&void 0!==s?s:{})),secureSettings:null!==(r=e.secureSettings)&&void 0!==r?r:{},type:e.type,name:n,disableResolveMessage:null!==(l=null!==(o=e.disableResolveMessage)&&void 0!==o?o:null==a?void 0:a.disableResolveMessage)&&void 0!==l?l:t.disableResolveMessage};return a&&(c.uid=a.uid),c}function S(e){return(0,v.isArray)(e)?e.forEach(S):"object"==typeof e&&null!==e&&Object.entries(e).forEach((t=>{let[n,a]=t;""===a||null==a?delete e[n]:S(a)})),e}var N=n(80916),w=n(45916);const C=e=>{let{pathPrefix:t,className:n,readOnly:a=!1}=e;const{register:i}=(0,N.Gc)();return(0,w.jsx)("div",{className:n,children:(0,w.jsx)(r.Field,{disabled:a,children:(0,w.jsx)(r.Checkbox,Object.assign({},i(`${t}sendResolved`),{label:"Send resolved",disabled:a,description:"Whether or not to notify about resolved alerts."}))})})};var O=n(36636),A=n(58257),$=n(29507);const T=[];function P(e){var t,n;const{name:i,formAPI:s,defaults:r,softDelete:l}=e,{watch:o,getValues:c,reset:d,setValue:u}=s,p=null!==(t=null!==(n=o(i))&&void 0!==n?n:r)&&void 0!==t?t:T,m=(0,a.useCallback)((e=>{const t=JSON.parse(JSON.stringify(c())),n=e(null!=p?p:[]);d((0,v.set)(t,i,n))}),[c,i,d,p]);return{fields:p,append:(0,a.useCallback)((e=>m((t=>[...t,e]))),[m]),remove:(0,a.useCallback)((e=>{l?u(`${i}.${e}.__deleted`,!0):m((t=>{const n=t.slice();return n.splice(e,1),n}))}),[m,i,u,l])}}var M,R,I,L=n(33899),q=n(39357),B=n(3799);const F=e=>{let{value:t,onChange:n,readOnly:i=!1}=e;const s=(0,r.useStyles2)(D),[l,o]=(0,a.useState)(E(t));(0,a.useEffect)((()=>o(E(t))),[t]);const c=e=>{n(V(e))},d=(e,t)=>{const n=l[t],a=l.map(((n,a)=>a===t?e:n));o(a),(e[0]||n[0])&&c(a)};return(0,w.jsxs)("div",{children:[!!l.length&&(0,w.jsxs)("table",{className:s.table,children:[(0,w.jsx)("thead",{children:(0,w.jsxs)("tr",{children:[M||(M=(0,w.jsx)("th",{children:"Name"})),R||(R=(0,w.jsx)("th",{children:"Value"})),!i&&(I||(I=(0,w.jsx)("th",{})))]})}),(0,w.jsx)("tbody",{children:l.map(((e,t)=>{let[n,a]=e;return(0,w.jsxs)("tr",{children:[(0,w.jsx)("td",{children:(0,w.jsx)(r.Input,{readOnly:i,value:n,onChange:e=>d([e.currentTarget.value,a],t)})}),(0,w.jsx)("td",{children:(0,w.jsx)(r.Input,{readOnly:i,value:a,onChange:e=>d([n,e.currentTarget.value],t)})}),!i&&(0,w.jsx)("td",{children:(0,w.jsx)(B.A,{icon:"trash-alt",tooltip:"delete",onClick:()=>(e=>{const t=l.slice(),n=t.splice(e,1)[0];o(t),n[0]&&c(t)})(t)})})]},t)}))})]}),!i&&(0,w.jsx)(r.Button,{className:s.addButton,type:"button",variant:"secondary",icon:"plus",size:"sm",onClick:()=>o([...l,["",""]]),children:"Add"})]})},D=e=>({addButton:O.css` margin-top: ${e.spacing(1)}; `,table:O.css` tbody td { padding: 0 ${e.spacing(1)} ${e.spacing(1)} 0; } `}),V=e=>{const t={};for(const[n,a]of e)n&&(t[n]=a);return t},E=e=>Object.entries(null!=e?e:{}),G=e=>{let{value:t,onChange:n,readOnly:a=!1}=e;const i=(0,r.useStyles2)(U);return(0,w.jsxs)("div",{children:[!(null==t||!t.length)&&t.map(((e,s)=>(0,w.jsxs)("div",{className:i.row,children:[(0,w.jsx)(r.Input,{readOnly:a,value:e,onChange:e=>((e,a)=>{t&&n(t.map(((t,n)=>n===a?e:t)))})(e.currentTarget.value,s)}),!a&&(0,w.jsx)(B.A,{className:i.deleteIcon,icon:"trash-alt",tooltip:"delete",onClick:()=>(e=>{if(!t)return;const a=t.slice();a.splice(e,1),n(a)})(s)})]},s))),!a&&(0,w.jsx)(r.Button,{className:i.addButton,type:"button",variant:"secondary",icon:"plus",size:"sm",onClick:()=>n([...null!=t?t:[],""]),children:"Add"})]})},U=e=>({row:O.css` display: flex; flex-direction: row; margin-bottom: ${e.spacing(1)}; align-items: center; `,deleteIcon:O.css` margin-left: ${e.spacing(1)}; `,addButton:O.css` margin-top: ${e.spacing(1)}; `});var W=n(91045);const z=e=>{let{label:t,description:n,children:i,className:s,size:l="xl"}=e;const o=(0,r.useStyles2)(Y),[c,d]=(0,a.useState)(!0),u=()=>d(!c);return(0,w.jsxs)("div",{className:(0,O.cx)(o.wrapper,s),children:[(0,w.jsxs)("div",{className:o.heading,onClick:u,children:[(0,w.jsx)(W.U,{className:o.caret,size:l,onToggle:u,isCollapsed:c}),(0,w.jsx)("h6",{children:t})]}),n&&(0,w.jsx)("p",{className:o.description,children:n}),(0,w.jsx)("div",{className:c?o.hidden:void 0,children:i})]})},Y=e=>({wrapper:O.css` margin-top: ${e.spacing(1)}; padding-bottom: ${e.spacing(1)}; `,caret:O.css` margin-left: -${e.spacing(.5)}; // make it align with fields despite icon size `,heading:O.css` cursor: pointer; h6 { display: inline-block; } `,hidden:O.css` display: none; `,description:O.css` color: ${e.colors.text.secondary}; font-size: ${e.typography.size.sm}; font-weight: ${e.typography.fontWeightRegular}; margin: 0; `}),Z=e=>({collapsibleSection:O.css` margin: 0; padding: 0; `,wrapper:O.css` margin: ${e.spacing(2,0)}; padding: ${e.spacing(1)}; border: solid 1px ${e.colors.border.medium}; border-radius: ${e.shape.borderRadius(1)}; position: relative; `,description:O.css` color: ${e.colors.text.secondary}; font-size: ${e.typography.size.sm}; font-weight: ${e.typography.fontWeightRegular}; margin: 0; `,deleteIcon:O.css` position: absolute; right: ${e.spacing(1)}; top: ${e.spacing(1)}; `,addButton:O.css` margin-top: ${e.spacing(1)}; `}),H=e=>{var t;let{option:n,pathPrefix:a,errors:i,defaultValues:s,readOnly:l=!1}=e;const o=(0,r.useStyles2)(Z),c=`${a}${n.propertyName}`,d=(0,N.Gc)(),{fields:u,append:p,remove:m}=P({name:c,formAPI:d,defaults:s});return(0,w.jsx)("div",{className:o.wrapper,children:(0,w.jsxs)(z,{className:o.collapsibleSection,label:`${n.label} (${u.length})`,description:n.description,children:[(null!==(t=null!=u?u:s)&&void 0!==t?t:[]).map(((e,t)=>{var a;return(0,w.jsxs)("div",{className:o.wrapper,children:[!l&&(0,w.jsx)(B.A,{"data-testid":`${c}.${t}.delete-button`,icon:"trash-alt",tooltip:"delete",onClick:()=>m(t),className:o.deleteIcon}),null===(a=n.subformOptions)||void 0===a?void 0:a.map((n=>{var a;return(0,w.jsx)(Q,{readOnly:l,defaultValue:null==e?void 0:e[n.propertyName],option:n,pathPrefix:`${c}.${t}.`,error:null==i||null===(a=i[t])||void 0===a?void 0:a[n.propertyName]},n.propertyName)}))]},t)})),!l&&(0,w.jsx)(r.Button,{"data-testid":`${c}.add-button`,className:o.addButton,type:"button",variant:"secondary",icon:"plus",size:"sm",onClick:()=>p({__id:String(Math.random())}),children:"Add"})]})})},J=e=>{var t;let{option:n,pathPrefix:i,errors:s,defaultValue:l,readOnly:o=!1}=e;const c=(0,r.useStyles2)(Z),d=`${i}${n.propertyName}`,{watch:u}=(0,N.Gc)(),p=u(d),m=void 0===p?l:p,[h,g]=(0,a.useState)(!!m);return(0,w.jsxs)("div",{className:c.wrapper,"data-testid":`${d}.container`,children:[(0,w.jsx)("h6",{children:n.label}),n.description&&(0,w.jsx)("p",{className:c.description,children:n.description}),h&&(0,w.jsxs)(w.Fragment,{children:[!o&&(0,w.jsx)(B.A,{"data-testid":`${d}.delete-button`,icon:"trash-alt",tooltip:"delete",onClick:()=>g(!1),className:c.deleteIcon}),(null!==(t=n.subformOptions)&&void 0!==t?t:[]).map((e=>(0,w.jsx)(Q,{readOnly:o,defaultValue:null==l?void 0:l[e.propertyName],option:e,pathPrefix:`${d}.`,error:null==s?void 0:s[e.propertyName]},e.propertyName)))]}),!h&&!o&&(0,w.jsx)(r.Button,{className:c.addButton,type:"button",variant:"secondary",icon:"plus",size:"sm",onClick:()=>g(!0),"data-testid":`${d}.add-button`,children:"Add"})]})},K=["onChange","ref"];const Q=e=>{let{option:t,invalid:n,pathPrefix:a,pathSuffix:i="",error:s,defaultValue:l,readOnly:o=!1}=e;const c=`${a}${i}`;return"subform"===t.element?(0,w.jsx)(J,{readOnly:o,defaultValue:l,option:t,errors:s,pathPrefix:c}):"subform_array"===t.element?(0,w.jsx)(H,{readOnly:o,defaultValues:l,option:t,pathPrefix:c,errors:s}):(0,w.jsx)(r.Field,{label:"checkbox"!==t.element?t.label:void 0,description:t.description||void 0,invalid:!!s,error:null==s?void 0:s.message,children:(0,w.jsx)(X,{id:`${c}${t.propertyName}`,defaultValue:l,option:t,invalid:n,pathPrefix:c,readOnly:o,pathIndex:a})})},X=e=>{let{option:t,invalid:n,id:i,pathPrefix:s="",pathIndex:l="",readOnly:o=!1}=e;const{control:c,register:d,unregister:u,getValues:p}=(0,N.Gc)(),m=`${s}${t.propertyName}`;switch((0,a.useEffect)((()=>()=>{u(m,{keepValue:!1})}),[u,m]),t.element){case"checkbox":return(0,w.jsx)(r.Checkbox,Object.assign({id:i,readOnly:o,disabled:o,className:ee.checkbox},d(m),{label:t.label,description:t.description}));case"input":return(0,w.jsx)(r.Input,Object.assign({id:i,readOnly:o||ae(t,p,l),invalid:n,type:t.inputType},d(m,{required:ne(t,p,l),validate:e=>""===t.validationRule||te(e,t.validationRule)}),{placeholder:t.placeholder}));case"select":return(0,w.jsx)(r.InputControl,{render:e=>{var a;let{field:{onChange:i}}=e,s=function(e,t){if(null==e)return{};var n,a,i={},s=Object.keys(e);for(a=0;a=0||(i[n]=e[n]);return i}(e.field,K);return(0,w.jsx)(r.Select,Object.assign({disabled:o},s,{options:null!==(a=t.selectOptions)&&void 0!==a?a:void 0,invalid:n,onChange:e=>i(e.value)}))},control:c,name:m});case"textarea":return(0,w.jsx)(r.TextArea,Object.assign({id:i,readOnly:o,invalid:n},d(m,{required:!!t.required&&"Required",validate:e=>""===t.validationRule||te(e,t.validationRule)})));case"string_array":return(0,w.jsx)(r.InputControl,{render:e=>{let{field:{value:t,onChange:n}}=e;return(0,w.jsx)(G,{readOnly:o,value:t,onChange:n})},control:c,name:m});case"key_value_map":return(0,w.jsx)(r.InputControl,{render:e=>{let{field:{value:t,onChange:n}}=e;return(0,w.jsx)(F,{readOnly:o,value:t,onChange:n})},control:c,name:m});default:return console.error("Element not supported",t.element),null}},ee={checkbox:O.css` height: auto; // native checkbox has fixed height which does not take into account description `},te=(e,t)=>!!RegExp(t).test(e)||"Invalid format",ne=(e,t,n)=>{if(!e.dependsOn)return!!e.required&&"Required";if((0,v.isEmpty)(t(`${n}secureFields`))){const a=t(`${n}secureSettings.${e.dependsOn}`);return!(Boolean(a)||!e.required)&&"Required"}return!(t(`${n}secureFields.${e.dependsOn}`)||!e.required)&&"Required"},ae=(e,t,n)=>!!e.dependsOn&&((0,v.isEmpty)(t(`${n}secureFields`))?t(`${n}secureSettings.${e.dependsOn}`):t(`${n}secureFields.${e.dependsOn}`));function ie(e){let{defaultValues:t,selectedChannelOptions:n,onResetSecureField:a,secureFields:i,errors:s,pathPrefix:l="",readOnly:o=!1}=e;const{watch:c}=(0,N.Gc)(),d=c();return(0,w.jsx)(w.Fragment,{children:n.map(((e,n)=>{var c,u;const p=`${e.label}-${n}`,m=d[`${l}settings.${e.showWhen.field}`];if(e.showWhen.field&&m!==e.showWhen.is)return null;if(i&&i[e.propertyName])return(0,w.jsx)(r.Field,{label:e.label,description:e.description||void 0,children:(0,w.jsx)(r.Input,{readOnly:!0,value:"Configured",suffix:o?null:(0,w.jsx)(r.Button,{onClick:()=>a(e.propertyName),fill:"text",type:"button",size:"sm",children:"Clear"})})},p);const h=null===(c=e.secure?null==s?void 0:s.secureSettings:null==s?void 0:s.settings)||void 0===c?void 0:c[e.propertyName],g=null==t||null===(u=t.settings)||void 0===u?void 0:u[e.propertyName];return(0,w.jsx)(Q,{defaultValue:g,readOnly:o,error:h,pathPrefix:l,pathSuffix:e.secure?"secureSettings.":"settings.",option:e},p)}))})}const se=["ref","onChange"];function re(e){var t;let{defaultValues:n,pathPrefix:i,onDuplicate:s,onDelete:l,onTest:o,notifiers:c,errors:d,secureFields:u,commonSettingsComponent:p,readOnly:m=!1}=e;const h=(0,r.useStyles2)(le),g=e=>`${i}${e}`,{control:f,watch:x,register:v,trigger:y,formState:b,setValue:j}=(0,N.Gc)(),_=null!==(t=x(g("type")))&&void 0!==t?t:n.type,{loading:k}=(0,L._)((e=>e.testReceivers));(0,a.useEffect)((()=>{v(`${i}.__id`),v(`${i}.secureFields`)}),[v,i]);const[S,C]=(0,a.useState)(null!=u?u:{}),O=e=>{if(S[e]){const t=Object.assign({},u);delete t[e],C(t),j(`${i}.secureFields`,t)}},A=(0,a.useMemo)((()=>c.map((e=>{let{name:t,type:n}=e;return{label:t,value:n}})).sort(((e,t)=>e.label.localeCompare(t.label)))),[c]),$=c.find((e=>{let{type:t}=e;return t===_})),T=null==$?void 0:$.options.filter((e=>e.required)),P=null==$?void 0:$.options.filter((e=>!e.required)),M=`contact-point-type-${i}`;return(0,w.jsxs)("div",{className:h.wrapper,"data-testid":"item-container",children:[(0,w.jsxs)("div",{className:h.topRow,children:[(0,w.jsx)("div",{children:(0,w.jsx)(r.Field,{label:"Contact point type",htmlFor:M,"data-testid":`${i}type`,children:(0,w.jsx)(r.InputControl,{name:g("type"),defaultValue:n.type,render:e=>{let{field:{onChange:t}}=e,n=function(e,t){if(null==e)return{};var n,a,i={},s=Object.keys(e);for(a=0;a=0||(i[n]=e[n]);return i}(e.field,se);return(0,w.jsx)(r.Select,Object.assign({disabled:m,inputId:M},n,{width:37,options:A,onChange:e=>t(null==e?void 0:e.value)}))},control:f,rules:{required:!0}})})}),!m&&(0,w.jsxs)("div",{className:h.buttons,children:[o&&(0,w.jsx)(r.Button,{disabled:k,size:"xs",variant:"secondary",type:"button",onClick:()=>(async()=>{await y(),0===Object.keys(b.errors).length&&o&&o()})(),icon:k?"fa fa-spinner":"message",children:"Test"}),(0,w.jsx)(r.Button,{size:"xs",variant:"secondary",type:"button",onClick:()=>s(),icon:"copy",children:"Duplicate"}),l&&(0,w.jsx)(r.Button,{"data-testid":`${i}delete-button`,size:"xs",variant:"secondary",type:"button",onClick:()=>l(),icon:"trash-alt",children:"Delete"})]})]}),$&&(0,w.jsxs)("div",{className:h.innerContent,children:[(0,w.jsx)(ie,{defaultValues:n,selectedChannelOptions:null!=T&&T.length?T:P,secureFields:S,errors:d,onResetSecureField:O,pathPrefix:i,readOnly:m}),!(null==T||!T.length||null==P||!P.length)&&(0,w.jsxs)(z,{label:`Optional ${$.name} settings`,children:[""!==$.info&&(0,w.jsx)(r.Alert,{title:"",severity:"info",children:$.info}),(0,w.jsx)(ie,{defaultValues:n,selectedChannelOptions:P,secureFields:S,onResetSecureField:O,errors:d,pathPrefix:i,readOnly:m})]}),(0,w.jsx)(z,{label:"Notification settings",children:(0,w.jsx)(p,{pathPrefix:i,readOnly:m})})]})]})}const le=e=>({buttons:O.css` & > * + * { margin-left: ${e.spacing(1)}; } `,innerContent:O.css` max-width: 536px; `,wrapper:O.css` margin: ${e.spacing(2,0)}; padding: ${e.spacing(1)}; border: solid 1px ${e.colors.border.medium}; border-radius: ${e.shape.borderRadius(1)}; max-width: ${e.breakpoints.values.xl}${e.breakpoints.unit}; `,topRow:O.css` display: flex; flex-direction: row; justify-content: space-between; `,channelSettingsHeader:O.css` margin-top: ${e.spacing(2)}; `});function oe(e){let{pathPrefix:t}=e;const{register:n}=(0,N.Gc)();return(0,a.useEffect)((()=>{n(`${t}.__id`),n(`${t}.__deleted`)}),[n,t]),(0,w.jsx)(w.Fragment,{})}var ce,de,ue;function pe(e){let{config:t,initialValues:n,defaultItem:i,notifiers:s,alertManagerSourceName:l,onSubmit:o,onTestChannel:c,takenReceiverNames:u,commonSettingsComponent:p}=e;const m=(0,A.iG)(),h=(0,r.useStyles2)(me),g=(0,d.RY)(l),f=n||{name:"",items:[Object.assign({},i,{__id:String(Math.random())})]},x=(0,N.cI)({defaultValues:JSON.parse(JSON.stringify(f))});(0,$.x)((e=>e.unifiedAlerting.saveAMConfig));const{loading:v}=(0,L._)((e=>e.saveAMConfig)),{handleSubmit:y,register:b,formState:{errors:j},getValues:_}=x,{fields:k,append:S,remove:C}=P({name:"items",formAPI:x,softDelete:!0}),O=(0,a.useCallback)((e=>!u.map((e=>e.trim().toLowerCase())).includes(e.trim().toLowerCase())||"Another receiver with this name already exists."),[u]);return(0,w.jsxs)(N.RV,Object.assign({},x,{children:[!t.alertmanager_config.route&&(ce||(ce=(0,w.jsx)(r.Alert,{severity:"warning",title:"Attention",children:"Because there is no default policy configured yet, this contact point will automatically be set as default."}))),(0,w.jsxs)("form",{onSubmit:y((e=>{o(Object.assign({},e,{items:e.items.filter((e=>!e.__deleted))}))}),(()=>{m.error("There are errors in the form. Please correct them and try again!")})),children:[(0,w.jsx)("h4",{className:h.heading,children:g?"Contact point":n?"Update contact point":"Create contact point"}),(0,w.jsx)(r.Field,{label:"Name",invalid:!!j.name,error:j.name&&j.name.message,required:!0,children:(0,w.jsx)(r.Input,Object.assign({readOnly:g,id:"name"},b("name",{required:"Name is required",validate:{nameIsAvailable:O}}),{width:39,placeholder:"Name"}))}),k.map(((e,t)=>{var a;const i=`items.${t}.`;if(e.__deleted)return(0,w.jsx)(oe,{pathPrefix:i},e.__id);const r=null==n?void 0:n.items.find((t=>{let{__id:n}=t;return n===e.__id}));return(0,w.jsx)(re,{defaultValues:e,onDuplicate:()=>{const e=_().items[t];S(Object.assign({},e,{__id:String(Math.random())}))},onTest:c?()=>{const e=_().items[t];c(e)}:void 0,onDelete:()=>C(t),pathPrefix:i,notifiers:s,secureFields:null==r?void 0:r.secureFields,errors:null==j||null===(a=j.items)||void 0===a?void 0:a[t],commonSettingsComponent:p,readOnly:g},e.__id)})),(0,w.jsxs)(w.Fragment,{children:[!g&&(0,w.jsx)(r.Button,{type:"button",icon:"plus",variant:"secondary",onClick:()=>S(Object.assign({},i,{__id:String(Math.random())})),children:"New contact point type"}),(0,w.jsxs)("div",{className:h.buttons,children:[!g&&(0,w.jsxs)(w.Fragment,{children:[v&&(de||(de=(0,w.jsx)(r.Button,{disabled:!0,icon:"fa fa-spinner",variant:"primary",children:"Saving..."}))),!v&&(ue||(ue=(0,w.jsx)(r.Button,{type:"submit",children:"Save contact point"})))]}),(0,w.jsx)(r.LinkButton,{disabled:v,fill:"outline",variant:"secondary","data-testid":"cancel-button",href:(0,q.eQ)("alerting/notifications",l),children:"Cancel"})]})]})]})]}))}const me=e=>({heading:O.css` margin: ${e.spacing(4,0)}; `,buttons:O.css` margin-top: ${e.spacing(4)}; & > * + * { margin-left: ${e.spacing(1)}; } `});var he;const ge=Object.freeze({__id:"",sendResolved:!0,secureSettings:{},settings:{},secureFields:{},type:"email"}),fe=e=>{let{existing:t,alertManagerSourceName:n,config:s}=e;const l=(0,i.useDispatch)(),o=(0,d.RY)(n),[c]=(0,a.useMemo)((()=>t?b(t,f):[void 0,{}]),[t]),p=(0,a.useMemo)((()=>{var e,n;return null!==(e=null===(n=s.alertmanager_config.receivers)||void 0===n?void 0:n.map((e=>{let{name:t}=e;return t})).filter((e=>e!==(null==t?void 0:t.name))))&&void 0!==e?e:[]}),[s,t]);return(0,w.jsxs)(w.Fragment,{children:[!o&&(he||(he=(0,w.jsx)(r.Alert,{title:"Info",severity:"info",children:"Note that empty string values will be replaced with global defaults where appropriate."}))),(0,w.jsx)(pe,{config:s,onSubmit:e=>{const a=function(e,t){const n={name:e.name};return e.items.forEach((e=>{let{__id:a,type:i,settings:s,sendResolved:r}=e;const l=S(Object.assign({},s,{send_resolved:null!=r?r:t.sendResolved})),o=`${i}_configs`;n[o]?n[o].push(l):n[o]=[l]})),n}(e,ge);l((0,u.mM)({newConfig:j(s,a,null==t?void 0:t.name),oldConfig:s,alertManagerSourceName:n,successMessage:t?"Contact point updated.":"Contact point created.",redirectPath:"/alerting/notifications"}))},initialValues:c,notifiers:f,alertManagerSourceName:n,defaultItem:ge,takenReceiverNames:p,commonSettingsComponent:C})]})},xe=e=>{let{pathPrefix:t,className:n}=e;const{register:a}=(0,N.Gc)();return(0,w.jsx)("div",{className:n,children:(0,w.jsx)(r.Field,{children:(0,w.jsx)(r.Checkbox,Object.assign({},a(`${t}disableResolveMessage`),{label:"Disable resolved message",description:"Disable the resolve message [OK] that is sent when alerting state returns to false"}))})})};var ve,ye,be,je,_e,ke,Se=n(93783),Ne=n(2394);!function(e){e.predefined="Predefined",e.custom="Custom"}(ke||(ke={}));const we=Object.values(ke).map((e=>({label:e,value:e}))),Ce={annotations:[{key:"",value:""}],labels:[{key:"",value:""}]},Oe=e=>{let{isOpen:t,onDismiss:n,onTest:i}=e;const[s,l]=(0,a.useState)(ke.predefined),o=(0,r.useStyles2)(Ae),c=(0,N.cI)({defaultValues:Ce,mode:"onBlur"});return(0,w.jsxs)(r.Modal,{onDismiss:n,isOpen:t,title:"Test contact point",children:[(0,w.jsxs)("div",{className:o.section,children:[ve||(ve=(0,w.jsx)(r.Label,{children:"Notification message"})),(0,w.jsx)(r.RadioButtonGroup,{options:we,value:s,onChange:e=>l(e)})]}),(0,w.jsx)(N.RV,Object.assign({},c,{children:(0,w.jsxs)("form",{onSubmit:c.handleSubmit((e=>{if(s===ke.custom){const t={annotations:e.annotations.filter((e=>{let{key:t,value:n}=e;return!!t&&!!n})).reduce(((e,t)=>{let{key:n,value:a}=t;return Object.assign({},e,{[n]:a})}),{}),labels:e.labels.filter((e=>{let{key:t,value:n}=e;return!!t&&!!n})).reduce(((e,t)=>{let{key:n,value:a}=t;return Object.assign({},e,{[n]:a})}),{})};i(t)}else i()})),children:[s===ke.predefined&&(0,w.jsxs)("div",{className:o.section,children:["You will send a test notification that uses a predefined alert. If you have defined a custom template or message, for better results switch to ",ye||(ye=(0,w.jsx)("strong",{children:"custom"}))," notification message, from above."]}),s===ke.custom&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("div",{className:o.section,children:"You will send a test notification that uses the annotations defined below. This is a good option if you use custom templates and messages."}),(0,w.jsx)("div",{className:o.section,children:be||(be=(0,w.jsx)(Se.Z,{}))}),(0,w.jsx)("div",{className:o.section,children:je||(je=(0,w.jsx)(Ne.Z,{}))})]}),_e||(_e=(0,w.jsx)(r.Modal.ButtonRow,{children:(0,w.jsx)(r.Button,{type:"submit",children:"Send test notification"})}))]})}))]})},Ae=e=>({flexRow:O.css` display: flex; flex-direction: row; align-items: flex-start; margin-bottom: ${e.spacing(1)}; `,section:O.css` margin-bottom: ${e.spacing(2)}; `});var $e;const Te=Object.freeze({__id:"",secureSettings:{},settings:{},secureFields:{},disableResolveMessage:!1,type:"email"}),Pe=e=>{let{existing:t,alertManagerSourceName:n,config:s}=e;const l=(0,L._)((e=>e.grafanaNotifiers)),[o,c]=(0,a.useState)(),p=(0,i.useDispatch)();(0,a.useEffect)((()=>{l.result||l.loading||p((0,u.Vj)())}),[l,p]);const[m,h]=(0,a.useMemo)((()=>t&&l.result?y(t,l.result):[void 0,{}]),[t,l.result]),g=e=>{const n=function(e,t,n){var a;return{name:e.name,grafana_managed_receiver_configs:(null!==(a=e.items)&&void 0!==a?a:[]).map((a=>{const i=t[a.__id];return k(a,n,e.name,i)}))}}(e,h,Te);p((0,u.mM)({newConfig:j(s,n,null==t?void 0:t.name),oldConfig:s,alertManagerSourceName:d.GC,successMessage:t?"Contact point updated.":"Contact point created",redirectPath:"/alerting/notifications"}))},f=e=>{c(e)},x=(0,a.useMemo)((()=>{var e,n;return null!==(e=null===(n=s.alertmanager_config.receivers)||void 0===n?void 0:n.map((e=>{let{name:t}=e;return t})).filter((e=>e!==(null==t?void 0:t.name))))&&void 0!==e?e:[]}),[s,t]);return l.result?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(pe,{config:s,onSubmit:g,initialValues:m,onTestChannel:f,notifiers:l.result,alertManagerSourceName:n,defaultItem:Te,takenReceiverNames:x,commonSettingsComponent:xe}),(0,w.jsx)(Oe,{onDismiss:()=>c(void 0),isOpen:!!o,onTest:e=>(e=>{if(o){const t=h[o.__id],a=k(o,Te,"test",t),i={alertManagerSourceName:n,receivers:[{name:"test",grafana_managed_receiver_configs:[a]}],alert:e};p((0,u.D8)(i))}})(e)})]}):$e||($e=(0,w.jsx)(r.LoadingPlaceholder,{text:"Loading notifiers..."}))};var Me;const Re=e=>{var t;let{config:n,receiverName:a,alertManagerSourceName:i}=e;const s=null===(t=n.alertmanager_config.receivers)||void 0===t?void 0:t.find((e=>{let{name:t}=e;return t===a}));return s?i===d.GC?(0,w.jsx)(Pe,{config:n,alertManagerSourceName:i,existing:s}):(0,w.jsx)(fe,{config:n,alertManagerSourceName:i,existing:s}):Me||(Me=(0,w.jsx)(r.InfoBox,{severity:"error",title:"Receiver not found",children:"Sorry, this receiver does not seem to exit."}))};var Ie,Le;const qe=Object.freeze({name:"",content:""}),Be=e=>{var t,n,a,s,l;let{existing:o,alertManagerSourceName:c,config:d}=e;const p=(0,r.useStyles2)(Fe),m=(0,i.useDispatch)();(0,$.x)((e=>e.unifiedAlerting.saveAMConfig));const{loading:h,error:g}=(0,L._)((e=>e.saveAMConfig)),{handleSubmit:f,register:x,formState:{errors:v}}=(0,N.cI)({mode:"onSubmit",defaultValues:null!=o?o:qe});return(0,w.jsxs)("form",{onSubmit:f((e=>{var t;const n=function(e,t){let n=t.trim();if(!n.match(/\{\{\s*define/)){const t=n.split("\n").map((e=>" "+e)).join("\n");n=`{{ define "${e}" }}\n${t}\n{{ end }}`}return n}(e.name,e.content),a=Object.assign({},d.template_files,{[e.name]:n});o&&o.name!==e.name&&delete a[o.name];const i=[...(null!==(t=d.alertmanager_config.templates)&&void 0!==t?t:[]).filter((e=>e!==(null==o?void 0:o.name))),e.name],s={template_files:a,alertmanager_config:Object.assign({},d.alertmanager_config,{templates:i})};m((0,u.mM)({alertManagerSourceName:c,newConfig:s,oldConfig:d,successMessage:"Template saved.",redirectPath:"/alerting/notifications"}))})),children:[(0,w.jsx)("h4",{children:o?"Edit message template":"Create message template"}),g&&(0,w.jsx)(r.Alert,{severity:"error",title:"Error saving template",children:g.message||(null==g||null===(t=g.data)||void 0===t?void 0:t.message)||String(g)}),(0,w.jsx)(r.Field,{label:"Template name",error:null==v||null===(n=v.name)||void 0===n?void 0:n.message,invalid:!(null===(a=v.name)||void 0===a||!a.message),required:!0,children:(0,w.jsx)(r.Input,Object.assign({},x("name",{required:{value:!0,message:"Required."},validate:{nameIsUnique:e=>!d.template_files[e]||(null==o?void 0:o.name)===e||"Another template with this name already exists."}}),{placeholder:"Give your template a name",width:42,autoFocus:!0}))}),(0,w.jsx)(r.Field,{description:(0,w.jsxs)(w.Fragment,{children:["You can use the"," ",(0,w.jsx)("a",{href:"https://pkg.go.dev/text/template?utm_source=godoc",target:"__blank",rel:"noreferrer",className:p.externalLink,children:"Go templating language"}),"."," ",(0,w.jsx)("a",{href:"https://prometheus.io/blog/2016/03/03/custom-alertmanager-templates/",target:"__blank",rel:"noreferrer",className:p.externalLink,children:"More info about alertmanager templates"})]}),label:"Content",error:null==v||null===(s=v.content)||void 0===s?void 0:s.message,invalid:!(null===(l=v.content)||void 0===l||!l.message),required:!0,children:(0,w.jsx)(r.TextArea,Object.assign({},x("content",{required:{value:!0,message:"Required."}}),{className:p.textarea,placeholder:"Message",rows:12}))}),(0,w.jsxs)("div",{className:p.buttons,children:[h&&(Ie||(Ie=(0,w.jsx)(r.Button,{disabled:!0,icon:"fa fa-spinner",variant:"primary",children:"Saving..."}))),!h&&(Le||(Le=(0,w.jsx)(r.Button,{type:"submit",variant:"primary",children:"Save template"}))),(0,w.jsx)(r.LinkButton,{disabled:h,href:(0,q.eQ)("alerting/notifications",c),variant:"secondary",type:"button",fill:"outline",children:"Cancel"})]})]})},Fe=e=>({externalLink:O.css` color: ${e.colors.text.secondary}; text-decoration: underline; `,buttons:O.css` & > * + * { margin-left: ${e.spacing(1)}; } `,textarea:O.css` max-width: 758px; `});var De;const Ve=e=>{var t;let{config:n,templateName:a,alertManagerSourceName:i}=e;const s=null===(t=n.template_files)||void 0===t?void 0:t[a];return s?(0,w.jsx)(Be,{alertManagerSourceName:i,config:n,existing:{name:a,content:s}}):De||(De=(0,w.jsx)(r.InfoBox,{severity:"error",title:"Template not found",children:"Sorry, this template does not seem to exit."}))};var Ee,Ge;const Ue={smtp_require_tls:!0},We=e=>{var t;let{config:n,alertManagerSourceName:a}=e;const s=(0,i.useDispatch)();(0,$.x)((e=>e.unifiedAlerting.saveAMConfig));const{loading:l,error:o}=(0,L._)((e=>e.saveAMConfig)),c=(0,d.RY)(a),p=(0,r.useStyles2)(ze),m=(0,N.cI)({defaultValues:JSON.parse(JSON.stringify(Object.assign({},Ue,null!==(t=n.alertmanager_config.global)&&void 0!==t?t:{})))}),{handleSubmit:h,formState:{errors:g}}=m;return(0,w.jsx)(N.RV,Object.assign({},m,{children:(0,w.jsxs)("form",{onSubmit:h((e=>{s((0,u.mM)({newConfig:Object.assign({},n,{alertmanager_config:Object.assign({},n.alertmanager_config,{global:S(e)})}),oldConfig:n,alertManagerSourceName:a,successMessage:"Global config updated.",redirectPath:(0,q.eQ)("/alerting/notifications",a)}))})),children:[(0,w.jsx)("h4",{className:p.heading,children:"Global config"}),o&&(0,w.jsx)(r.Alert,{severity:"error",title:"Error saving receiver",children:o.message||String(o)}),x.map((e=>(0,w.jsx)(Q,{readOnly:c,defaultValue:Ue[e.propertyName],option:e,error:g[e.propertyName],pathPrefix:""},e.propertyName))),(0,w.jsx)("div",{children:(0,w.jsxs)(r.HorizontalGroup,{children:[!c&&(0,w.jsxs)(w.Fragment,{children:[l&&(Ee||(Ee=(0,w.jsx)(r.Button,{disabled:!0,icon:"fa fa-spinner",variant:"primary",children:"Saving..."}))),!l&&(Ge||(Ge=(0,w.jsx)(r.Button,{type:"submit",children:"Save global config"})))]}),(0,w.jsx)(r.LinkButton,{disabled:l,fill:"outline",variant:"secondary",href:(0,q.eQ)("alerting/notifications",a),children:"Cancel"})]})})]})}))},ze=e=>({heading:O.css` margin: ${e.spacing(4,0)}; `}),Ye=e=>{let{alertManagerSourceName:t,config:n}=e;return t===d.GC?(0,w.jsx)(Pe,{alertManagerSourceName:t,config:n}):(0,w.jsx)(fe,{alertManagerSourceName:t,config:n})},Ze=e=>{let{config:t,alertManagerSourceName:n}=e;return(0,w.jsx)(Be,{config:t,alertManagerSourceName:n})};var He=n(58170),Je=n(53262),Ke=n(61959),Qe=n(12783),Xe=n(82969),et=n(82139);const tt={pagerduty:"PagerDuty",pushover:"Pushover",slack:"Slack",opsgenie:"OpsGenie",webhook:"Webhook",victorops:"VictorOps",wechat:"WeChat"};function nt(e,t){var n;return e.grafana_managed_receiver_configs?function(e,t){return e.map((e=>e.type)).map((e=>{var n,a;return null!==(n=null===(a=t.find((t=>t.type===e)))||void 0===a?void 0:a.name)&&void 0!==n?n:(0,v.capitalize)(e)})).reduce(((e,t)=>{var n;return Object.assign({},e,{[t]:(null!==(n=e[t])&&void 0!==n?n:0)+1})}),{})}(null!==(n=e.grafana_managed_receiver_configs)&&void 0!==n?n:[],t):function(e){return Object.entries(e).filter((e=>{let[t]=e;return"grafana_managed_receiver_configs"!==t&&t.endsWith("_configs")})).filter((e=>{let[t,n]=e;return Array.isArray(n)&&!!n.length})).reduce(((e,t)=>{var n,a;let[i,s]=t;const r=i.replace("_configs",""),l=null!==(n=tt[r])&&void 0!==n?n:(0,v.capitalize)(r);return Object.assign({},e,{[l]:(null!==(a=e[l])&&void 0!==a?a:0)+(Array.isArray(s)?s.length:1)})}),{})}(e)}var at=n(43397);const it=e=>{let{className:t,title:n,description:a,addButtonLabel:i,addButtonTo:s,children:l,showButton:o=!0}=e;const c=(0,r.useStyles2)(st);return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)("div",{className:(0,O.cx)(c.heading,t),children:[(0,w.jsxs)("div",{children:[(0,w.jsx)("h4",{children:n}),(0,w.jsx)("p",{className:c.description,children:a})]}),o&&(0,w.jsx)(at.Link,{to:s,children:(0,w.jsx)(r.Button,{type:"button",icon:"plus",children:i})})]}),l]})},st=e=>({heading:O.css` display: flex; justify-content: space-between; `,description:O.css` color: ${e.colors.text.secondary}; `});var rt,lt,ot,ct,dt,ut,pt,mt;const ht=e=>{let{config:t,alertManagerName:n}=e;const s=(0,i.useDispatch)(),l=(0,r.useStyles2)(Qe.D),o=(0,r.useStyles2)(gt),c=(0,d.RY)(n),p=(0,Xe.Ko)(n),m=(0,L._)((e=>e.grafanaNotifiers)),[h,g]=(0,a.useState)(),[f,x]=(0,a.useState)(!1),v=(0,a.useMemo)((()=>{var e,n;return null!==(e=null===(n=t.alertmanager_config.receivers)||void 0===n?void 0:n.map((e=>{var t;return{name:e.name,types:Object.entries(nt(e,null!==(t=m.result)&&void 0!==t?t:[])).map((e=>{let[t,n]=e;return n>1?`${t} (${n})`:t}))}})))&&void 0!==e?e:[]}),[t,m.result]);return(0,w.jsxs)(it,{className:o.section,title:"Contact points",description:"Define where the notifications will be sent to, for example email or Slack.",showButton:!c&&Ke.Vt.hasPermission(p.create),addButtonLabel:"New contact point",addButtonTo:(0,q.eQ)("/alerting/notifications/receivers/new",n),children:[(0,w.jsxs)("table",{className:l.table,"data-testid":"receivers-table",children:[(0,w.jsxs)("colgroup",{children:[rt||(rt=(0,w.jsx)("col",{})),lt||(lt=(0,w.jsx)("col",{})),(0,w.jsx)(Je.q,{actions:[p.update,p.delete],children:ot||(ot=(0,w.jsx)("col",{}))})]}),(0,w.jsx)("thead",{children:(0,w.jsxs)("tr",{children:[ct||(ct=(0,w.jsx)("th",{children:"Contact point name"})),dt||(dt=(0,w.jsx)("th",{children:"Type"})),(0,w.jsx)(Je.q,{actions:[p.update,p.delete],children:ut||(ut=(0,w.jsx)("th",{children:"Actions"}))})]})}),(0,w.jsxs)("tbody",{children:[!v.length&&(0,w.jsx)("tr",{className:l.evenRow,children:pt||(pt=(0,w.jsx)("td",{colSpan:3,children:"No receivers defined."}))}),v.map(((e,a)=>(0,w.jsxs)("tr",{className:a%2==0?l.evenRow:void 0,children:[(0,w.jsx)("td",{children:e.name}),(0,w.jsx)("td",{children:e.types.join(", ")}),(0,w.jsx)(Je.q,{actions:[p.update,p.delete],children:(0,w.jsxs)("td",{className:l.actionsCell,children:[!c&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(Je.q,{actions:[p.update],children:(0,w.jsx)(B.A,{"aria-label":"Edit","data-testid":"edit",to:(0,q.eQ)(`/alerting/notifications/receivers/${encodeURIComponent(e.name)}/edit`,n),tooltip:"Edit contact point",icon:"pen"})}),(0,w.jsx)(Je.q,{actions:[p.delete],children:(0,w.jsx)(B.A,{onClick:()=>{return n=e.name,void((0,et.nv)(n,t)?x(!0):g(n));var n},tooltip:"Delete contact point",icon:"trash-alt"})})]}),c&&(0,w.jsx)(Je.q,{actions:[p.update],children:(0,w.jsx)(B.A,{"data-testid":"view",to:(0,q.eQ)(`/alerting/notifications/receivers/${encodeURIComponent(e.name)}/edit`,n),tooltip:"View contact point",icon:"file-alt"})})]})})]},e.name)))]})]}),!!f&&(0,w.jsxs)(r.Modal,{isOpen:!0,title:"Cannot delete contact point",onDismiss:()=>x(!1),children:[mt||(mt=(0,w.jsx)("p",{children:"Contact point cannot be deleted because it is used in more policies. Please update or delete these policies first."})),(0,w.jsx)(r.Modal.ButtonRow,{children:(0,w.jsx)(r.Button,{variant:"secondary",onClick:()=>x(!1),fill:"outline",children:"Close"})})]}),!!h&&(0,w.jsx)(r.ConfirmModal,{isOpen:!0,title:"Delete contact point",body:`Are you sure you want to delete contact point "${h}"?`,confirmText:"Yes, delete",onConfirm:()=>{h&&s((0,u.X4)(h,n)),g(void 0)},onDismiss:()=>g(void 0)})]})},gt=e=>({section:O.css` margin-top: ${e.spacing(4)}; `});var ft,xt,vt,yt,bt,jt,_t,kt=n(52510);const St=e=>{let{config:t,alertManagerName:n}=e;const s=(0,i.useDispatch)(),[l,o]=(0,a.useState)({}),c=(0,r.useStyles2)(Qe.D),d=(0,Xe.Ko)(n),p=(0,a.useMemo)((()=>Object.entries(t.template_files)),[t]),[m,h]=(0,a.useState)();return(0,w.jsxs)(it,{title:"Message templates",description:"Templates construct the messages that get sent to the contact points.",addButtonLabel:"New template",addButtonTo:(0,q.eQ)("/alerting/notifications/templates/new",n),showButton:Ke.Vt.hasPermission(d.create),children:[(0,w.jsxs)("table",{className:c.table,"data-testid":"templates-table",children:[(0,w.jsxs)("colgroup",{children:[(0,w.jsx)("col",{className:c.colExpand}),ft||(ft=(0,w.jsx)("col",{})),xt||(xt=(0,w.jsx)("col",{}))]}),(0,w.jsx)("thead",{children:(0,w.jsxs)("tr",{children:[vt||(vt=(0,w.jsx)("th",{})),yt||(yt=(0,w.jsx)("th",{children:"Template"})),(0,w.jsx)(Je.q,{actions:[d.update,d.delete],children:bt||(bt=(0,w.jsx)("th",{children:"Actions"}))})]})}),(0,w.jsxs)("tbody",{children:[!p.length&&(0,w.jsx)("tr",{className:c.evenRow,children:jt||(jt=(0,w.jsx)("td",{colSpan:3,children:"No templates defined."}))}),p.map(((e,t)=>{let[i,s]=e;const r=!!l[i];return(0,w.jsxs)(a.Fragment,{children:[(0,w.jsxs)("tr",{className:t%2==0?c.evenRow:void 0,children:[(0,w.jsx)("td",{children:(0,w.jsx)(W.U,{isCollapsed:!l[i],onToggle:()=>o(Object.assign({},l,{[i]:!r}))})}),(0,w.jsx)("td",{children:i}),(0,w.jsx)(Je.q,{actions:[d.update,d.delete],children:(0,w.jsxs)("td",{className:c.actionsCell,children:[(0,w.jsx)(Je.q,{actions:[d.update],children:(0,w.jsx)(B.A,{to:(0,q.eQ)(`/alerting/notifications/templates/${encodeURIComponent(i)}/edit`,n),tooltip:"edit template",icon:"pen"})}),(0,w.jsx)(Je.q,{actions:[d.delete],children:(0,w.jsx)(B.A,{onClick:()=>h(i),tooltip:"delete template",icon:"trash-alt"})})]})})]},i),r&&(0,w.jsxs)("tr",{className:t%2==0?c.evenRow:void 0,children:[_t||(_t=(0,w.jsx)("td",{})),(0,w.jsx)("td",{colSpan:2,children:(0,w.jsx)(kt.C,{label:"Description",horizontal:!0,children:(0,w.jsx)("pre",{children:s})})})]})]},i)}))]})]}),!!m&&(0,w.jsx)(r.ConfirmModal,{isOpen:!0,title:"Delete template",body:`Are you sure you want to delete template "${m}"?`,confirmText:"Yes, delete",onConfirm:()=>{m&&s((0,u.S6)(m,n)),h(void 0)},onDismiss:()=>h(void 0)})]})};var Nt;const wt=e=>{let{config:t,alertManagerName:n}=e;const a=n!==d.GC,i=(0,r.useStyles2)(Ct),s=(0,d.RY)(n);return(0,w.jsxs)(w.Fragment,{children:[!s&&(0,w.jsx)(St,{config:t,alertManagerName:n}),(0,w.jsx)(ht,{config:t,alertManagerName:n}),a&&(0,w.jsx)(Je.q,{actions:[He.bW.AlertingNotificationsExternalWrite],children:(0,w.jsxs)(r.Alert,{className:i.section,severity:"info",title:"Global config for contact points",children:[Nt||(Nt=(0,w.jsx)("p",{children:"For each external Alertmanager you can define global settings, like server addresses, usernames and password, for all the supported contact points."})),(0,w.jsx)(r.LinkButton,{href:(0,q.eQ)("alerting/notifications/global-config",n),variant:"secondary",children:s?"View global config":"Edit global config"})]})})]})},Ct=e=>({section:O.css` margin-top: ${e.spacing(4)}; `});var Ot,At,$t=n(82498),Tt=n(1698),Pt=n(8455);const Mt=(0,r.withErrorBoundary)((()=>{const e=(0,Tt.k)("notification"),[t,n]=(0,$t.k)(e),p=(0,i.useDispatch)(),m=(0,s.TH)().pathname.endsWith("/alerting/notifications"),h=(0,L._)((e=>e.amConfigs)),{result:g,loading:f,error:x}=t&&h[t]||Pt.oq,v=(0,L._)((e=>e.grafanaNotifiers)),y=m||!g;(0,a.useEffect)((()=>{t&&y&&p((0,u.Yh)(t))}),[t,p,y]),(0,a.useEffect)((()=>{t!==d.GC||v.result||v.loading||v.error||p((0,u.Vj)())}),[t,p,v]);const b=!m;return t?(0,w.jsxs)(o.J,{pageId:"receivers",children:[(0,w.jsx)(l.P,{current:t,disabled:b,onChange:n,dataSources:e}),x&&!f&&(0,w.jsx)(r.Alert,{severity:"error",title:"Error loading Alertmanager config",children:x.message||"Unknown error."}),f&&!g&&(At||(At=(0,w.jsx)(r.LoadingPlaceholder,{text:"loading configuration..."}))),g&&!x&&(0,w.jsxs)(s.rs,{children:[(0,w.jsx)(s.AW,{exact:!0,path:"/alerting/notifications",children:(0,w.jsx)(wt,{config:g,alertManagerName:t})}),(0,w.jsx)(s.AW,{exact:!0,path:"/alerting/notifications/templates/new",children:(0,w.jsx)(Ze,{config:g,alertManagerSourceName:t})}),(0,w.jsx)(s.AW,{exact:!0,path:"/alerting/notifications/templates/:name/edit",children:e=>{let{match:n}=e;return(null==n?void 0:n.params.name)&&(0,w.jsx)(Ve,{alertManagerSourceName:t,config:g,templateName:decodeURIComponent(null==n?void 0:n.params.name)})}}),(0,w.jsx)(s.AW,{exact:!0,path:"/alerting/notifications/receivers/new",children:(0,w.jsx)(Ye,{config:g,alertManagerSourceName:t})}),(0,w.jsx)(s.AW,{exact:!0,path:"/alerting/notifications/receivers/:name/edit",children:e=>{let{match:n}=e;return(null==n?void 0:n.params.name)&&(0,w.jsx)(Re,{alertManagerSourceName:t,config:g,receiverName:decodeURIComponent(null==n?void 0:n.params.name)})}}),(0,w.jsx)(s.AW,{exact:!0,path:"/alerting/notifications/global-config",children:(0,w.jsx)(We,{config:g,alertManagerSourceName:t})})]})]}):m?(0,w.jsx)(o.J,{pageId:"receivers",children:(0,w.jsx)(c.I,{availableAlertManagers:e})}):Ot||(Ot=(0,w.jsx)(s.l_,{to:"/alerting/notifications"}))}),{style:"page"})},40256:(e,t,n)=>{n.d(t,{J:()=>l});n(68404);var a=n(18745),i=n(33801),s=n(8674),r=n(45916);const l=e=>{let{children:t,pageId:n,isLoading:l}=e;const o=(0,s.h)((0,a.useSelector)((e=>e.navIndex)),n);return(0,r.jsx)(i.Z,{navModel:o,children:(0,r.jsx)(i.Z.Contents,{isLoading:l,children:t})})}},53262:(e,t,n)=>{n.d(t,{q:()=>s});n(68404);var a=n(61959),i=n(45916);const s=e=>{let{actions:t,children:n,fallback:s=!0}=e;return t.some((e=>a.Vt.hasAccess(e,s)))?(0,i.jsx)(i.Fragment,{children:n}):null}},71308:(e,t,n)=>{n.d(t,{I:()=>m});n(68404);var a,i,s,r,l=n(69783),o=n(82498),c=n(50489),d=n(45916);const u=()=>a||(a=(0,d.jsx)(l.Alert,{title:"No Alertmanager found",severity:"warning",children:"We could not find any external Alertmanagers and you may not have access to the built-in Grafana Alertmanager."})),p=()=>i||(i=(0,d.jsx)(l.Alert,{title:"Selected Alertmanager not found. Select a different Alertmanager.",severity:"warning",children:"Selected Alertmanager no longer exists or you may not have permission to access it."})),m=e=>{let{availableAlertManagers:t}=e;const[n,a]=(0,o.k)(t),i=t.length>0;return(0,d.jsx)("div",{children:i?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(c.P,{onChange:a,dataSources:t}),s||(s=(0,d.jsx)(p,{}))]}):r||(r=(0,d.jsx)(u,{}))})}},93783:(e,t,n)=>{n.d(t,{Z:()=>g});var a=n(36636),i=n(68404),s=n(80916),r=n(69783),l=n(85464),o=n(19854),c=n(45916);const d=["value","existingKeys","aria-label"];const u=e=>{let{value:t,existingKeys:n,"aria-label":a}=e,s=function(e,t){if(null==e)return{};var n,a,i={},s=Object.keys(e);for(a=0;a=0||(i[n]=e[n]);return i}(e,d);const r=(0,i.useMemo)((()=>Object.values(l.q6).filter((e=>!n.includes(e))).map((e=>({value:e,label:l.vY[e]})))),[n]);return(0,c.jsx)(o.P,Object.assign({"aria-label":a,value:t,options:r,custom:!!t&&!Object.values(l.q6).includes(t)},s))},p=["ref"];var m;const h=e=>({annotationValueInput:a.css` width: 426px; `,textarea:a.css` height: 76px; `,addAnnotationsButton:a.css` flex-grow: 0; align-self: flex-start; margin-left: 148px; `,flexColumn:a.css` display: flex; flex-direction: column; `,field:a.css` margin-bottom: ${e.spacing.xs}; `,flexRow:a.css` display: flex; flex-direction: row; justify-content: flex-start; `,flexRowItemMargin:a.css` margin-left: ${e.spacing.xs}; `}),g=()=>{const e=(0,r.useStyles)(h),{control:t,register:n,watch:l,formState:{errors:o}}=(0,s.Gc)(),d=l("annotations"),g=(0,i.useCallback)((e=>d.filter(((t,n)=>n!==e)).map((e=>{let{key:t}=e;return t}))),[d]);return(0,c.jsxs)(c.Fragment,{children:[m||(m=(0,c.jsx)(r.Label,{children:"Summary and annotations"})),(0,c.jsx)(r.FieldArray,{name:"annotations",control:t,children:i=>{let{fields:s,append:l,remove:m}=i;return(0,c.jsxs)("div",{className:e.flexColumn,children:[s.map(((i,s)=>{var l,h,f,x,v,y,b,j,_,k,S,N,w,C,O;const A=null===(l=d[s])||void 0===l||null===(h=l.key)||void 0===h?void 0:h.toLocaleLowerCase().endsWith("url"),$=A?r.Input:r.TextArea;return(0,c.jsxs)("div",{className:e.flexRow,children:[(0,c.jsx)(r.Field,{className:e.field,invalid:!(null===(f=o.annotations)||void 0===f||null===(x=f[s])||void 0===x||null===(v=x.key)||void 0===v||!v.message),error:null===(y=o.annotations)||void 0===y||null===(b=y[s])||void 0===b||null===(j=b.key)||void 0===j?void 0:j.message,"data-testid":`annotation-key-${s}`,children:(0,c.jsx)(r.InputControl,{name:`annotations[${s}].key`,render:e=>{let{}=e,t=function(e,t){if(null==e)return{};var n,a,i={},s=Object.keys(e);for(a=0;a=0||(i[n]=e[n]);return i}(e.field,p);return(0,c.jsx)(u,Object.assign({},t,{"aria-label":`Annotation detail ${s+1}`,existingKeys:g(s),width:18}))},control:t,rules:{required:{value:!(null===(_=d[s])||void 0===_||!_.value),message:"Required."}}})}),(0,c.jsx)(r.Field,{className:(0,a.cx)(e.flexRowItemMargin,e.field),invalid:!(null===(k=o.annotations)||void 0===k||null===(S=k[s])||void 0===S||null===(N=S.value)||void 0===N||!N.message),error:null===(w=o.annotations)||void 0===w||null===(C=w[s])||void 0===C||null===(O=C.value)||void 0===O?void 0:O.message,children:(0,c.jsx)($,Object.assign({"data-testid":`annotation-value-${s}`,className:(0,a.cx)(e.annotationValueInput,{[e.textarea]:!A})},n(`annotations[${s}].value`),{placeholder:A?"https://":"Text",defaultValue:i.value}))}),(0,c.jsx)(r.Button,{type:"button",className:e.flexRowItemMargin,"aria-label":"delete annotation",icon:"trash-alt",variant:"secondary",onClick:()=>m(s)})]},i.id)})),(0,c.jsx)(r.Button,{className:e.addAnnotationsButton,icon:"plus-circle",type:"button",variant:"secondary",onClick:()=>{l({key:"",value:""})},children:"Add info"})]})}})]})}},2394:(e,t,n)=>{n.d(t,{Z:()=>d});var a,i,s=n(36636),r=(n(68404),n(80916)),l=n(69783),o=n(45916);const c=e=>({wrapper:s.css` margin-bottom: ${e.spacing.xl}; `,flexColumn:s.css` display: flex; flex-direction: column; `,flexRow:s.css` display: flex; flex-direction: row; justify-content: flex-start; & + button { margin-left: ${e.spacing.xs}; } `,deleteLabelButton:s.css` margin-left: ${e.spacing.xs}; align-self: flex-start; `,addLabelButton:s.css` flex-grow: 0; align-self: flex-start; `,centerAlignRow:s.css` align-items: baseline; `,equalSign:s.css` align-self: flex-start; width: 28px; justify-content: center; margin-left: ${e.spacing.xs}; `,labelInput:s.css` width: 175px; margin-bottom: ${e.spacing.sm}; & + & { margin-left: ${e.spacing.sm}; } `}),d=e=>{let{className:t}=e;const n=(0,l.useStyles)(c),{register:d,control:u,watch:p,formState:{errors:m}}=(0,r.Gc)(),h=p("labels");return(0,o.jsxs)("div",{className:(0,s.cx)(t,n.wrapper),children:[a||(a=(0,o.jsx)(l.Label,{children:"Custom Labels"})),(0,o.jsx)(l.FieldArray,{control:u,name:"labels",children:e=>{let{fields:t,append:a,remove:r}=e;return(0,o.jsx)(o.Fragment,{children:(0,o.jsxs)("div",{className:n.flexRow,children:[i||(i=(0,o.jsx)(l.InlineLabel,{width:18,children:"Labels"})),(0,o.jsxs)("div",{className:n.flexColumn,children:[t.map(((e,t)=>{var a,i,c,u,p,g,f,x,v,y,b,j,_,k;return(0,o.jsx)("div",{children:(0,o.jsxs)("div",{className:(0,s.cx)(n.flexRow,n.centerAlignRow),children:[(0,o.jsx)(l.Field,{className:n.labelInput,invalid:!(null===(a=m.labels)||void 0===a||null===(i=a[t])||void 0===i||null===(c=i.key)||void 0===c||!c.message),error:null===(u=m.labels)||void 0===u||null===(p=u[t])||void 0===p||null===(g=p.key)||void 0===g?void 0:g.message,children:(0,o.jsx)(l.Input,Object.assign({},d(`labels[${t}].key`,{required:{value:!(null===(f=h[t])||void 0===f||!f.value),message:"Required."}}),{placeholder:"key","data-testid":`label-key-${t}`,defaultValue:e.key}))}),(0,o.jsx)(l.InlineLabel,{className:n.equalSign,children:"="}),(0,o.jsx)(l.Field,{className:n.labelInput,invalid:!(null===(x=m.labels)||void 0===x||null===(v=x[t])||void 0===v||null===(y=v.value)||void 0===y||!y.message),error:null===(b=m.labels)||void 0===b||null===(j=b[t])||void 0===j||null===(_=j.value)||void 0===_?void 0:_.message,children:(0,o.jsx)(l.Input,Object.assign({},d(`labels[${t}].value`,{required:{value:!(null===(k=h[t])||void 0===k||!k.key),message:"Required."}}),{placeholder:"value","data-testid":`label-value-${t}`,defaultValue:e.value}))}),(0,o.jsx)(l.Button,{className:n.deleteLabelButton,"aria-label":"delete label",icon:"trash-alt",variant:"secondary",onClick:()=>{r(t)}})]})},e.id)})),(0,o.jsx)(l.Button,{className:n.addLabelButton,icon:"plus-circle",type:"button",variant:"secondary",onClick:()=>{a({})},children:"Add label"})]})]})})}})]})}},19854:(e,t,n)=>{n.d(t,{P:()=>r});var a=n(68404),i=n(69783),s=n(45916);const r=e=>{let{value:t,onChange:n,options:r,className:l,placeholder:o,width:c,custom:d,onCustomChange:u,disabled:p=!1,addLabel:m="+ Add new","aria-label":h}=e;const[g,f]=(0,a.useState)(d);(0,a.useEffect)((()=>{d&&f(d)}),[d]);const x=(0,a.useMemo)((()=>[...r,{value:"__add__",label:m}]),[r,m]);return g?(0,s.jsx)(i.Input,{"aria-label":h,width:c,autoFocus:!d,value:t||"",placeholder:o,className:l,disabled:p,onChange:e=>n(e.target.value)}):(0,s.jsx)(i.Select,{"aria-label":h,width:c,options:x,value:t,className:l,placeholder:o,disabled:p,onChange:e=>{const t=null==e?void 0:e.value;"__add__"===t?(f(!0),u&&u(!0),n("")):n(t)}})}},3799:(e,t,n)=>{n.d(t,{A:()=>r});n(68404);var a=n(69783),i=n(45916);const s=["tooltip","icon","to","target","onClick","className","tooltipPlacement"];const r=e=>{let{tooltip:t,icon:n,to:r,target:l,onClick:o,className:c,tooltipPlacement:d="top"}=e,u=function(e,t){if(null==e)return{};var n,a,i={},s=Object.keys(e);for(a=0;a=0||(i[n]=e[n]);return i}(e,s);const p="string"==typeof t?t:void 0;return(0,i.jsx)(a.Tooltip,{content:t,placement:d,children:r?(0,i.jsx)(a.LinkButton,Object.assign({variant:"secondary",fill:"text",icon:n,href:r,size:"sm",target:l},u,{"aria-label":p})):(0,i.jsx)(a.Button,Object.assign({className:c,variant:"secondary",fill:"text",size:"sm",icon:n,type:"button",onClick:o},u,{"aria-label":p}))})}},82498:(e,t,n)=>{n.d(t,{k:()=>o});var a=n(68404),i=n(26011),s=n(17421),r=n(85464),l=n(19462);function o(e){const[t,n]=(0,i.K)(),o=function(e){return(0,a.useCallback)((t=>e.map((e=>e.name)).includes(t)),[e])}(e),c=(0,a.useCallback)((e=>{o(e)&&(e===l.GC?(s.Z.delete(r.de),n({[r.c4]:null})):(s.Z.set(r.de,e),n({[r.c4]:e})))}),[n,o]),d=t[r.c4];if(d&&"string"==typeof d)return o(d)?[d,c]:[void 0,c];const u=s.Z.get(r.de);return u&&"string"==typeof u&&o(u)?(c(u),[u,c]):o(l.GC)?[l.GC,c]:[void 0,c]}},1698:(e,t,n)=>{n.d(t,{k:()=>s});var a=n(68404),i=n(19462);function s(e){return(0,a.useMemo)((()=>(0,i.LE)(e)),[e])}},12783:(e,t,n)=>{n.d(t,{D:()=>i});var a=n(36636);const i=e=>({table:a.css` width: 100%; border-radius: ${e.shape.borderRadius()}; border: solid 1px ${e.colors.border.weak}; background-color: ${e.colors.background.secondary}; th { padding: ${e.spacing(1)}; } td { padding: 0 ${e.spacing(1)}; } tr { height: 38px; } `,evenRow:a.css` background-color: ${e.colors.background.primary}; `,colExpand:a.css` width: 36px; `,actionsCell:a.css` text-align: right; width: 1%; white-space: nowrap; & > * + * { margin-left: ${e.spacing(.5)}; } `})}}]); //# sourceMappingURL=NotificationsListPage.f1ca641f4eb7496dd504.js.map