"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[6590],{3839(E,j,t){t.r(j),t.d(j,{SnapshotListPage:()=>y,default:()=>$});var s=t(74848),m=t(13791),d=t(96540),S=t(24705),a=t(92745),g=t(43173),f=t(50201),u=t(89640),b=t(92807),C=t(71599),v=t(8735),T=t(22803),i=t(70255),p=t(45861),L=t(63142),P=t(21348),R=t(15130),k=t(11257);const A=({snapshot:e,onRemove:n})=>{const l=e.externalUrl||e.url,h=R.TP.hasPermission(k.w.SnapshotsDelete),r=h?"":(0,a.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)(a.x6,{i18nKey:"snapshot.external-badge",children:"External"})})}),(0,s.jsx)("td",{className:"text-center",children:(0,s.jsx)(p.z9,{href:l,variant:"secondary",size:"sm",icon:"eye",children:(0,s.jsx)(a.x6,{i18nKey:"snapshot.view-button",children:"View"})})}),(0,s.jsx)("td",{className:"text-right",children:(0,s.jsx)(p.$n,{variant:"destructive",size:"sm",icon:"times",onClick:n,disabled:!h,tooltip:r})})]})},N=({rootProps:e})=>{const n=(0,L.of)(Y);return(0,s.jsxs)("tr",{...e,children:[(0,s.jsx)("td",{children:(0,s.jsx)(i.A,{width:80})}),(0,s.jsx)("td",{children:(0,s.jsx)(i.A,{width:240})}),(0,s.jsx)("td",{}),(0,s.jsx)("td",{children:(0,s.jsx)(i.A,{width:63,height:24,containerClassName:n.blockSkeleton})}),(0,s.jsx)("td",{children:(0,s.jsx)(i.A,{width:22,height:24,containerClassName:n.blockSkeleton})})]})},c=(0,P.j)(A,N),Y=()=>({blockSkeleton:(0,T.css)({display:"block",lineHeight:1})});async function D(){return(0,v.s)().getSnapshots().then(e=>e.map(n=>({...n,url:`${g.$.appUrl}dashboard/snapshot/${n.key}`})))}const K=()=>{const[e,n]=(0,d.useState)([]),[l,h]=(0,d.useState)(!1),[r,x]=(0,d.useState)();(0,S.A)(async()=>{h(!0);const o=await D();h(!1),n(o)},[n]);const w=(0,d.useCallback)(async o=>{const z=e.filter(F=>F.key!==o.key);n(z),await(0,v.s)().deleteSnapshot(o.key).catch(()=>{n(e)})},[e]);return!l&&e.length===0?(0,s.jsx)(f.p,{variant:"call-to-action",message:(0,a.t)("snapshot.empty-state.message","You haven't created any snapshots yet"),children:(0,s.jsxs)(a.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/#share-a-snapshot",children:"Learn more"})]})}):(0,s.jsxs)(b.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)(a.x6,{i18nKey:"snapshot.name-column-header",children:"Name"})})}),(0,s.jsx)("th",{children:(0,s.jsx)("strong",{children:(0,s.jsx)(a.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(o=>(0,s.jsx)(c,{snapshot:o,onRemove:()=>x(o)},o.key))})]}),(0,s.jsx)(C.u,{isOpen:!!r,title:(0,a.t)("manage-dashboards.snapshot-list-table.title-delete","Delete"),body:(0,a.t)("manage-dashboards.snapshot-list-table.body-delete","Are you sure you want to delete '{{snapshotToRemove}}'?",{snapshotToRemove:r?.name}),confirmText:(0,a.t)("manage-dashboards.snapshot-list-table.confirmText-delete","Delete"),onDismiss:()=>x(void 0),onConfirm:()=>{w(r),x(void 0)}})]})},y=({})=>(0,s.jsx)(m.Y,{navId:"dashboards/snapshots",children:(0,s.jsx)(m.Y.Contents,{children:(0,s.jsx)(K,{})})}),$=y}}]);

//# sourceMappingURL=SnapshotListPage.230fe9eae5e6946431d0.js.map