draggableTabBar.tsx 1003 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import 'intersection-observer'; // polyfill
  2. import {useState} from 'react';
  3. import type {Key} from '@react-types/shared';
  4. import {DraggableTabList} from 'sentry/components/draggableTabs/draggableTabList';
  5. import {TabPanels, Tabs} from 'sentry/components/tabs';
  6. export interface Tab {
  7. content: React.ReactNode;
  8. key: Key;
  9. label: string;
  10. queryCount?: number;
  11. }
  12. export interface DraggableTabBarProps {
  13. tabs: Tab[];
  14. tempTabContent: React.ReactNode;
  15. }
  16. export function DraggableTabBar(props: DraggableTabBarProps) {
  17. const [tabs, setTabs] = useState<Tab[]>([...props.tabs]);
  18. return (
  19. <Tabs>
  20. <DraggableTabList tabs={tabs} setTabs={setTabs} orientation="horizontal">
  21. {tabs.map(tab => (
  22. <DraggableTabList.Item key={tab.key}>{tab.label}</DraggableTabList.Item>
  23. ))}
  24. </DraggableTabList>
  25. <TabPanels>
  26. {tabs.map(tab => (
  27. <TabPanels.Item key={tab.key}>{tab.content}</TabPanels.Item>
  28. ))}
  29. </TabPanels>
  30. </Tabs>
  31. );
  32. }