"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[1893],{77738:(F,c,t)=>{t.r(c),t.d(c,{WriteTargetConfig:()=>g,WriteTargetConfigUnconnected:()=>D,default:()=>S});var e=t(74848),M=t(32196),n=t(96540),O=t(49785),u=t(71468),i=t(26272),h=t(19347),m=t(40845),W=t(14578),E=t(88575),C=t(10354),T=t(55852),l=t(28138),d=t(21780),v=t(17422),A=t(51612),P=t(82063),I=t(95114);function L(a){return{navModel:(0,v.tc)(a.navIndex,"recordedQueries"),prometheusWriteTarget:(0,I.S)(a.recordedQueries)}}const U={getPrometheusWriteTarget:P.Nd},B=(0,u.connect)(L,U),D=({navModel:a,prometheusWriteTarget:r,getPrometheusWriteTarget:s})=>{const[_,f]=(0,n.useState)(),[p,x]=(0,n.useState)(r?.remote_write_path),j=(0,m.of)(K),{register:y,handleSubmit:N}=(0,O.mN)({defaultValues:r});(0,n.useEffect)(()=>{s()},[s]),(0,n.useEffect)(()=>{(async()=>{if(r){const $=await(0,h.l)().getInstanceSettings(r.data_source_uid);f($)}})()},[r]);const Q=o=>{R(_?.uid,o.remote_write_path)},Y=(0,e.jsxs)("span",{children:["Select the data source where metrics will be written",(0,e.jsx)("a",{href:"https://grafana.com/docs/grafana/latest/enterprise/recorded-queries/#remote-write-target",className:j.docsLink,target:"_blank",rel:"noreferrer",children:(0,e.jsx)(W.I,{name:"info-circle"})})]});return(0,e.jsx)(d.YW,{navModel:a,children:(0,e.jsx)(d.YW.Contents,{children:(0,e.jsxs)("form",{onSubmit:N(Q),style:{maxWidth:"600px"},children:[(0,e.jsx)(E.D,{label:Y,children:(0,e.jsx)(A.s,{onChange:f,current:_?.name,placeholder:"Select a data source",type:"prometheus",noDefault:!0,alerting:!0,"aria-label":"Write target config select data source"})}),(0,e.jsx)(E.D,{label:"Remote write path",children:(0,e.jsx)(C.p,{...y("remote_write_path"),onChange:o=>x(o.currentTarget.value),placeholder:"/api/v1/write","aria-label":"Write target config remote write path"})}),(0,e.jsx)(T.$n,{disabled:!p||!_,type:"submit","aria-label":"Write target config save",children:"Save"})]},r?.data_source_uid)})})};function R(a,r){(0,P.Of)({data_source_uid:a,remote_write_path:r}).then(()=>{l.A.emit(i.r1.alertSuccess,["Prometheus remote write target created"])}).catch(s=>{l.A.emit(i.r1.alertError,[s.data.message])})}const K=a=>({docsLink:(0,M.css)`
      margin-left: ${a.spacing(1)};
    `}),g=B(D),S=g}}]);

//# sourceMappingURL=WriteTargetConfig.21d0605786b6500b9bf1.js.map