DataHoverTabs.tsx 776 B

123456789101112131415161718192021222324252627282930
  1. import React, { Dispatch, SetStateAction } from 'react';
  2. import { Tab, TabsBar } from '@grafana/ui';
  3. import { GeomapLayerHover } from '../event';
  4. type Props = {
  5. layers?: GeomapLayerHover[];
  6. setActiveTabIndex: Dispatch<SetStateAction<number>>;
  7. activeTabIndex: number;
  8. };
  9. export const DataHoverTabs = ({ layers, setActiveTabIndex, activeTabIndex }: Props) => {
  10. return (
  11. <TabsBar>
  12. {layers &&
  13. layers.map((g, index) => (
  14. <Tab
  15. key={index}
  16. label={g.layer.getName()}
  17. active={index === activeTabIndex}
  18. counter={g.features.length > 1 ? g.features.length : null}
  19. onChangeTab={() => {
  20. setActiveTabIndex(index);
  21. }}
  22. />
  23. ))}
  24. </TabsBar>
  25. );
  26. };