"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[3778],{29249:(e,a,n)=>{n.r(a),n.d(a,{FolderLibraryPanelsPage:()=>p,default:()=>f});var s=n(68404),i=n(1485),l=n(66015),o=n(90894),d=n(8674),r=n(46159),t=n(1586),c=n(87413),u=n(49545),h=n(45916);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)},1586:(e,a,n)=>{n.d(a,{b:()=>f});var s,i=n(27549),l=n(82897),o=n(68404),d=n(87982),r=n(98712),t=n(9617),c=n(59385),u=n(2563),h=n(40920),b=n(23078),p=n(45916);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.80595b710b81b1bb13da.js.map