2021-02-04 19:15:23 +01:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React, { Component } from 'react';
|
2022-08-03 16:56:11 +02:00
|
|
|
import classnames from 'classnames';
|
2022-02-15 01:02:51 +01:00
|
|
|
import SiteOrigin from '../../ui/site-origin';
|
|
|
|
import Box from '../../ui/box';
|
|
|
|
import {
|
|
|
|
FLEX_DIRECTION,
|
2023-02-02 21:15:26 +01:00
|
|
|
JustifyContent,
|
2022-02-15 01:02:51 +01:00
|
|
|
} from '../../../helpers/constants/design-system';
|
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(flask)
|
2023-03-24 17:16:46 +01:00
|
|
|
import SnapAuthorship from '../flask/snap-authorship';
|
2022-02-15 01:02:51 +01:00
|
|
|
///: END:ONLY_INCLUDE_IN
|
2020-04-02 11:09:53 +02:00
|
|
|
|
|
|
|
export default class PermissionsConnectHeader extends Component {
|
2022-03-14 18:40:21 +01:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(flask)
|
|
|
|
static contextTypes = {
|
|
|
|
t: PropTypes.func,
|
|
|
|
};
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
|
2020-04-02 11:09:53 +02:00
|
|
|
static propTypes = {
|
2022-08-03 16:56:11 +02:00
|
|
|
className: PropTypes.string,
|
2021-12-15 00:54:46 +01:00
|
|
|
iconUrl: PropTypes.string,
|
2020-07-02 19:08:43 +02:00
|
|
|
iconName: PropTypes.string.isRequired,
|
|
|
|
siteOrigin: PropTypes.string.isRequired,
|
2020-04-02 11:09:53 +02:00
|
|
|
headerTitle: PropTypes.node,
|
2022-02-15 01:02:51 +01:00
|
|
|
boxProps: PropTypes.shape({ ...Box.propTypes }),
|
2020-04-02 11:09:53 +02:00
|
|
|
headerText: PropTypes.string,
|
2022-10-04 23:33:51 +02:00
|
|
|
leftIcon: PropTypes.node,
|
2022-08-03 16:56:11 +02:00
|
|
|
rightIcon: PropTypes.node,
|
2022-02-15 01:02:51 +01:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(flask)
|
2022-03-14 18:40:21 +01:00
|
|
|
snapVersion: PropTypes.string,
|
2022-08-03 18:02:44 +02:00
|
|
|
isSnapInstallOrUpdate: PropTypes.bool,
|
2022-02-15 01:02:51 +01:00
|
|
|
///: END:ONLY_INCLUDE_IN
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-04-02 11:09:53 +02:00
|
|
|
|
|
|
|
static defaultProps = {
|
2021-12-15 00:54:46 +01:00
|
|
|
iconUrl: null,
|
2020-04-02 11:09:53 +02:00
|
|
|
headerTitle: '',
|
|
|
|
headerText: '',
|
2022-02-15 01:02:51 +01:00
|
|
|
boxProps: {},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-04-02 11:09:53 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
renderHeaderIcon() {
|
2022-05-25 18:19:02 +02:00
|
|
|
const {
|
|
|
|
iconUrl,
|
|
|
|
iconName,
|
|
|
|
siteOrigin,
|
2022-10-04 23:33:51 +02:00
|
|
|
leftIcon,
|
2022-08-03 16:56:11 +02:00
|
|
|
rightIcon,
|
2022-05-25 18:19:02 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(flask)
|
2022-08-03 18:02:44 +02:00
|
|
|
isSnapInstallOrUpdate,
|
2022-05-25 18:19:02 +02:00
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(flask)
|
2022-08-03 18:02:44 +02:00
|
|
|
if (isSnapInstallOrUpdate) {
|
2022-05-25 18:19:02 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
2020-04-02 11:09:53 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="permissions-connect-header__icon">
|
2022-05-24 18:04:07 +02:00
|
|
|
<SiteOrigin
|
|
|
|
chip
|
|
|
|
siteOrigin={siteOrigin}
|
2023-03-23 17:32:54 +01:00
|
|
|
title={siteOrigin}
|
2022-05-24 18:04:07 +02:00
|
|
|
iconSrc={iconUrl}
|
|
|
|
name={iconName}
|
2022-10-04 23:33:51 +02:00
|
|
|
leftIcon={leftIcon}
|
2022-08-03 16:56:11 +02:00
|
|
|
rightIcon={rightIcon}
|
2022-05-24 18:04:07 +02:00
|
|
|
/>
|
2020-04-02 11:09:53 +02:00
|
|
|
</div>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-04-02 11:09:53 +02:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
render() {
|
2022-02-15 01:02:51 +01:00
|
|
|
const {
|
|
|
|
boxProps,
|
2022-08-03 16:56:11 +02:00
|
|
|
className,
|
2022-02-15 01:02:51 +01:00
|
|
|
headerTitle,
|
|
|
|
headerText,
|
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(flask)
|
2022-05-25 18:19:02 +02:00
|
|
|
siteOrigin,
|
2022-08-03 18:02:44 +02:00
|
|
|
isSnapInstallOrUpdate,
|
2022-02-15 01:02:51 +01:00
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
} = this.props;
|
2020-04-02 11:09:53 +02:00
|
|
|
return (
|
2022-02-15 01:02:51 +01:00
|
|
|
<Box
|
2022-08-03 16:56:11 +02:00
|
|
|
className={classnames('permissions-connect-header', className)}
|
2022-02-15 01:02:51 +01:00
|
|
|
flexDirection={FLEX_DIRECTION.COLUMN}
|
2023-02-02 21:15:26 +01:00
|
|
|
justifyContent={JustifyContent.center}
|
2022-02-15 01:02:51 +01:00
|
|
|
{...boxProps}
|
|
|
|
>
|
2020-11-03 00:41:28 +01:00
|
|
|
{this.renderHeaderIcon()}
|
|
|
|
<div className="permissions-connect-header__title">{headerTitle}</div>
|
2022-02-15 01:02:51 +01:00
|
|
|
{
|
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(flask)
|
2023-03-24 17:16:46 +01:00
|
|
|
isSnapInstallOrUpdate && <SnapAuthorship snapId={siteOrigin} />
|
2022-03-14 18:40:21 +01:00
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
}
|
2020-11-03 00:41:28 +01:00
|
|
|
<div className="permissions-connect-header__subtitle">{headerText}</div>
|
2022-02-15 01:02:51 +01:00
|
|
|
</Box>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-04-02 11:09:53 +02:00
|
|
|
}
|
|
|
|
}
|