The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Make Cmd+J toggle the logs mode instead of collapsing the console (#28274)
martmull9a81e9cc8ff0
diff --git a/packages/twenty-front/src/modules/log-console/components/LogConsole.tsx b/packages/twenty-front/src/modules/log-console/components/LogConsole.tsxindex 766f15a31cb..2765dfcf861 100644--- a/packages/twenty-front/src/modules/log-console/components/LogConsole.tsx+++ b/packages/twenty-front/src/modules/log-console/components/LogConsole.tsx@@ -1,4 +1,3 @@-import { formatShortcut } from 'twenty-ui/primitives/typography';import { styled } from '@linaria/react';import { useLingui } from '@lingui/react/macro';import { useReducedMotion } from 'framer-motion';@@ -27,6 +26,7 @@ import { LOG_CONSOLE_NARROW_BODY_MAX_WIDTH } from '@/log-console/constants/LogCoimport { LOG_CONSOLE_SOURCES } from '@/log-console/constants/LogConsoleSources';import { LOG_CONSOLE_TAB_LIST_INSTANCE_ID } from '@/log-console/constants/LogConsoleTabListInstanceId';import { useIsLogConsoleAllowed } from '@/log-console/hooks/useIsLogConsoleAllowed';+import { useSetIsLogConsoleEnabled } from '@/log-console/hooks/useSetIsLogConsoleEnabled';import { isLogConsoleFullScreenState } from '@/log-console/states/isLogConsoleFullScreenState';import { logConsoleActiveSourceIdState } from '@/log-console/states/logConsoleActiveSourceIdState';import { logConsoleDisplayModeState } from '@/log-console/states/logConsoleDisplayModeState';@@ -262,6 +262,7 @@ export const LogConsole = () => {const isLogConsoleAllowed = useIsLogConsoleAllowed();const isLogConsoleEnabled = useAtomStateValue(isLogConsoleEnabledState);+ const { setIsLogConsoleEnabled } = useSetIsLogConsoleEnabled();const currentWorkspace = useAtomStateValue(currentWorkspaceState);const isClickHouseConfigured = useAtomStateValue(isClickHouseConfiguredState);@@ -359,12 +360,10 @@ export const LogConsole = () => {setIsLogConsoleFullScreen(false);};- const toggleHotkeyLabel = formatShortcut({- shortcut: ['Mod', 'J'],- });-- const toggleHotkeyEffect = isVisible ? (- <LogConsoleToggleHotkeyEffect onToggle={toggleLogConsoleOpen} />+ const toggleHotkeyEffect = isLogConsoleAllowed ? (+ <LogConsoleToggleHotkeyEffect+ onToggle={() => setIsLogConsoleEnabled(!isLogConsoleEnabled)}+ />) : null;if (!isDefined(displayedLayout)) {@@ -628,7 +627,7 @@ export const LogConsole = () => {<IconButtonsize="sm"variant="outline"- tooltip={`${openOrCollapseLabel} | ${toggleHotkeyLabel}`}+ tooltip={openOrCollapseLabel}aria-label={openOrCollapseLabel}onClick={toggleLogConsoleOpen}>diff --git a/packages/twenty-front/src/modules/log-console/components/__tests__/LogConsole.test.tsx b/packages/twenty-front/src/modules/log-console/components/__tests__/LogConsole.test.tsxindex a9a63d109e4..cfa876cba8c 100644--- a/packages/twenty-front/src/modules/log-console/components/__tests__/LogConsole.test.tsx+++ b/packages/twenty-front/src/modules/log-console/components/__tests__/LogConsole.test.tsx@@ -316,27 +316,47 @@ describe('LogConsole', () => {expect(jotaiStore.get(logConsoleActiveSourceIdState.atom)).toBe('app-logs');});- it('toggles with Mod+J on a page that turns off modifier hotkeys', async () => {+ it('turns logs on and off with Mod+J on a page that turns off modifier hotkeys', async () => {+ mockShouldReduceMotion = true;renderWithLogsFeatureFlag(true);act(() => {- jotaiStore.set(isLogConsoleEnabledState.atom, true);jotaiStore.set(focusStackState.atom, [SETTINGS_PAGE_FOCUS_STACK_ITEM]);- jotaiStore.set(logConsoleDisplayModeState.atom, 'collapsed');});await userEvent.keyboard('{Control>}j{/Control}');- expect(jotaiStore.get(logConsoleDisplayModeState.atom)).toBe('open');+ expect(jotaiStore.get(isLogConsoleEnabledState.atom)).toBe(true);+ expect(await screen.findByText('Log results')).toBeInTheDocument();await userEvent.keyboard('{Meta>}j{/Meta}');- expect(jotaiStore.get(logConsoleDisplayModeState.atom)).toBe('collapsed');+ expect(jotaiStore.get(isLogConsoleEnabledState.atom)).toBe(false);+ expect(screen.queryByText('Log results')).not.toBeInTheDocument();});- it('ignores Mod+J while a dialog turns off modifier hotkeys', async () => {+ it('turns logs off with Mod+J while the console is collapsed', async () => {renderWithLogsFeatureFlag(true);act(() => {jotaiStore.set(isLogConsoleEnabledState.atom, true);+ jotaiStore.set(logConsoleDisplayModeState.atom, 'collapsed');+ });++ await userEvent.keyboard('{Control>}j{/Control}');++ expect(jotaiStore.get(isLogConsoleEnabledState.atom)).toBe(false);+ });++ it('ignores Mod+J when logs are not allowed', async () => {+ renderWithLogsFeatureFlag(false);++ await userEvent.keyboard('{Control>}j{/Control}');++ expect(jotaiStore.get(isLogConsoleEnabledState.atom)).toBe(false);+ });++ it('ignores Mod+J while a dialog turns off modifier hotkeys', async () => {+ renderWithLogsFeatureFlag(true);+ act(() => {jotaiStore.set(focusStackState.atom, [SETTINGS_PAGE_FOCUS_STACK_ITEM,{@@ -356,7 +376,7 @@ describe('LogConsole', () => {await userEvent.keyboard('{Control>}j{/Control}');- expect(jotaiStore.get(logConsoleDisplayModeState.atom)).toBe('collapsed');+ expect(jotaiStore.get(isLogConsoleEnabledState.atom)).toBe(false);});it('stays hidden when the logs feature flag is off', async () => {diff --git a/packages/twenty-front/src/modules/navigation/components/LogsSwitch.tsx b/packages/twenty-front/src/modules/navigation/components/LogsSwitch.tsxindex 54996a98c79..73286c62b24 100644--- a/packages/twenty-front/src/modules/navigation/components/LogsSwitch.tsx+++ b/packages/twenty-front/src/modules/navigation/components/LogsSwitch.tsx@@ -7,6 +7,7 @@ import { useId } from 'react';import { isDefined } from 'twenty-shared/utils';import { IconTerminal } from 'twenty-ui/icon';import { Switch } from 'twenty-ui/primitives/input';+import { formatShortcut } from 'twenty-ui/primitives/typography';import { themeCssVariables, useTheme } from 'twenty-ui/theme';const StyledContainer = styled.label<{ isCompact: boolean }>`@@ -69,7 +70,7 @@ export const LogsSwitch = ({<StyledContainerhtmlFor={instanceId}isCompact={isCompact}- title={isCompact ? label : undefined}+ title={`${label} | ${formatShortcut({ shortcut: ['Mod', 'J'] })}`}>{isDefined(sequence) && (<LogsSwitchTypingEffect