"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[7878],{24921:(e,n,a)=>{a.r(n),a.d(n,{LibraryPanelsPage:()=>t,default:()=>d});var s=a(76687),i=a(28781),l=a(90793),o=a(56632),r=a(52010);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},56632:(e,n,a)=>{a.d(n,{b:()=>f});var s,i=a(77813),l=a(86832),o=a(76687),r=a(85994),t=a(49622),d=a(27668),c=a(99397),u=a(62533),h=a(55312),b=a(79877),p=a(52010);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.32cbd5ce632d76aa298e.js.map