mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
63 lines
1.9 KiB
TypeScript
63 lines
1.9 KiB
TypeScript
import React, { FC } from 'react';
|
|
|
|
import { Button, Icon } from '@grafana/ui';
|
|
|
|
import { PluginDashboard } from '../../types';
|
|
|
|
export interface Props {
|
|
dashboards: PluginDashboard[];
|
|
onImport: (dashboard: PluginDashboard, overwrite: boolean) => void;
|
|
onRemove: (dashboard: PluginDashboard) => void;
|
|
}
|
|
|
|
const DashboardsTable: FC<Props> = ({ dashboards, onImport, onRemove }) => {
|
|
function buttonText(dashboard: PluginDashboard) {
|
|
return dashboard.revision !== dashboard.importedRevision ? 'Update' : 'Re-import';
|
|
}
|
|
|
|
return (
|
|
<table className="filter-table">
|
|
<tbody>
|
|
{dashboards.map((dashboard, index) => {
|
|
return (
|
|
<tr key={`${dashboard.dashboardId}-${index}`}>
|
|
<td className="width-1">
|
|
<Icon name="apps" />
|
|
</td>
|
|
<td>
|
|
{dashboard.imported ? (
|
|
<a href={dashboard.importedUrl}>{dashboard.title}</a>
|
|
) : (
|
|
<span>{dashboard.title}</span>
|
|
)}
|
|
</td>
|
|
<td style={{ textAlign: 'right' }}>
|
|
{!dashboard.imported ? (
|
|
<Button variant="secondary" size="sm" onClick={() => onImport(dashboard, false)}>
|
|
Import
|
|
</Button>
|
|
) : (
|
|
<Button variant="secondary" size="sm" onClick={() => onImport(dashboard, true)}>
|
|
{buttonText(dashboard)}
|
|
</Button>
|
|
)}
|
|
{dashboard.imported && (
|
|
<Button
|
|
aria-label="Delete dashboard"
|
|
icon="trash-alt"
|
|
variant="destructive"
|
|
size="sm"
|
|
onClick={() => onRemove(dashboard)}
|
|
/>
|
|
)}
|
|
</td>
|
|
</tr>
|
|
);
|
|
})}
|
|
</tbody>
|
|
</table>
|
|
);
|
|
};
|
|
|
|
export default DashboardsTable;
|