"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[5295],{17942:(g,o,t)=>{t.r(o),t.d(o,{SnapshotListPage:()=>p,default:()=>S});var e=t(39953),m=t(13253),h=t(99292),u=t(4148),E=t(32688),i=t(4919),c=t(32840),a=t(62679);function v(){return(0,u.i)().get("/api/dashboard/snapshots").then(s=>s.map(l=>({...l,url:`${E.config.appUrl}dashboard/snapshot/${l.key}`})))}const d=()=>{const[s,l]=(0,e.useState)([]),[y,f]=(0,e.useState)();(0,h.Z)(async()=>{const n=await v();l(n)},[l]);const x=(0,e.useCallback)(async n=>{const r=s.filter(C=>C.key!==n.key);l(r),await(0,u.i)().delete(`/api/snapshots/${n.key}`).catch(()=>{l(s)})},[s]);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,e.createElement(a.cC,{i18nKey:"snapshot.name-column-header"},"Name"))),e.createElement("th",null,e.createElement("strong",null,e.createElement(a.cC,{i18nKey:"snapshot.url-column-header"},"Snapshot url"))),e.createElement("th",{style:{width:"70px"}}),e.createElement("th",{style:{width:"30px"}}),e.createElement("th",{style:{width:"25px"}}))),e.createElement("tbody",null,s.map(n=>{const r=n.externalUrl||n.url;return e.createElement("tr",{key:n.key},e.createElement("td",null,e.createElement("a",{href:r},n.name)),e.createElement("td",null,e.createElement("a",{href:r},r)),e.createElement("td",null,n.external&&e.createElement("span",{className:"query-keyword"},e.createElement(a.cC,{i18nKey:"snapshot.external-badge"},"External"))),e.createElement("td",{className:"text-center"},e.createElement(i.Qj,{href:r,variant:"secondary",size:"sm",icon:"eye"},e.createElement(a.cC,{i18nKey:"snapshot.view-button"},"View"))),e.createElement("td",{className:"text-right"},e.createElement(i.zx,{variant:"destructive",size:"sm",icon:"times",onClick:()=>f(n)})))}))),e.createElement(c.s,{isOpen:!!y,icon:"trash-alt",title:"Delete",body:`Are you sure you want to delete '${y?.name}'?`,confirmText:"Delete",onDismiss:()=>f(void 0),onConfirm:()=>{x(y),f(void 0)}}))},p=({})=>e.createElement(m.T,{navId:"dashboards/snapshots"},e.createElement(m.T.Contents,null,e.createElement(d,null))),S=p},99292:(g,o,t)=>{var e;e={value:!0};var m=t(52732),h=t(39953),u=m.__importDefault(t(95681));function E(i,c){c===void 0&&(c=[]);var a=u.default(i,c,{loading:!0}),v=a[0],d=a[1];return h.useEffect(function(){d()},[d]),v}o.Z=E}}]);

//# sourceMappingURL=SnapshotListPage.78b4d17150d86a2bd62c.js.map