SnapshotListPage.d32eb7df6376fa763b7d.js.map 6.8 KB

1
  1. {"version":3,"file":"SnapshotListPage.d32eb7df6376fa763b7d.js","mappings":"yPAkBO,MAAMA,EAAwB,KACnC,MAAOC,EAAWC,IAAgBC,EAAAA,EAAAA,UAAqB,KAChDC,EAAgBC,IAAqBF,EAAAA,EAAAA,YACtCG,EAAcC,EAAAA,gBAAAA,cAA8BC,SAC5CC,EAAUC,OAAOC,SAASC,KAC1BC,EAAUJ,EAAQK,UAAU,EAAGL,EAAQM,QAAQT,KAErDU,EAAAA,EAAAA,IAASC,UACP,MAAMC,QAjBDC,EAAAA,EAAAA,iBACJC,IAAI,4BACJC,MAAMC,GACEA,EAAOC,KAAKC,GAAD,iBACbA,EADa,CAEhBC,IAAM,uBAAsBD,EAASE,YAazCxB,EAAagB,KACZ,CAAChB,IAEJ,MAAMyB,GAAmBC,EAAAA,EAAAA,cACvBX,MAAAA,IACE,MAAMY,EAAoB5B,EAAU6B,QAAQC,GAAOA,EAAGL,MAAQF,EAASE,MACvExB,EAAa2B,SACPV,EAAAA,EAAAA,iBACHa,OAAQ,kBAAiBR,EAASE,OAClCO,OAAM,KACL/B,EAAaD,QAGnB,CAACA,IAGH,OACE,4BACE,mBAAOiC,UAAU,eAAjB,WACE,4BACE,iCACE,yBACE,wCAFJ,OAIE,yBACE,iDAEF,eAAIC,MAAO,CAAEC,MAAO,WACpB,eAAID,MAAO,CAAEC,MAAO,WACpB,eAAID,MAAO,CAAEC,MAAO,gBAGxB,2BACGnC,EAAUsB,KAAKC,IACd,MAAMC,EAAMD,EAASa,aAAeb,EAASC,IACvChB,EAAUe,EAASa,aAAgB,GAAExB,IAAUW,EAASC,MAC9D,OACE,2BACE,yBACE,cAAGb,KAAMa,EAAT,SAAeD,EAASc,UAE1B,yBACE,cAAG1B,KAAMa,EAAT,SAAehB,OAEjB,wBAAKe,EAASe,WAAT,OAAqB,iBAAML,UAAU,gBAAhB,2BAC1B,eAAIA,UAAU,cAAd,UACE,SAAC,EAAAM,WAAD,CAAY5B,KAAMa,EAAKgB,QAAQ,YAAYC,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<Snapshot[]>([]);\n const [removeSnapshot, setRemoveSnapshot] = useState<Snapshot | undefined>();\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 <div>\n <table className=\"filter-table\">\n <thead>\n <tr>\n <th>\n <strong>Name</strong>\n </th>\n <th>\n <strong>Snapshot url</strong>\n </th>\n <th style={{ width: '70px' }}></th>\n <th style={{ width: '30px' }}></th>\n <th style={{ width: '25px' }}></th>\n </tr>\n </thead>\n <tbody>\n {snapshots.map((snapshot) => {\n const url = snapshot.externalUrl || snapshot.url;\n const fullUrl = snapshot.externalUrl || `${baseUrl}${snapshot.url}`;\n return (\n <tr key={snapshot.key}>\n <td>\n <a href={url}>{snapshot.name}</a>\n </td>\n <td>\n <a href={url}>{fullUrl}</a>\n </td>\n <td>{snapshot.external && <span className=\"query-keyword\">External</span>}</td>\n <td className=\"text-center\">\n <LinkButton href={url} variant=\"secondary\" size=\"sm\" icon=\"eye\">\n View\n </LinkButton>\n </td>\n <td className=\"text-right\">\n <Button variant=\"destructive\" size=\"sm\" icon=\"times\" onClick={() => setRemoveSnapshot(snapshot)} />\n </td>\n </tr>\n );\n })}\n </tbody>\n </table>\n\n <ConfirmModal\n isOpen={!!removeSnapshot}\n icon=\"trash-alt\"\n title=\"Delete\"\n body={`Are you sure you want to delete '${removeSnapshot?.name}'?`}\n confirmText=\"Delete\"\n onDismiss={() => setRemoveSnapshot(undefined)}\n onConfirm={() => {\n doRemoveSnapshot(removeSnapshot!);\n setRemoveSnapshot(undefined);\n }}\n />\n </div>\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<Props> = ({ navModel, location }) => {\n return (\n <Page navModel={navModel}>\n <Page.Contents>\n <SnapshotListTable />\n </Page.Contents>\n </Page>\n );\n};\n\nconst mapStateToProps: MapStateToProps<ConnectedProps, {}, StoreState> = (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":""}