"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[7878],{33505:(b,d,a)=>{a.r(d),a.d(d,{LibraryPanelsPage:()=>c,default:()=>m});var l=a(39953),i=a(13253),O=a(13880),e=a(9791);const c=()=>{const[E,s]=(0,l.useState)(void 0);return l.createElement(i.T,{navId:"dashboards/library-panels"},l.createElement(i.T.Contents,null,l.createElement(O.N,{onClick:s,showSecondaryActions:!0,showSort:!0,showPanelFilter:!0,showFolderFilter:!0}),E?l.createElement(e.b,{onDismiss:()=>s(void 0),libraryPanel:E}):null))},m=c},9791:(b,d,a)=>{a.d(d,{b:()=>L});var l=a(41407),i=a(97368),O=a.n(i),e=a(39953),c=a(69307),m=a(13601),E=a(82803),s=a(73075),v=a(9558),C=a(4919),t=a(62679),M=a(64840);function L({libraryPanel:o,onDismiss:r}){const _=(0,E.wW)(f),[h,p]=(0,e.useState)(!1),[n,g]=(0,e.useState)(0),[u,A]=(0,e.useState)(void 0);(0,e.useEffect)(()=>{(async()=>{const K=await(0,M.Ef)(o.uid);g(K.length)})()},[o.uid]);const D=(0,e.useCallback)(P=>y(o.uid,P,p),[o.uid]),T=(0,e.useMemo)(()=>O()(D,300,{leading:!0}),[D]),B=P=>{P.preventDefault(),m.E1.push(c.Cj.renderUrl(`/d/${u?.value?.uid}`,{}))};return e.createElement(s.u,{title:(0,t.t)("library-panels.modal.title","View panel in dashboard"),onDismiss:r,onClickBackdrop:r,isOpen:!0},e.createElement("div",{className:_.container},n===0?e.createElement("span",null,e.createElement(t.cC,{i18nKey:"library-panels.modal.panel-not-linked"},"Panel is not linked to a dashboard. Add the panel to a dashboard and retry.")):null,n>0?e.createElement(e.Fragment,null,e.createElement("p",null,e.createElement(t.cC,{i18nKey:"library-panels.modal.body",count:n},"This panel is being used in ",{count:n}," dashboard. Please choose which dashboard to view the panel in:")),e.createElement(v.qb,{isClearable:!0,isLoading:h,defaultOptions:!0,loadOptions:T,onChange:A,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),e.createElement(s.u.ButtonRow,null,e.createElement(C.zx,{variant:"secondary",onClick:r,fill:"outline"},e.createElement(t.cC,{i18nKey:"library-panels.modal.button-cancel"},"Cancel")),e.createElement(C.zx,{onClick:B,disabled:!u},u?(0,t.t)("library-panels.modal.button-view-panel1","View panel in {{label}}...",{label:u?.label}):(0,t.t)("library-panels.modal.button-view-panel2","View panel in dashboard..."))))}async function y(o,r,_){_(!0);const p=(await(0,M.E8)(o)).filter(n=>n.title.toLowerCase().includes(r.toLowerCase())).map(n=>({label:n.title,value:n}));return _(!1),p}function f(o){return{container:(0,l.css)``}}}}]);

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