| 1 | /** |
| 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | * |
| 4 | * This source code is licensed under the MIT license found in the |
| 5 | * LICENSE file in the root directory of this source tree. |
| 6 | */ |
| 7 | |
| 8 | import {Button} from 'isl-components/Button'; |
| 9 | import {Icon} from 'isl-components/Icon'; |
| 10 | import {Tooltip} from 'isl-components/Tooltip'; |
| 11 | import {useAtomValue} from 'jotai'; |
| 12 | import {lazy, Suspense} from 'react'; |
| 13 | import {t} from '../i18n'; |
| 14 | import {debugToolsEnabledState} from './DebugToolsState'; |
| 15 | |
| 16 | const DebugToolsMenu = lazy(() => import('./DebugToolsMenu')); |
| 17 | |
| 18 | export function DebugToolsButton() { |
| 19 | const debugEnabled = useAtomValue(debugToolsEnabledState); |
| 20 | if (!debugEnabled) { |
| 21 | return null; |
| 22 | } |
| 23 | return ( |
| 24 | <Tooltip |
| 25 | component={dismiss => ( |
| 26 | <Suspense fallback={<Icon icon="loading" />}> |
| 27 | <DebugToolsMenu dismiss={dismiss} /> |
| 28 | </Suspense> |
| 29 | )} |
| 30 | title={t('Debug Tools')} |
| 31 | trigger="click" |
| 32 | group="topbar" |
| 33 | placement="bottom"> |
| 34 | <Button icon> |
| 35 | <Icon icon="pulse" /> |
| 36 | </Button> |
| 37 | </Tooltip> |
| 38 | ); |
| 39 | } |
| 40 | |