1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
/*
* SonarQube
* Copyright (C) 2009-2019 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
import * as classNames from 'classnames';
import { FormattedMessage } from 'react-intl';
import { Link } from 'react-router';
import UpgradeOrganizationAdvantages from './UpgradeOrganizationAdvantages';
import RecommendedIcon from '../../../components/icons-components/RecommendedIcon';
import { Alert } from '../../../components/ui/Alert';
import { formatPrice } from '../organization/utils';
import { translate } from '../../../helpers/l10n';
import './CardPlan.css';
interface Props {
className?: string;
disabled?: boolean;
onClick?: () => void;
selected?: boolean;
startingPrice?: number;
}
interface CardProps extends Props {
children: React.ReactNode;
recommended?: string;
title: string;
}
export default function CardPlan(props: CardProps) {
const { className, disabled, onClick, recommended, selected, startingPrice } = props;
const isActionable = Boolean(onClick);
return (
<div
aria-checked={selected}
className={classNames(
'card-plan',
{ 'card-plan-actionable': isActionable, disabled, selected },
className
)}
onClick={isActionable && !disabled ? onClick : undefined}
role="radio"
tabIndex={0}>
<h2 className="card-plan-header big-spacer-bottom">
<span className="display-flex-center">
{isActionable && (
<i className={classNames('icon-radio', 'spacer-right', { 'is-checked': selected })} />
)}
{props.title}
</span>
{startingPrice !== undefined &&
(startingPrice ? (
<FormattedMessage
defaultMessage={translate('billing.price_from_x')}
id="billing.price_from_x"
values={{
price: <span className="card-plan-price">{formatPrice(startingPrice)}</span>
}}
/>
) : (
<span className="card-plan-price">{formatPrice(0)}</span>
))}
</h2>
<div className="card-plan-body">{props.children}</div>
{recommended && (
<div className="card-plan-recommended">
<RecommendedIcon className="spacer-right" />
<FormattedMessage
defaultMessage={recommended}
id={recommended}
values={{ recommended: <strong>{translate('recommended')}</strong> }}
/>
</div>
)}
</div>
);
}
interface FreeProps extends Props {
almName?: string;
hasWarning: boolean;
}
export function FreeCardPlan({ almName, hasWarning, ...props }: FreeProps) {
const showInfo = almName && props.disabled;
const showWarning = almName && hasWarning && !props.disabled;
return (
<CardPlan startingPrice={0} title={translate('billing.free_plan.title')} {...props}>
<>
<div className="spacer-left">
<ul className="big-spacer-left note">
<li className="little-spacer-bottom">
{translate('billing.free_plan.all_projects_analyzed_public')}
</li>
<li>{translate('billing.free_plan.anyone_can_browse_source_code')}</li>
</ul>
</div>
{showWarning && (
<Alert variant="warning">
<FormattedMessage
defaultMessage={translate('billing.free_plan.private_repo_warning')}
id="billing.free_plan.private_repo_warning"
values={{ alm: almName }}
/>
</Alert>
)}
{showInfo && (
<Alert variant="info">
<FormattedMessage
defaultMessage={translate('billing.free_plan.not_available_info')}
id="billing.free_plan.not_available_info"
values={{ alm: almName }}
/>
</Alert>
)}
</>
</CardPlan>
);
}
interface PaidProps extends Props {
isRecommended: boolean;
}
export function PaidCardPlan({ isRecommended, ...props }: PaidProps) {
return (
<CardPlan
recommended={isRecommended ? translate('billing.paid_plan.recommended') : undefined}
title={translate('billing.paid_plan.title')}
{...props}>
<>
<UpgradeOrganizationAdvantages />
<div className="big-spacer-left">
<Link className="spacer-left" target="_blank" to="/about/pricing">
{translate('billing.pricing.learn_more')}
</Link>
</div>
</>
</CardPlan>
);
}
|