"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[7878],{7708:(e,n,a)=>{a.r(n),a.d(n,{LibraryPanelsPage:()=>u,default:()=>h});var s=a(68404),l=a(18745),i=a(33801),o=a(8674),t=a(19586),d=a(1586),r=a(45916);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)},1586:(e,n,a)=>{a.d(n,{b:()=>h});var s,l=a(36636),i=a(82897),o=a(68404),t=a(43215),d=a(90923),r=a(69783),c=a(23078),u=a(45916);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.98f5a524ee8835ae9074.js.map