"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[7878],{7708:(e,n,a)=>{a.r(n),a.d(n,{LibraryPanelsPage:()=>t,default:()=>d});var s=a(68404),i=a(90894),l=a(46159),o=a(1586),r=a(45916);const t=()=>{const[e,n]=(0,s.useState)(void 0);return(0,r.jsx)(i.T,{navId:"dashboards/library-panels",children:(0,r.jsxs)(i.T.Contents,{children:[(0,r.jsx)(l.N,{onClick:n,showSecondaryActions:!0,showSort:!0,showPanelFilter:!0,showFolderFilter:!0}),e?(0,r.jsx)(o.b,{onDismiss:()=>n(void 0),libraryPanel:e}):null]})})},d=t},1586:(e,n,a)=>{a.d(n,{b:()=>f});var s,i=a(27549),l=a(82897),o=a(68404),r=a(87982),t=a(98712),d=a(9617),c=a(59385),u=a(2563),h=a(40920),b=a(23078),p=a(45916);function f(e){let{libraryPanel:n,onDismiss:a}=e;const i=(0,d.wW)(w),[f,v]=(0,o.useState)(!1),[x,j]=(0,o.useState)(0),[C,g]=(0,o.useState)(void 0);(0,o.useEffect)((()=>{(async()=>{const e=await(0,b.Ef)(n.uid);j(e.length)})()}),[n.uid]);const k=(0,o.useCallback)((e=>async function(e,n,a){a(!0);const s=(await(0,b.E8)(e)).filter((e=>e.title.toLowerCase().includes(n.toLowerCase()))).map((e=>({label:e.title,value:e})));return a(!1),s}(n.uid,e,v)),[n.uid]),y=(0,o.useMemo)((()=>(0,l.debounce)(k,300,{leading:!0,trailing:!0})),[k]);return(0,p.jsxs)(c.u,{title:"View panel in dashboard",onDismiss:a,onClickBackdrop:a,isOpen:!0,children:[(0,p.jsxs)("div",{className:i.container,children:[0===x?s||(s=(0,p.jsx)("span",{children:"Panel is not linked to a dashboard. Add the panel to a dashboard and retry."})):null,x>0?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("p",{children:["This panel is being used in"," ",(0,p.jsxs)("strong",{children:[x," ",x>1?"dashboards":"dashboard"]}),".Please choose which dashboard to view the panel in:"]}),(0,p.jsx)(u.qb,{isClearable:!0,isLoading:f,defaultOptions:!0,loadOptions:y,onChange:g,placeholder:"Start typing to search for dashboard",noOptionsMessage:"No dashboards found"})]}):null]}),(0,p.jsxs)(c.u.ButtonRow,{children:[(0,p.jsx)(h.zx,{variant:"secondary",onClick:a,fill:"outline",children:"Cancel"}),(0,p.jsx)(h.zx,{onClick:e=>{var n;e.preventDefault(),t.E1.push(r.Cj.renderUrl(`/d/${null==C||null===(n=C.value)||void 0===n?void 0:n.uid}`,{}))},disabled:!Boolean(C),children:C?`View panel in ${null==C?void 0:C.label}...`:"View panel in dashboard..."})]})]})}function w(e){return{container:i.css``}}}}]);
//# sourceMappingURL=LibraryPanelsPage.b500630dcf2c377a1268.js.map