1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-03 06:34:27 +01:00
metamask-extension/ui/components/app/permissions-connect-header/permissions-connect-header.component.js
Hassan Malik a7179a6b88
[FLASK] Add update snap UI (#15143)
* added snap-update folder

* addded update route, snap update component, updated permissions connect components

* added actions and selectors

* updated permissions selectors and updated permissions connect container to have update snap logic

* updated translations, added selector, updated request object

* updated translations, added update snap permission list component

* more fixes

* added CSS, redid some HTML

* lint fixes

* Add missing grantPermissions action

* updated button padding

* fixes

* removed prop type

* fix Update & Install wrapping

* made changes for forthcoming snap controller PR

* removed ununsed imports

* updated css

* re-added padding rule and removed unused translation messages

* addressed comments

* add subtext for new permissions

* lint fix

* removed unused translations

* some more changes

* fix e2e tests

* lint fix

* added in delay for e2e tests

* Revert "added in delay for e2e tests"

This reverts commit 095962a2c0c9de0b0b343d3134bb0787044dd8ce.

* fixed routing logic

Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com>
Co-authored-by: Guillaume Roux <guillaumeroux123@gmail.com>
2022-08-03 12:02:44 -04:00

106 lines
2.7 KiB
JavaScript

import PropTypes from 'prop-types';
import React, { Component } from 'react';
import classnames from 'classnames';
import SiteOrigin from '../../ui/site-origin';
import Box from '../../ui/box';
import {
FLEX_DIRECTION,
JUSTIFY_CONTENT,
} from '../../../helpers/constants/design-system';
///: BEGIN:ONLY_INCLUDE_IN(flask)
import SnapsAuthorshipPill from '../flask/snaps-authorship-pill';
///: END:ONLY_INCLUDE_IN
export default class PermissionsConnectHeader extends Component {
///: BEGIN:ONLY_INCLUDE_IN(flask)
static contextTypes = {
t: PropTypes.func,
};
///: END:ONLY_INCLUDE_IN
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,
rightIcon: PropTypes.node,
///: BEGIN:ONLY_INCLUDE_IN(flask)
snapVersion: PropTypes.string,
isSnapInstallOrUpdate: PropTypes.bool,
///: END:ONLY_INCLUDE_IN
};
static defaultProps = {
iconUrl: null,
headerTitle: '',
headerText: '',
boxProps: {},
};
renderHeaderIcon() {
const {
iconUrl,
iconName,
siteOrigin,
rightIcon,
///: BEGIN:ONLY_INCLUDE_IN(flask)
isSnapInstallOrUpdate,
///: END:ONLY_INCLUDE_IN
} = this.props;
///: BEGIN:ONLY_INCLUDE_IN(flask)
if (isSnapInstallOrUpdate) {
return null;
}
///: END:ONLY_INCLUDE_IN
return (
<div className="permissions-connect-header__icon">
<SiteOrigin
chip
siteOrigin={siteOrigin}
iconSrc={iconUrl}
name={iconName}
rightIcon={rightIcon}
/>
</div>
);
}
render() {
const {
boxProps,
className,
headerTitle,
headerText,
///: BEGIN:ONLY_INCLUDE_IN(flask)
siteOrigin,
snapVersion,
isSnapInstallOrUpdate,
///: END:ONLY_INCLUDE_IN
} = this.props;
return (
<Box
className={classnames('permissions-connect-header', className)}
flexDirection={FLEX_DIRECTION.COLUMN}
justifyContent={JUSTIFY_CONTENT.CENTER}
{...boxProps}
>
{this.renderHeaderIcon()}
<div className="permissions-connect-header__title">{headerTitle}</div>
{
///: BEGIN:ONLY_INCLUDE_IN(flask)
isSnapInstallOrUpdate && (
<SnapsAuthorshipPill snapId={siteOrigin} version={snapVersion} />
)
///: END:ONLY_INCLUDE_IN
}
<div className="permissions-connect-header__subtitle">{headerText}</div>
</Box>
);
}
}