2022-01-24 12:21:28 +01:00
|
|
|
import React from 'react';
|
2021-11-07 09:17:19 +01:00
|
|
|
|
|
|
|
export default function TabDropdown({
|
2022-01-24 12:21:28 +01:00
|
|
|
setPickedTab,
|
|
|
|
pickedTab,
|
2021-11-07 09:17:19 +01:00
|
|
|
}: {
|
2022-01-24 12:21:28 +01:00
|
|
|
setPickedTab: (tab_id: number) => void;
|
|
|
|
pickedTab: number;
|
2021-11-07 09:17:19 +01:00
|
|
|
}) {
|
2022-01-29 20:50:44 +01:00
|
|
|
const [tabs, setTabs] = React.useState([]);
|
|
|
|
React.useEffect(() => {
|
2022-01-24 12:21:28 +01:00
|
|
|
browser.tabs.query({ currentWindow: true }).then(setTabs);
|
|
|
|
}, []);
|
|
|
|
return (
|
|
|
|
<select
|
|
|
|
id="tab_dropdown"
|
|
|
|
value={pickedTab}
|
|
|
|
onChange={async (e) => {
|
|
|
|
setPickedTab(parseInt(e.target.value));
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{tabs.map((tab) => (
|
|
|
|
<option value={tab.id} key={tab.id}>
|
|
|
|
{tab.title}
|
|
|
|
</option>
|
|
|
|
))}
|
|
|
|
</select>
|
|
|
|
);
|
2021-11-07 09:17:19 +01:00
|
|
|
}
|