mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
[MMI] Added code fencing in account details modal and selected accounts (#18070)
* Added code fencing in account details modal and selected accounts * Fixed pipeline issues * Remove one code fence
This commit is contained in:
parent
f0fd1772ee
commit
c7bb906b03
@ -8,6 +8,10 @@ import EditableLabel from '../../../ui/editable-label';
|
|||||||
import Button from '../../../ui/button';
|
import Button from '../../../ui/button';
|
||||||
import { getURLHostName } from '../../../../helpers/utils/util';
|
import { getURLHostName } from '../../../../helpers/utils/util';
|
||||||
import { isHardwareKeyring } from '../../../../helpers/utils/hardware';
|
import { isHardwareKeyring } from '../../../../helpers/utils/hardware';
|
||||||
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
||||||
|
import CustodyLabels from '../../../institutional/custody-labels/custody-labels';
|
||||||
|
import { toChecksumHexAddress } from '../../../../../shared/modules/hexstring-utils';
|
||||||
|
///: END:ONLY_INCLUDE_IN
|
||||||
import {
|
import {
|
||||||
MetaMetricsEventCategory,
|
MetaMetricsEventCategory,
|
||||||
MetaMetricsEventLinkType,
|
MetaMetricsEventLinkType,
|
||||||
@ -28,6 +32,10 @@ export default class AccountDetailsModal extends Component {
|
|||||||
history: PropTypes.object,
|
history: PropTypes.object,
|
||||||
hideModal: PropTypes.func,
|
hideModal: PropTypes.func,
|
||||||
blockExplorerLinkText: PropTypes.object,
|
blockExplorerLinkText: PropTypes.object,
|
||||||
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
||||||
|
accountType: PropTypes.string,
|
||||||
|
custodyAccountDetails: PropTypes.object,
|
||||||
|
///: END:ONLY_INCLUDE_IN
|
||||||
};
|
};
|
||||||
|
|
||||||
static contextTypes = {
|
static contextTypes = {
|
||||||
@ -46,6 +54,10 @@ export default class AccountDetailsModal extends Component {
|
|||||||
history,
|
history,
|
||||||
hideModal,
|
hideModal,
|
||||||
blockExplorerLinkText,
|
blockExplorerLinkText,
|
||||||
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
||||||
|
accountType,
|
||||||
|
custodyAccountDetails,
|
||||||
|
///: END:ONLY_INCLUDE_IN
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const { name, address } = selectedIdentity;
|
const { name, address } = selectedIdentity;
|
||||||
|
|
||||||
@ -59,6 +71,17 @@ export default class AccountDetailsModal extends Component {
|
|||||||
exportPrivateKeyFeatureEnabled = false;
|
exportPrivateKeyFeatureEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
||||||
|
if (keyring?.type?.search('Custody') !== -1) {
|
||||||
|
exportPrivateKeyFeatureEnabled = false;
|
||||||
|
}
|
||||||
|
const showCustodyLabels = accountType === 'custody';
|
||||||
|
const custodyLabels = custodyAccountDetails
|
||||||
|
? custodyAccountDetails[toChecksumHexAddress(selectedIdentity.address)]
|
||||||
|
?.labels
|
||||||
|
: {};
|
||||||
|
///: END:ONLY_INCLUDE_IN
|
||||||
|
|
||||||
const routeToAddBlockExplorerUrl = () => {
|
const routeToAddBlockExplorerUrl = () => {
|
||||||
hideModal();
|
hideModal();
|
||||||
history.push(`${NETWORKS_ROUTE}#blockExplorerUrl`);
|
history.push(`${NETWORKS_ROUTE}#blockExplorerUrl`);
|
||||||
@ -88,7 +111,11 @@ export default class AccountDetailsModal extends Component {
|
|||||||
onSubmit={(label) => setAccountLabel(address, label)}
|
onSubmit={(label) => setAccountLabel(address, label)}
|
||||||
accounts={this.props.accounts}
|
accounts={this.props.accounts}
|
||||||
/>
|
/>
|
||||||
|
{
|
||||||
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
||||||
|
showCustodyLabels && <CustodyLabels labels={custodyLabels} />
|
||||||
|
///: END:ONLY_INCLUDE_IN
|
||||||
|
}
|
||||||
<QrView
|
<QrView
|
||||||
Qr={{
|
Qr={{
|
||||||
data: address,
|
data: address,
|
||||||
|
@ -12,7 +12,13 @@ import {
|
|||||||
getCurrentChainId,
|
getCurrentChainId,
|
||||||
getMetaMaskAccountsOrdered,
|
getMetaMaskAccountsOrdered,
|
||||||
getBlockExplorerLinkText,
|
getBlockExplorerLinkText,
|
||||||
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
||||||
|
getAccountType,
|
||||||
|
///: END:ONLY_INCLUDE_IN
|
||||||
} from '../../../../selectors';
|
} from '../../../../selectors';
|
||||||
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
||||||
|
import { getCustodyAccountDetails } from '../../../../selectors/institutional/selectors';
|
||||||
|
///: END:ONLY_INCLUDE_IN
|
||||||
import AccountDetailsModal from './account-details-modal.component';
|
import AccountDetailsModal from './account-details-modal.component';
|
||||||
|
|
||||||
const mapStateToProps = (state) => {
|
const mapStateToProps = (state) => {
|
||||||
@ -23,6 +29,10 @@ const mapStateToProps = (state) => {
|
|||||||
rpcPrefs: getRpcPrefsForCurrentProvider(state),
|
rpcPrefs: getRpcPrefsForCurrentProvider(state),
|
||||||
accounts: getMetaMaskAccountsOrdered(state),
|
accounts: getMetaMaskAccountsOrdered(state),
|
||||||
blockExplorerLinkText: getBlockExplorerLinkText(state, true),
|
blockExplorerLinkText: getBlockExplorerLinkText(state, true),
|
||||||
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
||||||
|
accountType: getAccountType(state),
|
||||||
|
custodyAccountDetails: getCustodyAccountDetails(state),
|
||||||
|
///: END:ONLY_INCLUDE_IN
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -29,6 +29,14 @@ exports[`SelectedAccount Component should match snapshot 1`] = `
|
|||||||
class="selected-account__address"
|
class="selected-account__address"
|
||||||
>
|
>
|
||||||
0x0DC...E7bc
|
0x0DC...E7bc
|
||||||
|
<div
|
||||||
|
class="selected-account__copy"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="box mm-icon mm-icon--size-md box--display-inline-block box--flex-direction-row box--color-icon-alternative"
|
||||||
|
style="mask-image: url('./images/icons/undefined.svg');"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
class="selected-account__copy"
|
class="selected-account__copy"
|
||||||
>
|
>
|
||||||
|
@ -6,6 +6,11 @@ import { shortenAddress } from '../../../helpers/utils/util';
|
|||||||
import Tooltip from '../../ui/tooltip';
|
import Tooltip from '../../ui/tooltip';
|
||||||
import { toChecksumHexAddress } from '../../../../shared/modules/hexstring-utils';
|
import { toChecksumHexAddress } from '../../../../shared/modules/hexstring-utils';
|
||||||
import { SECOND } from '../../../../shared/constants/time';
|
import { SECOND } from '../../../../shared/constants/time';
|
||||||
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
||||||
|
import { getEnvironmentType } from '../../../../app/scripts/lib/util';
|
||||||
|
import { ENVIRONMENT_TYPE_POPUP } from '../../../../shared/constants/app';
|
||||||
|
import CustodyLabels from '../../institutional/custody-labels/custody-labels';
|
||||||
|
///: END:ONLY_INCLUDE_IN
|
||||||
import { Icon, IconName, IconSize } from '../../component-library';
|
import { Icon, IconName, IconSize } from '../../component-library';
|
||||||
import { IconColor } from '../../../helpers/constants/design-system';
|
import { IconColor } from '../../../helpers/constants/design-system';
|
||||||
|
|
||||||
@ -20,6 +25,12 @@ class SelectedAccount extends Component {
|
|||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
selectedIdentity: PropTypes.object.isRequired,
|
selectedIdentity: PropTypes.object.isRequired,
|
||||||
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
||||||
|
accountType: PropTypes.string,
|
||||||
|
accountDetails: PropTypes.object,
|
||||||
|
provider: PropTypes.object,
|
||||||
|
isCustodianSupportedChain: PropTypes.bool,
|
||||||
|
///: END:ONLY_INCLUDE_IN
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@ -35,21 +46,57 @@ class SelectedAccount extends Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { t } = this.context;
|
const { t } = this.context;
|
||||||
const { selectedIdentity } = this.props;
|
const {
|
||||||
|
selectedIdentity,
|
||||||
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
||||||
|
accountType,
|
||||||
|
accountDetails,
|
||||||
|
provider,
|
||||||
|
isCustodianSupportedChain,
|
||||||
|
///: END:ONLY_INCLUDE_IN
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
const checksummedAddress = toChecksumHexAddress(selectedIdentity.address);
|
const checksummedAddress = toChecksumHexAddress(selectedIdentity.address);
|
||||||
|
|
||||||
|
let title = this.state.copied
|
||||||
|
? t('copiedExclamation')
|
||||||
|
: t('copyToClipboard');
|
||||||
|
|
||||||
|
let showAccountCopyIcon = true;
|
||||||
|
|
||||||
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
||||||
|
const custodyLabels = accountDetails
|
||||||
|
? accountDetails[toChecksumHexAddress(selectedIdentity.address)]?.labels
|
||||||
|
: {};
|
||||||
|
const showCustodyLabels =
|
||||||
|
getEnvironmentType() !== ENVIRONMENT_TYPE_POPUP &&
|
||||||
|
accountType === 'custody' &&
|
||||||
|
custodyLabels;
|
||||||
|
|
||||||
|
const tooltipText = this.state.copied
|
||||||
|
? t('copiedExclamation')
|
||||||
|
: t('copyToClipboard');
|
||||||
|
|
||||||
|
title = isCustodianSupportedChain
|
||||||
|
? tooltipText
|
||||||
|
: t('custodyWrongChain', [provider.nickname || provider.type]);
|
||||||
|
|
||||||
|
showAccountCopyIcon = isCustodianSupportedChain;
|
||||||
|
///: END:ONLY_INCLUDE_IN
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="selected-account">
|
<div className="selected-account">
|
||||||
<Tooltip
|
<Tooltip
|
||||||
wrapperClassName="selected-account__tooltip-wrapper"
|
wrapperClassName="selected-account__tooltip-wrapper"
|
||||||
position="bottom"
|
position="bottom"
|
||||||
title={
|
title={title}
|
||||||
this.state.copied ? t('copiedExclamation') : t('copyToClipboard')
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
className="selected-account__clickable"
|
className="selected-account__clickable"
|
||||||
data-testid="selected-account-click"
|
data-testid="selected-account-click"
|
||||||
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
||||||
|
disabled={!isCustodianSupportedChain}
|
||||||
|
///: END:ONLY_INCLUDE_IN
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
this.setState({ copied: true });
|
this.setState({ copied: true });
|
||||||
this.copyTimeout = setTimeout(
|
this.copyTimeout = setTimeout(
|
||||||
@ -63,7 +110,23 @@ class SelectedAccount extends Component {
|
|||||||
{selectedIdentity.name}
|
{selectedIdentity.name}
|
||||||
</div>
|
</div>
|
||||||
<div className="selected-account__address">
|
<div className="selected-account__address">
|
||||||
|
{
|
||||||
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
||||||
|
showCustodyLabels && <CustodyLabels labels={custodyLabels} />
|
||||||
|
///: END:ONLY_INCLUDE_IN
|
||||||
|
}
|
||||||
{shortenAddress(checksummedAddress)}
|
{shortenAddress(checksummedAddress)}
|
||||||
|
{showAccountCopyIcon && (
|
||||||
|
<div className="selected-account__copy">
|
||||||
|
<Icon
|
||||||
|
name={
|
||||||
|
this.state.copied ? IconName.COPY_SUCCESS : IconName.COPY
|
||||||
|
}
|
||||||
|
size={IconSize.SM}
|
||||||
|
color={IconColor.iconAlternative}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<div className="selected-account__copy">
|
<div className="selected-account__copy">
|
||||||
<Icon
|
<Icon
|
||||||
name={
|
name={
|
||||||
|
@ -1,10 +1,28 @@
|
|||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { getSelectedIdentity } from '../../../selectors';
|
import {
|
||||||
|
getSelectedIdentity,
|
||||||
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
||||||
|
getAccountType,
|
||||||
|
///: END:ONLY_INCLUDE_IN
|
||||||
|
} from '../../../selectors';
|
||||||
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
||||||
|
import {
|
||||||
|
getCustodyAccountDetails,
|
||||||
|
getIsCustodianSupportedChain,
|
||||||
|
} from '../../../selectors/institutional/selectors';
|
||||||
|
import { getProviderConfig } from '../../../ducks/metamask/metamask';
|
||||||
|
///: END:ONLY_INCLUDE_IN
|
||||||
import SelectedAccount from './selected-account.component';
|
import SelectedAccount from './selected-account.component';
|
||||||
|
|
||||||
const mapStateToProps = (state) => {
|
const mapStateToProps = (state) => {
|
||||||
return {
|
return {
|
||||||
selectedIdentity: getSelectedIdentity(state),
|
selectedIdentity: getSelectedIdentity(state),
|
||||||
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
||||||
|
accountType: getAccountType(state),
|
||||||
|
accountDetails: getCustodyAccountDetails(state),
|
||||||
|
provider: getProviderConfig(state),
|
||||||
|
isCustodianSupportedChain: getIsCustodianSupportedChain(state),
|
||||||
|
///: END:ONLY_INCLUDE_IN
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user