mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-12 04:37:13 +01:00
f946c030b5
* added wrapper around account list to prevent storybook from collapsing the list * updated translation files * added snap-connect page * refactored account list out of the choose account component * fixed width * removed unnecessary scss from choose-account component, fixed props in choose account story * removed snaps-connect page, added comments to ChooseAccount * updated choose account subtitle text, updated styling for title & subtitle, removed redundant account list story * updated component name, updated paths * fixed linter errors * added comments * removed unused message * removed selectAccounts key from all locales * updated class name for account list header, updated allAreSelected function to use length checks * Revert "removed unused message" This reverts commit 32771bc83c08f120825ef75f0741f3034e7dbecb. * Revert "removed selectAccounts key from all locales" This reverts commit ccfa4a860f9a75693d893d7c404384e719de297e. * updated locale messages to use selectAccounts key * removed stray import * updated scss * updated translation key * removed chooseAccounts key from en locale * removed optional chaining * changes * updated subjectMetadata * updated subject types * update useOriginMetadata function to include unknown subject type * updated permission connect header props, removed host and added subjectType to targetSubjectMetadata * added subjectType to targetSubjectMetadata * removed console.log * changed prop name to iconUrl
121 lines
3.6 KiB
JavaScript
121 lines
3.6 KiB
JavaScript
import PropTypes from 'prop-types';
|
|
import React, { PureComponent } from 'react';
|
|
import PermissionsConnectHeader from '../../permissions-connect-header';
|
|
import Tooltip from '../../../ui/tooltip';
|
|
import PermissionsConnectPermissionList from '../../permissions-connect-permission-list';
|
|
|
|
export default class PermissionPageContainerContent extends PureComponent {
|
|
static propTypes = {
|
|
subjectMetadata: PropTypes.shape({
|
|
name: PropTypes.string.isRequired,
|
|
origin: PropTypes.string.isRequired,
|
|
subjectType: PropTypes.string.isRequired,
|
|
extensionId: PropTypes.string,
|
|
iconUrl: PropTypes.string,
|
|
}),
|
|
selectedPermissions: PropTypes.object.isRequired,
|
|
selectedIdentities: PropTypes.array,
|
|
allIdentitiesSelected: PropTypes.bool,
|
|
};
|
|
|
|
static defaultProps = {
|
|
selectedIdentities: [],
|
|
allIdentitiesSelected: false,
|
|
};
|
|
|
|
static contextTypes = {
|
|
t: PropTypes.func,
|
|
};
|
|
|
|
renderRequestedPermissions() {
|
|
const { selectedPermissions } = this.props;
|
|
|
|
return (
|
|
<div className="permission-approval-container__content__requested">
|
|
<PermissionsConnectPermissionList permissions={selectedPermissions} />
|
|
</div>
|
|
);
|
|
}
|
|
|
|
renderAccountTooltip(textContent) {
|
|
const { selectedIdentities } = this.props;
|
|
const { t } = this.context;
|
|
|
|
return (
|
|
<Tooltip
|
|
key="all-account-connect-tooltip"
|
|
position="bottom"
|
|
wrapperClassName="permission-approval-container__bold-title-elements"
|
|
html={
|
|
<div style={{ display: 'flex', flexDirection: 'column' }}>
|
|
{selectedIdentities.slice(0, 6).map((identity, index) => {
|
|
return (
|
|
<div key={`tooltip-identity-${index}`}>
|
|
{identity.addressLabel}
|
|
</div>
|
|
);
|
|
})}
|
|
{selectedIdentities.length > 6
|
|
? t('plusXMore', [selectedIdentities.length - 6])
|
|
: null}
|
|
</div>
|
|
}
|
|
>
|
|
{textContent}
|
|
</Tooltip>
|
|
);
|
|
}
|
|
|
|
getTitle() {
|
|
const {
|
|
subjectMetadata,
|
|
selectedIdentities,
|
|
allIdentitiesSelected,
|
|
} = this.props;
|
|
const { t } = this.context;
|
|
|
|
if (subjectMetadata.extensionId) {
|
|
return t('externalExtension', [subjectMetadata.extensionId]);
|
|
} else if (allIdentitiesSelected) {
|
|
return t('connectToAll', [
|
|
this.renderAccountTooltip(t('connectToAllAccounts')),
|
|
]);
|
|
} else if (selectedIdentities.length > 1) {
|
|
return t('connectToMultiple', [
|
|
this.renderAccountTooltip(
|
|
t('connectToMultipleNumberOfAccounts', [selectedIdentities.length]),
|
|
),
|
|
]);
|
|
}
|
|
return t('connectTo', [selectedIdentities[0]?.addressLabel]);
|
|
}
|
|
|
|
render() {
|
|
const { subjectMetadata } = this.props;
|
|
const { t } = this.context;
|
|
|
|
const title = this.getTitle();
|
|
|
|
return (
|
|
<div className="permission-approval-container__content">
|
|
<div className="permission-approval-container__content-container">
|
|
<PermissionsConnectHeader
|
|
iconUrl={subjectMetadata.iconUrl}
|
|
iconName={subjectMetadata.name}
|
|
headerTitle={title}
|
|
headerText={
|
|
subjectMetadata.extensionId
|
|
? t('allowExternalExtensionTo', [subjectMetadata.extensionId])
|
|
: t('allowThisSiteTo')
|
|
}
|
|
siteOrigin={subjectMetadata.origin}
|
|
/>
|
|
<section className="permission-approval-container__permissions-container">
|
|
{this.renderRequestedPermissions()}
|
|
</section>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
}
|