This repository has been archived by the owner on Jan 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 123
/
MainInstallButton.js
59 lines (53 loc) · 2.32 KB
/
MainInstallButton.js
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
import React from 'react';
import classnames from 'classnames';
import { installAddon } from '../lib/addon';
export default class MainInstallButton extends React.Component {
constructor(props) {
super(props);
this.state = {
isInstalling: false
};
}
render() {
const { isFirefox, hasAddon } = this.props;
const isInstalling = this.state.isInstalling && !hasAddon;
return (
<div>
{(!isFirefox) ? (
<div>
<span data-l10n-id="landingDownloadFirefoxDesc" className="parens">(Test Pilot is available for Firefox on Windows, OS X and Linux)</span>
<a href="https://www.mozilla.org/firefox" className="button primary download-firefox">
<div className="button-icon">
<div className="button-icon-badge"></div>
</div>
<div className="button-copy">
<div data-l10n-id="landingDownloadFirefoxTitle" className="button-title">Firefox</div>
<div data-l10n-id="landingDownloadFirefoxSubTitle" className="button-description">Free Download</div>
</div>
</a>
</div>
) : (
<div>
<button onClick={e => this.install(e)} data-hook="install"
className={classnames('button extra-large primary install', { 'state-change': isInstalling })}>
{hasAddon && <span className="progress-btn-msg" data-l10n-id="landingInstallingButton">Installed</span>}
{!hasAddon && !isInstalling &&
<span className="default-btn-msg" data-l10n-id="landingInstallButton">Install the Test Pilot Add-on</span>}
{!hasAddon && isInstalling &&
<span className="progress-btn-msg" data-l10n-id="landingInstallingButton">Installing...</span>}
<div className="state-change-inner"></div>
</button>
</div>
)}
{isFirefox && <p data-l10n-id="landingLegalNotice" className="legal-information">By proceeding,
you agree to the <a href="/terms">Terms of Use</a> and <a href="/privacy">Privacy Notice</a> of Test Pilot</p>}
</div>
);
}
install() {
const { eventCategory, hasAddon } = this.props;
if (hasAddon) { return; }
this.setState({ isInstalling: true });
installAddon(eventCategory);
}
}