Skip to content

Commit

Permalink
chore(suite): unify debug mode usage
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasklim committed Jan 23, 2025
1 parent 08dc1e4 commit 769cb04
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { spacings } from '@trezor/theme';
import { useDispatch, useSelector } from 'src/hooks/suite';
import { goto } from 'src/actions/suite/routerActions';
import { SettingsAnchor } from 'src/constants/suite/anchors';
import { selectIsDebugModeActive } from 'src/reducers/suite/suiteReducer';

import { QuickActionButton } from './QuickActionButton';
import { TooltipRow } from './TooltipRow';
Expand Down Expand Up @@ -73,27 +74,27 @@ export const DebugAndExperimental = () => {

const isEapEnabled = useSelector(state => state.desktopUpdate.allowPrerelease);
const isExperimental = useSelector(state => state.suite.settings.experimental !== undefined);
const isDebugMode = useSelector(state => state.suite.settings.debug.showDebugMenu);
const isDebug = useSelector(selectIsDebugModeActive);

const handleEapClick = () => {
dispatch(goto('settings-index', { anchor: SettingsAnchor.EarlyAccess }));
};

if (!isEapEnabled && !isExperimental && !isDebugMode) return null;
if (!isEapEnabled && !isExperimental && !isDebug) return null;

return (
<QuickActionButton
tooltip={
<DebugAndExperimentalTooltip
isDebugMode={isDebugMode}
isDebugMode={isDebug}
isEapEnabled={isEapEnabled}
isExperimental={isExperimental}
/>
}
onClick={handleEapClick}
>
<Relative $size={getIconSize(iconSizes.medium)}>
{isDebugMode && (
{isDebug && (
<Absolute>
<Icon name="debug" variant="destructive" size={iconSizes.medium} />
</Absolute>
Expand Down
5 changes: 3 additions & 2 deletions packages/suite/src/views/settings/SettingsGeneral/Theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import { ActionColumn, ActionSelect, TextColumn, Translation } from 'src/compone
import { useDispatch, useSelector, useTranslation } from 'src/hooks/suite';
import { SettingsAnchor } from 'src/constants/suite/anchors';
import { getOsTheme } from 'src/utils/suite/env';
import { selectIsDebugModeActive } from 'src/reducers/suite/suiteReducer';

type ThemeColorVariantWithSystem = ThemeColorVariant | 'system';
type Option = { value: ThemeColorVariantWithSystem; label: string };

const useThemeOptions = () => {
const { translationString } = useTranslation();
const showDebugMenu = useSelector(state => state.suite.settings.debug.showDebugMenu);
const isDebug = useSelector(selectIsDebugModeActive);

const systemOption: Option = {
value: 'system',
Expand All @@ -29,7 +30,7 @@ const useThemeOptions = () => {

const optionGroups = [
{ options: [systemOption] },
{ options: [lightOption, darkOption, ...(showDebugMenu ? [debugOption] : [])] },
{ options: [lightOption, darkOption, ...(isDebug ? [debugOption] : [])] },
];

const getOption = (theme: ThemeColorVariantWithSystem) => {
Expand Down
6 changes: 4 additions & 2 deletions packages/suite/src/views/wallet/details/CoinjoinLogs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useSelector } from 'src/hooks/suite/useSelector';
import { useAnchor } from 'src/hooks/suite/useAnchor';
import { CoinjoinLogsAnchor } from 'src/constants/suite/anchors';
import { anchorOutlineStyles } from 'src/utils/suite/anchor';
import { selectIsDebugModeActive } from 'src/reducers/suite/suiteReducer';

// eslint-disable-next-line local-rules/no-override-ds-component
const SetupCard = styled(Card)<{ $shouldHighlight?: boolean }>`
Expand All @@ -19,10 +20,11 @@ const SetupCard = styled(Card)<{ $shouldHighlight?: boolean }>`
`;

export const CoinjoinLogs = () => {
const showDebugMenu = useSelector(state => state.suite.settings.debug.showDebugMenu);
const isDebug = useSelector(selectIsDebugModeActive);

const { anchorRef, shouldHighlight } = useAnchor(CoinjoinLogsAnchor);

if (!showDebugMenu) return null;
if (!isDebug) return null;

return (
<SetupCard ref={anchorRef} $shouldHighlight={shouldHighlight}>
Expand Down

0 comments on commit 769cb04

Please sign in to comment.