"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[5295],{40410:(K,i,t)=>{t.r(i),t.d(i,{SnapshotListPage:()=>S,default:()=>w});var e=t(85960),d=t(20989),v=t(84041),g=t(90857),f=t(77980),r=t(95329),E=t(83676),p=t(66681),o=t(34785),u=t(29165),C=t(47257),k=t(31560);const x=({snapshot:n,onRemove:l})=>{const s=n.externalUrl||n.url;return e.createElement("tr",null,e.createElement("td",null,e.createElement("a",{href:s},n.name)),e.createElement("td",null,e.createElement("a",{href:s},s)),e.createElement("td",null,n.external&&e.createElement("span",{className:"query-keyword"},e.createElement(r.cC,{i18nKey:"snapshot.external-badge"},"External"))),e.createElement("td",{className:"text-center"},e.createElement(u.Qj,{href:s,variant:"secondary",size:"sm",icon:"eye"},e.createElement(r.cC,{i18nKey:"snapshot.view-button"},"View"))),e.createElement("td",{className:"text-right"},e.createElement(u.zx,{variant:"destructive",size:"sm",icon:"times",onClick:l})))},T=({rootProps:n})=>{const l=(0,C.wW)(b);return e.createElement("tr",{...n},e.createElement("td",null,e.createElement(o.Z,{width:80})),e.createElement("td",null,e.createElement(o.Z,{width:240})),e.createElement("td",null),e.createElement("td",null,e.createElement(o.Z,{width:63,height:24,containerClassName:l.blockSkeleton})),e.createElement("td",null,e.createElement(o.Z,{width:22,height:24,containerClassName:l.blockSkeleton})))},c=(0,k.y)(x,T),b=()=>({blockSkeleton:(0,p.css)({display:"block",lineHeight:1})});function L(){return(0,E.G)().getSnapshots().then(n=>n.map(l=>({...l,url:`${g.config.appUrl}dashboard/snapshot/${l.key}`})))}const N=()=>{const[n,l]=(0,e.useState)([]),[s,y]=(0,e.useState)(!1),[m,h]=(0,e.useState)();(0,v.Z)(async()=>{y(!0);const a=await L();y(!1),l(a)},[l]);const R=(0,e.useCallback)(async a=>{const Z=n.filter(z=>z.key!==a.key);l(Z),await(0,E.G)().deleteSnapshot(a.key).catch(()=>{l(n)})},[n]);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(r.cC,{i18nKey:"snapshot.name-column-header"},"Name"))),e.createElement("th",null,e.createElement("strong",null,e.createElement(r.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?e.createElement(e.Fragment,null,e.createElement(c.Skeleton,null),e.createElement(c.Skeleton,null),e.createElement(c.Skeleton,null)):n.map(a=>e.createElement(c,{key:a.key,snapshot:a,onRemove:()=>h(a)})))),e.createElement(f.s,{isOpen:!!m,icon:"trash-alt",title:"Delete",body:`Are you sure you want to delete '${m?.name}'?`,confirmText:"Delete",onDismiss:()=>h(void 0),onConfirm:()=>{R(m),h(void 0)}}))},S=({})=>e.createElement(d.T,{navId:"dashboards/snapshots"},e.createElement(d.T.Contents,null,e.createElement(N,null))),w=S}}]);

//# sourceMappingURL=SnapshotListPage.86fb137e7b91287d3c86.js.map