mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-23 02:10:12 +01:00
f829f0069d
* Add support for snap authorship component at the top of PermissionConnect * Add PermissionCellOptions * Add details popover * Add action for revoking dynamic permissions * Improve UI and revoke logic * Better eth_accounts screen support * Fix tests * Fix lint * More linting fixes * Fix missing fence * Add another fence * Unnest permission page to fix weird CSS issues * Hide footer on permissions connect when using a snap
85 lines
2.2 KiB
JavaScript
85 lines
2.2 KiB
JavaScript
import PropTypes from 'prop-types';
|
|
import React, { Component } from 'react';
|
|
import classnames from 'classnames';
|
|
///: BEGIN:ONLY_INCLUDE_IN(snaps)
|
|
import { SubjectType } from '@metamask/subject-metadata-controller';
|
|
///: END:ONLY_INCLUDE_IN
|
|
import SiteOrigin from '../../ui/site-origin';
|
|
import Box from '../../ui/box';
|
|
import {
|
|
FLEX_DIRECTION,
|
|
JustifyContent,
|
|
} from '../../../helpers/constants/design-system';
|
|
|
|
export default class PermissionsConnectHeader extends Component {
|
|
static propTypes = {
|
|
className: PropTypes.string,
|
|
iconUrl: PropTypes.string,
|
|
iconName: PropTypes.string.isRequired,
|
|
siteOrigin: PropTypes.string.isRequired,
|
|
headerTitle: PropTypes.node,
|
|
boxProps: PropTypes.shape({ ...Box.propTypes }),
|
|
headerText: PropTypes.string,
|
|
leftIcon: PropTypes.node,
|
|
rightIcon: PropTypes.node,
|
|
subjectType: PropTypes.string,
|
|
};
|
|
|
|
static defaultProps = {
|
|
iconUrl: null,
|
|
headerTitle: '',
|
|
headerText: '',
|
|
boxProps: {},
|
|
};
|
|
|
|
renderHeaderIcon() {
|
|
const {
|
|
iconUrl,
|
|
iconName,
|
|
siteOrigin,
|
|
leftIcon,
|
|
rightIcon,
|
|
///: BEGIN:ONLY_INCLUDE_IN(snaps)
|
|
subjectType,
|
|
///: END:ONLY_INCLUDE_IN
|
|
} = this.props;
|
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(snaps)
|
|
|
|
if (subjectType === SubjectType.Snap) {
|
|
return null;
|
|
}
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
return (
|
|
<div className="permissions-connect-header__icon">
|
|
<SiteOrigin
|
|
chip
|
|
siteOrigin={siteOrigin}
|
|
title={siteOrigin}
|
|
iconSrc={iconUrl}
|
|
name={iconName}
|
|
leftIcon={leftIcon}
|
|
rightIcon={rightIcon}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
render() {
|
|
const { boxProps, className, headerTitle, headerText } = this.props;
|
|
return (
|
|
<Box
|
|
className={classnames('permissions-connect-header', className)}
|
|
flexDirection={FLEX_DIRECTION.COLUMN}
|
|
justifyContent={JustifyContent.center}
|
|
{...boxProps}
|
|
>
|
|
{this.renderHeaderIcon()}
|
|
<div className="permissions-connect-header__title">{headerTitle}</div>
|
|
<div className="permissions-connect-header__subtitle">{headerText}</div>
|
|
</Box>
|
|
);
|
|
}
|
|
}
|