refactor(command-menu-item): rename Actions to CommandMenuItem (#18489)
actions are being renamed to command menu item, they will be migrated to server and will be served as headless front components --------- Co-authored-by: Raphaël Bosi <71827178+bosiraphael@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { styled } from '@linaria/react';
|
||||
import { ActionMenuComponentInstanceContext } from '@/action-menu/states/contexts/ActionMenuComponentInstanceContext';
|
||||
import { CommandMenuComponentInstanceContext } from '@/command-menu/states/contexts/CommandMenuComponentInstanceContext';
|
||||
import { SIDE_PANEL_COMPONENT_INSTANCE_ID } from '@/side-panel/constants/SidePanelComponentInstanceId';
|
||||
import { contextStoreCurrentObjectMetadataItemIdComponentState } from '@/context-store/states/contextStoreCurrentObjectMetadataItemIdComponentState';
|
||||
import { contextStoreCurrentViewIdComponentState } from '@/context-store/states/contextStoreCurrentViewIdComponentState';
|
||||
@@ -56,13 +56,13 @@ export const SidePanelContainer = ({ children }: SidePanelContainerProps) => {
|
||||
<ContextStoreComponentInstanceContext.Provider
|
||||
value={{ instanceId: SIDE_PANEL_COMPONENT_INSTANCE_ID }}
|
||||
>
|
||||
<ActionMenuComponentInstanceContext.Provider
|
||||
<CommandMenuComponentInstanceContext.Provider
|
||||
value={{ instanceId: SIDE_PANEL_COMPONENT_INSTANCE_ID }}
|
||||
>
|
||||
<StyledSidePanelContainer isMobile={isMobile}>
|
||||
{children}
|
||||
</StyledSidePanelContainer>
|
||||
</ActionMenuComponentInstanceContext.Provider>
|
||||
</CommandMenuComponentInstanceContext.Provider>
|
||||
</ContextStoreComponentInstanceContext.Provider>
|
||||
</RecordComponentInstanceContextsWrapper>
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ActionComponent } from '@/action-menu/actions/display/components/ActionComponent';
|
||||
import { CommandMenuItemComponent } from '@/command-menu-item/display/components/CommandMenuItemComponent';
|
||||
import { SidePanelGroup } from '@/side-panel/components/SidePanelGroup';
|
||||
import { SidePanelDefaultSelectionEffect } from '@/side-panel/components/SidePanelDefaultSelectionEffect';
|
||||
import { SIDE_PANEL_SELECTABLE_LIST_ID } from '@/side-panel/constants/SidePanelSelectableListId';
|
||||
@@ -6,7 +6,7 @@ import { SIDE_PANEL_TOP_BAR_HEIGHT } from '@/side-panel/constants/SidePanelTopBa
|
||||
import { SIDE_PANEL_LIST_PADDING } from '@/side-panel/constants/SidePanelListPadding';
|
||||
import { SIDE_PANEL_FOCUS_ID } from '@/side-panel/constants/SidePanelFocusId';
|
||||
import { hasUserSelectedSidePanelListItemState } from '@/side-panel/states/hasUserSelectedSidePanelListItemState';
|
||||
import { type SidePanelActionGroupConfig } from '@/side-panel/types/SidePanelActionGroupConfig';
|
||||
import { type SidePanelCommandMenuItemGroupConfig } from '@/side-panel/types/SidePanelCommandMenuItemGroupConfig';
|
||||
import { SelectableList } from '@/ui/layout/selectable-list/components/SelectableList';
|
||||
import { useSetAtomState } from '@/ui/utilities/state/jotai/hooks/useSetAtomState';
|
||||
import { ScrollWrapper } from '@/ui/utilities/scroll/components/ScrollWrapper';
|
||||
@@ -15,7 +15,7 @@ import { t } from '@lingui/core/macro';
|
||||
import { MOBILE_VIEWPORT, themeCssVariables } from 'twenty-ui/theme-constants';
|
||||
|
||||
export type SidePanelListProps = {
|
||||
commandGroups: SidePanelActionGroupConfig[];
|
||||
commandGroups: SidePanelCommandMenuItemGroupConfig[];
|
||||
selectableItemIds: string[];
|
||||
children?: React.ReactNode;
|
||||
loading?: boolean;
|
||||
@@ -83,7 +83,7 @@ export const SidePanelList = ({
|
||||
items?.length ? (
|
||||
<SidePanelGroup heading={heading} key={heading}>
|
||||
{items.map((item) => (
|
||||
<ActionComponent action={item} key={item.key} />
|
||||
<CommandMenuItemComponent action={item} key={item.key} />
|
||||
))}
|
||||
</SidePanelGroup>
|
||||
) : null,
|
||||
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
import { DEFAULT_RECORD_ACTIONS_CONFIG } from '@/action-menu/actions/record-actions/constants/DefaultRecordActionsConfig';
|
||||
import { MultipleRecordsActionKeys } from '@/action-menu/actions/record-actions/multiple-records/types/MultipleRecordsActionKeys';
|
||||
import { getActionLabel } from '@/action-menu/utils/getActionLabel';
|
||||
import { DEFAULT_RECORD_COMMAND_MENU_ITEMS_CONFIG } from '@/command-menu-item/record/constants/DefaultRecordCommandMenuItemsConfig';
|
||||
import { MultipleRecordsCommandKeys } from '@/command-menu-item/record/multiple-records/types/MultipleRecordsCommandKeys';
|
||||
import { getCommandMenuItemLabel } from '@/command-menu-item/utils/getCommandMenuItemLabel';
|
||||
import { SidePanelPageInfoLayout } from '@/side-panel/components/SidePanelPageInfoLayout';
|
||||
import { useFindManyRecordsSelectedInContextStore } from '@/context-store/hooks/useFindManyRecordsSelectedInContextStore';
|
||||
import { t } from '@lingui/core/macro';
|
||||
@@ -21,13 +21,13 @@ export const SidePanelMultipleRecordsInfo = ({
|
||||
});
|
||||
|
||||
const { Icon, label } =
|
||||
DEFAULT_RECORD_ACTIONS_CONFIG[MultipleRecordsActionKeys.UPDATE];
|
||||
DEFAULT_RECORD_COMMAND_MENU_ITEMS_CONFIG[MultipleRecordsCommandKeys.UPDATE];
|
||||
|
||||
return (
|
||||
<SidePanelPageInfoLayout
|
||||
icon={<Icon size={theme.icon.size.md} stroke={theme.icon.stroke.sm} />}
|
||||
iconColor={theme.font.color.tertiary}
|
||||
title={getActionLabel(label)}
|
||||
title={getCommandMenuItemLabel(label)}
|
||||
label={t`${totalCount} selected`}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ActionMenuContextProvider } from '@/action-menu/contexts/ActionMenuContextProvider';
|
||||
import { CommandMenuContextProvider } from '@/command-menu-item/contexts/CommandMenuContextProvider';
|
||||
import { SidePanelContainer } from '@/side-panel/components/SidePanelContainer';
|
||||
import { SidePanelTopBar } from '@/side-panel/components/SidePanelTopBar';
|
||||
import { SIDE_PANEL_PAGES_CONFIG } from '@/side-panel/constants/SidePanelPagesConfig';
|
||||
@@ -51,13 +51,13 @@ export const SidePanelRouter = () => {
|
||||
<SidePanelTopBar />
|
||||
</motion.div>
|
||||
<StyledSidePanelContent>
|
||||
<ActionMenuContextProvider
|
||||
<CommandMenuContextProvider
|
||||
isInSidePanel={true}
|
||||
displayType="listItem"
|
||||
actionMenuType="command-menu"
|
||||
containerType="command-menu-list"
|
||||
>
|
||||
{sidePanelPageComponent}
|
||||
</ActionMenuContextProvider>
|
||||
</CommandMenuContextProvider>
|
||||
</StyledSidePanelContent>
|
||||
</SidePanelPageComponentInstanceContext.Provider>
|
||||
</SidePanelContainer>
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@ import { recordStoreFamilyState } from '@/object-record/record-store/states/reco
|
||||
import { jotaiStore } from '@/ui/utilities/state/jotai/jotaiStore';
|
||||
import { type ObjectRecord } from '@/object-record/types/ObjectRecord';
|
||||
import { ComponentDecorator } from 'twenty-ui/testing';
|
||||
import { getJestMetadataAndApolloMocksAndActionMenuWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksAndActionMenuWrapper';
|
||||
import { getJestMetadataAndApolloMocksAndCommandMenuWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksAndCommandMenuWrapper';
|
||||
import { mockedCompanyRecords } from '~/testing/mock-data/generated/data/companies/mock-companies-data';
|
||||
import { generatedMockObjectMetadataItems } from '~/testing/utils/generatedMockObjectMetadataItems';
|
||||
|
||||
@@ -145,7 +145,7 @@ const createContextStoreWrapper = ({
|
||||
companies: typeof mockedCompanyRecords;
|
||||
componentInstanceId: string;
|
||||
}) => {
|
||||
return getJestMetadataAndApolloMocksAndActionMenuWrapper({
|
||||
return getJestMetadataAndApolloMocksAndCommandMenuWrapper({
|
||||
apolloMocks: [
|
||||
{
|
||||
request: {
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ import { jotaiStore } from '@/ui/utilities/state/jotai/jotaiStore';
|
||||
import { ContextStoreViewType } from '@/context-store/types/ContextStoreViewType';
|
||||
import { SidePanelPages } from 'twenty-shared/types';
|
||||
import { Icon123, useIcons } from 'twenty-ui/display';
|
||||
import { getJestMetadataAndApolloMocksAndActionMenuWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksAndActionMenuWrapper';
|
||||
import { getJestMetadataAndApolloMocksAndCommandMenuWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksAndCommandMenuWrapper';
|
||||
import { generatedMockObjectMetadataItems } from '~/testing/utils/generatedMockObjectMetadataItems';
|
||||
|
||||
jest.mock('uuid', () => ({
|
||||
@@ -21,7 +21,7 @@ const personMockObjectMetadataItem = generatedMockObjectMetadataItems.find(
|
||||
(item) => item.nameSingular === 'person',
|
||||
)!;
|
||||
|
||||
const wrapper = getJestMetadataAndApolloMocksAndActionMenuWrapper({
|
||||
const wrapper = getJestMetadataAndApolloMocksAndCommandMenuWrapper({
|
||||
apolloMocks: [],
|
||||
componentInstanceId: SIDE_PANEL_COMPONENT_INSTANCE_ID,
|
||||
contextStoreCurrentObjectMetadataNameSingular:
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ import { ContextStoreViewType } from '@/context-store/types/ContextStoreViewType
|
||||
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
|
||||
import { SidePanelPages } from 'twenty-shared/types';
|
||||
import { IconCalendarEvent } from 'twenty-ui/display';
|
||||
import { getJestMetadataAndApolloMocksAndActionMenuWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksAndActionMenuWrapper';
|
||||
import { getJestMetadataAndApolloMocksAndCommandMenuWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksAndCommandMenuWrapper';
|
||||
import { generatedMockObjectMetadataItems } from '~/testing/utils/generatedMockObjectMetadataItems';
|
||||
|
||||
jest.mock('uuid', () => ({
|
||||
@@ -26,7 +26,7 @@ const personMockObjectMetadataItem = generatedMockObjectMetadataItems.find(
|
||||
(item) => item.nameSingular === 'person',
|
||||
)!;
|
||||
|
||||
const wrapper = getJestMetadataAndApolloMocksAndActionMenuWrapper({
|
||||
const wrapper = getJestMetadataAndApolloMocksAndCommandMenuWrapper({
|
||||
apolloMocks: [],
|
||||
componentInstanceId: SIDE_PANEL_COMPONENT_INSTANCE_ID,
|
||||
contextStoreCurrentObjectMetadataNameSingular:
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ import { ContextStoreViewType } from '@/context-store/types/ContextStoreViewType
|
||||
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
|
||||
import { SidePanelPages } from 'twenty-shared/types';
|
||||
import { IconMail } from 'twenty-ui/display';
|
||||
import { getJestMetadataAndApolloMocksAndActionMenuWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksAndActionMenuWrapper';
|
||||
import { getJestMetadataAndApolloMocksAndCommandMenuWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksAndCommandMenuWrapper';
|
||||
import { generatedMockObjectMetadataItems } from '~/testing/utils/generatedMockObjectMetadataItems';
|
||||
|
||||
jest.mock('uuid', () => ({
|
||||
@@ -26,7 +26,7 @@ const personMockObjectMetadataItem = generatedMockObjectMetadataItems.find(
|
||||
(item) => item.nameSingular === 'person',
|
||||
)!;
|
||||
|
||||
const wrapper = getJestMetadataAndApolloMocksAndActionMenuWrapper({
|
||||
const wrapper = getJestMetadataAndApolloMocksAndCommandMenuWrapper({
|
||||
apolloMocks: [],
|
||||
componentInstanceId: SIDE_PANEL_COMPONENT_INSTANCE_ID,
|
||||
contextStoreCurrentObjectMetadataNameSingular:
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ import { getLabelIdentifierFieldMetadataItem } from '@/object-metadata/utils/get
|
||||
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
|
||||
import { SidePanelPages } from 'twenty-shared/types';
|
||||
import { useIcons } from 'twenty-ui/display';
|
||||
import { getJestMetadataAndApolloMocksAndActionMenuWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksAndActionMenuWrapper';
|
||||
import { getJestMetadataAndApolloMocksAndCommandMenuWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksAndCommandMenuWrapper';
|
||||
import { generatedMockObjectMetadataItems } from '~/testing/utils/generatedMockObjectMetadataItems';
|
||||
|
||||
jest.mock('uuid', () => ({
|
||||
@@ -44,7 +44,7 @@ const personMockObjectMetadataItem = generatedMockObjectMetadataItems.find(
|
||||
(item) => item.nameSingular === 'person',
|
||||
)!;
|
||||
|
||||
const wrapper = getJestMetadataAndApolloMocksAndActionMenuWrapper({
|
||||
const wrapper = getJestMetadataAndApolloMocksAndCommandMenuWrapper({
|
||||
apolloMocks: [],
|
||||
componentInstanceId: SIDE_PANEL_COMPONENT_INSTANCE_ID,
|
||||
contextStoreCurrentObjectMetadataNameSingular:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { SIDE_PANEL_COMPONENT_INSTANCE_ID } from '@/side-panel/constants/SidePanelComponentInstanceId';
|
||||
import { SIDE_PANEL_FOCUS_ID } from '@/side-panel/constants/SidePanelFocusId';
|
||||
import { useSidePanelCloseAnimationCompleteCleanup } from '@/side-panel/hooks/useSidePanelCloseAnimationCompleteCleanup';
|
||||
import { useCopyContextStoreStates } from '@/command-menu/hooks/useCopyContextStoreAndActionMenuStates';
|
||||
import { useCopyContextStoreStates } from '@/command-menu/hooks/useCopyContextStoreAndCommandMenuStates';
|
||||
import { sidePanelNavigationMorphItemsByPageState } from '@/side-panel/states/sidePanelNavigationMorphItemsByPageState';
|
||||
import { sidePanelNavigationStackState } from '@/side-panel/states/sidePanelNavigationStackState';
|
||||
import { sidePanelPageInfoState } from '@/side-panel/states/sidePanelPageInfoState';
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
import { ActionMenuComponentInstanceContext } from '@/action-menu/states/contexts/ActionMenuComponentInstanceContext';
|
||||
import { CommandMenuComponentInstanceContext } from '@/command-menu/states/contexts/CommandMenuComponentInstanceContext';
|
||||
import { SidePanelPageComponentInstanceContext } from '@/side-panel/states/contexts/SidePanelPageComponentInstanceContext';
|
||||
import { useContextStoreObjectMetadataItemOrThrow } from '@/context-store/hooks/useContextStoreObjectMetadataItemOrThrow';
|
||||
import { ContextStoreComponentInstanceContext } from '@/context-store/states/contexts/ContextStoreComponentInstanceContext';
|
||||
@@ -33,7 +33,7 @@ export const SidePanelMergeRecordPage = () => {
|
||||
instanceId: sidePanelPageInstanceId,
|
||||
}}
|
||||
>
|
||||
<ActionMenuComponentInstanceContext.Provider
|
||||
<CommandMenuComponentInstanceContext.Provider
|
||||
value={{ instanceId: sidePanelPageInstanceId }}
|
||||
>
|
||||
<StyledSidePanelRecord>
|
||||
@@ -41,7 +41,7 @@ export const SidePanelMergeRecordPage = () => {
|
||||
objectNameSingular={objectMetadataItem.nameSingular}
|
||||
/>
|
||||
</StyledSidePanelRecord>
|
||||
</ActionMenuComponentInstanceContext.Provider>
|
||||
</CommandMenuComponentInstanceContext.Provider>
|
||||
</ContextStoreComponentInstanceContext.Provider>
|
||||
</RecordComponentInstanceContextsWrapper>
|
||||
);
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
import { ActionMenuComponentInstanceContext } from '@/action-menu/states/contexts/ActionMenuComponentInstanceContext';
|
||||
import { CommandMenuComponentInstanceContext } from '@/command-menu/states/contexts/CommandMenuComponentInstanceContext';
|
||||
import { TimelineActivityContext } from '@/activities/timeline-activities/contexts/TimelineActivityContext';
|
||||
import { viewableRecordIdComponentState } from '@/side-panel/pages/record-page/states/viewableRecordIdComponentState';
|
||||
import { viewableRecordNameSingularComponentState } from '@/side-panel/pages/record-page/states/viewableRecordNameSingularComponentState';
|
||||
@@ -72,7 +72,7 @@ export const SidePanelRecordPage = () => {
|
||||
instanceId: sidePanelPageInstanceId,
|
||||
}}
|
||||
>
|
||||
<ActionMenuComponentInstanceContext.Provider
|
||||
<CommandMenuComponentInstanceContext.Provider
|
||||
value={{ instanceId: sidePanelPageInstanceId }}
|
||||
>
|
||||
<StyledSidePanelRecord hasDeletedRecordBanner={!!recordDeletedAt}>
|
||||
@@ -90,7 +90,7 @@ export const SidePanelRecordPage = () => {
|
||||
/>
|
||||
</TimelineActivityContext.Provider>
|
||||
</StyledSidePanelRecord>
|
||||
</ActionMenuComponentInstanceContext.Provider>
|
||||
</CommandMenuComponentInstanceContext.Provider>
|
||||
</ContextStoreComponentInstanceContext.Provider>
|
||||
</RecordComponentInstanceContextsWrapper>
|
||||
);
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@ import { SidePanelList } from '@/side-panel/components/SidePanelList';
|
||||
import { SIDE_PANEL_PREVIOUS_COMPONENT_INSTANCE_ID } from '@/side-panel/constants/SidePanelPreviousComponentInstanceId';
|
||||
import { SIDE_PANEL_RESET_CONTEXT_TO_SELECTION } from '@/side-panel/constants/SidePanelResetContextToSelection';
|
||||
import { sidePanelSearchState } from '@/side-panel/states/sidePanelSearchState';
|
||||
import { type SidePanelActionGroupConfig } from '@/side-panel/types/SidePanelActionGroupConfig';
|
||||
import { type SidePanelCommandMenuItemGroupConfig } from '@/side-panel/types/SidePanelCommandMenuItemGroupConfig';
|
||||
import { contextStoreCurrentObjectMetadataItemIdComponentState } from '@/context-store/states/contextStoreCurrentObjectMetadataItemIdComponentState';
|
||||
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
|
||||
import { SidePanelResetContextToSelectionButton } from '@/side-panel/pages/root/components/SidePanelResetContextToSelectionButton';
|
||||
@@ -49,7 +49,7 @@ export const SidePanelRootPage = () => {
|
||||
(item) => item.id === contextStoreCurrentObjectMetadataItemId,
|
||||
);
|
||||
|
||||
const commandGroups: SidePanelActionGroupConfig[] = [
|
||||
const commandGroups: SidePanelCommandMenuItemGroupConfig[] = [
|
||||
{
|
||||
heading: t`Record Selection`,
|
||||
items: matchingStandardActionRecordSelectionActions
|
||||
|
||||
+10
-10
@@ -1,6 +1,6 @@
|
||||
import { type ActionConfig } from '@/action-menu/actions/types/ActionConfig';
|
||||
import { ActionScope } from '@/action-menu/actions/types/ActionScope';
|
||||
import { ActionType } from '@/action-menu/actions/types/ActionType';
|
||||
import { type CommandMenuItemConfig } from '@/command-menu-item/types/CommandMenuItemConfig';
|
||||
import { CommandMenuItemScope } from '@/command-menu-item/types/CommandMenuItemScope';
|
||||
import { CommandMenuItemType } from '@/command-menu-item/types/CommandMenuItemType';
|
||||
import { renderHook } from '@testing-library/react';
|
||||
import { IconPlus } from 'twenty-ui/display';
|
||||
import { useFilterActionsWithSidePanelSearch } from '@/side-panel/pages/root/hooks/useFilterActionsWithSidePanelSearch';
|
||||
@@ -8,12 +8,12 @@ import { useFilterActionsWithSidePanelSearch } from '@/side-panel/pages/root/hoo
|
||||
const MockComponent = <div>Mock Component</div>;
|
||||
|
||||
describe('useFilterActionsWithSidePanelSearch', () => {
|
||||
const mockActions: ActionConfig[] = [
|
||||
const mockActions: CommandMenuItemConfig[] = [
|
||||
{
|
||||
key: 'action-1',
|
||||
label: 'Create Record',
|
||||
type: ActionType.Standard,
|
||||
scope: ActionScope.Global,
|
||||
type: CommandMenuItemType.Standard,
|
||||
scope: CommandMenuItemScope.Global,
|
||||
position: 1,
|
||||
Icon: IconPlus,
|
||||
shouldBeRegistered: () => true,
|
||||
@@ -23,8 +23,8 @@ describe('useFilterActionsWithSidePanelSearch', () => {
|
||||
{
|
||||
key: 'action-2',
|
||||
label: 'Delete Record',
|
||||
type: ActionType.Standard,
|
||||
scope: ActionScope.RecordSelection,
|
||||
type: CommandMenuItemType.Standard,
|
||||
scope: CommandMenuItemScope.RecordSelection,
|
||||
position: 2,
|
||||
Icon: IconPlus,
|
||||
shouldBeRegistered: () => true,
|
||||
@@ -34,8 +34,8 @@ describe('useFilterActionsWithSidePanelSearch', () => {
|
||||
{
|
||||
key: 'action-3',
|
||||
label: 'Update Record',
|
||||
type: ActionType.Standard,
|
||||
scope: ActionScope.Object,
|
||||
type: CommandMenuItemType.Standard,
|
||||
scope: CommandMenuItemScope.Object,
|
||||
position: 3,
|
||||
Icon: IconPlus,
|
||||
shouldBeRegistered: () => true,
|
||||
|
||||
+6
-6
@@ -1,17 +1,17 @@
|
||||
import { type ActionConfig } from '@/action-menu/actions/types/ActionConfig';
|
||||
import { getActionLabel } from '@/action-menu/utils/getActionLabel';
|
||||
import { type CommandMenuItemConfig } from '@/command-menu-item/types/CommandMenuItemConfig';
|
||||
import { getCommandMenuItemLabel } from '@/command-menu-item/utils/getCommandMenuItemLabel';
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
import { useCallback } from 'react';
|
||||
import { normalizeSearchText } from '~/utils/normalizeSearchText';
|
||||
|
||||
const checkInShortcuts = (action: ActionConfig, search: string) => {
|
||||
const checkInShortcuts = (action: CommandMenuItemConfig, search: string) => {
|
||||
const concatenatedString = action.hotKeys?.join('') ?? '';
|
||||
const searchNormalized = normalizeSearchText(search.trim());
|
||||
return normalizeSearchText(concatenatedString).includes(searchNormalized);
|
||||
};
|
||||
|
||||
const checkInLabels = (action: ActionConfig, search: string) => {
|
||||
const actionLabel = getActionLabel(action.label);
|
||||
const checkInLabels = (action: CommandMenuItemConfig, search: string) => {
|
||||
const actionLabel = getCommandMenuItemLabel(action.label);
|
||||
if (isNonEmptyString(actionLabel)) {
|
||||
const searchNormalized = normalizeSearchText(search);
|
||||
return normalizeSearchText(actionLabel).includes(searchNormalized);
|
||||
@@ -27,7 +27,7 @@ export const useFilterActionsWithSidePanelSearch = ({
|
||||
sidePanelSearch,
|
||||
}: UseFilterActionsWithSidePanelSearchProps) => {
|
||||
const filterActionsWithSidePanelSearch = useCallback(
|
||||
(actions: ActionConfig[]) => {
|
||||
(actions: CommandMenuItemConfig[]) => {
|
||||
return actions.filter((action) =>
|
||||
sidePanelSearch.length > 0
|
||||
? checkInShortcuts(action, sidePanelSearch) ||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { SIDE_PANEL_COMPONENT_INSTANCE_ID } from '@/side-panel/constants/SidePanelComponentInstanceId';
|
||||
import { SIDE_PANEL_PREVIOUS_COMPONENT_INSTANCE_ID } from '@/side-panel/constants/SidePanelPreviousComponentInstanceId';
|
||||
import { useCopyContextStoreStates } from '@/command-menu/hooks/useCopyContextStoreAndActionMenuStates';
|
||||
import { useCopyContextStoreStates } from '@/command-menu/hooks/useCopyContextStoreAndCommandMenuStates';
|
||||
import { useResetContextStoreStates } from '@/command-menu/hooks/useResetContextStoreStates';
|
||||
|
||||
export const useResetPreviousSidePanelContext = () => {
|
||||
|
||||
+56
-50
@@ -1,67 +1,73 @@
|
||||
import { type ActionConfig } from '@/action-menu/actions/types/ActionConfig';
|
||||
import { ActionScope } from '@/action-menu/actions/types/ActionScope';
|
||||
import { ActionType } from '@/action-menu/actions/types/ActionType';
|
||||
import { ActionMenuContext } from '@/action-menu/contexts/ActionMenuContext';
|
||||
import { type CommandMenuItemConfig } from '@/command-menu-item/types/CommandMenuItemConfig';
|
||||
import { CommandMenuItemScope } from '@/command-menu-item/types/CommandMenuItemScope';
|
||||
import { CommandMenuItemType } from '@/command-menu-item/types/CommandMenuItemType';
|
||||
import { CommandMenuContext } from '@/command-menu-item/contexts/CommandMenuContext';
|
||||
import { useContext } from 'react';
|
||||
|
||||
export const useSidePanelActions = () => {
|
||||
const { actions } = useContext(ActionMenuContext);
|
||||
const { commandMenuItems } = useContext(CommandMenuContext);
|
||||
|
||||
const navigateActions = actions?.filter(
|
||||
(action) => action.type === ActionType.Navigation,
|
||||
const navigateActions = commandMenuItems?.filter(
|
||||
(action) => action.type === CommandMenuItemType.Navigation,
|
||||
);
|
||||
|
||||
const actionRecordSelectionActions: ActionConfig[] = actions?.filter(
|
||||
const actionRecordSelectionActions: CommandMenuItemConfig[] =
|
||||
commandMenuItems?.filter(
|
||||
(action) =>
|
||||
action.type === CommandMenuItemType.Standard &&
|
||||
action.scope === CommandMenuItemScope.RecordSelection,
|
||||
);
|
||||
|
||||
const actionObjectActions: CommandMenuItemConfig[] = commandMenuItems?.filter(
|
||||
(action) =>
|
||||
action.type === ActionType.Standard &&
|
||||
action.scope === ActionScope.RecordSelection,
|
||||
action.type === CommandMenuItemType.Standard &&
|
||||
action.scope === CommandMenuItemScope.Object,
|
||||
);
|
||||
|
||||
const actionObjectActions: ActionConfig[] = actions?.filter(
|
||||
const actionGlobalActions: CommandMenuItemConfig[] = commandMenuItems?.filter(
|
||||
(action) =>
|
||||
action.type === ActionType.Standard &&
|
||||
action.scope === ActionScope.Object,
|
||||
action.type === CommandMenuItemType.Standard &&
|
||||
action.scope === CommandMenuItemScope.Global,
|
||||
);
|
||||
|
||||
const actionGlobalActions: ActionConfig[] = actions?.filter(
|
||||
(action) =>
|
||||
action.type === ActionType.Standard &&
|
||||
action.scope === ActionScope.Global,
|
||||
const workflowRunRecordSelectionActions: CommandMenuItemConfig[] =
|
||||
commandMenuItems?.filter(
|
||||
(action) =>
|
||||
action.type === CommandMenuItemType.WorkflowRun &&
|
||||
action.scope === CommandMenuItemScope.RecordSelection,
|
||||
);
|
||||
|
||||
const workflowRunGlobalActions: CommandMenuItemConfig[] =
|
||||
commandMenuItems?.filter(
|
||||
(action) =>
|
||||
action.type === CommandMenuItemType.WorkflowRun &&
|
||||
action.scope === CommandMenuItemScope.Global,
|
||||
);
|
||||
|
||||
const frontComponentGlobalActions: CommandMenuItemConfig[] =
|
||||
commandMenuItems?.filter(
|
||||
(action) =>
|
||||
action.type === CommandMenuItemType.FrontComponent &&
|
||||
action.scope === CommandMenuItemScope.Global,
|
||||
);
|
||||
|
||||
const frontComponentRecordSelectionActions: CommandMenuItemConfig[] =
|
||||
commandMenuItems?.filter(
|
||||
(action) =>
|
||||
action.type === CommandMenuItemType.FrontComponent &&
|
||||
action.scope === CommandMenuItemScope.RecordSelection,
|
||||
);
|
||||
|
||||
const fallbackActions: CommandMenuItemConfig[] = commandMenuItems?.filter(
|
||||
(action) => action.type === CommandMenuItemType.Fallback,
|
||||
);
|
||||
|
||||
const workflowRunRecordSelectionActions: ActionConfig[] = actions?.filter(
|
||||
(action) =>
|
||||
action.type === ActionType.WorkflowRun &&
|
||||
action.scope === ActionScope.RecordSelection,
|
||||
);
|
||||
|
||||
const workflowRunGlobalActions: ActionConfig[] = actions?.filter(
|
||||
(action) =>
|
||||
action.type === ActionType.WorkflowRun &&
|
||||
action.scope === ActionScope.Global,
|
||||
);
|
||||
|
||||
const frontComponentGlobalActions: ActionConfig[] = actions?.filter(
|
||||
(action) =>
|
||||
action.type === ActionType.FrontComponent &&
|
||||
action.scope === ActionScope.Global,
|
||||
);
|
||||
|
||||
const frontComponentRecordSelectionActions: ActionConfig[] = actions?.filter(
|
||||
(action) =>
|
||||
action.type === ActionType.FrontComponent &&
|
||||
action.scope === ActionScope.RecordSelection,
|
||||
);
|
||||
|
||||
const fallbackActions: ActionConfig[] = actions?.filter(
|
||||
(action) => action.type === ActionType.Fallback,
|
||||
);
|
||||
|
||||
const createRelatedRecordActions: ActionConfig[] = actions?.filter(
|
||||
(action) =>
|
||||
action.type === ActionType.Standard &&
|
||||
action.scope === ActionScope.CreateRelatedRecord,
|
||||
);
|
||||
const createRelatedRecordActions: CommandMenuItemConfig[] =
|
||||
commandMenuItems?.filter(
|
||||
(action) =>
|
||||
action.type === CommandMenuItemType.Standard &&
|
||||
action.scope === CommandMenuItemScope.CreateRelatedRecord,
|
||||
);
|
||||
|
||||
return {
|
||||
navigateActions,
|
||||
|
||||
+9
-9
@@ -1,7 +1,7 @@
|
||||
import { Action } from '@/action-menu/actions/components/Action';
|
||||
import { ActionLink } from '@/action-menu/actions/components/ActionLink';
|
||||
import { ActionScope } from '@/action-menu/actions/types/ActionScope';
|
||||
import { ActionType } from '@/action-menu/actions/types/ActionType';
|
||||
import { Command } from '@/command-menu-item/display/components/Command';
|
||||
import { CommandLink } from '@/command-menu-item/display/components/CommandLink';
|
||||
import { CommandMenuItemScope } from '@/command-menu-item/types/CommandMenuItemScope';
|
||||
import { CommandMenuItemType } from '@/command-menu-item/types/CommandMenuItemType';
|
||||
import { MAX_SEARCH_RESULTS } from '@/command-menu/constants/MaxSearchResults';
|
||||
import { useOpenRecordInSidePanel } from '@/side-panel/hooks/useOpenRecordInSidePanel';
|
||||
import { sidePanelSearchState } from '@/side-panel/states/sidePanelSearchState';
|
||||
@@ -56,8 +56,8 @@ export const useSidePanelSearchRecords = () => {
|
||||
return (searchData?.search.edges.map((edge) => edge.node) ?? []).map(
|
||||
(searchRecord, index) => {
|
||||
const baseAction = {
|
||||
type: ActionType.Navigation,
|
||||
scope: ActionScope.Global,
|
||||
type: CommandMenuItemType.Navigation,
|
||||
scope: CommandMenuItemScope.Global,
|
||||
key: searchRecord.recordId,
|
||||
label: searchRecord.label,
|
||||
position: index,
|
||||
@@ -89,7 +89,7 @@ export const useSidePanelSearchRecords = () => {
|
||||
return {
|
||||
...baseAction,
|
||||
component: (
|
||||
<Action
|
||||
<Command
|
||||
onClick={() => {
|
||||
searchRecord.objectNameSingular === 'task'
|
||||
? openRecordInSidePanel({
|
||||
@@ -101,7 +101,7 @@ export const useSidePanelSearchRecords = () => {
|
||||
objectNameSingular: CoreObjectNameSingular.Note,
|
||||
});
|
||||
}}
|
||||
closeSidePanelOnCommandMenuListActionExecution={false}
|
||||
closeSidePanelOnCommandMenuListExecution={false}
|
||||
/>
|
||||
),
|
||||
};
|
||||
@@ -110,7 +110,7 @@ export const useSidePanelSearchRecords = () => {
|
||||
return {
|
||||
...baseAction,
|
||||
component: (
|
||||
<ActionLink
|
||||
<CommandLink
|
||||
to={AppPath.RecordShowPage}
|
||||
params={{
|
||||
objectNameSingular: searchRecord.objectNameSingular,
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
import { type ActionConfig } from '@/action-menu/actions/types/ActionConfig';
|
||||
|
||||
export type SidePanelActionGroupConfig = {
|
||||
heading: string;
|
||||
items?: ActionConfig[];
|
||||
};
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import { type CommandMenuItemConfig } from '@/command-menu-item/types/CommandMenuItemConfig';
|
||||
|
||||
export type SidePanelCommandMenuItemGroupConfig = {
|
||||
heading: string;
|
||||
items?: CommandMenuItemConfig[];
|
||||
};
|
||||
Reference in New Issue
Block a user