mirror of
https://github.com/grafana/grafana.git
synced 2025-02-03 12:11:09 -06:00
c809d63065
* refactor(loginpage): migrate custom button styles to use Button component * refactor(certificationkey): prefer grafana-ui form elements over html elements and classnames * refactor(axisselector): prefer grafana-ui Button component over html button element * refactor(input-datasource): replace use of btn class with grafana-ui components * chore(grafana-ui): delete deprecated ToggleButtonGroup component * refactor: replace btn and cta-form__close class usage with IconButton * chore(closebutton): post master merge use v2 theme * refactor(permissionlist): remove usage of .btn classname * Wip * docs(styling): update styling and theme docs import paths * refactor(alerting): remote btn classnames from TestRuleResult * refactor(apikeys): prefer grafana-ui Button components over btn classNames * refactor(folders): prefer grafana-ui Button components over btn classNames * refactor(teams): prefer grafana-ui Button components over btn classNames * refactor(datasources): prefer grafana-ui Button components over btn classNames * refactor: prefer grafana-ui Button components over btn classNames * Minor style tweak to service buttons * test: update snapshots related to button changes * chore(input-datasource): remove unused import declaration * refactor(loginservicebuttons): rename theme.palette to theme.colors Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
55 lines
1.8 KiB
TypeScript
55 lines
1.8 KiB
TypeScript
import React, { FC } from 'react';
|
|
import { PluginDashboard } from '../../types';
|
|
import { Button, Icon } from '@grafana/ui';
|
|
|
|
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 icon="trash-alt" variant="destructive" size="sm" onClick={() => onRemove(dashboard)} />
|
|
)}
|
|
</td>
|
|
</tr>
|
|
);
|
|
})}
|
|
</tbody>
|
|
</table>
|
|
);
|
|
};
|
|
|
|
export default DashboardsTable;
|