Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

410 open in side panel #10363

Merged
merged 27 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f8f8e5a
make view settings also appear on the table
bosiraphael Feb 19, 2025
c870d56
create dropdown content
bosiraphael Feb 19, 2025
3493512
add openRecordIn to view workspace entity
bosiraphael Feb 19, 2025
b40d7e6
use openRecordIn value in the frontend
bosiraphael Feb 19, 2025
10e1e9d
fix back arrow behavior
bosiraphael Feb 19, 2025
6d9a88f
create useObjectOptions hook
bosiraphael Feb 19, 2025
3872144
open record in right drawer on kanban page
bosiraphael Feb 19, 2025
ed49f96
open record in the right page
bosiraphael Feb 19, 2025
169af1b
reset states when the animation ends
bosiraphael Feb 19, 2025
9a33bdb
reset navigation stack when opening record page in the command menu
bosiraphael Feb 19, 2025
5aab67f
open new record in the right page
bosiraphael Feb 19, 2025
a05824c
fix the opening of the record title cell
bosiraphael Feb 19, 2025
5ed4765
fix error on record deletion
bosiraphael Feb 20, 2025
8831c81
fix
bosiraphael Feb 20, 2025
6363134
fix
bosiraphael Feb 20, 2025
cac0484
set default view openRecordIn to RECORD_PAGE for workflow objects
bosiraphael Feb 20, 2025
5e72c2f
remove hardcoded record creation redirection for workflows
bosiraphael Feb 20, 2025
28527f5
open record title cell only inside command menu
bosiraphael Feb 20, 2025
41ca524
create script to update all default views on workflow objects
bosiraphael Feb 20, 2025
3c0b44f
update command
bosiraphael Feb 20, 2025
21d68c1
add command to the module providers
bosiraphael Feb 20, 2025
8727a9b
Merge branch 'main' into 410-open-in-side-panel
bosiraphael Feb 20, 2025
dcced76
fix test
bosiraphael Feb 20, 2025
b02cfb3
fix lint and mocks
bosiraphael Feb 20, 2025
a75bea0
add translation prefix
bosiraphael Feb 21, 2025
0f8d0fc
use standard ids in the command instead of name singular
bosiraphael Feb 21, 2025
5dc6662
add translations
bosiraphael Feb 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ export const CommandMenuContainer = ({
}: {
children: React.ReactNode;
}) => {
const { toggleCommandMenu, closeCommandMenu } = useCommandMenu();
const {
toggleCommandMenu,
closeCommandMenu,
onCommandMenuCloseAnimationComplete,
} = useCommandMenu();

const isCommandMenuOpened = useRecoilValue(isCommandMenuOpenedState);

Expand Down Expand Up @@ -98,7 +102,7 @@ export const CommandMenuContainer = ({
>
<ActionMenuContext.Provider
value={{
isInRightDrawer: false,
isInRightDrawer: true,
onActionExecutedCallback: ({ key }) => {
if (
key !== RecordAgnosticActionsKey.SEARCH_RECORDS &&
Expand All @@ -121,7 +125,10 @@ export const CommandMenuContainer = ({
<RunWorkflowRecordAgnosticActionMenuEntriesSetter />
)}
<ActionMenuConfirmationModals />
<AnimatePresence mode="wait">
<AnimatePresence
mode="wait"
onExitComplete={onCommandMenuCloseAnimationComplete}
>
{isCommandMenuOpened && (
<StyledCommandMenu
data-testid="command-menu"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,17 @@ export const CommandMenuContextChipGroupsWithRecordSelection = ({
/>
));

const recordSelectionContextChip = totalCount
? {
text: getSelectedRecordsContextText(
objectMetadataItem,
records,
totalCount,
),
Icons: Avatars,
}
: undefined;
const recordSelectionContextChip =
totalCount && records.length > 0
? {
text: getSelectedRecordsContextText(
objectMetadataItem,
records,
totalCount,
),
Icons: Avatars,
}
: undefined;

const contextChipsWithRecordSelection = [
recordSelectionContextChip,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const CommandMenuContextRecordChip = ({
instanceId,
});

if (loading || !totalCount) {
if (loading || !totalCount || records.length === 0) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,31 +74,33 @@ export const useCommandMenu = () => {
);

const closeCommandMenu = useRecoilCallback(
({ snapshot, set }) =>
({ set }) =>
() => {
const isCommandMenuOpened = snapshot
.getLoadable(isCommandMenuOpenedState)
.getValue();
set(isCommandMenuOpenedState, false);
},
[],
);

if (isCommandMenuOpened) {
resetContextStoreStates('command-menu');
resetContextStoreStates('command-menu-previous');

set(viewableRecordIdState, null);
set(commandMenuPageState, CommandMenuPages.Root);
set(commandMenuPageInfoState, {
title: undefined,
Icon: undefined,
});
set(isCommandMenuOpenedState, false);
set(commandMenuSearchState, '');
set(commandMenuNavigationStackState, []);
resetSelectedItem();
set(hasUserSelectedCommandState, false);
goBackToPreviousHotkeyScope();

emitRightDrawerCloseEvent();
}
const onCommandMenuCloseAnimationComplete = useRecoilCallback(
({ set }) =>
() => {
resetContextStoreStates('command-menu');
resetContextStoreStates('command-menu-previous');

set(viewableRecordIdState, null);
set(commandMenuPageState, CommandMenuPages.Root);
set(commandMenuPageInfoState, {
title: undefined,
Icon: undefined,
});
set(isCommandMenuOpenedState, false);
set(commandMenuSearchState, '');
set(commandMenuNavigationStackState, []);
resetSelectedItem();
set(hasUserSelectedCommandState, false);
goBackToPreviousHotkeyScope();

emitRightDrawerCloseEvent();
},
[goBackToPreviousHotkeyScope, resetContextStoreStates, resetSelectedItem],
);
Expand All @@ -109,7 +111,10 @@ export const useCommandMenu = () => {
page,
pageTitle,
pageIcon,
}: CommandMenuNavigationStackItem) => {
resetNavigationStack = false,
}: CommandMenuNavigationStackItem & {
resetNavigationStack?: boolean;
}) => {
set(commandMenuPageState, page);
set(commandMenuPageInfoState, {
title: pageTitle,
Expand All @@ -120,10 +125,14 @@ export const useCommandMenu = () => {
.getLoadable(commandMenuNavigationStackState)
.getValue();

set(commandMenuNavigationStackState, [
...currentNavigationStack,
{ page, pageTitle, pageIcon },
]);
if (resetNavigationStack) {
set(commandMenuNavigationStackState, [{ page, pageTitle, pageIcon }]);
} else {
set(commandMenuNavigationStackState, [
...currentNavigationStack,
{ page, pageTitle, pageIcon },
]);
}
openCommandMenu();
};
},
Expand Down Expand Up @@ -248,6 +257,7 @@ export const useCommandMenu = () => {
? t`New ${capitalizedObjectNameSingular}`
: capitalizedObjectNameSingular,
pageIcon: Icon,
resetNavigationStack: true,
});
};
},
Expand Down Expand Up @@ -315,6 +325,7 @@ export const useCommandMenu = () => {
return {
openRootCommandMenu,
closeCommandMenu,
onCommandMenuCloseAnimationComplete,
navigateCommandMenu,
navigateCommandMenuHistory,
goBackFromCommandMenu,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadat
import { AGGREGATE_OPERATIONS } from '@/object-record/record-table/constants/AggregateOperations';
import { prefetchViewsState } from '@/prefetch/states/prefetchViewsState';
import { AppPath } from '@/types/AppPath';
import { ViewOpenRecordInType } from '@/views/types/ViewOpenRecordInType';
import { ViewType } from '@/views/types/ViewType';
import { getCompanyObjectMetadataItem } from '~/testing/mock-data/companies';
import { generatedMockObjectMetadataItems } from '~/testing/mock-data/generatedMockObjectMetadataItems';
Expand Down Expand Up @@ -38,6 +39,7 @@ const renderHooks = ({
type: ViewType.Table,
key: null,
isCompact: false,
openRecordIn: ViewOpenRecordInType.SIDE_PANEL,
viewFields: [],
viewGroups: [],
viewSorts: [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { AvatarChip, AvatarChipVariant } from 'twenty-ui';

import { useCommandMenu } from '@/command-menu/hooks/useCommandMenu';
import { getLinkToShowPage } from '@/object-metadata/utils/getLinkToShowPage';
import { useRecordChipData } from '@/object-record/hooks/useRecordChipData';
import { recordIndexOpenRecordInState } from '@/object-record/record-index/states/recordIndexOpenRecordInState';
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { ViewOpenRecordInType } from '@/views/types/ViewOpenRecordInType';
import { MouseEvent } from 'react';
import { useRecoilValue } from 'recoil';

export type RecordChipProps = {
objectNameSingular: string;
Expand All @@ -23,8 +27,18 @@ export const RecordChip = ({
record,
});

const { openRecordInCommandMenu } = useCommandMenu();

const recordIndexOpenRecordIn = useRecoilValue(recordIndexOpenRecordInState);

const handleClick = (e: MouseEvent<Element>) => {
e.stopPropagation();
if (recordIndexOpenRecordIn === ViewOpenRecordInType.SIDE_PANEL) {
openRecordInCommandMenu({
recordId: record.id,
objectNameSingular,
});
}
};

return (
Expand All @@ -36,7 +50,11 @@ export const RecordChip = ({
className={className}
variant={variant}
onClick={handleClick}
to={getLinkToShowPage(objectNameSingular, record)}
to={
recordIndexOpenRecordIn === ViewOpenRecordInType.RECORD_PAGE
? getLinkToShowPage(objectNameSingular, record)
: undefined
}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ObjectOptionsDropdownRecordGroupFieldsContent } from '@/object-record/o
import { ObjectOptionsDropdownRecordGroupsContent } from '@/object-record/object-options-dropdown/components/ObjectOptionsDropdownRecordGroupsContent';
import { ObjectOptionsDropdownRecordGroupSortContent } from '@/object-record/object-options-dropdown/components/ObjectOptionsDropdownRecordGroupSortContent';
import { ObjectOptionsDropdownViewSettingsContent } from '@/object-record/object-options-dropdown/components/ObjectOptionsDropdownViewSettingsContent';
import { ObjectOptionsDropdownViewSettingsOpenInContent } from '@/object-record/object-options-dropdown/components/ObjectOptionsDropdownViewSettingsOpenInContent';
import { useOptionsDropdown } from '@/object-record/object-options-dropdown/hooks/useOptionsDropdown';

export const ObjectOptionsDropdownContent = () => {
Expand All @@ -14,6 +15,8 @@ export const ObjectOptionsDropdownContent = () => {
switch (currentContentId) {
case 'viewSettings':
return <ObjectOptionsDropdownViewSettingsContent />;
case 'viewSettingsOpenIn':
return <ObjectOptionsDropdownViewSettingsOpenInContent />;
case 'fields':
return <ObjectOptionsDropdownFieldsContent />;
case 'hiddenFields':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import { DropdownMenuSeparator } from '@/ui/layout/dropdown/components/DropdownM
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
import { useGetCurrentView } from '@/views/hooks/useGetCurrentView';
import { ViewType } from '@/views/types/ViewType';
import { isDefined } from 'twenty-shared';

export const ObjectOptionsDropdownMenuContent = () => {
Expand Down Expand Up @@ -104,20 +103,17 @@ export const ObjectOptionsDropdownMenuContent = () => {
<DropdownMenuHeader StartIcon={CurrentViewIcon ?? IconList}>
{currentView?.name}
</DropdownMenuHeader>
{/** TODO: Should be removed when view settings contains more options */}
{viewType === ViewType.Kanban && (
<>
<DropdownMenuItemsContainer scrollable={false}>
<MenuItem
onClick={() => onContentChange('viewSettings')}
LeftIcon={IconLayout}
text="View settings"
hasSubMenu
/>
</DropdownMenuItemsContainer>
<DropdownMenuSeparator />
</>
)}

<DropdownMenuItemsContainer scrollable={false}>
<MenuItem
onClick={() => onContentChange('viewSettings')}
LeftIcon={IconLayout}
text="View settings"
hasSubMenu
/>
</DropdownMenuItemsContainer>
<DropdownMenuSeparator />

<DropdownMenuItemsContainer scrollable={false}>
<MenuItem
onClick={() => onContentChange('fields')}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
import {
IconBaselineDensitySmall,
IconChevronLeft,
IconLayoutNavbar,
IconLayoutSidebarRight,
MenuItem,
MenuItemToggle,
} from 'twenty-ui';

import { useObjectOptionsForBoard } from '@/object-record/object-options-dropdown/hooks/useObjectOptionsForBoard';
import { useOptionsDropdown } from '@/object-record/object-options-dropdown/hooks/useOptionsDropdown';
import { recordIndexOpenRecordInState } from '@/object-record/record-index/states/recordIndexOpenRecordInState';
import { DropdownMenuHeader } from '@/ui/layout/dropdown/components/DropdownMenuHeader';
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
import { useGetCurrentView } from '@/views/hooks/useGetCurrentView';
import { ViewOpenRecordInType } from '@/views/types/ViewOpenRecordInType';
import { ViewType } from '@/views/types/ViewType';
import { useRecoilValue } from 'recoil';

export const ObjectOptionsDropdownViewSettingsContent = () => {
const { currentViewWithCombinedFiltersAndSorts } = useGetCurrentView();

const { recordIndexId, objectMetadataItem, viewType, resetContent } =
useOptionsDropdown();
const {
recordIndexId,
objectMetadataItem,
viewType,
resetContent,
onContentChange,
} = useOptionsDropdown();

const { isCompactModeActive, setAndPersistIsCompactModeActive } =
useObjectOptionsForBoard({
Expand All @@ -24,12 +35,29 @@ export const ObjectOptionsDropdownViewSettingsContent = () => {
viewBarId: recordIndexId,
});

const recordIndexOpenRecordIn = useRecoilValue(recordIndexOpenRecordInState);

return (
<>
<DropdownMenuHeader StartIcon={IconChevronLeft} onClick={resetContent}>
View settings
</DropdownMenuHeader>
<DropdownMenuItemsContainer>
<MenuItem
onClick={() => onContentChange('viewSettingsOpenIn')}
LeftIcon={
recordIndexOpenRecordIn === ViewOpenRecordInType.SIDE_PANEL
? IconLayoutSidebarRight
: IconLayoutNavbar
}
text="Open in"
contextualText={
recordIndexOpenRecordIn === ViewOpenRecordInType.SIDE_PANEL
? 'Side Panel'
: 'Record Page'
}
hasSubMenu
/>
{viewType === ViewType.Kanban && (
<MenuItemToggle
LeftIcon={IconBaselineDensitySmall}
Expand Down
Loading
Loading