"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[3778],{84125:(e,n,a)=>{a.r(n),a.d(n,{FolderLibraryPanelsPage:()=>f,default:()=>p});var s=a(76687),l=a(46958),o=a(8650),i=a(36131),d=a(3276),t=a(63983),r=a(56632),c=a(89348),u=a(92114),h=a(52010);const b={getFolderByUid:c.Pb};function f(e){let{navModel:n,getFolderByUid:a,folderUid:l,folder:d}=e;const{loading:c}=(0,o.Z)((async()=>await a(l)),[a,l]),[u,b]=(0,s.useState)(void 0);return(0,h.jsx)(i.Z,{navModel:n,children:(0,h.jsxs)(i.Z.Contents,{isLoading:c,children:[(0,h.jsx)(t.N,{onClick:b,currentFolderId:d.id,showSecondaryActions:!0,showSort:!0,showPanelFilter:!0}),u?(0,h.jsx)(r.b,{onDismiss:()=>b(void 0),libraryPanel:u}):null]})})}const p=(0,l.connect)(((e,n)=>{const a=n.match.params.uid;return{navModel:(0,d.h)(e.navIndex,`folder-library-panels-${a}`,(0,u._)(1)),folderUid:a,folder:e.folder}}),b)(f)},56632:(e,n,a)=>{a.d(n,{b:()=>h});var s,l=a(68490),o=a(86832),i=a(76687),d=a(19177),t=a(10967),r=a(70534),c=a(79877),u=a(52010);function h(e){let{libraryPanel:n,onDismiss:a}=e;const l=(0,r.useStyles2)(b),[h,f]=(0,i.useState)(!1),[p,v]=(0,i.useState)(0),[g,w]=(0,i.useState)(void 0);(0,i.useEffect)((()=>{(async()=>{const e=await(0,c.Ef)(n.uid);v(e.length)})()}),[n.uid]);const x=(0,i.useCallback)((e=>async function(e,n,a){a(!0);const s=(await(0,c.E8)(e)).filter((e=>e.title.toLowerCase().includes(n.toLowerCase()))).map((e=>({label:e.title,value:e})));return a(!1),s}(n.uid,e,f)),[n.uid]),y=(0,i.useMemo)((()=>(0,o.debounce)(x,300,{leading:!0,trailing:!0})),[x]);return(0,u.jsxs)(r.Modal,{title:"View panel in dashboard",onDismiss:a,onClickBackdrop:a,isOpen:!0,children:[(0,u.jsxs)("div",{className:l.container,children:[0===p?s||(s=(0,u.jsx)("span",{children:"Panel is not linked to a dashboard. Add the panel to a dashboard and retry."})):null,p>0?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("p",{children:["This panel is being used in"," ",(0,u.jsxs)("strong",{children:[p," ",p>1?"dashboards":"dashboard"]}),".Please choose which dashboard to view the panel in:"]}),(0,u.jsx)(r.AsyncSelect,{isClearable:!0,isLoading:h,defaultOptions:!0,loadOptions:y,onChange:w,placeholder:"Start typing to search for dashboard",noOptionsMessage:"No dashboards found"})]}):null]}),(0,u.jsxs)(r.Modal.ButtonRow,{children:[(0,u.jsx)(r.Button,{variant:"secondary",onClick:a,fill:"outline",children:"Cancel"}),(0,u.jsx)(r.Button,{onClick:e=>{var n;e.preventDefault(),t.locationService.push(d.urlUtil.renderUrl(`/d/${null==g||null===(n=g.value)||void 0===n?void 0:n.uid}`,{}))},disabled:!Boolean(g),children:g?`View panel in ${null==g?void 0:g.label}...`:"View panel in dashboard..."})]})]})}function b(e){return{container:l.css``}}}}]);
//# sourceMappingURL=FolderLibraryPanelsPage.ee36a3f7ba79e0b72c59.js.map