2025-05-15 15:17:14 +08:00
|
|
|
import { Trans } from '@grafana/i18n';
|
2022-07-20 15:25:09 +08:00
|
|
|
import { Button } from '@grafana/ui';
|
|
|
|
|
|
|
|
import { DataSourceRights } from '../types';
|
|
|
|
|
|
|
|
import { DataSourceReadOnlyMessage } from './DataSourceReadOnlyMessage';
|
|
|
|
|
|
|
|
export type Props = {
|
|
|
|
dataSourceRights: DataSourceRights;
|
|
|
|
onDelete: () => void;
|
|
|
|
};
|
|
|
|
|
|
|
|
export function DataSourceLoadError({ dataSourceRights, onDelete }: Props) {
|
|
|
|
const { readOnly, hasDeleteRights } = dataSourceRights;
|
|
|
|
const canDelete = !readOnly && hasDeleteRights;
|
2025-05-12 17:38:26 +08:00
|
|
|
const navigateBack = () => window.history.back();
|
2022-07-20 15:25:09 +08:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{readOnly && <DataSourceReadOnlyMessage />}
|
|
|
|
|
|
|
|
<div className="gf-form-button-row">
|
|
|
|
{canDelete && (
|
|
|
|
<Button type="submit" variant="destructive" onClick={onDelete}>
|
2025-03-27 18:12:25 +08:00
|
|
|
<Trans i18nKey="datasources.data-source-load-error.delete">Delete</Trans>
|
2022-07-20 15:25:09 +08:00
|
|
|
</Button>
|
|
|
|
)}
|
|
|
|
|
|
|
|
<Button variant="secondary" fill="outline" type="button" onClick={navigateBack}>
|
2025-03-27 18:12:25 +08:00
|
|
|
<Trans i18nKey="datasources.data-source-load-error.back">Back</Trans>
|
2022-07-20 15:25:09 +08:00
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|