"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[6590],{15278(E,j,t){t.r(j),t.d(j,{SnapshotListPage:()=>S,default:()=>$});var s=t(74848),m=t(54122),i=t(96540),p=t(24705),f=t(32370),g=t(59830),u=t(54731),C=t(99134),A=t(65164),o=t(11817),v=t(77274),L=t(22803),d=t(70255),y=t(54594),T=t(29675),b=t(71815),P=t(61351),k=t(61491);const N=({snapshot:e,onRemove:n})=>{const l=e.externalUrl||e.url,h=P.TP.hasPermission(k.AccessControlAction.SnapshotsDelete),r=h?"":(0,o.t)("snapshot.share.delete-permission-tooltip","You don't have permission to delete snapshots");return(0,s.jsxs)("tr",{children:[(0,s.jsx)("td",{children:(0,s.jsx)("a",{href:l,children:e.name})}),(0,s.jsx)("td",{children:(0,s.jsx)("a",{href:l,children:l})}),(0,s.jsx)("td",{children:e.external&&(0,s.jsx)("span",{className:"query-keyword",children:(0,s.jsx)(o.x6,{i18nKey:"snapshot.external-badge",children:"External"})})}),(0,s.jsx)("td",{className:"text-center",children:(0,s.jsx)(y.z9,{href:l,variant:"secondary",size:"sm",icon:"eye",children:(0,s.jsx)(o.x6,{i18nKey:"snapshot.view-button",children:"View"})})}),(0,s.jsx)("td",{className:"text-right",children:(0,s.jsx)(y.$n,{variant:"destructive",size:"sm",icon:"times",onClick:n,disabled:!h,tooltip:r})})]})},Y=({rootProps:e})=>{const n=(0,T.of)(R);return(0,s.jsxs)("tr",{...e,children:[(0,s.jsx)("td",{children:(0,s.jsx)(d.A,{width:80})}),(0,s.jsx)("td",{children:(0,s.jsx)(d.A,{width:240})}),(0,s.jsx)("td",{}),(0,s.jsx)("td",{children:(0,s.jsx)(d.A,{width:63,height:24,containerClassName:n.blockSkeleton})}),(0,s.jsx)("td",{children:(0,s.jsx)(d.A,{width:22,height:24,containerClassName:n.blockSkeleton})})]})},c=(0,b.j)(N,Y),R=()=>({blockSkeleton:(0,L.css)({display:"block",lineHeight:1})});async function D(){return(0,v.s)().getSnapshots().then(e=>e.map(n=>({...n,url:`${f.$.appUrl}dashboard/snapshot/${n.key}`})))}const K=()=>{const[e,n]=(0,i.useState)([]),[l,h]=(0,i.useState)(!1),[r,x]=(0,i.useState)();(0,p.A)(async()=>{h(!0);const a=await D();h(!1),n(a)},[n]);const z=(0,i.useCallback)(async a=>{const F=e.filter(w=>w.key!==a.key);n(F),await(0,v.s)().deleteSnapshot(a.key).catch(()=>{n(e)})},[e]);return!l&&e.length===0?(0,s.jsx)(g.p,{variant:"call-to-action",message:(0,o.t)("snapshot.empty-state.message","You haven't created any snapshots yet"),children:(0,s.jsxs)(o.x6,{i18nKey:"snapshot.empty-state.more-info",children:["You can create a snapshot of any dashboard through the ",(0,s.jsx)("b",{children:"Share"})," modal."," ",(0,s.jsx)(u.Y,{external:!0,href:"https://grafana.com/docs/grafana/latest/dashboards/share-dashboards-panels/#publish-a-snapshot",children:"Learn more"})]})}):(0,s.jsxs)(C.P,{overflowY:"visible",overflowX:"auto",width:"100%",children:[(0,s.jsxs)("table",{className:"filter-table",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:(0,s.jsx)("strong",{children:(0,s.jsx)(o.x6,{i18nKey:"snapshot.name-column-header",children:"Name"})})}),(0,s.jsx)("th",{children:(0,s.jsx)("strong",{children:(0,s.jsx)(o.x6,{i18nKey:"snapshot.url-column-header",children:"Snapshot url"})})}),(0,s.jsx)("th",{style:{width:"70px"}}),(0,s.jsx)("th",{style:{width:"30px"}}),(0,s.jsx)("th",{style:{width:"25px"}})]})}),(0,s.jsx)("tbody",{children:l?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(c.Skeleton,{}),(0,s.jsx)(c.Skeleton,{}),(0,s.jsx)(c.Skeleton,{})]}):e.map(a=>(0,s.jsx)(c,{snapshot:a,onRemove:()=>x(a)},a.key))})]}),(0,s.jsx)(A.u,{isOpen:!!r,icon:"trash-alt",title:"Delete",body:`Are you sure you want to delete '${r?.name}'?`,confirmText:"Delete",onDismiss:()=>x(void 0),onConfirm:()=>{z(r),x(void 0)}})]})},S=({})=>(0,s.jsx)(m.Y,{navId:"dashboards/snapshots",children:(0,s.jsx)(m.Y.Contents,{children:(0,s.jsx)(K,{})})}),$=S}}]);

//# sourceMappingURL=SnapshotListPage.41243805570c0e18b06e.js.map