"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[3778],{84125:(e,a,n)=>{n.r(a),n.d(a,{FolderLibraryPanelsPage:()=>p,default:()=>f});var s=n(76687),i=n(30415),l=n(68021),o=n(28781),d=n(3276),r=n(90793),t=n(56632),c=n(89348),u=n(92114),h=n(52010);const b={getFolderByUid:c.Pb};function p(e){let{pageNav:a,getFolderByUid:n,folderUid:i,folder:d}=e;const{loading:c}=(0,l.Z)((async()=>await n(i)),[n,i]),[u,b]=(0,s.useState)(void 0);return(0,h.jsx)(o.T,{navId:"dashboards/browse",pageNav:a.main,children:(0,h.jsxs)(o.T.Contents,{isLoading:c,children:[(0,h.jsx)(r.N,{onClick:b,currentFolderId:d.id,showSecondaryActions:!0,showSort:!0,showPanelFilter:!0}),u?(0,h.jsx)(t.b,{onDismiss:()=>b(void 0),libraryPanel:u}):null]})})}const f=(0,i.connect)(((e,a)=>{const n=a.match.params.uid;return{pageNav:(0,d.h)(e.navIndex,`folder-library-panels-${n}`,(0,u._)(1)),folderUid:n,folder:e.folder}}),b)(p)},56632:(e,a,n)=>{n.d(a,{b:()=>f});var s,i=n(77813),l=n(86832),o=n(76687),d=n(85994),r=n(49622),t=n(27668),c=n(99397),u=n(62533),h=n(55312),b=n(79877),p=n(52010);function f(e){let{libraryPanel:a,onDismiss:n}=e;const i=(0,t.wW)(g),[f,v]=(0,o.useState)(!1),[w,x]=(0,o.useState)(0),[j,C]=(0,o.useState)(void 0);(0,o.useEffect)((()=>{(async()=>{const e=await(0,b.Ef)(a.uid);x(e.length)})()}),[a.uid]);const y=(0,o.useCallback)((e=>async function(e,a,n){n(!0);const s=(await(0,b.E8)(e)).filter((e=>e.title.toLowerCase().includes(a.toLowerCase()))).map((e=>({label:e.title,value:e})));return n(!1),s}(a.uid,e,v)),[a.uid]),k=(0,o.useMemo)((()=>(0,l.debounce)(y,300,{leading:!0,trailing:!0})),[y]);return(0,p.jsxs)(c.u,{title:"View panel in dashboard",onDismiss:n,onClickBackdrop:n,isOpen:!0,children:[(0,p.jsxs)("div",{className:i.container,children:[0===w?s||(s=(0,p.jsx)("span",{children:"Panel is not linked to a dashboard. Add the panel to a dashboard and retry."})):null,w>0?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("p",{children:["This panel is being used in"," ",(0,p.jsxs)("strong",{children:[w," ",w>1?"dashboards":"dashboard"]}),".Please choose which dashboard to view the panel in:"]}),(0,p.jsx)(u.qb,{isClearable:!0,isLoading:f,defaultOptions:!0,loadOptions:k,onChange:C,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:n,fill:"outline",children:"Cancel"}),(0,p.jsx)(h.zx,{onClick:e=>{var a;e.preventDefault(),r.E1.push(d.Cj.renderUrl(`/d/${null==j||null===(a=j.value)||void 0===a?void 0:a.uid}`,{}))},disabled:!Boolean(j),children:j?`View panel in ${null==j?void 0:j.label}...`:"View panel in dashboard..."})]})]})}function g(e){return{container:i.css``}}}}]);
//# sourceMappingURL=FolderLibraryPanelsPage.2b59412a0a3fff4b6104.js.map