Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into gtk-grafana/multiple-…
Browse files Browse the repository at this point in the history
…include-ui__levels
  • Loading branch information
gtk-grafana committed Feb 21, 2025
2 parents 3fc58b2 + 39f1110 commit 6eda6ce
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 35 deletions.
22 changes: 20 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

View [releases](https://github.com/grafana/explore-logs/releases/) on GitHub for up-to-date changelog information.

## 1.0.8
* Open in Explore logs button by @kozhuhds in https://github.com/grafana/explore-logs/pull/1035
* Table: Add manage columns button to table header by @gtk-grafana in https://github.com/grafana/explore-logs/pull/1057
* Table: Hide custom pixel width, surface field menu options in column header by @gtk-grafana in https://github.com/grafana/explore-logs/pull/1064
* Service selection: Pagination by @gtk-grafana in https://github.com/grafana/explore-logs/pull/1058
* Make OTEL endpoint configurable in generator dockerfile by @shantanualsi in https://github.com/grafana/explore-logs/pull/1075
* Service Selection Pagination: Generate options based on total count by @matyax in https://github.com/grafana/explore-logs/pull/1077
* Service Selection Pagination: Check for possibly undefined in options by @matyax in https://github.com/grafana/explore-logs/pull/1080
* Explore links: Add pattern filter support by @gtk-grafana in https://github.com/grafana/explore-logs/pull/1036
* Logs Panel: Display error message when logs fail to load by @matyax in https://github.com/grafana/explore-logs/pull/1079
* Docs: Migrate images to media service by @robbymilo in https://github.com/grafana/explore-logs/pull/1081
* Query runner: Allow direction to be updated when sort order changes by @matyax in https://github.com/grafana/explore-logs/pull/1082
* Investigations: change investigations plugin id by @svennergr in https://github.com/grafana/explore-logs/pull/1084
* Grafana Drilldown Logs by @gtk-grafana in https://github.com/grafana/explore-logs/pull/1054
* Labels combobox: Cannot add more then 2 values for same label by @gtk-grafana in https://github.com/grafana/explore-logs/pull/1088
* README: Fix missing image, empty section by @gtk-grafana in https://github.com/grafana/explore-logs/pull/1089
* No loki datasource: Splash page by @gtk-grafana in https://github.com/grafana/explore-logs/pull/1061
* Fix splash page relative URL, update img in readme by @gtk-grafana in https://github.com/grafana/explore-logs/pull/1090
* Docs: Fix title copy by @knylander-grafana in https://github.com/grafana/explore-logs/pull/1092

## 1.0.7
* Link extensions: Add support for line filters by @gtk-grafana in https://github.com/grafana/explore-logs/pull/997
* Link extensions: Add support for fields by @gtk-grafana in https://github.com/grafana/explore-logs/pull/999
Expand All @@ -16,8 +36,6 @@ View [releases](https://github.com/grafana/explore-logs/releases/) on GitHub for
* Filters: Expression builder - differentiate user input from selected tags/values by @gtk-grafana in https://github.com/grafana/explore-logs/issues/1045
* Upgrade scenes to prevent panels from not being hidden by @svennergr in https://github.com/grafana/explore-logs/issues/1025



## 1.0.6
* Line filters: Regex support by @gtk-grafana in https://github.com/grafana/explore-logs/pull/963
* Line filters: Allow backticks5 by @gtk-grafana in https://github.com/grafana/explore-logs/pull/992
Expand Down
1 change: 1 addition & 0 deletions docs/sources/_index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: Grafana Logs Drilldown
menuTitle: Logs Drilldown
canonical: https://grafana.com/docs/grafana/latest/explore/simplified-exploration/logs/
description: Learn about the new experience for browsing your Loki logs without writing queries.
weight: 100
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "grafana-lokiexplore-app",
"version": "1.0.7",
"version": "1.0.8",
"bundlewatch": {
"files": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import React from 'react';
import { render, screen, fireEvent } from '@testing-library/react';
import { useReturnToPrevious } from '@grafana/runtime';
import { OpenInExploreLogsButtonProps } from './types';
import OpenInExploreLogsButton from './OpenInExploreLogsButton';
import { OpenInLogsDrilldownButtonProps } from './types';
import OpenInLogsDrilldownButton from './OpenInLogsDrilldownButton';
import { AbstractLabelOperator } from '@grafana/data';
import { addCustomInputPrefixAndValueLabels, encodeFilter } from 'services/extensions/utils';

jest.mock('@grafana/runtime', () => ({
useReturnToPrevious: jest.fn(),
}));

describe('OpenInExploreLogsButton', () => {
describe('OpenInLogsDrilldownButton', () => {
const setReturnToPreviousMock = jest.fn();

beforeEach(() => {
(useReturnToPrevious as jest.Mock).mockReturnValue(setReturnToPreviousMock);
});

it('should render the button with correct href (Equal operator)', () => {
const props: OpenInExploreLogsButtonProps = {
const props: OpenInLogsDrilldownButtonProps = {
datasourceUid: 'test-datasource',
streamSelectors: [{ name: 'job', value: 'test-job', operator: AbstractLabelOperator.Equal }],
from: 'now-1h',
to: 'now',
};

render(<OpenInExploreLogsButton {...props} />);
render(<OpenInLogsDrilldownButton {...props} />);

const linkButton = screen.getByRole('link', { name: /open in explore logs/i });
const linkButton = screen.getByRole('link', { name: /open in logs drilldown/i });
expect(linkButton).toBeInTheDocument();
expect(linkButton).toHaveAttribute(
'href',
Expand All @@ -38,14 +38,14 @@ describe('OpenInExploreLogsButton', () => {
});

it('should handle NotEqual operator correctly', () => {
const props: OpenInExploreLogsButtonProps = {
const props: OpenInLogsDrilldownButtonProps = {
streamSelectors: [
{ name: 'job', value: 'test-job', operator: AbstractLabelOperator.Equal },
{ name: 'test_label_key', value: 'test-label-value', operator: AbstractLabelOperator.NotEqual },
],
};

render(<OpenInExploreLogsButton {...props} />);
render(<OpenInLogsDrilldownButton {...props} />);

const linkButton = screen.getByRole('link');
expect(linkButton).toHaveAttribute(
Expand All @@ -57,14 +57,14 @@ describe('OpenInExploreLogsButton', () => {
});

it('should handle EqualRegEx operator with properly encoded PromQL values', () => {
const props: OpenInExploreLogsButtonProps = {
const props: OpenInLogsDrilldownButtonProps = {
streamSelectors: [
{ name: 'job', value: 'test-job', operator: AbstractLabelOperator.Equal },
{ name: 'test_label_key', value: 'special.(char)+|value$', operator: AbstractLabelOperator.EqualRegEx },
],
};

render(<OpenInExploreLogsButton {...props} />);
render(<OpenInLogsDrilldownButton {...props} />);

const linkButton = screen.getByRole('link');
expect(linkButton).toHaveAttribute(
Expand All @@ -78,14 +78,14 @@ describe('OpenInExploreLogsButton', () => {
});

it('should handle NotEqualRegEx operator with properly encoded PromQL values', () => {
const props: OpenInExploreLogsButtonProps = {
const props: OpenInLogsDrilldownButtonProps = {
streamSelectors: [
{ name: 'job', value: 'test-job', operator: AbstractLabelOperator.Equal },
{ name: 'test_label_key', value: 'special.(char)+|value$', operator: AbstractLabelOperator.NotEqualRegEx },
],
};

render(<OpenInExploreLogsButton {...props} />);
render(<OpenInLogsDrilldownButton {...props} />);

const linkButton = screen.getByRole('link');
expect(linkButton).toHaveAttribute(
Expand All @@ -99,17 +99,17 @@ describe('OpenInExploreLogsButton', () => {
});

it('should not render button if labelMatchers is empty', () => {
render(<OpenInExploreLogsButton streamSelectors={[]} />);
render(<OpenInLogsDrilldownButton streamSelectors={[]} />);
expect(screen.queryByRole('link')).not.toBeInTheDocument();
});

it('should call setReturnToPrevious on click', () => {
const props: OpenInExploreLogsButtonProps = {
const props: OpenInLogsDrilldownButtonProps = {
streamSelectors: [{ name: 'job', value: 'test-job', operator: AbstractLabelOperator.Equal }],
returnToPreviousSource: 'test-source',
};

render(<OpenInExploreLogsButton {...props} />);
render(<OpenInLogsDrilldownButton {...props} />);

const linkButton = screen.getByRole('link');
fireEvent.click(linkButton);
Expand All @@ -120,12 +120,12 @@ describe('OpenInExploreLogsButton', () => {
it('should render using custom renderButton prop', () => {
const renderButtonMock = jest.fn(({ href }) => <a href={href}>Custom Button</a>);

const props: OpenInExploreLogsButtonProps = {
const props: OpenInLogsDrilldownButtonProps = {
streamSelectors: [{ name: 'job', value: 'test-job', operator: AbstractLabelOperator.Equal }],
renderButton: renderButtonMock,
};

render(<OpenInExploreLogsButton {...props} />);
render(<OpenInLogsDrilldownButton {...props} />);
expect(screen.getByText('Custom Button')).toBeInTheDocument();
expect(renderButtonMock).toHaveBeenCalledWith(expect.objectContaining({ href: expect.any(String) }));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
stringifyAdHocValues,
UrlParameters,
} from 'services/extensions/links';
import { OpenInExploreLogsButtonProps } from './types';
import { OpenInLogsDrilldownButtonProps } from './types';
import { AbstractLabelOperator } from '@grafana/data';
import { LabelFilterOp } from 'services/filterTypes';

Expand All @@ -22,14 +22,14 @@ const operatorMap = {
[AbstractLabelOperator.NotEqualRegEx]: LabelFilterOp.RegexNotEqual,
};

export default function OpenInExploreLogsButton({
export default function OpenInLogsDrilldownButton({
datasourceUid,
streamSelectors,
from,
to,
returnToPreviousSource,
renderButton,
}: OpenInExploreLogsButtonProps) {
}: OpenInLogsDrilldownButtonProps) {
const setReturnToPrevious = useReturnToPrevious();

const href = useMemo(() => {
Expand Down Expand Up @@ -86,7 +86,7 @@ export default function OpenInExploreLogsButton({
href={href}
onClick={() => setReturnToPrevious(returnToPreviousSource || 'previous')}
>
Open in Explore Logs
Open in Logs Drilldown
</LinkButton>
);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AbstractLabelMatcher } from '@grafana/data';

export interface OpenInExploreLogsButtonProps {
export interface OpenInLogsDrilldownButtonProps {
datasourceUid?: string;
streamSelectors: AbstractLabelMatcher[];
from?: string;
Expand Down
4 changes: 2 additions & 2 deletions src/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
"exposedComponents": [
{
"id": "grafana-lokiexplore-app/open-in-explore-logs-button/v1",
"title": "Open in Explore Logs button",
"description": "A button that opens a logs view in the Explore Logs app."
"title": "Open in Logs Drilldown button",
"description": "A button that opens a logs view in the Logs Drilldown app."
}
],
"extensionPoints": [
Expand Down
16 changes: 8 additions & 8 deletions src/services/extensions/exposedComponents.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import { LinkButton } from '@grafana/ui';
import { OpenInExploreLogsButtonProps } from 'Components/OpenInExploreLogsButton/types';
import { OpenInLogsDrilldownButtonProps } from 'Components/OpenInLogsDrilldownButton/types';
import React, { lazy, Suspense } from 'react';
const OpenInExploreLogsButton = lazy(() => import('Components/OpenInExploreLogsButton/OpenInExploreLogsButton'));
const OpenInLogsDrilldownButton = lazy(() => import('Components/OpenInLogsDrilldownButton/OpenInLogsDrilldownButton'));

function SuspendedOpenInExploreLogsButton(props: OpenInExploreLogsButtonProps) {
function SuspendedOpenInLogsDrilldownButton(props: OpenInLogsDrilldownButtonProps) {
return (
<Suspense
fallback={
<LinkButton variant="secondary" disabled>
Open in Explore Logs
Open in Logs Drilldown
</LinkButton>
}
>
<OpenInExploreLogsButton {...props} />
<OpenInLogsDrilldownButton {...props} />
</Suspense>
);
}

export const exposedComponents = [
{
id: `grafana-lokiexplore-app/open-in-explore-logs-button/v1`,
title: 'Open in Explore Logs button',
description: 'A button that opens a logs view in the Explore Logs app.',
component: SuspendedOpenInExploreLogsButton,
title: 'Open in Logs Drilldown button',
description: 'A button that opens a logs view in the Logs Drilldown app.',
component: SuspendedOpenInLogsDrilldownButton,
},
];

0 comments on commit 6eda6ce

Please sign in to comment.