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