Skip to content

Commit

Permalink
Merge branch 'master' into ako/80792/playwright-setup-redo
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-hosseini-deriv committed Apr 14, 2023
2 parents 1a1defb + d7aaba9 commit b7c0d00
Show file tree
Hide file tree
Showing 69 changed files with 342 additions and 337 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ const FinancialDetails = props => {
is_disabled={isDesktop()}
>
<Text as='p' color='prominent' size='xxs' className='trading-assessment__side-note'>
<Localize
i18n_default_text='We collect information about your employment as part of our due
diligence obligations, as required by anti-money laundering legislation.'
/>
<Localize i18n_default_text='We collect information about your employment as part of our due diligence obligations, as required by anti-money laundering legislation.' />
</Text>
<ThemedScrollbars autoHide={!(window.innerHeight < 890)} height={height - 77}>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ const PersonalDetails = ({
/>
);
};

/*
In most modern browsers, setting autocomplete to "off" will not prevent a password manager from asking the user if they would like to save username and password information, or from automatically filling in those values in a site's login form.
check this link https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion#the_autocomplete_attribute_and_login_fields
*/
// for dropdowns use 'none'
const autocomplete_value = 'none';

return (
<Formik
innerRef={selected_step_ref}
Expand Down Expand Up @@ -320,7 +328,7 @@ const PersonalDetails = ({
(props.value?.place_of_birth && has_real_account)
}
data-lpignore='true'
autoComplete='off' // prevent chrome autocomplete
autoComplete={autocomplete_value} // prevent chrome autocomplete
type='text'
label={
is_mf
Expand Down Expand Up @@ -384,7 +392,7 @@ const PersonalDetails = ({
<Autocomplete
{...field}
data-lpignore='true'
autoComplete='off' // prevent chrome autocomplete
autoComplete={autocomplete_value} // prevent chrome autocomplete
type='text'
label={
is_mf
Expand Down Expand Up @@ -475,7 +483,7 @@ const PersonalDetails = ({
<Autocomplete
{...field}
data-lpignore='true'
autoComplete='off' // prevent chrome autocomplete
autoComplete={autocomplete_value} // prevent chrome autocomplete
type='text'
label={
is_mf
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,83 @@
import React from 'react';
import { Button, Icon, Modal, Text } from '@deriv/components';
import { Button, Icon, Modal, Text, DesktopWrapper, MobileDialog, MobileWrapper } from '@deriv/components';
import { localize } from '@deriv/translations';
import { isMobile } from '@deriv/shared';

const RiskToleranceWarningModal = ({ show_risk_modal, handleAcceptRisk, title, button_text, body_content }) => {
const RiskToleranceWarningModal = ({
show_risk_modal,
handleAcceptRisk,
title,
button_text,
body_content,
has_sub_header = false,
}) => {
return (
<Modal
width='44rem'
title={title}
height={isMobile() ? '44rem' : '41rem'}
is_open={show_risk_modal}
className='center-risk-modal'
toggleModal={handleAcceptRisk}
has_close_icon={!isMobile()}
>
<Modal.Body>
<Icon icon='IcRedWarning' size={isMobile() ? 65 : 63} />
<Text
as='p'
size='xs'
align='center'
line_height={isMobile() ? 'l' : 's'}
className='risk-acceptance__text'
<React.Fragment>
<DesktopWrapper>
<Modal
width='44rem'
title={title}
height='41rem'
is_open={show_risk_modal}
className='center-risk-modal'
toggleModal={handleAcceptRisk}
has_close_icon={false}
>
{body_content}
</Text>
</Modal.Body>
<Modal.Footer>
<Button type='button' large text={button_text || localize('OK')} primary onClick={handleAcceptRisk} />
</Modal.Footer>
</Modal>
<Modal.Body>
<Icon icon='IcRedWarning' size='63' />
<Text as='p' size='xs' align='center' line_height='s' className='risk-acceptance__text'>
{body_content}
</Text>
</Modal.Body>
<Modal.Footer>
<Button
type='button'
large
text={button_text || localize('OK')}
primary
onClick={handleAcceptRisk}
/>
</Modal.Footer>
</Modal>
</DesktopWrapper>
<MobileWrapper>
<MobileDialog
visible={show_risk_modal}
title={has_sub_header ? localize('Trading Experience Assessment') : title}
portal_element_id='modal_root'
has_close_icon={false}
>
<Modal.Body className='risk-tolerance-modal'>
{has_sub_header ? (
<Text
size='xs'
line_height='s'
weight='bold'
as='p'
className='risk-tolerance-modal__title'
>
{title}
<div className='risk-tolerance-modal__title--separator' />
</Text>
) : null}
<div className='risk-tolerance-modal__wrapper'>
<Icon icon='IcRedWarning' size='65' />
<Text as='p' size='xs' align='center' line_height='l' className='risk-acceptance__text'>
{body_content}
</Text>
</div>
</Modal.Body>
<Modal.Footer className='risk-tolerance-modal__footer'>
<Button
type='button'
large
text={button_text || localize('OK')}
primary
onClick={handleAcceptRisk}
/>
</Modal.Footer>
</MobileDialog>
</MobileWrapper>
</React.Fragment>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ import { TModalContent, TAccountType, TAccountCard, TTradingPlatformAvailableAcc
import { TIconTypes } from 'Types';
import { CFD_PLATFORMS } from '@deriv/shared';

const derived_account: TAccountType = {
const getDerivedAccount = (): TAccountType => ({
title_and_type: localize('Derived'),
icon: 'Derived',
description: localize('Trade CFDs on MT5 with Derived indices that simulate real-world market movements.'),
};
});

const financial_account: TAccountType = {
const getFinancialAccount = (): TAccountType => ({
title_and_type: localize('Financial'),
icon: 'Financial',
description: localize('Trade CFDs on MT5 with forex, stock indices, commodities, and cryptocurrencies.'),
};
});

const AccountCard = ({ selectAccountTypeCard, account_type_card, title_and_type, description, icon }: TAccountCard) => {
const cardSelection = (cardType: string) => {
Expand Down Expand Up @@ -60,19 +60,19 @@ const ModalContent = ({
{is_synthetic_available && (
<AccountCard
account_type_card={account_type_card}
selectAccountTypeCard={() => selectAccountTypeCard(`${derived_account.title_and_type}`)}
description={derived_account.description}
title_and_type={derived_account.title_and_type}
icon={derived_account.icon}
selectAccountTypeCard={() => selectAccountTypeCard(`${getDerivedAccount().title_and_type}`)}
description={getDerivedAccount().description}
title_and_type={getDerivedAccount().title_and_type}
icon={getDerivedAccount().icon}
/>
)}
{is_financial_available && (
<AccountCard
account_type_card={account_type_card}
selectAccountTypeCard={() => selectAccountTypeCard(`${financial_account.title_and_type}`)}
description={financial_account.description}
title_and_type={financial_account.title_and_type}
icon={financial_account.icon}
selectAccountTypeCard={() => selectAccountTypeCard(`${getFinancialAccount().title_and_type}`)}
description={getFinancialAccount().description}
title_and_type={getFinancialAccount().title_and_type}
icon={getFinancialAccount().icon}
/>
)}
</div>
Expand Down Expand Up @@ -101,7 +101,7 @@ const MT5AccountTypeModal = () => {
);

const set_account_type = () =>
account_type_card === 'Derived'
account_type_card === localize('Derived')
? setAccountType({ category: 'real', type: 'synthetic' })
: setAccountType({ category: 'real', type: 'financial' });

Expand Down
1 change: 0 additions & 1 deletion packages/bot-skeleton/src/scratch/dbot-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class DBotStore extends DBotStoreInterface {
this.is_dark_mode_on = store.is_dark_mode_on || false;
this.client = store.client;
this.flyout = store.flyout;
this.populateConfig = store.populateConfig;
this.toolbar = store.toolbar;
this.toolbox = store.toolbox;
this.save_modal = store.save_modal;
Expand Down
1 change: 1 addition & 0 deletions packages/bot-skeleton/src/services/api/api-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class APIBase {
subscribe() {
doUntilDone(() => this.api.send({ balance: 1, subscribe: 1 }));
doUntilDone(() => this.api.send({ transaction: 1, subscribe: 1 }));
doUntilDone(() => this.api.send({ proposal_open_contract: 1, subscribe: 1 }));
}

getActiveSymbols = async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { getRoundedNumber } from '@deriv/shared';
import { sell, openContractReceived } from './state/actions';
import { contractStatus, contract as broadcastContract } from '../utils/broadcast';
import { doUntilDone } from '../utils/helpers';
import DBotStore from '../../../scratch/dbot-store';
import { api_base } from '../../api/api-base';

export default Engine =>
Expand Down Expand Up @@ -51,29 +49,6 @@ export default Engine =>
});
}

subscribeToOpenContract(contract_id = this.contractId) {
this.contractId = contract_id;
const request_object = {
proposal_open_contract: 1,
contract_id,
subscribe: 1,
};

doUntilDone(() => api_base.api.send(request_object))
.then(data => {
const { populateConfig } = DBotStore.instance;
populateConfig(data.proposal_open_contract);
this.openContractId = data.proposal_open_contract.id;
})
.catch(error => {
if (error.error.code !== 'AlreadySubscribed') {
doUntilDone(() => api_base.api.send(request_object)).then(
response => (this.openContractId = response.proposal_open_contract.id)
);
}
});
}

setContractFlags(contract) {
const { is_expired, is_valid_to_sell, is_sold, entry_tick } = contract;

Expand Down
36 changes: 2 additions & 34 deletions packages/bot-skeleton/src/services/tradeEngine/trade/Proposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,9 @@ export default Engine =>
}

renewProposalsOnPurchase() {
this.unsubscribeProposals().then(() => this.requestProposals());
}

clearProposals() {
this.data.proposals = [];
this.store.dispatch(clearProposals());
this.requestProposals();
}

requestProposals() {
Expand Down Expand Up @@ -98,11 +95,7 @@ export default Engine =>
const subscription = api_base.api.onMessage().subscribe(response => {
if (response.data.msg_type === 'proposal') {
const { passthrough, proposal } = response.data;
if (
proposal &&
this.data.proposals.findIndex(p => p.id === proposal.id) === -1 &&
!this.data.forget_proposal_ids.includes(proposal.id)
) {
if (proposal && this.data.proposals.findIndex(p => p.id === proposal.id) === -1) {
// Add proposals based on the ID returned by the API.
this.data.proposals.push({ ...proposal, ...passthrough });
this.checkProposalReady();
Expand All @@ -112,31 +105,6 @@ export default Engine =>
api_base.pushSubscription(subscription);
}

unsubscribeProposals() {
const { proposals } = this.data;
const removeForgetProposalById = forget_proposal_id =>
(this.data.forget_proposal_ids = this.data.forget_proposal_ids.filter(id => id !== forget_proposal_id));

this.clearProposals();

return Promise.all(
proposals.map(proposal => {
if (!this.data.forget_proposal_ids.includes(proposal.id)) {
this.data.forget_proposal_ids.push(proposal.id);
}

if (proposal.error) {
removeForgetProposalById(proposal.id);
return Promise.resolve();
}

return doUntilDone(() => api_base.api.forget(proposal.id)).then(() => {
removeForgetProposalById(proposal.id);
});
})
);
}

checkProposalReady() {
// Proposals are considered ready when the proposals in our memory match the ones
// we've requested from the API, we determine this by checking the passthrough of the response.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default Engine =>
buy,
});

this.subscribeToOpenContract(buy.contract_id);
this.contractId = buy.contract_id;
this.store.dispatch(purchaseSuccessful());
this.renewProposalsOnPurchase();
delayIndex = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ export default class TradeEngine extends Balance(Purchase(Sell(OpenContract(Prop
this.data = {
contract: {},
proposals: [],
forget_proposal_ids: [],
};
this.store = createStore(rootReducer, applyMiddleware(thunk));
}
Expand Down
3 changes: 1 addition & 2 deletions packages/bot-web-ui/src/stores/app-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,12 @@ export default class AppStore {
const { handleFileChange } = load_modal;
const { toggleStrategyModal } = quick_strategy;
const { startLoading, endLoading } = blockly_store;
const { populateConfig, setContractUpdateConfig } = summary_card;
const { setContractUpdateConfig } = summary_card;

this.dbot_store = {
is_mobile: false,
client,
flyout,
populateConfig,
toolbar,
save_modal,
startLoading,
Expand Down
9 changes: 0 additions & 9 deletions packages/bot-web-ui/src/stores/summary-card-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export default class SummaryCardStore {
getLimitOrder: action.bound,
onBotContractEvent: action.bound,
onChange: action.bound,
populateConfig: action.bound,
populateContractUpdateConfig: action.bound,
setContractUpdateConfig: action.bound,
updateLimitOrder: action.bound,
Expand Down Expand Up @@ -141,14 +140,6 @@ export default class SummaryCardStore {
this.validateProperty(name, this[name]);
}

populateConfig(contract_info) {
this.contract_info = contract_info;

if (this.is_multiplier && contract_info.contract_id && contract_info.limit_order) {
this.populateContractUpdateConfig(this.contract_info);
}
}

populateContractUpdateConfig(response) {
const contract_update_config = getContractUpdateConfig(response);

Expand Down
Loading

0 comments on commit b7c0d00

Please sign in to comment.