2019-10-19 16:38:07 +02:00
|
|
|
import * as React from 'react';
|
|
|
|
|
import { translate } from 'react-i18next';
|
|
|
|
|
import classNames from 'classnames';
|
|
|
|
|
import styled from 'styled-components';
|
|
|
|
|
import { InfoItem } from './InfoItem';
|
|
|
|
|
import { Icon } from '@scm-manager/ui-components';
|
2019-08-13 08:23:37 +02:00
|
|
|
|
|
|
|
|
type Props = {
|
2019-10-19 16:38:07 +02:00
|
|
|
type: 'plugin' | 'feature';
|
|
|
|
|
item: InfoItem;
|
2019-08-13 08:23:37 +02:00
|
|
|
|
|
|
|
|
// context props
|
2019-10-19 16:38:07 +02:00
|
|
|
t: (p: string) => string;
|
2019-08-13 08:23:37 +02:00
|
|
|
};
|
|
|
|
|
|
2019-10-09 16:17:02 +02:00
|
|
|
const BottomMarginA = styled.a`
|
|
|
|
|
display: blocK;
|
|
|
|
|
margin-bottom: 1.5rem;
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const FixedSizedIconWrapper = styled.div`
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
|
|
|
|
width: 160px;
|
|
|
|
|
height: 160px;
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const LightBlueIcon = styled(Icon)`
|
|
|
|
|
margin-bottom: 0.5em;
|
|
|
|
|
color: #bff1e6;
|
|
|
|
|
`;
|
2019-08-13 08:23:37 +02:00
|
|
|
|
2019-10-09 16:17:02 +02:00
|
|
|
const ContentWrapper = styled.div`
|
2019-10-09 17:47:29 +02:00
|
|
|
min-height: 10.5rem;
|
2019-10-09 16:17:02 +02:00
|
|
|
margin-left: 1.5em;
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
class InfoBox extends React.Component<Props> {
|
2019-08-13 08:23:37 +02:00
|
|
|
renderBody = () => {
|
2019-08-15 10:08:48 +02:00
|
|
|
const { item, t } = this.props;
|
2019-10-19 16:38:07 +02:00
|
|
|
const title = item ? item.title : t('login.loading');
|
|
|
|
|
const summary = item ? item.summary : t('login.loading');
|
2019-08-13 08:23:37 +02:00
|
|
|
|
|
|
|
|
return (
|
2019-10-19 16:38:07 +02:00
|
|
|
<ContentWrapper className={classNames('media-content', 'content')}>
|
2019-08-15 10:30:48 +02:00
|
|
|
<h4 className="has-text-link">{title}</h4>
|
2019-08-13 08:23:37 +02:00
|
|
|
<p>{summary}</p>
|
2019-10-09 16:17:02 +02:00
|
|
|
</ContentWrapper>
|
2019-08-13 08:23:37 +02:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
render() {
|
2019-10-09 16:17:02 +02:00
|
|
|
const { item, type, t } = this.props;
|
2019-10-19 16:38:07 +02:00
|
|
|
const icon = type === 'plugin' ? 'puzzle-piece' : 'star';
|
2019-08-13 08:23:37 +02:00
|
|
|
return (
|
2019-10-09 16:17:02 +02:00
|
|
|
<BottomMarginA href={item._links.self.href}>
|
2019-08-13 08:23:37 +02:00
|
|
|
<div className="box media">
|
|
|
|
|
<figure className="media-left">
|
2019-10-09 16:17:02 +02:00
|
|
|
<FixedSizedIconWrapper
|
|
|
|
|
className={classNames(
|
2019-10-19 16:38:07 +02:00
|
|
|
'image',
|
|
|
|
|
'box',
|
|
|
|
|
'has-text-weight-bold',
|
|
|
|
|
'has-text-white',
|
|
|
|
|
'has-background-info',
|
2019-10-09 16:17:02 +02:00
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
<LightBlueIcon className="fa-2x" name={icon} color="inherit" />
|
2019-10-19 16:38:07 +02:00
|
|
|
<div className="is-size-4">{t('login.' + type)}</div>
|
|
|
|
|
<div className="is-size-4">{t('login.tip')}</div>
|
2019-10-09 16:17:02 +02:00
|
|
|
</FixedSizedIconWrapper>
|
2019-08-13 08:23:37 +02:00
|
|
|
</figure>
|
|
|
|
|
{this.renderBody()}
|
|
|
|
|
</div>
|
2019-10-09 16:17:02 +02:00
|
|
|
</BottomMarginA>
|
2019-08-13 08:23:37 +02:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-19 16:38:07 +02:00
|
|
|
export default translate('commons')(InfoBox);
|