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

DTRA / Kate / FEQ-2213 + FEQ-2205 / Made popover optional #15197

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
32 changes: 20 additions & 12 deletions packages/core/src/App/Components/Layout/Header/account-actions.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as PropTypes from 'prop-types';
import React from 'react';
import { Button, Icon, Popover } from '@deriv/components';
import { routes, formatMoney, PlatformContext, moduleLoader } from '@deriv/shared';
import { routes, formatMoney, PlatformContext, moduleLoader, isTabletOs } from '@deriv/shared';
import { localize, Localize } from '@deriv/translations';
import { LoginButton } from './login-button.jsx';
import { SignupButton } from './signup-button.jsx';
Expand Down Expand Up @@ -41,6 +41,11 @@ const AccountActions = React.memo(
}) => {
const { is_appstore } = React.useContext(PlatformContext);
const { isDesktop } = useDevice();
const accountSettings = (
<BinaryLink className='account-settings-toggle' to={routes.personal_details}>
<Icon icon='IcUserOutline' />
</BinaryLink>
);

if (is_logged_in) {
if (isDesktop) {
Expand All @@ -52,18 +57,21 @@ const AccountActions = React.memo(
toggleDialog={toggleNotifications}
tooltip_message={<Localize i18n_default_text='View notifications' />}
should_disable_pointer_events
showPopover={!isTabletOs}
/>
<Popover
classNameBubble='account-settings-toggle__tooltip'
alignment='bottom'
message={<Localize i18n_default_text='Manage account settings' />}
should_disable_pointer_events
zIndex={9999}
>
<BinaryLink className='account-settings-toggle' to={routes.personal_details}>
<Icon icon='IcUserOutline' />
</BinaryLink>
</Popover>
{isTabletOs ? (
accountSettings
) : (
<Popover
classNameBubble='account-settings-toggle__tooltip'
alignment='bottom'
message={<Localize i18n_default_text='Manage account settings' />}
should_disable_pointer_events
zIndex={9999}
>
{accountSettings}
</Popover>
)}
<React.Suspense fallback={<div />}>
<AccountInfo
acc_switcher_disabled_message={acc_switcher_disabled_message}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const ToggleNotificationsDrawer = ({
toggleDialog,
tooltip_message,
should_disable_pointer_events = false,
showPopover = true,
}) => {
const { isMobile } = useDevice();
const notifications_toggler_el = (
Expand Down Expand Up @@ -44,15 +45,19 @@ const ToggleNotificationsDrawer = ({
'notifications-toggle--active': is_visible,
})}
>
<Popover
classNameBubble='notifications-toggle__tooltip'
alignment='bottom'
message={tooltip_message}
should_disable_pointer_events={should_disable_pointer_events}
zIndex='9999'
>
{notifications_toggler_el}
</Popover>
{showPopover ? (
<Popover
classNameBubble='notifications-toggle__tooltip'
alignment='bottom'
message={tooltip_message}
should_disable_pointer_events={should_disable_pointer_events}
zIndex='9999'
>
{notifications_toggler_el}
</Popover>
) : (
notifications_toggler_el
)}
<NotificationsDialog is_visible={is_visible} toggleDialog={toggleDialog} />
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { useHistory } from 'react-router';
import { routes } from '@deriv/shared';
import { routes, isTabletOs } from '@deriv/shared';
import { Button, Icon, Popover } from '@deriv/components';
import { localize, Localize } from '@deriv/translations';
import { observer, useStore } from '@deriv/stores';
Expand Down Expand Up @@ -29,6 +29,12 @@ const AccountActionsWallets = observer(() => {
history.push(routes.wallets_transfer, { toAccountLoginId: loginid });
};

const accountSettings = (
<BinaryLink className='account-settings-toggle' to={routes.personal_details}>
<Icon icon='IcUserOutline' />
</BinaryLink>
);

if (!is_logged_in) {
return (
<React.Fragment>
Expand Down Expand Up @@ -62,18 +68,21 @@ const AccountActionsWallets = observer(() => {
toggleDialog={toggleNotificationsModal}
tooltip_message={<Localize i18n_default_text='View notifications' />}
should_disable_pointer_events
showPopover={!isTabletOs}
/>
<Popover
classNameBubble='account-settings-toggle__tooltip'
alignment='bottom'
message={<Localize i18n_default_text='Manage account settings' />}
should_disable_pointer_events
zIndex='9999'
>
<BinaryLink className='account-settings-toggle' to={routes.personal_details}>
<Icon icon='IcUserOutline' />
</BinaryLink>
</Popover>
{isTabletOs ? (
accountSettings
) : (
<Popover
classNameBubble='account-settings-toggle__tooltip'
alignment='bottom'
message={<Localize i18n_default_text='Manage account settings' />}
should_disable_pointer_events
zIndex='9999'
>
{accountSettings}
</Popover>
)}
<AccountInfoWallets is_dialog_on={is_accounts_switcher_on} toggleDialog={toggleAccountsDialog} />
{!is_virtual && !currency && (
<div className='set-currency'>
Expand Down
3 changes: 2 additions & 1 deletion packages/shared/src/utils/os/os_detect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ export const isMobileOs = () =>

export const isTabletOs =
/ipad|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase()) ||
(/android/i.test(navigator.userAgent.toLowerCase()) && !/mobile/i.test(navigator.userAgent.toLowerCase()));
(/android/i.test(navigator.userAgent.toLowerCase()) && !/mobile/i.test(navigator.userAgent.toLowerCase())) ||
(/MacIntel|Linux/.test(navigator.platform) && navigator.maxTouchPoints > 0);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: function for detection TabletOS was taken from here. Failing test cases were also fixed there.


export const OSDetect = () => {
// For testing purposes or more compatibility, if we set 'config.os'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import PurchaseButton from 'Modules/Trading/Components/Elements/purchase-button'
import CancelDealInfo from '../Form/Purchase/cancel-deal-info';
import { TProposalTypeInfo, TTradeStore } from 'Types';
import { useDevice } from '@deriv-com/ui';
import { isTabletOs } from '@deriv/shared';

type TPurchaseFieldset = {
basis: string;
Expand Down Expand Up @@ -158,7 +159,7 @@ const PurchaseFieldset = ({
</Popover>
) : (
<React.Fragment>
{is_multiplier ? (
{is_multiplier && !isTabletOs ? (
<Popover
alignment='left'
is_bubble_hover_enabled
Expand Down
Loading