"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[7878],{24921:(e,n,a)=>{a.r(n),a.d(n,{LibraryPanelsPage:()=>u,default:()=>h});var s=a(76687),l=a(46958),i=a(36131),o=a(3276),t=a(63983),d=a(56632),r=a(52010);const c=e=>({navModel:(0,o.h)(e.navIndex,"library-panels")}),u=((0,l.connect)(c,void 0),e=>{let{navModel:n}=e;const[a,l]=(0,s.useState)(void 0);return(0,r.jsx)(i.Z,{navModel:n,children:(0,r.jsxs)(i.Z.Contents,{children:[(0,r.jsx)(t.N,{onClick:l,showSecondaryActions:!0,showSort:!0,showPanelFilter:!0,showFolderFilter:!0}),a?(0,r.jsx)(d.b,{onDismiss:()=>l(void 0),libraryPanel:a}):null]})})}),h=(0,l.connect)(c)(u)},56632:(e,n,a)=>{a.d(n,{b:()=>h});var s,l=a(68490),i=a(86832),o=a(76687),t=a(19177),d=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,p]=(0,o.useState)(!1),[v,f]=(0,o.useState)(0),[w,x]=(0,o.useState)(void 0);(0,o.useEffect)((()=>{(async()=>{const e=await(0,c.Ef)(n.uid);f(e.length)})()}),[n.uid]);const j=(0,o.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,p)),[n.uid]),g=(0,o.useMemo)((()=>(0,i.debounce)(j,300,{leading:!0,trailing:!0})),[j]);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===v?s||(s=(0,u.jsx)("span",{children:"Panel is not linked to a dashboard. Add the panel to a dashboard and retry."})):null,v>0?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("p",{children:["This panel is being used in"," ",(0,u.jsxs)("strong",{children:[v," ",v>1?"dashboards":"dashboard"]}),".Please choose which dashboard to view the panel in:"]}),(0,u.jsx)(r.AsyncSelect,{isClearable:!0,isLoading:h,defaultOptions:!0,loadOptions:g,onChange:x,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(),d.locationService.push(t.urlUtil.renderUrl(`/d/${null==w||null===(n=w.value)||void 0===n?void 0:n.uid}`,{}))},disabled:!Boolean(w),children:w?`View panel in ${null==w?void 0:w.label}...`:"View panel in dashboard..."})]})]})}function b(e){return{container:l.css``}}}}]);
//# sourceMappingURL=LibraryPanelsPage.2848c4796abc21586782.js.map