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

fix #6127 updated support button #6422

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -3,7 +3,7 @@ import { useRecoilValue, useSetRecoilState } from 'recoil';

import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
import { SettingsNavigationDrawerItems } from '@/settings/components/SettingsNavigationDrawerItems';
import { SupportChat } from '@/support/components/SupportChat';
import { SupportDropdown } from '@/support/components/SupportDropdown';
import { GithubVersionLink } from '@/ui/navigation/link/components/GithubVersionLink';
import {
NavigationDrawer,
Expand Down Expand Up @@ -53,7 +53,7 @@ export const AppNavigationDrawer = ({
undefined,
title: currentWorkspace?.displayName ?? undefined,
children: <MainNavigationDrawerItems />,
footer: <SupportChat />,
footer: <SupportDropdown />,
};

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { useCallback, useEffect, useState } from 'react';
import styled from '@emotion/styled';
import { isNonEmptyString } from '@sniptt/guards';
import { useCallback, useEffect, useState } from 'react';
import { useRecoilValue } from 'recoil';
import { IconHelpCircle } from 'twenty-ui';

import { currentUserState } from '@/auth/states/currentUserState';
import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
import { supportChatState } from '@/client-config/states/supportChatState';
import { useIsPrefetchLoading } from '@/prefetch/hooks/useIsPrefetchLoading';
import { SupportChatSkeletonLoader } from '@/support/components/SupportChatSkeletonLoader';
import { SupportButtonSkeletonLoader } from '@/support/components/SupportButtonSkeletonLoader';
import { Button } from '@/ui/input/button/components/Button';
import { WorkspaceMember } from '@/workspace-member/types/WorkspaceMember';
import { User } from '~/generated/graphql';
Expand All @@ -34,7 +34,7 @@ const insertScript = ({
document.body.appendChild(script);
};

export const SupportChat = () => {
export const SupportButton = () => {
const currentUser = useRecoilValue(currentUserState);
const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);
const supportChat = useRecoilValue(supportChatState);
Expand Down Expand Up @@ -102,7 +102,7 @@ export const SupportChat = () => {
]);

if (loading) {
return <SupportChatSkeletonLoader />;
return <SupportButtonSkeletonLoader />;
}

return isFrontChatLoaded ? (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Skeleton, { SkeletonTheme } from 'react-loading-skeleton';
import { useTheme } from '@emotion/react';

export const SupportChatSkeletonLoader = () => {
export const SupportButtonSkeletonLoader = () => {
const theme = useTheme();
return (
<SkeletonTheme
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { SupportButton } from '@/support/components/SupportButton';
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
import { DropdownMenu } from '@/ui/layout/dropdown/components/DropdownMenu';
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem';
import { IconHelpCircle, IconMessage } from 'twenty-ui';

export const SupportDropdown = () => {
const dropdownId = `support-field-active-action-dropdown`;

const { closeDropdown } = useDropdown(dropdownId);

const handleTalkToUs = () => {
window.FrontChat?.('show');
closeDropdown();
};

const handleUserGuide = () => {
window.open('https://twenty.com/user-guide', '_blank');
closeDropdown();
};

return (
<Dropdown
dropdownId={dropdownId}
dropdownPlacement="top-start"
dropdownOffset={{ x: 0, y: -28 }}
clickableComponent={<SupportButton />}
dropdownComponents={
<DropdownMenu width="160px">
<DropdownMenuItemsContainer>
<MenuItem
text="Talk to us"
LeftIcon={IconMessage}
onClick={handleTalkToUs}
/>
<MenuItem
text="Documentation"
LeftIcon={IconHelpCircle}
onClick={handleUserGuide}
/>
</DropdownMenuItemsContainer>
</DropdownMenu>
}
dropdownHotkeyScope={{
scope: dropdownId,
}}
/>
);
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from '@storybook/jest';
import { Meta, StoryObj } from '@storybook/react';
import { within } from '@storybook/test';
import { within, userEvent } from '@storybook/test';
import { useSetRecoilState } from 'recoil';

import { currentUserState } from '@/auth/states/currentUserState';
Expand All @@ -14,11 +14,11 @@ import {
mockedWorkspaceMemberData,
} from '~/testing/mock-data/users';

import { SupportChat } from '../SupportChat';
import { SupportDropdown } from '@/support/components/SupportDropdown';

const meta: Meta<typeof SupportChat> = {
title: 'Modules/Support/SupportChat',
component: SupportChat,
const meta: Meta<typeof SupportDropdown> = {
title: 'Modules/Support/SupportDropdown',
component: SupportDropdown,
decorators: [
(Story) => {
const setCurrentUser = useSetRecoilState(currentUserState);
Expand All @@ -42,11 +42,16 @@ const meta: Meta<typeof SupportChat> = {
};

export default meta;
type Story = StoryObj<typeof SupportChat>;
type Story = StoryObj<typeof SupportDropdown>;

export const Default: Story = {
play: async () => {
const canvas = within(document.body);

expect(await canvas.findByText('Support')).toBeInTheDocument();
await userEvent.click(canvas.getByText('Support'));

expect(await canvas.findByText('Documentation')).toBeInTheDocument();
expect(await canvas.findByText('Talk to us')).toBeInTheDocument();
},
};
4 changes: 2 additions & 2 deletions packages/twenty-front/src/pages/settings/SettingsBilling.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
import { SettingsBillingCoverImage } from '@/billing/components/SettingsBillingCoverImage';
import { useOnboardingStatus } from '@/onboarding/hooks/useOnboardingStatus';
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
import { SupportChat } from '@/support/components/SupportChat';
import { SupportButton } from '@/support/components/SupportButton';
import { AppPath } from '@/types/AppPath';
import { Info } from '@/ui/display/info/components/Info';
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
Expand Down Expand Up @@ -218,7 +218,7 @@ export const SettingsBilling = () => {
)}
</SettingsPageContainer>
<StyledInvisibleChat>
<SupportChat />
<SupportButton />
</StyledInvisibleChat>
<ConfirmationModal
isOpen={isSwitchingIntervalModalOpen}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export {
IconMailCog,
IconMap,
IconMaximize,
IconMessage,
IconMinus,
IconMoneybag,
IconMouse2,
Expand Down
Loading