FolderLibraryPanelsPage.76ccf2d724ac4bf5f5f7.js 2.7 KB

12
  1. "use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[3778],{29249:(e,n,a)=>{a.r(n),a.d(n,{FolderLibraryPanelsPage:()=>f,default:()=>p});var s=a(68404),l=a(18745),o=a(94087),i=a(33801),d=a(8674),t=a(19586),r=a(1586),c=a(87413),u=a(49545),h=a(45916);const b={getFolderByUid:c.Pb};function f(e){let{navModel:n,getFolderByUid:a,folderUid:l,folder:d}=e;const{loading:c}=(0,o.Z)((async()=>await a(l)),[a,l]),[u,b]=(0,s.useState)(void 0);return(0,h.jsx)(i.Z,{navModel:n,children:(0,h.jsxs)(i.Z.Contents,{isLoading:c,children:[(0,h.jsx)(t.N,{onClick:b,currentFolderId:d.id,showSecondaryActions:!0,showSort:!0,showPanelFilter:!0}),u?(0,h.jsx)(r.b,{onDismiss:()=>b(void 0),libraryPanel:u}):null]})})}const p=(0,l.connect)(((e,n)=>{const a=n.match.params.uid;return{navModel:(0,d.h)(e.navIndex,`folder-library-panels-${a}`,(0,u._)(1)),folderUid:a,folder:e.folder}}),b)(f)},1586:(e,n,a)=>{a.d(n,{b:()=>h});var s,l=a(36636),o=a(82897),i=a(68404),d=a(43215),t=a(90923),r=a(69783),c=a(23078),u=a(45916);function h(e){let{libraryPanel:n,onDismiss:a}=e;const l=(0,r.useStyles2)(b),[h,f]=(0,i.useState)(!1),[p,v]=(0,i.useState)(0),[g,w]=(0,i.useState)(void 0);(0,i.useEffect)((()=>{(async()=>{const e=await(0,c.Ef)(n.uid);v(e.length)})()}),[n.uid]);const x=(0,i.useCallback)((e=>async function(e,n,a){a(!0);const s=(await(0,c.E8)(e)).filter((e=>e.title.toLowerCase().includes(n.toLowerCase()))).map((e=>({label:e.title,value:e})));return a(!1),s}(n.uid,e,f)),[n.uid]),y=(0,i.useMemo)((()=>(0,o.debounce)(x,300,{leading:!0,trailing:!0})),[x]);return(0,u.jsxs)(r.Modal,{title:"View panel in dashboard",onDismiss:a,onClickBackdrop:a,isOpen:!0,children:[(0,u.jsxs)("div",{className:l.container,children:[0===p?s||(s=(0,u.jsx)("span",{children:"Panel is not linked to a dashboard. Add the panel to a dashboard and retry."})):null,p>0?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("p",{children:["This panel is being used in"," ",(0,u.jsxs)("strong",{children:[p," ",p>1?"dashboards":"dashboard"]}),".Please choose which dashboard to view the panel in:"]}),(0,u.jsx)(r.AsyncSelect,{isClearable:!0,isLoading:h,defaultOptions:!0,loadOptions:y,onChange:w,placeholder:"Start typing to search for dashboard",noOptionsMessage:"No dashboards found"})]}):null]}),(0,u.jsxs)(r.Modal.ButtonRow,{children:[(0,u.jsx)(r.Button,{variant:"secondary",onClick:a,fill:"outline",children:"Cancel"}),(0,u.jsx)(r.Button,{onClick:e=>{var n;e.preventDefault(),t.locationService.push(d.urlUtil.renderUrl(`/d/${null==g||null===(n=g.value)||void 0===n?void 0:n.uid}`,{}))},disabled:!Boolean(g),children:g?`View panel in ${null==g?void 0:g.label}...`:"View panel in dashboard..."})]})]})}function b(e){return{container:l.css``}}}}]);
  2. //# sourceMappingURL=FolderLibraryPanelsPage.76ccf2d724ac4bf5f5f7.js.map