"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[5804],{95576(m,E,a){a.r(E),a.d(E,{BrowseFolderLibraryPanelsPage:()=>D,default:()=>v});var n=a(74848),P=a(96540),b=a(54148),s=a(98970),u=a(40210),o=a(43003),O=a(66198),h=a(24438),M=a(72327);function D(){const{uid:c=""}=(0,b.g)(),{data:t}=(0,s.u$)(c),[l,d]=(0,P.useState)(void 0),[_]=(0,s.HP)(),p=(0,P.useMemo)(()=>{if(!t)return;const e=(0,O.R4)(t),r=(0,O.pq)(t.uid),C=e.children?.find(f=>f.id===r);return C&&(C.active=!0),e},[t]),i=c?async e=>{if(t){const r=await _({...t,title:e});if("error"in r)throw r.error}}:void 0;return(0,n.jsx)(u.Y,{navId:"dashboards/browse",pageNav:p,onEditTitle:i,actions:(0,n.jsx)(n.Fragment,{children:t&&(0,n.jsx)(o.m,{folder:t})}),children:(0,n.jsxs)(u.Y.Contents,{children:[(0,n.jsx)(h.j,{onClick:d,currentFolderUID:c,showSecondaryActions:!0,showSort:!0,showPanelFilter:!0}),l?(0,n.jsx)(M.F,{onDismiss:()=>d(void 0),libraryPanel:l}):null]})})}const v=D},72327(m,E,a){a.d(E,{F:()=>c});var n=a(74848),P=a(76459),b=a.n(P),s=a(96540),u=a(5556),o=a(92745),O=a(36490),h=a(22787),M=a(45861),D=a(18857),v=a(30124);function c({libraryPanel:l,onDismiss:d}){const[_,p]=(0,s.useState)(!1),[i,e]=(0,s.useState)(0),[r,C]=(0,s.useState)(void 0);(0,s.useEffect)(()=>{(async()=>{const B=await(0,v.GN)(l.uid);e(B.length)})()},[l.uid]);const f=(0,s.useCallback)(L=>t(l.uid,L,p),[l.uid]),y=(0,s.useMemo)(()=>b()(f,300,{leading:!0}),[f]),g=L=>{L.preventDefault(),O.Ny.push(u.kM.renderUrl(`/d/${r?.value?.uid}`,{}))};return(0,n.jsxs)(h.a,{title:(0,o.t)("library-panels.modal.title","View panel in dashboard"),onDismiss:d,onClickBackdrop:d,isOpen:!0,children:[(0,n.jsxs)("div",{children:[i===0?(0,n.jsx)("span",{children:(0,n.jsx)(o.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,i>0?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{children:(0,n.jsxs)(o.x6,{i18nKey:"library-panels.modal.body",count:i,children:["This panel is being used in ",{count:i}," dashboard. Please choose which dashboard to view the panel in:"]})}),(0,n.jsx)(D.DW,{isClearable:!0,isLoading:_,defaultOptions:!0,loadOptions:y,onChange:C,placeholder:(0,o.t)("library-panels.modal.select-placeholder","Start typing to search for dashboard"),noOptionsMessage:(0,o.t)("library-panels.modal.select-no-options-message","No dashboards found")})]}):null]}),(0,n.jsxs)(h.a.ButtonRow,{children:[(0,n.jsx)(M.$n,{variant:"secondary",onClick:d,fill:"outline",children:(0,n.jsx)(o.x6,{i18nKey:"library-panels.modal.button-cancel",children:"Cancel"})}),(0,n.jsx)(M.$n,{onClick:g,disabled:!r,children:r?(0,o.t)("library-panels.modal.button-view-panel1","View panel in {{label}}...",{label:r?.label}):(0,o.t)("library-panels.modal.button-view-panel2","View panel in dashboard...")})]})]})}async function t(l,d,_){_(!0);const i=(await(0,v.xV)(l))?.filter(e=>e.name.toLowerCase().includes(d.toLowerCase())).map(e=>({label:e.name,value:e}));return _(!1),i||[]}}}]);

//# sourceMappingURL=FolderLibraryPanelsPage.dd9230ba4f72b6b3dc1b.js.map