"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[8516],{10748(b,c,a){a.r(c),a.d(c,{LibraryPanelsPage:()=>e,default:()=>p});var n=a(74848),P=a(96540),_=a(5246),s=a(91410),O=a(65025);const e=()=>{const[d,i]=(0,P.useState)(void 0);return(0,n.jsx)(_.Y,{navId:"dashboards/library-panels",children:(0,n.jsxs)(_.Y.Contents,{children:[(0,n.jsx)(s.j,{onClick:i,showSecondaryActions:!0,showSort:!0,showPanelFilter:!0,showFolderFilter:!0}),d?(0,n.jsx)(O.F,{onDismiss:()=>i(void 0),libraryPanel:d}):null]})})},p=e},65025(b,c,a){a.d(c,{F:()=>L});var n=a(74848),P=a(76459),_=a.n(P),s=a(96540),O=a(91715),e=a(52358),p=a(98391),d=a(8208),i=a(45270),v=a(87748),M=a(56997);function L({libraryPanel:o,onDismiss:r}){const[h,D]=(0,s.useState)(!1),[t,l]=(0,s.useState)(0),[u,g]=(0,s.useState)(void 0);(0,s.useEffect)(()=>{(async()=>{const x=await(0,M.GN)(o.uid);l(x.length)})()},[o.uid]);const C=(0,s.useCallback)(E=>f(o.uid,E,D),[o.uid]),y=(0,s.useMemo)(()=>_()(C,300,{leading:!0}),[C]),m=E=>{E.preventDefault(),p.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:r,onClickBackdrop:r,isOpen:!0,children:[(0,n.jsxs)("div",{children:[t===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,t>0?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{children:(0,n.jsxs)(e.x6,{i18nKey:"library-panels.modal.body",count:t,tOptions:{defaultValue_one:"This panel is being used in {{count}} dashboard. Please choose which dashboard to view the panel in:",defaultValue_other:"This panel is being used in {{count}} dashboard. Please choose which dashboard to view the panel in:"},children:["This panel is being used in ",{count:t}," dashboard. Please choose which dashboard to view the panel in:"]})}),(0,n.jsx)(v.DW,{isClearable:!0,isLoading:h,defaultOptions:!0,loadOptions:y,onChange:g,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)(i.$n,{variant:"secondary",onClick:r,fill:"outline",children:(0,n.jsx)(e.x6,{i18nKey:"library-panels.modal.button-cancel",children:"Cancel"})}),(0,n.jsx)(i.$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 f(o,r,h){h(!0);const t=(await(0,M.xV)(o))?.filter(l=>l.name.toLowerCase().includes(r.toLowerCase())).map(l=>({label:l.name,value:l}));return h(!1),t||[]}}}]);

//# sourceMappingURL=LibraryPanelsPage.564857943cb79e030623.js.map