1
1
mirror of https://github.com/twentyhq/twenty.git synced 2024-12-22 03:11:44 +03:00

Fix right drawer bug ()

This commit is contained in:
Charles Bochet 2023-07-10 21:46:20 -07:00 committed by GitHub
parent ebf5f67f63
commit e1161e96a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 2 deletions

View File

@ -4,7 +4,7 @@ import { useRecoilValue } from 'recoil';
import { v4 } from 'uuid'; import { v4 } from 'uuid';
import { currentUserState } from '@/auth/states/currentUserState'; import { currentUserState } from '@/auth/states/currentUserState';
import { GET_COMMENT_THREADS_BY_TARGETS } from '@/comments/services'; import { GET_COMMENT_THREAD } from '@/comments/services';
import { CommentForDrawer } from '@/comments/types/CommentForDrawer'; import { CommentForDrawer } from '@/comments/types/CommentForDrawer';
import { AutosizeTextInput } from '@/ui/components/inputs/AutosizeTextInput'; import { AutosizeTextInput } from '@/ui/components/inputs/AutosizeTextInput';
import { isNonEmptyString } from '@/utils/type-guards/isNonEmptyString'; import { isNonEmptyString } from '@/utils/type-guards/isNonEmptyString';
@ -69,7 +69,7 @@ export function CommentThreadComments({ commentThread }: OwnProps) {
commentText: commentText, commentText: commentText,
createdAt: new Date().toISOString(), createdAt: new Date().toISOString(),
}, },
refetchQueries: [getOperationName(GET_COMMENT_THREADS_BY_TARGETS) ?? ''], refetchQueries: [getOperationName(GET_COMMENT_THREAD) ?? ''],
}); });
} }

View File

