"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[9133],{77632:(V,y,a)=>{a.d(y,{H:()=>ge});var e=a(66111),u=a(47956),p=a(86647),C=a(2555),h=a(27876),r=a(25e3),i=a(63065),v=a(9892),m=a(68183),b=a(81764),B=a(46967),L=a(8944),D=a(72648),x=a(19985);function g({dataSourceName:t,isDefault:n,onDefaultChange:o,onNameChange:s,alertingSupported:l,disabled:d}){return e.createElement(e.Fragment,null,e.createElement(I,{enabled:l}),e.createElement("div",{className:"gf-form-group","aria-label":"Datasource settings page basic settings"},e.createElement("div",{className:"gf-form-inline"},e.createElement("div",{className:"gf-form max-width-30"},e.createElement(b._,{label:"Name",tooltip:`The name is used when you select the data source in panels. The default data source is
              'preselected in new panels.`,grow:!0,disabled:d},e.createElement(B.I,{id:"basic-settings-name",type:"text",value:t,placeholder:"Name",onChange:c=>s(c.currentTarget.value),required:!0,"aria-label":m.wl.pages.DataSource.name}))),e.createElement(b._,{label:"Default",labelWidth:8,disabled:d},e.createElement(L.x,{id:"basic-settings-default",value:n,onChange:c=>{o(c.currentTarget.checked)}})))))}function I({enabled:t}){const n=(0,D.wW)(G);return e.createElement("div",{className:n.badge},t?e.createElement(x.C,{color:"green",icon:"check-circle",text:"Alerting supported"}):e.createElement(x.C,{color:"orange",icon:"exclamation-triangle",text:"Alerting not supported"}))}const G=t=>({badge:v.css`
    margin-bottom: ${t.spacing(2)};
  `});var P=a(31403);function Y({canSave:t,canDelete:n,onDelete:o,onSubmit:s,onTest:l}){return e.createElement("div",{className:"gf-form-button-row"},e.createElement(P.zx,{type:"button",variant:"destructive",disabled:!n,onClick:o,"data-testid":m.wl.pages.DataSource.delete},"Delete"),t&&e.createElement(P.zx,{type:"submit",variant:"primary",disabled:!t,onClick:s,"data-testid":m.wl.pages.DataSource.saveAndTest},"Save & test"),!t&&e.createElement(P.zx,{variant:"primary",onClick:l},"Test"))}var Q=a(59959),O=a(45253),J=a(59796),H=a(47694);const X="datasources.settings.cloudInfoBox.isDismissed";function Z({dataSource:t}){let n="",o="";if(t.readOnly||(t.version??0)>2||H.vc.buildInfo.edition!==Q.e.OpenSource)return null;switch(t.type){case"prometheus":n="Prometheus",o="Loki";break;case"loki":n="Loki",o="Prometheus";break;default:return null}return e.createElement(J.G,{storageKey:X,defaultValue:!1},(s,l)=>s?null:e.createElement(O.b,{title:`Configure your ${n} data source below`,severity:"info",bottomSpacing:4,onRemove:()=>{l(!0)}},"Or skip the effort and get ",n," (and ",o,") as fully-managed, scalable, and hosted data sources from Grafana Labs with the"," ",e.createElement("a",{className:"external-link",href:`https://grafana.com/signup/cloud/connect-account?src=grafana-oss&cnt=${t.type}-settings`,target:"_blank",rel:"noreferrer",title:"The free plan includes 10k active metrics and 50gb storage."},"free-forever Grafana Cloud plan"),"."))}const k="This data source was added by config and cannot be modified using the UI. Please contact your server admin to update this data source.";function j(){return e.createElement(O.b,{"aria-label":m.wl.pages.DataSource.readOnly,severity:"info",title:"Provisioned data source"},k)}function q({dataSourceRights:t,onDelete:n}){const{readOnly:o,hasDeleteRights:s}=t,l=!o&&s,d=()=>history.back();return e.createElement(e.Fragment,null,o&&e.createElement(j,null),e.createElement("div",{className:"gf-form-button-row"},l&&e.createElement(P.zx,{type:"submit",variant:"destructive",onClick:n},"Delete"),e.createElement(P.zx,{variant:"secondary",fill:"outline",type:"button",onClick:d},"Back")))}const _="You are not allowed to modify this data source. Please contact your server admin to update this data source.";function ee(){return e.createElement(O.b,{severity:"info",title:"Missing rights"},_)}function te({plugin:t,pageId:n}){if(!t||!t.configPages)return null;const o=t.configPages.find(({id:s})=>s===n);return o?e.createElement(o.body,{plugin:t,query:{}}):e.createElement("div",null,"Page not found: ",o)}var $=a(82897),ae=a(11484);class ne extends e.PureComponent{constructor(n){super(n),this.element=null,this.onModelChanged=o=>{this.props.onModelChange(o)},this.scopeProps={ctrl:{datasourceMeta:n.dataSourceMeta,current:(0,$.cloneDeep)(n.dataSource)},onModelChanged:this.onModelChanged},this.onModelChanged=this.onModelChanged.bind(this)}componentDidMount(){const{plugin:n}=this.props;if(this.element&&!n.components.ConfigEditor){const o=(0,ae.w)(),s='<plugin-component type="datasource-config-ctrl" />';this.component=o.load(this.element,this.scopeProps,s)}}componentDidUpdate(n){const{plugin:o}=this.props;!o.components.ConfigEditor&&this.props.dataSource!==n.dataSource&&(this.scopeProps.ctrl.current=(0,$.cloneDeep)(this.props.dataSource),this.component?.digest())}componentWillUnmount(){this.component&&this.component.destroy()}render(){const{plugin:n,dataSource:o}=this.props;return n?e.createElement("div",{ref:s=>this.element=s},n.components.ConfigEditor&&e.createElement(n.components.ConfigEditor,{options:o,onOptionsChange:this.onModelChanged})):null}}var oe=a(81731);function se({state:t}){return e.createElement("div",{className:"gf-form"},e.createElement("div",{className:"gf-form-label width-10"},"Plugin state"),e.createElement("div",{className:"gf-form-label gf-form-label--transparent"},e.createElement(oe.u,{state:t})))}var re=a(35645),w=a(29460),le=a(77582);const ie=(t,n)=>({content:v.css`
      color: ${t.colors.text.secondary};
      padding-top: ${n?t.spacing(1):0};
      max-height: 50vh;
      overflow-y: auto;
    `,disabled:v.css`
      pointer-events: none;
      color: ${t.colors.text.secondary};
    `}),z=({title:t,exploreUrl:n,dataSourceId:o,onDashboardLinkClicked:s})=>{const l=(0,D.l4)(),d=Boolean(t),c=ie(l,d),f=le.Vt.hasPermission(h.AccessControlAction.DataSourcesExplore);return e.createElement("div",{className:c.content},"Next, you can start to visualize data by"," ",e.createElement(w.r,{"aria-label":"Create a dashboard",href:`/dashboard/new-with-ds/${o}`,className:"external-link",onClick:s},"building a dashboard"),", or by querying data in the"," ",e.createElement(w.r,{"aria-label":"Explore data",className:(0,v.cx)("external-link",{[`${c.disabled}`]:!f,"test-disabled":!f}),href:n},"Explore view"),".")};z.displayName="AlertSuccessMessage";const ce=new Set(["success","info","warning","error"]),de=t=>ce.has(t),ue=t=>t.toLowerCase()==="ok"?"success":de(t)?t:"info";function me({testingStatus:t,exploreUrl:n,dataSource:o}){const s=ue(t?.status??"error"),l=t?.message,d=t?.details?.message,c=t?.details?.verboseMessage,f=()=>{(0,i.hJ)({grafana_version:re.v.buildInfo.version,datasource_uid:o.uid,plugin_name:o.typeName,path:location.pathname})};return l?e.createElement("div",{className:"gf-form-group p-t-2"},e.createElement(O.b,{severity:s,title:l,"aria-label":m.wl.pages.DataSource.alert},t?.details&&e.createElement(e.Fragment,null,d,s==="success"?e.createElement(z,{title:l,exploreUrl:n,dataSourceId:o.uid,onDashboardLinkClicked:f}):null,c?e.createElement("details",{style:{whiteSpace:"pre-wrap"}},String(c)):null))):null}function ge({uid:t,pageId:n}){(0,r.E)(t);const o=(0,h.useDispatch)(),s=(0,r.wl)(t),l=(0,r.Qs)(s.type),d=(0,r._l)(),c=(0,r.YY)(t),f=(0,r.Rz)(t),N=(0,r.q6)(),R=(0,r.hw)(t),A=(0,r.qj)(),U=E=>o((0,r.yr)(E)),M=E=>o((0,r.BX)(E)),W=E=>o((0,r.rl)(E));return e.createElement(fe,{pageId:n,dataSource:s,dataSourceMeta:l,dataSourceSettings:d,dataSourceRights:c,exploreUrl:f,onDelete:N,onDefaultChange:U,onNameChange:M,onOptionsChange:W,onTest:R,onUpdate:A})}function fe({pageId:t,dataSource:n,dataSourceMeta:o,dataSourceSettings:s,dataSourceRights:l,exploreUrl:d,onDelete:c,onDefaultChange:f,onNameChange:N,onOptionsChange:R,onTest:A,onUpdate:U}){const{plugin:M,loadError:W,testingStatus:E,loading:he}=s,{readOnly:T,hasWriteRights:K,hasDeleteRights:Ee}=l,pe=n.id>0,S=(0,p.F)()?.getInstanceSettings(n.uid),ve=Boolean(S?.meta?.alerting??!1),De=S?.type==="alertmanager",ye=ve||De,F=async Ce=>{Ce.preventDefault(),(0,i.ij)("save_and_test");try{await U({...n}),(0,i.aL)("success")}catch{(0,i.aL)("fail");return}A()};return W?e.createElement(q,{dataSourceRights:l,onDelete:()=>{(0,i.ij)("delete"),c()}}):he?e.createElement(C.Z,null):!pe||!S?null:t?e.createElement(u.n,{instanceSettings:S},e.createElement(te,{pageId:t,plugin:M})):e.createElement("form",{onSubmit:F},!K&&e.createElement(ee,null),T&&e.createElement(j,null),o.state&&e.createElement(se,{state:o.state}),e.createElement(Z,{dataSource:n}),e.createElement(g,{dataSourceName:n.name,isDefault:n.isDefault,onDefaultChange:f,onNameChange:N,alertingSupported:ye,disabled:T||!K}),M&&e.createElement(u.n,{instanceSettings:S},e.createElement(ne,{plugin:M,dataSource:n,dataSourceMeta:o,onModelChange:R})),e.createElement(me,{testingStatus:E,exploreUrl:d,dataSource:n}),e.createElement(Y,{onSubmit:F,onDelete:()=>{(0,i.ij)("delete"),c()},onTest:()=>{(0,i.ij)("test"),A()},canDelete:!T&&Ee,canSave:!T&&K}))}},3515:(V,y,a)=>{a.d(y,{K:()=>L});var e=a(9892),u=a(66111),p=a(35645),C=a(72648),h=a(31403),r=a(77582),i=a(27876),v=a(25e3),m=a(63065),b=a(85597);const B=D=>({button:(0,e.css)({marginLeft:D.spacing(2)})});function L({uid:D}){const x=(0,C.wW)(B),g=(0,v.wl)(D),I=r.Vt.hasPermission(i.AccessControlAction.DataSourcesExplore);return u.createElement(u.Fragment,null,u.createElement(h.Qj,{icon:"apps",fill:"outline",variant:"secondary",href:`dashboard/new-with-ds/${g.uid}`,onClick:()=>{(0,m.ij)("build_a_dashboard"),(0,m.hJ)({grafana_version:p.v.buildInfo.version,datasource_uid:g.uid,plugin_name:g.typeName,path:location.pathname})}},"Build a dashboard"),I&&u.createElement(h.Qj,{icon:"compass",fill:"outline",variant:"secondary",className:x.button,href:(0,b.iU)(g),onClick:()=>{(0,m.ij)("explore"),(0,m.U4)({grafana_version:p.v.buildInfo.version,datasource_uid:g.uid,plugin_name:g.typeName,path:location.pathname})}},"Explore"))}},81731:(V,y,a)=>{a.d(y,{u:()=>C});var e=a(66111),u=a(59250),p=a(19985);const C=r=>{const i=h(r.state);return i?e.createElement(p.C,{color:i.color,title:i.tooltip,text:i.text,icon:i.icon}):null};function h(r){switch(r){case u.BV.deprecated:return{text:"Deprecated",color:"red",tooltip:"This feature is deprecated and will be removed in a future release"};case u.BV.alpha:return{text:"Alpha",color:"blue",tooltip:"This feature is experimental and future updates might not be backward compatible"};case u.BV.beta:return{text:"Beta",color:"blue",tooltip:"This feature is close to complete but not fully tested"};default:return null}}}}]);

//# sourceMappingURL=9133.1f0698b65351ea3817e7.js.map