"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[7878],{"./public/app/features/library-panels/LibraryPanelsPage.tsx":(e,a,n)=>{n.r(a),n.d(a,{LibraryPanelsPage:()=>u,default:()=>p});var s=n("./node_modules/react/index.js"),l=n("./node_modules/react-redux/es/index.js"),o=n("./public/app/core/selectors/navModel.ts"),r=n("./public/app/core/components/Page/Page.tsx"),i=n("./public/app/features/library-panels/components/LibraryPanelsSearch/LibraryPanelsSearch.tsx"),t=n("./public/app/features/library-panels/components/OpenLibraryPanelModal/OpenLibraryPanelModal.tsx"),d=n("./node_modules/react/jsx-runtime.js");const c=e=>({navModel:(0,o.h)(e.navIndex,"library-panels")}),u=((0,l.connect)(c,void 0),({navModel:e})=>{const[a,n]=(0,s.useState)(void 0);return(0,d.jsx)(r.Z,{navModel:e,children:(0,d.jsxs)(r.Z.Contents,{children:[(0,d.jsx)(i.N,{onClick:n,showSecondaryActions:!0,showSort:!0,showPanelFilter:!0,showFolderFilter:!0}),a?(0,d.jsx)(t.b,{onDismiss:()=>n(void 0),libraryPanel:a}):null]})})}),p=(0,l.connect)(c)(u)},"./public/app/features/library-panels/components/OpenLibraryPanelModal/OpenLibraryPanelModal.tsx":(e,a,n)=>{n.d(a,{b:()=>p});var s,l=n("./node_modules/react/index.js"),o=n("./node_modules/@emotion/css/dist/emotion-css.esm.js"),r=n("./packages/grafana-ui/src/index.ts"),i=n("./packages/grafana-data/src/index.ts"),t=n("./packages/grafana-runtime/src/index.ts"),d=n("./public/app/features/library-panels/state/api.ts"),c=n("./node_modules/lodash/lodash.js"),u=n("./node_modules/react/jsx-runtime.js");function p({libraryPanel:e,onDismiss:a}){const n=(0,r.useStyles2)(h),[o,p]=(0,l.useState)(!1),[b,x]=(0,l.useState)(0),[f,m]=(0,l.useState)(void 0);(0,l.useEffect)((()=>{(async()=>{const a=await(0,d.Ef)(e.uid);x(a.length)})()}),[e.uid]);const y=(0,l.useCallback)((a=>async function(e,a,n){n(!0);const s=(await(0,d.E8)(e)).filter((e=>e.title.toLowerCase().includes(a.toLowerCase()))).map((e=>({label:e.title,value:e})));return n(!1),s}(e.uid,a,p)),[e.uid]),j=(0,l.useMemo)((()=>(0,c.debounce)(y,300,{leading:!0,trailing:!0})),[y]);return(0,u.jsxs)(r.Modal,{title:"View panel in dashboard",onDismiss:a,onClickBackdrop:a,isOpen:!0,children:[(0,u.jsxs)("div",{className:n.container,children:[0===b?s||(s=(0,u.jsx)("span",{children:"Panel is not linked to a dashboard. Add the panel to a dashboard and retry."})):null,b>0?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("p",{children:["This panel is being used in"," ",(0,u.jsxs)("strong",{children:[b," ",b>1?"dashboards":"dashboard"]}),".Please choose which dashboard to view the panel in:"]}),(0,u.jsx)(r.AsyncSelect,{menuShouldPortal:!0,isClearable:!0,isLoading:o,defaultOptions:!0,loadOptions:j,onChange:m,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 a;e.preventDefault(),t.locationService.push(i.urlUtil.renderUrl(`/d/${null==f||null===(a=f.value)||void 0===a?void 0:a.uid}`,{}))},disabled:!Boolean(f),children:f?`View panel in ${null==f?void 0:f.label}...`:"View panel in dashboard..."})]})]})}function h(e){return{container:o.css``}}}}]);
//# sourceMappingURL=LibraryPanelsPage.8128b05ac04b15cbf98d.js.map