271 remove is command menu v2 enabled (#10809)
Closes https://github.com/twentyhq/core-team-issues/issues/271 This PR - Removes the feature flag IS_COMMAND_MENU_V2_ENABLED - Removes all old Right drawer components - Removes the Action menu bar - Removes unused Copilot page
This commit is contained in:
@ -1,19 +1,10 @@
|
||||
import styled from '@emotion/styled';
|
||||
import { useRecoilCallback } from 'recoil';
|
||||
import { Avatar, GRAY_SCALE } from 'twenty-ui';
|
||||
|
||||
import { ActivityRow } from '@/activities/components/ActivityRow';
|
||||
import { EmailThreadNotShared } from '@/activities/emails/components/EmailThreadNotShared';
|
||||
import { useEmailThread } from '@/activities/emails/hooks/useEmailThread';
|
||||
import { emailThreadIdWhenEmailThreadWasClosedState } from '@/activities/emails/states/lastViewableEmailThreadIdState';
|
||||
import { useCommandMenu } from '@/command-menu/hooks/useCommandMenu';
|
||||
import { useRightDrawer } from '@/ui/layout/right-drawer/hooks/useRightDrawer';
|
||||
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
|
||||
import {
|
||||
FeatureFlagKey,
|
||||
MessageChannelVisibility,
|
||||
TimelineThread,
|
||||
} from '~/generated/graphql';
|
||||
import { MessageChannelVisibility, TimelineThread } from '~/generated/graphql';
|
||||
import { formatToHumanReadableDate } from '~/utils/date-utils';
|
||||
|
||||
const StyledHeading = styled.div<{ unread: boolean }>`
|
||||
@ -77,11 +68,7 @@ type EmailThreadPreviewProps = {
|
||||
};
|
||||
|
||||
export const EmailThreadPreview = ({ thread }: EmailThreadPreviewProps) => {
|
||||
const { openEmailThread } = useEmailThread();
|
||||
const { openEmailThreadInCommandMenu } = useCommandMenu();
|
||||
const isCommandMenuV2Enabled = useIsFeatureEnabled(
|
||||
FeatureFlagKey.IsCommandMenuV2Enabled,
|
||||
);
|
||||
|
||||
const visibility = thread.visibility;
|
||||
|
||||
@ -103,48 +90,19 @@ export const EmailThreadPreview = ({ thread }: EmailThreadPreviewProps) => {
|
||||
false,
|
||||
];
|
||||
|
||||
const { isSameEventThanRightDrawerClose } = useRightDrawer();
|
||||
const handleThreadClick = () => {
|
||||
const canOpen =
|
||||
thread.visibility === MessageChannelVisibility.SHARE_EVERYTHING;
|
||||
|
||||
const handleThreadClick = useRecoilCallback(
|
||||
({ snapshot }) =>
|
||||
(event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
|
||||
const clickJustTriggeredEmailDrawerClose =
|
||||
isSameEventThanRightDrawerClose(event.nativeEvent);
|
||||
|
||||
const emailThreadIdWhenEmailThreadWasClosed = snapshot
|
||||
.getLoadable(emailThreadIdWhenEmailThreadWasClosedState)
|
||||
.getValue();
|
||||
|
||||
const canOpen =
|
||||
thread.visibility === MessageChannelVisibility.SHARE_EVERYTHING &&
|
||||
(!clickJustTriggeredEmailDrawerClose ||
|
||||
emailThreadIdWhenEmailThreadWasClosed !== thread.id);
|
||||
|
||||
if (canOpen) {
|
||||
if (isCommandMenuV2Enabled) {
|
||||
openEmailThreadInCommandMenu(thread.id);
|
||||
} else {
|
||||
openEmailThread(thread.id);
|
||||
}
|
||||
}
|
||||
},
|
||||
[
|
||||
isCommandMenuV2Enabled,
|
||||
isSameEventThanRightDrawerClose,
|
||||
openEmailThread,
|
||||
openEmailThreadInCommandMenu,
|
||||
thread.id,
|
||||
thread.visibility,
|
||||
],
|
||||
);
|
||||
if (canOpen) {
|
||||
openEmailThreadInCommandMenu(thread.id);
|
||||
}
|
||||
};
|
||||
|
||||
const isDisabled = visibility !== MessageChannelVisibility.SHARE_EVERYTHING;
|
||||
|
||||
return (
|
||||
<ActivityRow
|
||||
onClick={(event) => handleThreadClick(event)}
|
||||
disabled={isDisabled}
|
||||
>
|
||||
<ActivityRow onClick={handleThreadClick} disabled={isDisabled}>
|
||||
<StyledHeading unread={!thread.read}>
|
||||
<StyledParticipantsContainer>
|
||||
<Avatar
|
||||
|
||||
Reference in New Issue
Block a user