"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[5295],{17821:(e,t,s)=>{s.r(t),s.d(t,{SnapshotListPage:()=>y,default:()=>m});var n,a,r,i=s(68404),l=s(18745),c=s(33801),d=s(8674),o=s(90662),h=s(90923),x=s(69783),j=s(45916);const u=()=>{const[e,t]=(0,i.useState)([]),[s,l]=(0,i.useState)(),c=h.locationService.getLocation().pathname,d=window.location.href,u=d.substring(0,d.indexOf(c));(0,o.Z)((async()=>{const e=await(0,h.getBackendSrv)().get("/api/dashboard/snapshots").then((e=>e.map((e=>Object.assign({},e,{url:`/dashboard/snapshot/${e.key}`})))));t(e)}),[t]);const p=(0,i.useCallback)((async s=>{const n=e.filter((e=>e.key!==s.key));t(n),await(0,h.getBackendSrv)().delete(`/api/snapshots/${s.key}`).catch((()=>{t(e)}))}),[e]);return(0,j.jsxs)("div",{children:[(0,j.jsxs)("table",{className:"filter-table",children:[(0,j.jsx)("thead",{children:(0,j.jsxs)("tr",{children:[n||(n=(0,j.jsx)("th",{children:(0,j.jsx)("strong",{children:"Name"})})),a||(a=(0,j.jsx)("th",{children:(0,j.jsx)("strong",{children:"Snapshot url"})})),(0,j.jsx)("th",{style:{width:"70px"}}),(0,j.jsx)("th",{style:{width:"30px"}}),(0,j.jsx)("th",{style:{width:"25px"}})]})}),(0,j.jsx)("tbody",{children:e.map((e=>{const t=e.externalUrl||e.url,s=e.externalUrl||`${u}${e.url}`;return(0,j.jsxs)("tr",{children:[(0,j.jsx)("td",{children:(0,j.jsx)("a",{href:t,children:e.name})}),(0,j.jsx)("td",{children:(0,j.jsx)("a",{href:t,children:s})}),(0,j.jsx)("td",{children:e.external&&(r||(r=(0,j.jsx)("span",{className:"query-keyword",children:"External"})))}),(0,j.jsx)("td",{className:"text-center",children:(0,j.jsx)(x.LinkButton,{href:t,variant:"secondary",size:"sm",icon:"eye",children:"View"})}),(0,j.jsx)("td",{className:"text-right",children:(0,j.jsx)(x.Button,{variant:"destructive",size:"sm",icon:"times",onClick:()=>l(e)})})]},e.key)}))})]}),(0,j.jsx)(x.ConfirmModal,{isOpen:!!s,icon:"trash-alt",title:"Delete",body:`Are you sure you want to delete '${null==s?void 0:s.name}'?`,confirmText:"Delete",onDismiss:()=>l(void 0),onConfirm:()=>{p(s),l(void 0)}})]})};var p;const y=e=>{let{navModel:t,location:s}=e;return(0,j.jsx)(c.Z,{navModel:t,children:p||(p=(0,j.jsx)(c.Z.Contents,{children:(0,j.jsx)(u,{})}))})},m=(0,l.connect)((e=>({navModel:(0,d.h)(e.navIndex,"snapshots")})))(y)}}]);
//# sourceMappingURL=SnapshotListPage.d32eb7df6376fa763b7d.js.map