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AAYC,KAAK,KAAKC,KAAK,MAA1D,qBAIF,eAAIT,UAAU,aAAd,UACE,SAAC,EAAAU,OAAD,CAAQH,QAAQ,cAAcC,KAAK,KAAKC,KAAK,QAAQE,QAAS,IAAMxC,EAAkBmB,SAdjFA,EAASE,cAsB1B,SAAC,EAAAoB,aAAD,CACEC,SAAU3C,EACVuC,KAAK,YACLK,MAAM,SACNC,KAAO,oCAAmC7C,MAAAA,OAApC,EAAoCA,EAAgBkC,SAC1DY,YAAY,SACZC,UAAW,IAAM9C,OAAkB+C,GACnCC,UAAW,KACT1B,EAAiBvB,GACjBC,OAAkB+C,U,MC9ErB,MAAME,EAA8B,IAA4B,IAA3B,SAAEC,EAAF,SAAY5C,GAAe,EACrE,OACE,SAAC6C,EAAA,EAAD,CAAMD,SAAUA,EAAhB,gBACE,SAACC,EAAA,WAAD,WACE,SAACxD,EAAD,UAUR,GAAeyD,EAAAA,EAAAA,UAJ2DC,IAAD,CACvEH,UAAUI,EAAAA,EAAAA,GAAYD,EAAME,SAAU,gBAGxC,CAAwCN","sources":["webpack://grafana/./public/app/features/manage-dashboards/components/SnapshotListTable.tsx","webpack://grafana/./public/app/features/manage-dashboards/SnapshotListPage.tsx"],"sourcesContent":["import React, { FC, useState, useCallback } from 'react';\nimport useAsync from 'react-use/lib/useAsync';\n\nimport { getBackendSrv, locationService } from '@grafana/runtime';\nimport { ConfirmModal, Button, LinkButton } from '@grafana/ui';\n\nimport { Snapshot } from '../types';\n\nexport function getSnapshots() {\n return getBackendSrv()\n .get('/api/dashboard/snapshots')\n .then((result: Snapshot[]) => {\n return result.map((snapshot) => ({\n ...snapshot,\n url: `/dashboard/snapshot/${snapshot.key}`,\n }));\n });\n}\nexport const SnapshotListTable: FC = () => {\n const [snapshots, setSnapshots] = useState([]);\n const [removeSnapshot, setRemoveSnapshot] = useState();\n const currentPath = locationService.getLocation().pathname;\n const fullUrl = window.location.href;\n const baseUrl = fullUrl.substring(0, fullUrl.indexOf(currentPath));\n\n useAsync(async () => {\n const response = await getSnapshots();\n setSnapshots(response);\n }, [setSnapshots]);\n\n const doRemoveSnapshot = useCallback(\n async (snapshot: Snapshot) => {\n const filteredSnapshots = snapshots.filter((ss) => ss.key !== snapshot.key);\n setSnapshots(filteredSnapshots);\n await getBackendSrv()\n .delete(`/api/snapshots/${snapshot.key}`)\n .catch(() => {\n setSnapshots(snapshots);\n });\n },\n [snapshots]\n );\n\n return (\n
\n \n \n \n \n \n \n \n \n \n \n \n {snapshots.map((snapshot) => {\n const url = snapshot.externalUrl || snapshot.url;\n const fullUrl = snapshot.externalUrl || `${baseUrl}${snapshot.url}`;\n return (\n \n \n \n \n \n \n \n );\n })}\n \n
\n Name\n \n Snapshot url\n
\n {snapshot.name}\n \n {fullUrl}\n {snapshot.external && External}\n \n View\n \n \n
\n\n setRemoveSnapshot(undefined)}\n onConfirm={() => {\n doRemoveSnapshot(removeSnapshot!);\n setRemoveSnapshot(undefined);\n }}\n />\n
\n );\n};\n","import React, { FC } from 'react';\nimport { MapStateToProps, connect } from 'react-redux';\n\nimport { NavModel } from '@grafana/data';\nimport Page from 'app/core/components/Page/Page';\nimport { getNavModel } from 'app/core/selectors/navModel';\nimport { StoreState } from 'app/types';\n\nimport { GrafanaRouteComponentProps } from '../../core/navigation/types';\n\nimport { SnapshotListTable } from './components/SnapshotListTable';\n\ninterface ConnectedProps {\n navModel: NavModel;\n}\ninterface Props extends ConnectedProps, GrafanaRouteComponentProps {}\n\nexport const SnapshotListPage: FC = ({ navModel, location }) => {\n return (\n \n \n \n \n \n );\n};\n\nconst mapStateToProps: MapStateToProps = (state: StoreState) => ({\n navModel: getNavModel(state.navIndex, 'snapshots'),\n});\n\nexport default connect(mapStateToProps)(SnapshotListPage);\n"],"names":["SnapshotListTable","snapshots","setSnapshots","useState","removeSnapshot","setRemoveSnapshot","currentPath","locationService","pathname","fullUrl","window","location","href","baseUrl","substring","indexOf","useAsync","async","response","getBackendSrv","get","then","result","map","snapshot","url","key","doRemoveSnapshot","useCallback","filteredSnapshots","filter","ss","delete","catch","className","style","width","externalUrl","name","external","LinkButton","variant","size","icon","Button","onClick","ConfirmModal","isOpen","title","body","confirmText","onDismiss","undefined","onConfirm","SnapshotListPage","navModel","Page","connect","state","getNavModel","navIndex"],"sourceRoot":""}