mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* Implement log samples * Explore: Implement logs sample panel * Log samples: Add documentation * Update docs * Add info for log sample * Fix label * Update * Default to true * Fix copy in test * Update public/app/features/explore/LogsSamplePanel.tsx Co-authored-by: Sven Grossmann <sven.grossmann@grafana.com> * Use timeZone from grafana/schema * Rename data props to queryResponse * Unify name to logs sample * Remove redundant optional parameters in LogsSamplePanel * Make intervalMs parameter optional in dataFrameToLogsModel and remove undefined argument when not needed * Fix incorrect position of copy log line button * Update public/app/core/logsModel.ts Co-authored-by: Sven Grossmann <sven.grossmann@grafana.com> Co-authored-by: Sven Grossmann <sven.grossmann@grafana.com>
37 lines
937 B
TypeScript
37 lines
937 B
TypeScript
import React, { useState } from 'react';
|
|
|
|
import { DataQueryError } from '@grafana/data';
|
|
import { Alert, Button } from '@grafana/ui';
|
|
|
|
type Props = {
|
|
error: DataQueryError;
|
|
title: string;
|
|
};
|
|
export function SupplementaryResultError(props: Props) {
|
|
const [isOpen, setIsOpen] = useState(false);
|
|
const SHORT_ERROR_MESSAGE_LIMIT = 100;
|
|
const { error, title } = props;
|
|
// generic get-error-message-logic, taken from
|
|
// /public/app/features/explore/ErrorContainer.tsx
|
|
const message = error.message || error.data?.message || '';
|
|
const showButton = !isOpen && message.length > SHORT_ERROR_MESSAGE_LIMIT;
|
|
|
|
return (
|
|
<Alert title={title} severity="warning">
|
|
{showButton ? (
|
|
<Button
|
|
variant="secondary"
|
|
size="xs"
|
|
onClick={() => {
|
|
setIsOpen(true);
|
|
}}
|
|
>
|
|
Show details
|
|
</Button>
|
|
) : (
|
|
message
|
|
)}
|
|
</Alert>
|
|
);
|
|
}
|