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KAWuCT,GAIpC,MAAMsB,UAA6BC,EAAAA,cAAqB,qDAOlD,CAAC3C,EAA4B4C,KACtC,MAAM,WAAEP,EAAF,gBAAchB,GAAoBwB,KAAKjB,MACvCkB,EAAY,CAChBC,SAAU/C,EAAU+C,SACpBC,KAAMhD,EAAUgD,KAChBJ,UAAAA,EACAK,OAAQ,IAGNZ,GACFS,EAAKG,OAAOC,KAAK,CACf3C,KAAM,IACN4C,KAAM,aACNJ,SAAUV,EAAWc,KACrBC,MAAOf,EAAW9B,OAItBc,EAAgByB,EAAM9C,EAAUW,UAzB2B,mBA4BjDX,IACV6C,KAAKjB,MAAMJ,gBAAgBxB,EAAUgC,QA5BhB,0BACrB,MAAM,eAAEV,EAAF,aAAkBO,GAAiBgB,KAAKjB,YACxCN,EAAeO,GACrBgB,KAAKjB,MAAML,uBA4Bb8B,SACE,MAAM,WAAEzD,EAAF,SAAcqC,EAAd,UAAwBO,GAAcK,KAAKjB,MACjD,OACE,SAAC,IAAD,CAAMK,SAAUA,EAAhB,UACE,SAAC,aAAD,CAAeO,UAAWA,EAA1B,UACE,SAAC,IAAD,CACE5C,WAAYA,EACZC,SAAU,CAACG,EAAW4C,IAAcC,KAAKhD,SAASG,EAAW4C,GAC7D9C,SAAWE,GAAc6C,KAAK/C,SAASE,UAQnD,QAAeyB,EAAUiB","sources":["webpack://grafana/./public/app/features/datasources/DashboardsTable.tsx","webpack://grafana/./public/app/features/datasources/DataSourceDashboards.tsx"],"sourcesContent":["import React, { FC } from 'react';\n\nimport { Button, Icon } from '@grafana/ui';\n\nimport { PluginDashboard } from '../../types';\n\nexport interface Props {\n dashboards: PluginDashboard[];\n onImport: (dashboard: PluginDashboard, overwrite: boolean) => void;\n onRemove: (dashboard: PluginDashboard) => void;\n}\n\nconst DashboardsTable: FC<Props> = ({ dashboards, onImport, onRemove }) => {\n function buttonText(dashboard: PluginDashboard) {\n return dashboard.revision !== dashboard.importedRevision ? 'Update' : 'Re-import';\n }\n\n return (\n <table className=\"filter-table\">\n <tbody>\n {dashboards.map((dashboard, index) => {\n return (\n <tr key={`${dashboard.dashboardId}-${index}`}>\n <td className=\"width-1\">\n <Icon name=\"apps\" />\n </td>\n <td>\n {dashboard.imported ? (\n <a href={dashboard.importedUrl}>{dashboard.title}</a>\n ) : (\n <span>{dashboard.title}</span>\n )}\n </td>\n <td style={{ textAlign: 'right' }}>\n {!dashboard.imported ? (\n <Button variant=\"secondary\" size=\"sm\" onClick={() => onImport(dashboard, false)}>\n Import\n </Button>\n ) : (\n <Button variant=\"secondary\" size=\"sm\" onClick={() => onImport(dashboard, true)}>\n {buttonText(dashboard)}\n </Button>\n )}\n {dashboard.imported && (\n <Button icon=\"trash-alt\" variant=\"destructive\" size=\"sm\" onClick={() => onRemove(dashboard)} />\n )}\n </td>\n </tr>\n );\n })}\n </tbody>\n </table>\n );\n};\n\nexport default DashboardsTable;\n","import React, { PureComponent } from 'react';\nimport { connect, ConnectedProps } from 'react-redux';\n\nimport Page from 'app/core/components/Page/Page';\nimport { GrafanaRouteComponentProps } from 'app/core/navigation/types';\nimport { getNavModel } from 'app/core/selectors/navModel';\nimport { PluginDashboard, StoreState } from 'app/types';\n\nimport { importDashboard, removeDashboard } from '../dashboard/state/actions';\nimport { loadPluginDashboards } from '../plugins/admin/state/actions';\n\nimport DashboardTable from './DashboardsTable';\nimport { loadDataSource } from './state/actions';\nimport { getDataSource } from './state/selectors';\n\nexport interface OwnProps extends GrafanaRouteComponentProps<{ uid: string }> {}\n\nfunction mapStateToProps(state: StoreState, props: OwnProps) {\n const dataSourceId = props.match.params.uid;\n\n return {\n navModel: getNavModel(state.navIndex, `datasource-dashboards-${dataSourceId}`),\n dashboards: state.plugins.dashboards,\n dataSource: getDataSource(state.dataSources, dataSourceId),\n isLoading: state.plugins.isLoadingPluginDashboards,\n dataSourceId,\n };\n}\n\nconst mapDispatchToProps = {\n importDashboard,\n loadDataSource,\n loadPluginDashboards,\n removeDashboard,\n};\n\nconst connector = connect(mapStateToProps, mapDispatchToProps);\n\nexport type Props = OwnProps & ConnectedProps<typeof connector>;\n\nexport class DataSourceDashboards extends PureComponent<Props> {\n async componentDidMount() {\n const { loadDataSource, dataSourceId } = this.props;\n await loadDataSource(dataSourceId);\n this.props.loadPluginDashboards();\n }\n\n onImport = (dashboard: PluginDashboard, overwrite: boolean) => {\n const { dataSource, importDashboard } = this.props;\n const data: any = {\n pluginId: dashboard.pluginId,\n path: dashboard.path,\n overwrite,\n inputs: [],\n };\n\n if (dataSource) {\n data.inputs.push({\n name: '*',\n type: 'datasource',\n pluginId: dataSource.type,\n value: dataSource.name,\n });\n }\n\n importDashboard(data, dashboard.title);\n };\n\n onRemove = (dashboard: PluginDashboard) => {\n this.props.removeDashboard(dashboard.uid);\n };\n\n render() {\n const { dashboards, navModel, isLoading } = this.props;\n return (\n <Page navModel={navModel}>\n <Page.Contents isLoading={isLoading}>\n <DashboardTable\n dashboards={dashboards}\n onImport={(dashboard, overwrite) => this.onImport(dashboard, overwrite)}\n onRemove={(dashboard) => this.onRemove(dashboard)}\n />\n </Page.Contents>\n </Page>\n );\n }\n}\n\nexport default connector(DataSourceDashboards);\n"],"names":["dashboards","onImport","onRemove","buttonText","dashboard","revision","importedRevision","className","map","index","Icon","name","imported","href","importedUrl","title","style","textAlign","Button","variant","size","onClick","icon","dashboardId","mapDispatchToProps","importDashboard","loadDataSource","loadPluginDashboards","removeDashboard","connector","connect","state","props","dataSourceId","match","params","uid","navModel","getNavModel","navIndex","plugins","dataSource","getDataSource","dataSources","isLoading","isLoadingPluginDashboards","DataSourceDashboards","PureComponent","overwrite","this","data","pluginId","path","inputs","push","type","value","render"],"sourceRoot":""}
|