This repository was archived by the owner on Dec 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 969
/
Copy pathtorrentViewer.js
100 lines (90 loc) · 2.68 KB
/
torrentViewer.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
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
const React = require('react')
// Components
const Button = require('../../components/button')
const TorrentFileList = require('./torrentFileList')
const TorrentStatus = require('./torrentStatus')
class TorrentViewer extends React.Component {
constructor () {
super()
this.state = {} // Needed for SortableTable.stateOwner
}
render () {
const {
name,
torrentId,
torrent,
serverUrl,
errorMessage,
torrentIdProtocol,
dispatch
} = this.props
let titleElem, mainButtonId, saveButton
if (torrent) {
if (name) {
// No localization, just use the torrent name
titleElem = <div className='sectionTitle'>{name}</div>
} else {
// 'Loading torrent information...'
titleElem = <div className='sectionTitle' data-l10n-id='torrentLoadingInfo' />
}
mainButtonId = torrent.progress < 1 ? 'downloading' : 'seeding'
} else {
const l10nStart = name ? 'startPrompt' : 'startPromptUntitled'
const l10nArgs = {name}
titleElem = (
<div
data-l10n-id={l10nStart}
data-l10n-args={JSON.stringify(l10nArgs)}
className='sectionTitle' />
)
mainButtonId = 'startDownload'
}
if (torrentIdProtocol === 'magnet:') {
saveButton = (
<Button
l10nId='copyMagnetLink'
className='whiteButton copyMagnetLink'
onClick={() => dispatch('copyMagnetLink')}
/>
)
} else {
saveButton = (
<Button
l10nId='saveTorrentFile'
className='whiteButton saveTorrentFile'
onClick={() => dispatch('saveTorrentFile')}
/>
)
}
const legalNotice = torrent != null
? <a className='legalNotice' data-l10n-id='poweredByWebTorrent' href='https://webtorrent.io' target='_blank' />
: <div className='legalNotice' data-l10n-id='legalNotice' />
return (
<div className='siteDetailsPage'>
<div className='siteDetailsPageHeader'>
{titleElem}
<div className='headerActions'>
<Button
l10nId={mainButtonId}
className='primaryButton mainButton'
disabled={!!torrent}
onClick={() => dispatch('start')}
/>
{saveButton}
</div>
</div>
<div className='siteDetailsPageContent'>
<TorrentStatus torrent={torrent} errorMessage={errorMessage} />
<TorrentFileList
torrentId={torrentId}
torrent={torrent}
serverUrl={serverUrl}
stateOwner={this}
/>
{legalNotice}
</div>
</div>
)
}
}
module.exports = TorrentViewer