Add hotkeys to command menu items (#18682)
Add hotkeys column to the entity and plug it to the front end command menu item display --------- Co-authored-by: Charles Bochet <charles@twenty.com> Co-authored-by: Charles Bochet <charlesBochet@users.noreply.github.com>
This commit is contained in:
@@ -2,6 +2,8 @@ import { styled } from '@linaria/react';
|
||||
import { i18n, type MessageDescriptor } from '@lingui/core';
|
||||
import { isString } from '@sniptt/guards';
|
||||
import { type MouseEvent } from 'react';
|
||||
import { type Nullable } from 'twenty-shared/types';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import {
|
||||
AppTooltip,
|
||||
type IconComponent,
|
||||
@@ -19,7 +21,7 @@ export type CommandMenuButtonProps = {
|
||||
command: {
|
||||
key: string;
|
||||
label: string | MessageDescriptor;
|
||||
shortLabel?: string | MessageDescriptor;
|
||||
shortLabel?: Nullable<string | MessageDescriptor>;
|
||||
Icon: IconComponent;
|
||||
isPrimaryCTA?: boolean;
|
||||
};
|
||||
@@ -40,10 +42,9 @@ export const CommandMenuButton = ({
|
||||
}: CommandMenuButtonProps) => {
|
||||
const resolvedLabel = getCommandMenuButtonLabel(command.label);
|
||||
|
||||
const resolvedShortLabel =
|
||||
command.shortLabel === undefined
|
||||
? undefined
|
||||
: getCommandMenuButtonLabel(command.shortLabel);
|
||||
const resolvedShortLabel = isDefined(command.shortLabel)
|
||||
? getCommandMenuButtonLabel(command.shortLabel)
|
||||
: undefined;
|
||||
|
||||
const buttonAccent = command.isPrimaryCTA ? 'blue' : 'default';
|
||||
|
||||
|
||||
@@ -4,9 +4,10 @@ import { IconArrowUpRight, type IconComponent } from 'twenty-ui/display';
|
||||
import { MenuItem } from 'twenty-ui/navigation';
|
||||
|
||||
import { useCommandMenuOnItemClick } from '@/command-menu/hooks/useCommandMenuOnItemClick';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { isSelectedItemIdComponentFamilyState } from '@/ui/layout/selectable-list/states/isSelectedItemIdComponentFamilyState';
|
||||
import { useAtomComponentFamilyStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentFamilyStateValue';
|
||||
import { type Nullable } from 'twenty-shared/types';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export type CommandMenuItemProps = {
|
||||
label: string;
|
||||
@@ -15,7 +16,7 @@ export type CommandMenuItemProps = {
|
||||
id: string;
|
||||
onClick?: () => void;
|
||||
Icon?: IconComponent;
|
||||
hotKeys?: string[];
|
||||
hotKeys?: Nullable<string[]>;
|
||||
LeftComponent?: ReactNode;
|
||||
RightComponent?: ReactNode;
|
||||
contextualTextPosition?: 'left' | 'right';
|
||||
|
||||
Reference in New Issue
Block a user