09bfb617b2
This PR introduces a new side panel to edit records and the ability to minimize the side panel. The goal is leverage this sidepanel to be able to create records while being in another show page. I'm opening the PR for feedback since it involved refactoring and therefore already touches a lot of files, even though it was quick to implement. <img width="1503" alt="Screenshot 2024-05-23 at 17 41 37" src="https://github.com/twentyhq/twenty/assets/6399865/6f17e7a8-f4e9-4eb4-b392-c756db7198ac">
34 lines
1.3 KiB
TypeScript
34 lines
1.3 KiB
TypeScript
import { useRecoilState, useSetRecoilState } from 'recoil';
|
|
|
|
import { activityIdInDrawerState } from '@/activities/states/activityIdInDrawerState';
|
|
import { viewableRecordIdState } from '@/object-record/record-right-drawer/states/viewableRecordIdState';
|
|
import { useRightDrawer } from '@/ui/layout/right-drawer/hooks/useRightDrawer';
|
|
import { RightDrawerHotkeyScope } from '@/ui/layout/right-drawer/types/RightDrawerHotkeyScope';
|
|
import { RightDrawerPages } from '@/ui/layout/right-drawer/types/RightDrawerPages';
|
|
import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope';
|
|
|
|
export const useOpenActivityRightDrawer = () => {
|
|
const { openRightDrawer, isRightDrawerOpen, rightDrawerPage } =
|
|
useRightDrawer();
|
|
const [viewableRecordId, setViewableRecordId] = useRecoilState(
|
|
viewableRecordIdState,
|
|
);
|
|
const setActivityIdInDrawer = useSetRecoilState(activityIdInDrawerState);
|
|
const setHotkeyScope = useSetHotkeyScope();
|
|
|
|
return (activityId: string) => {
|
|
if (
|
|
isRightDrawerOpen &&
|
|
rightDrawerPage === RightDrawerPages.EditActivity &&
|
|
viewableRecordId === activityId
|
|
) {
|
|
return;
|
|
}
|
|
|
|
setHotkeyScope(RightDrawerHotkeyScope.RightDrawer, { goto: false });
|
|
setViewableRecordId(activityId);
|
|
setActivityIdInDrawer(activityId);
|
|
openRightDrawer(RightDrawerPages.EditActivity);
|
|
};
|
|
};
|