"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[5295],{11155:(p,o,t)=>{t.r(o),t.d(o,{SnapshotListPage:()=>s,default:()=>x});var e=t(66111),u=t(8412),h=t(42638),m=t(54899),E=t(37932),i=t(31403),r=t(98102);function d(){return(0,m.i)().get("/api/dashboard/snapshots").then(l=>l.map(n=>({...n,url:`/dashboard/snapshot/${n.key}`})))}const f=()=>{const[l,n]=(0,e.useState)([]),[v,y]=(0,e.useState)(),b=E.E1.getLocation().pathname,S=window.location.href,k=S.substring(0,S.indexOf(b));(0,h.Z)(async()=>{const a=await d();n(a)},[n]);const C=(0,e.useCallback)(async a=>{const c=l.filter(g=>g.key!==a.key);n(c),await(0,m.i)().delete(`/api/snapshots/${a.key}`).catch(()=>{n(l)})},[l]);return e.createElement("div",null,e.createElement("table",{className:"filter-table"},e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,e.createElement("strong",null,"Name")),e.createElement("th",null,e.createElement("strong",null,"Snapshot url")),e.createElement("th",{style:{width:"70px"}}),e.createElement("th",{style:{width:"30px"}}),e.createElement("th",{style:{width:"25px"}}))),e.createElement("tbody",null,l.map(a=>{const c=a.externalUrl||a.url,g=a.externalUrl||`${k}${a.url}`;return e.createElement("tr",{key:a.key},e.createElement("td",null,e.createElement("a",{href:c},a.name)),e.createElement("td",null,e.createElement("a",{href:c},g)),e.createElement("td",null,a.external&&e.createElement("span",{className:"query-keyword"},"External")),e.createElement("td",{className:"text-center"},e.createElement(i.Qj,{href:c,variant:"secondary",size:"sm",icon:"eye"},"View")),e.createElement("td",{className:"text-right"},e.createElement(i.zx,{variant:"destructive",size:"sm",icon:"times",onClick:()=>y(a)})))}))),e.createElement(r.s,{isOpen:!!v,icon:"trash-alt",title:"Delete",body:`Are you sure you want to delete '${v?.name}'?`,confirmText:"Delete",onDismiss:()=>y(void 0),onConfirm:()=>{C(v),y(void 0)}}))},s=({})=>e.createElement(u.T,{navId:"dashboards/snapshots"},e.createElement(u.T.Contents,null,e.createElement(f,null))),x=s},42638:(p,o,t)=>{var e;e={value:!0};var u=t(9683),h=t(66111),m=u.__importDefault(t(55986));function E(i,r){r===void 0&&(r=[]);var d=m.default(i,r,{loading:!0}),f=d[0],s=d[1];return h.useEffect(function(){s()},[s]),f}o.Z=E}}]);

//# sourceMappingURL=SnapshotListPage.265f67e19fc29e8c4d5f.js.map