"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[7878],{45407:(L,r,e)=>{e.r(r),e.d(r,{LibraryPanelsPage:()=>E,default:()=>O});var t=e(68404),d=e(79396),P=e(23189),a=e(7725);const E=()=>{const[c,s]=(0,t.useState)(void 0);return t.createElement(d.T,{navId:"dashboards/library-panels"},t.createElement(d.T.Contents,null,t.createElement(P.N,{onClick:s,showSecondaryActions:!0,showSort:!0,showPanelFilter:!0,showFolderFilter:!0}),c?t.createElement(a.b,{onDismiss:()=>s(void 0),libraryPanel:c}):null))},O=E},7725:(L,r,e)=>{e.d(r,{b:()=>g});var t=e(9892),d=e(99151),P=e.n(d),a=e(68404),E=e(27677),O=e(37932),c=e(72648),s=e(35029),f=e(53217),h=e(31403),C=e(86648);function g({libraryPanel:o,onDismiss:l}){const i=(0,c.wW)(p),[D,M]=(0,a.useState)(!1),[n,A]=(0,a.useState)(0),[_,T]=(0,a.useState)(void 0);(0,a.useEffect)(()=>{(async()=>{const U=await(0,C.Ef)(o.uid);A(U.length)})()},[o.uid]);const m=(0,a.useCallback)(u=>v(o.uid,u,M),[o.uid]),B=(0,a.useMemo)(()=>P()(m,300,{leading:!0}),[m]),R=u=>{u.preventDefault(),O.E1.push(E.Cj.renderUrl(`/d/${_?.value?.uid}`,{}))};return a.createElement(s.u,{title:"View panel in dashboard",onDismiss:l,onClickBackdrop:l,isOpen:!0},a.createElement("div",{className:i.container},n===0?a.createElement("span",null,"Panel is not linked to a dashboard. Add the panel to a dashboard and retry."):null,n>0?a.createElement(a.Fragment,null,a.createElement("p",null,"This panel is being used in"," ",a.createElement("strong",null,n," ",n>1?"dashboards":"dashboard"),".Please choose which dashboard to view the panel in:"),a.createElement(f.qb,{isClearable:!0,isLoading:D,defaultOptions:!0,loadOptions:B,onChange:T,placeholder:"Start typing to search for dashboard",noOptionsMessage:"No dashboards found"})):null),a.createElement(s.u.ButtonRow,null,a.createElement(h.zx,{variant:"secondary",onClick:l,fill:"outline"},"Cancel"),a.createElement(h.zx,{onClick:R,disabled:!Boolean(_)},_?`View panel in ${_?.label}...`:"View panel in dashboard...")))}async function v(o,l,i){i(!0);const M=(await(0,C.E8)(o)).filter(n=>n.title.toLowerCase().includes(l.toLowerCase())).map(n=>({label:n.title,value:n}));return i(!1),M}function p(o){return{container:t.css``}}}}]);

//# sourceMappingURL=LibraryPanelsPage.71a2c0fb618376e404cb.js.map