"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[8516],{21155(v,_,a){a.r(_),a.d(_,{LibraryPanelsPage:()=>e,default:()=>M});var n=a(74848),h=a(96540),c=a(13791),s=a(24438),O=a(72327);const e=()=>{const[d,r]=(0,h.useState)(void 0);return(0,n.jsx)(c.Y,{navId:"dashboards/library-panels",children:(0,n.jsxs)(c.Y.Contents,{children:[(0,n.jsx)(s.j,{onClick:r,showSecondaryActions:!0,showSort:!0,showPanelFilter:!0,showFolderFilter:!0}),d?(0,n.jsx)(O.F,{onDismiss:()=>r(void 0),libraryPanel:d}):null]})})},M=e},72327(v,_,a){a.d(_,{F:()=>y});var n=a(74848),h=a(76459),c=a.n(h),s=a(96540),O=a(5556),e=a(92745),M=a(36490),d=a(22787),r=a(45861),L=a(54604),p=a(30124);function y({libraryPanel:t,onDismiss:i}){const[E,D]=(0,s.useState)(!1),[l,o]=(0,s.useState)(0),[u,f]=(0,s.useState)(void 0);(0,s.useEffect)(()=>{(async()=>{const x=await(0,p.GN)(t.uid);o(x.length)})()},[t.uid]);const C=(0,s.useCallback)(P=>b(t.uid,P,D),[t.uid]),g=(0,s.useMemo)(()=>c()(C,300,{leading:!0}),[C]),m=P=>{P.preventDefault(),M.Ny.push(O.kM.renderUrl(`/d/${u?.value?.uid}`,{}))};return(0,n.jsxs)(d.a,{title:(0,e.t)("library-panels.modal.title","View panel in dashboard"),onDismiss:i,onClickBackdrop:i,isOpen:!0,children:[(0,n.jsxs)("div",{children:[l===0?(0,n.jsx)("span",{children:(0,n.jsx)(e.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)(e.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)(L.DW,{isClearable:!0,isLoading:E,defaultOptions:!0,loadOptions:g,onChange:f,placeholder:(0,e.t)("library-panels.modal.select-placeholder","Start typing to search for dashboard"),noOptionsMessage:(0,e.t)("library-panels.modal.select-no-options-message","No dashboards found")})]}):null]}),(0,n.jsxs)(d.a.ButtonRow,{children:[(0,n.jsx)(r.$n,{variant:"secondary",onClick:i,fill:"outline",children:(0,n.jsx)(e.x6,{i18nKey:"library-panels.modal.button-cancel",children:"Cancel"})}),(0,n.jsx)(r.$n,{onClick:m,disabled:!u,children:u?(0,e.t)("library-panels.modal.button-view-panel1","View panel in {{label}}...",{label:u?.label}):(0,e.t)("library-panels.modal.button-view-panel2","View panel in dashboard...")})]})]})}async function b(t,i,E){E(!0);const l=(await(0,p.xV)(t))?.filter(o=>o.name.toLowerCase().includes(i.toLowerCase())).map(o=>({label:o.name,value:o}));return E(!1),l||[]}}}]);

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