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

//# sourceMappingURL=SnapshotListPage.eaf397332fddc9fa4619.js.map