Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

3.6 KB
Raw Blame
import {
	ArrowUpToLine,
	Atom,
	Filter,
	SquareMousePointer,
	Terminal,
	Binoculars,
} from '@signozhq/icons';
import { Button, Tooltip } from 'antd';
import cx from 'classnames';
import { ExplorerViews } from 'pages/LogsExplorer/utils';

import './ToolbarActions.styles.scss';

interface LeftToolbarActionsProps {
	items: any;
	selectedView: string;
	onChangeSelectedView: (view: ExplorerViews) => void;
	showFilter: boolean;
	handleFilterVisibilityChange: () => void;
}

const activeTab = 'active-tab';

export default function LeftToolbarActions({
	items,
	selectedView,
	onChangeSelectedView,
	showFilter,
	handleFilterVisibilityChange,
}: LeftToolbarActionsProps): JSX.Element {
	const { clickhouse, list, timeseries, table, trace } = items;

	return (
		<div className="left-toolbar">
			{!showFilter && (
				<Tooltip title="Show Filters">
					<Button onClick={handleFilterVisibilityChange} className="filter-btn">
						<Filter size={12} />
						<ArrowUpToLine size={12} style={{ transform: 'rotate(90deg)' }} />
					</Button>
				</Tooltip>
			)}
			<div className="left-toolbar-query-actions">
				{list?.show && (
					<Tooltip title="List View">
						<Button
							disabled={list.disabled}
							className={cx(
								'list-view-tab',
								'explorer-view-option',
								selectedView === list.key ? activeTab : '',
							)}
							onClick={(): void => onChangeSelectedView(list.key)}
							data-testid="explorer-view-list"
							aria-pressed={selectedView === list.key}
						>
							<SquareMousePointer size={14} data-testid="search-view" />
							List View
						</Button>
					</Tooltip>
				)}

				{trace?.show && (
					<Tooltip title="Trace View">
						<Button
							disabled={trace.disabled}
							className={cx(
								'trace-view-tab',
								'explorer-view-option',
								selectedView === trace.key ? activeTab : '',
							)}
							onClick={(): void => onChangeSelectedView(trace.key)}
							data-testid="explorer-view-trace"
							aria-pressed={selectedView === trace.key}
						>
							<SquareMousePointer size={14} data-testid="trace-view" />
							Trace View
						</Button>
					</Tooltip>
				)}

				{timeseries?.show && (
					<Tooltip title="Time Series">
						<Button
							disabled={timeseries.disabled}
							className={cx(
								'timeseries-view-tab',
								'explorer-view-option',
								selectedView === timeseries.key ? activeTab : '',
							)}
							onClick={(): void => onChangeSelectedView(timeseries.key)}
							data-testid="explorer-view-timeseries"
							aria-pressed={selectedView === timeseries.key}
						>
							<Atom size={14} data-testid="query-builder-view" />
							Time Series
						</Button>
					</Tooltip>
				)}

				{clickhouse?.show && (
					<Tooltip title="Clickhouse">
						<Button
							disabled={clickhouse.disabled}
							className={cx(
								'clickhouse-view-tab',
								'explorer-view-option',
								selectedView === clickhouse.key ? activeTab : '',
							)}
							onClick={(): void => onChangeSelectedView(clickhouse.key)}
						>
							<Terminal size={14} data-testid="clickhouse-view" />
							Clickhouse
						</Button>
					</Tooltip>
				)}

				{table?.show && (
					<Tooltip title="Table">
						<Button
							disabled={table.disabled}
							className={cx(
								'table-view-tab',
								'explorer-view-option',
								selectedView === table.key ? activeTab : '',
							)}
							onClick={(): void => onChangeSelectedView(table.key)}
							data-testid="explorer-view-table"
							aria-pressed={selectedView === table.key}
						>
							<Binoculars size={14} data-testid="query-builder-view-v2" />
							Table
						</Button>
					</Tooltip>
				)}
			</div>
		</div>
	);
}