"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[5295],{"./public/app/features/manage-dashboards/SnapshotListPage.tsx":(e,a,t)=>{t.r(a),t.d(a,{SnapshotListPage:()=>m,default:()=>y});var s,n,r,c=t("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/index.js"),d=t("./.yarn/__virtual__/react-redux-virtual-7ad20a440e/3/opt/drone/yarncache/react-redux-npm-7.2.6-134f5ed64d-0bf142ce0d.zip/node_modules/react-redux/es/index.js"),i=t("./public/app/core/components/Page/Page.tsx"),l=t("./packages/grafana-ui/src/index.ts"),o=t("./packages/grafana-runtime/src/index.ts"),h=t("./.yarn/__virtual__/react-use-virtual-00326e70ba/3/opt/drone/yarncache/react-use-npm-17.3.2-a032cbeb01-7379460f51.zip/node_modules/react-use/lib/useAsync.js"),x=t("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/jsx-runtime.js");const u=()=>{const[e,a]=(0,c.useState)([]),[t,d]=(0,c.useState)(),i=o.locationService.getLocation().pathname,u=window.location.href,p=u.substr(0,u.indexOf(i));(0,h.Z)((async()=>{const e=await(0,o.getBackendSrv)().get("/api/dashboard/snapshots").then((e=>e.map((e=>Object.assign({},e,{url:`/dashboard/snapshot/${e.key}`})))));a(e)}),[a]);const j=(0,c.useCallback)((async t=>{const s=e.filter((e=>e.key!==t.key));a(s),await(0,o.getBackendSrv)().delete(`/api/snapshots/${t.key}`).catch((()=>{a(e)}))}),[e]);return(0,x.jsxs)("div",{children:[(0,x.jsxs)("table",{className:"filter-table",children:[(0,x.jsx)("thead",{children:(0,x.jsxs)("tr",{children:[s||(s=(0,x.jsx)("th",{children:(0,x.jsx)("strong",{children:"Name"})})),n||(n=(0,x.jsx)("th",{children:(0,x.jsx)("strong",{children:"Snapshot url"})})),(0,x.jsx)("th",{style:{width:"70px"}}),(0,x.jsx)("th",{style:{width:"30px"}}),(0,x.jsx)("th",{style:{width:"25px"}})]})}),(0,x.jsx)("tbody",{children:e.map((e=>{const a=e.externalUrl||e.url,t=e.externalUrl||`${p}${e.url}`;return(0,x.jsxs)("tr",{children:[(0,x.jsx)("td",{children:(0,x.jsx)("a",{href:a,children:e.name})}),(0,x.jsx)("td",{children:(0,x.jsx)("a",{href:a,children:t})}),(0,x.jsx)("td",{children:e.external&&(r||(r=(0,x.jsx)("span",{className:"query-keyword",children:"External"})))}),(0,x.jsx)("td",{className:"text-center",children:(0,x.jsx)(l.LinkButton,{href:a,variant:"secondary",size:"sm",icon:"eye",children:"View"})}),(0,x.jsx)("td",{className:"text-right",children:(0,x.jsx)(l.Button,{variant:"destructive",size:"sm",icon:"times",onClick:()=>d(e)})})]},e.key)}))})]}),(0,x.jsx)(l.ConfirmModal,{isOpen:!!t,icon:"trash-alt",title:"Delete",body:`Are you sure you want to delete '${null==t?void 0:t.name}'?`,confirmText:"Delete",onDismiss:()=>d(void 0),onConfirm:()=>{j(t),d(void 0)}})]})};var p,j=t("./public/app/core/selectors/navModel.ts");const m=e=>{let{navModel:a,location:t}=e;return(0,x.jsx)(i.Z,{navModel:a,children:p||(p=(0,x.jsx)(i.Z.Contents,{children:(0,x.jsx)(u,{})}))})},y=(0,d.connect)((e=>({navModel:(0,j.h)(e.navIndex,"snapshots")})))(m)}}]);
//# sourceMappingURL=SnapshotListPage.cd4ada1146b53ad3284f.js.map