The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/plugins/panel/canvas/editor/TabsEditor.tsx

38 lines
926 B

import React, { useState } from 'react';
import { Tab, TabsBar } from '@grafana/ui/src';
import { InlineEditTabs } from '../types';
type Props = {
onTabChange: (v: string) => void;
};
export const TabsEditor = ({ onTabChange }: Props) => {
const [activeTab, setActiveTab] = useState<string>(InlineEditTabs.SelectedElement);
const tabs = [
{ label: 'Selected Element', value: InlineEditTabs.SelectedElement },
{ label: 'Element Management', value: InlineEditTabs.ElementManagement },
];
const onCurrentTabChange = (value: string) => {
onTabChange(value);
setActiveTab(value);
};
return (
<>
<TabsBar>
{tabs.map((t, index) => (
<Tab
key={`${t.value}-${index}`}
label={t.label}
active={t.value === activeTab}
onChangeTab={() => onCurrentTabChange(t.value!)}
/>
))}
</TabsBar>
</>
);
};