"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[5295],{55177:(p,o,t)=>{t.r(o),t.d(o,{SnapshotListPage:()=>s,default:()=>x});var e=t(27702),u=t(44644),h=t(80601),m=t(73289),E=t(26129),i=t(66670),r=t(3613);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},80601:(p,o,t)=>{var e;e={value:!0};var u=t(48314),h=t(27702),m=u.__importDefault(t(58281));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.2e79119f9cf1784bfcdc.js.map