"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[8516],{9808:(L,i,a)=>{a.r(i),a.d(i,{LibraryPanelsPage:()=>c,default:()=>E});var n=a(74848),M=a(96540),_=a(54122),e=a(43518),p=a(20741);const c=()=>{const[u,d]=(0,M.useState)(void 0);return(0,n.jsx)(_.Y,{navId:"dashboards/library-panels",children:(0,n.jsxs)(_.Y.Contents,{children:[(0,n.jsx)(e.j,{onClick:d,showSecondaryActions:!0,showSort:!0,showPanelFilter:!0,showFolderFilter:!0}),u?(0,n.jsx)(p.F,{onDismiss:()=>d(void 0),libraryPanel:u}):null]})})},E=c},20741:(L,i,a)=>{a.d(i,{F:()=>y});var n=a(74848),M=a(76459),_=a.n(M),e=a(96540),p=a(93407),c=a(53027),E=a(25356),u=a(44826),d=a(54594),t=a(11817),D=a(81569);function y({libraryPanel:s,onDismiss:r}){const[P,C]=(0,e.useState)(!1),[l,o]=(0,e.useState)(0),[h,f]=(0,e.useState)(void 0);(0,e.useEffect)(()=>{(async()=>{const x=await(0,D.GN)(s.uid);o(x.length)})()},[s.uid]);const v=(0,e.useCallback)(O=>b(s.uid,O,C),[s.uid]),g=(0,e.useMemo)(()=>_()(v,300,{leading:!0}),[v]),m=O=>{O.preventDefault(),c.Ny.push(p.kM.renderUrl(`/d/${h?.value?.uid}`,{}))};return(0,n.jsxs)(E.a,{title:(0,t.t)("library-panels.modal.title","View panel in dashboard"),onDismiss:r,onClickBackdrop:r,isOpen:!0,children:[(0,n.jsxs)("div",{children:[l===0?(0,n.jsx)("span",{children:(0,n.jsx)(t.x6,{i18nKey:"library-panels.modal.panel-not-linked",children:"Panel is not linked to a dashboard. Add the panel to a dashboard and retry."})}):null,l>0?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{children:(0,n.jsxs)(t.x6,{i18nKey:"library-panels.modal.body",count:l,children:["This panel is being used in ",{count:l}," dashboard. Please choose which dashboard to view the panel in:"]})}),(0,n.jsx)(u.DW,{isClearable:!0,isLoading:P,defaultOptions:!0,loadOptions:g,onChange:f,placeholder:(0,t.t)("library-panels.modal.select-placeholder","Start typing to search for dashboard"),noOptionsMessage:(0,t.t)("library-panels.modal.select-no-options-message","No dashboards found")})]}):null]}),(0,n.jsxs)(E.a.ButtonRow,{children:[(0,n.jsx)(d.$n,{variant:"secondary",onClick:r,fill:"outline",children:(0,n.jsx)(t.x6,{i18nKey:"library-panels.modal.button-cancel",children:"Cancel"})}),(0,n.jsx)(d.$n,{onClick:m,disabled:!h,children:h?(0,t.t)("library-panels.modal.button-view-panel1","View panel in {{label}}...",{label:h?.label}):(0,t.t)("library-panels.modal.button-view-panel2","View panel in dashboard...")})]})]})}async function b(s,r,P){P(!0);const l=(await(0,D.xV)(s)).filter(o=>o.title.toLowerCase().includes(r.toLowerCase())).map(o=>({label:o.title,value:o}));return P(!1),l}}}]);

//# sourceMappingURL=LibraryPanelsPage.b4e0f509bc5b6bf4f494.js.map