@ -1,5 +1,7 @@
import { useRecoilState } from 'recoil'; import { useRecoilState } from 'recoil';
import { useSetHotkeysScope } from '@/hotkeys/hooks/useSetHotkeysScope';
import { InternalHotkeysScope } from '@/hotkeys/types/internal/InternalHotkeysScope';
import { RightDrawerPages } from '@/ui/layout/right-drawer/types/RightDrawerPages'; import { RightDrawerPages } from '@/ui/layout/right-drawer/types/RightDrawerPages';
import { useOpenRightDrawer } from '../../ui/layout/right-drawer/hooks/useOpenRightDrawer'; import { useOpenRightDrawer } from '../../ui/layout/right-drawer/hooks/useOpenRightDrawer';
@ -10,8 +12,10 @@ export function useOpenCommentThreadRightDrawer() {
const [, setViewableCommentThreadId] = useRecoilState( const [, setViewableCommentThreadId] = useRecoilState(
viewableCommentThreadIdState, viewableCommentThreadIdState,
); );
const setHotkeysScope = useSetHotkeysScope();
return function openCommentThreadRightDrawer(commentThreadId: string) { return function openCommentThreadRightDrawer(commentThreadId: string) {
setHotkeysScope(InternalHotkeysScope.RightDrawer, { goto: false });
setViewableCommentThreadId(commentThreadId); setViewableCommentThreadId(commentThreadId);
openRightDrawer(RightDrawerPages.EditCommentThread); openRightDrawer(RightDrawerPages.EditCommentThread);
}; };

View File

@ -4,6 +4,8 @@ import { v4 } from 'uuid';
import { currentUserState } from '@/auth/states/currentUserState'; import { currentUserState } from '@/auth/states/currentUserState';
import { GET_COMPANIES } from '@/companies/services'; import { GET_COMPANIES } from '@/companies/services';
import { useSetHotkeysScope } from '@/hotkeys/hooks/useSetHotkeysScope';
import { InternalHotkeysScope } from '@/hotkeys/types/internal/InternalHotkeysScope';
import { GET_PEOPLE } from '@/people/services'; import { GET_PEOPLE } from '@/people/services';
import { RightDrawerPages } from '@/ui/layout/right-drawer/types/RightDrawerPages'; import { RightDrawerPages } from '@/ui/layout/right-drawer/types/RightDrawerPages';
import { selectedRowIdsState } from '@/ui/tables/states/selectedRowIdsState'; import { selectedRowIdsState } from '@/ui/tables/states/selectedRowIdsState';
@ -28,6 +30,7 @@ export function useOpenCreateCommentThreadDrawerForSelectedRowIds() {
const [, setViewableCommentThreadId] = useRecoilState( const [, setViewableCommentThreadId] = useRecoilState(
viewableCommentThreadIdState, viewableCommentThreadIdState,
); );
const setHotkeysScope = useSetHotkeysScope();
const [, setCommentableEntityArray] = useRecoilState( const [, setCommentableEntityArray] = useRecoilState(
commentableEntityArrayState, commentableEntityArrayState,
@ -64,6 +67,7 @@ export function useOpenCreateCommentThreadDrawerForSelectedRowIds() {
getOperationName(GET_COMMENT_THREADS_BY_TARGETS) ?? '', getOperationName(GET_COMMENT_THREADS_BY_TARGETS) ?? '',
], ],
onCompleted(data) { onCompleted(data) {
setHotkeysScope(InternalHotkeysScope.RightDrawer, { goto: false });
setViewableCommentThreadId(data.createOneCommentThread.id); setViewableCommentThreadId(data.createOneCommentThread.id);
setCommentableEntityArray(commentableEntityArray); setCommentableEntityArray(commentableEntityArray);
openRightDrawer(RightDrawerPages.CreateCommentThread); openRightDrawer(RightDrawerPages.CreateCommentThread);

View File

@ -4,6 +4,8 @@ import { v4 } from 'uuid';
import { currentUserState } from '@/auth/states/currentUserState'; import { currentUserState } from '@/auth/states/currentUserState';
import { GET_COMPANIES } from '@/companies/services'; import { GET_COMPANIES } from '@/companies/services';
import { useSetHotkeysScope } from '@/hotkeys/hooks/useSetHotkeysScope';
import { InternalHotkeysScope } from '@/hotkeys/types/internal/InternalHotkeysScope';
import { GET_PEOPLE } from '@/people/services'; import { GET_PEOPLE } from '@/people/services';
import { RightDrawerPages } from '@/ui/layout/right-drawer/types/RightDrawerPages'; import { RightDrawerPages } from '@/ui/layout/right-drawer/types/RightDrawerPages';
import { useCreateCommentThreadMutation } from '~/generated/graphql'; import { useCreateCommentThreadMutation } from '~/generated/graphql';
@ -21,6 +23,7 @@ export function useOpenCreateCommentThreadDrawer() {
const openRightDrawer = useOpenRightDrawer(); const openRightDrawer = useOpenRightDrawer();
const [createCommentThreadMutation] = useCreateCommentThreadMutation(); const [createCommentThreadMutation] = useCreateCommentThreadMutation();
const currentUser = useRecoilValue(currentUserState); const currentUser = useRecoilValue(currentUserState);
const setHotkeysScope = useSetHotkeysScope();
const [, setCommentableEntityArray] = useRecoilState( const [, setCommentableEntityArray] = useRecoilState(
commentableEntityArrayState, commentableEntityArrayState,
@ -51,6 +54,7 @@ export function useOpenCreateCommentThreadDrawer() {
getOperationName(GET_COMMENT_THREADS_BY_TARGETS) ?? '', getOperationName(GET_COMMENT_THREADS_BY_TARGETS) ?? '',
], ],
onCompleted(data) { onCompleted(data) {
setHotkeysScope(InternalHotkeysScope.RightDrawer, { goto: false });
setViewableCommentThreadId(data.createOneCommentThread.id); setViewableCommentThreadId(data.createOneCommentThread.id);
setCommentableEntityArray([entity]); setCommentableEntityArray([entity]);
openRightDrawer(RightDrawerPages.CreateCommentThread); openRightDrawer(RightDrawerPages.CreateCommentThread);

View File

@ -1,5 +1,7 @@
import { useRecoilState } from 'recoil'; import { useRecoilState } from 'recoil';
import { useSetHotkeysScope } from '@/hotkeys/hooks/useSetHotkeysScope';
import { InternalHotkeysScope } from '@/hotkeys/types/internal/InternalHotkeysScope';
import { RightDrawerPages } from '@/ui/layout/right-drawer/types/RightDrawerPages'; import { RightDrawerPages } from '@/ui/layout/right-drawer/types/RightDrawerPages';
import { useOpenRightDrawer } from '../../ui/layout/right-drawer/hooks/useOpenRightDrawer'; import { useOpenRightDrawer } from '../../ui/layout/right-drawer/hooks/useOpenRightDrawer';
@ -11,10 +13,12 @@ export function useOpenTimelineRightDrawer() {
const [, setCommentableEntityArray] = useRecoilState( const [, setCommentableEntityArray] = useRecoilState(
commentableEntityArrayState, commentableEntityArrayState,
); );
const setHotkeysScope = useSetHotkeysScope();
return function openTimelineRightDrawer( return function openTimelineRightDrawer(
commentableEntityArray: CommentableEntity[], commentableEntityArray: CommentableEntity[],
) { ) {
setHotkeysScope(InternalHotkeysScope.RightDrawer, { goto: false });
setCommentableEntityArray(commentableEntityArray); setCommentableEntityArray(commentableEntityArray);
openRightDrawer(RightDrawerPages.Timeline); openRightDrawer(RightDrawerPages.Timeline);
}; };