-
Notifications
You must be signed in to change notification settings - Fork 527
Expand file tree
/
Copy pathIsNotConnected.js
More file actions
95 lines (92 loc) · 5.38 KB
/
IsNotConnected.js
File metadata and controls
95 lines (92 loc) · 5.38 KB
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
import React, { useState } from 'react'
import { connect } from 'redux-bundler-react'
import { withTranslation, Trans } from 'react-i18next'
import classNames from 'classnames'
import ApiAddressForm from '../api-address-form/ApiAddressForm.js'
import Box from '../box/Box.tsx'
import Shell from '../shell/Shell.tsx'
import GlyphAttention from '../../icons/GlyphAttention.js'
const TABS = {
UNIX: 'unix',
POWERSHELL: 'windowsPS',
WINDOWS: 'windowsCMD'
}
const IsNotConnected = ({ t, apiUrl, connected, sameOrigin, ipfsApiAddress, doUpdateIpfsApiAddress }) => {
const [activeTab, setActiveTab] = useState(TABS.UNIX)
const defaultDomains = ['http://localhost:3000', 'http://127.0.0.1:5001', 'https://webui.ipfs.io']
const origin = window.location.origin
const addOrigin = defaultDomains.indexOf(origin) === -1
return (
<Box className='pv3 ph4 lh-copy charcoal'>
<div className='flex flex-wrap items-center'>
<GlyphAttention style={{ height: 76 }} className='fill-red mr' role='presentation' />
<h1 className='montserrat fw4 charcoal ma0 f3 red'>{t('app:status.couldNotConnect')}</h1>
</div>
<Trans i18nKey='notConnected.paragraph1' t={t}>
<p className='fw6 mb3'>Check out the installation guide in the <a className='link blue' href='https://docs.ipfs.tech/install/command-line-quick-start/' target='_blank' rel='noopener noreferrer'>IPFS Docs</a>, or try these common fixes:</p>
</Trans>
<ol className='pl3 pt2'>
<Trans i18nKey='notConnected.paragraph2' t={t}>
<li className='mb3'>Is your IPFS daemon running? Try starting or restarting Kubo from your terminal:</li>
</Trans>
<Shell title='Any Shell'>
<code className='db'><b className='no-select'>$ </b>ipfs daemon</code>
<code className='db'>Initializing daemon...</code>
<code className='db'>RPC API server listening on /ip4/127.0.0.1/tcp/5001</code>
</Shell>
{ !sameOrigin && (
<div>
<Trans i18nKey='notConnected.paragraph3' t={t}>
<li className='mb3 mt4'>Is your Kubo RPC API configured to allow <a className='link blue' href='https://github.com/ipfs/ipfs-webui#configure-kubo-rpc-api-cors-headers'>cross-origin (CORS) requests</a>? If not, run these commands and then start your daemon from the terminal:</li>
</Trans>
<div className='br1 overflow-hidden'>
<div className='f7 mb0 sans-serif charcoal pv1 pl2 bg-black-20 flex items-center overflow-x-auto'>
<button onClick={() => setActiveTab(TABS.UNIX)} className={classNames('pointer mr3 ttu tracked', activeTab === TABS.UNIX && 'fw7')}>
Unix & MacOS
</button>
<button onClick={() => setActiveTab(TABS.POWERSHELL)} className={classNames('pointer mr3 ttu tracked', activeTab === TABS.POWERSHELL && 'fw7')}>
Windows Powershell
</button>
<button onClick={() => setActiveTab(TABS.WINDOWS)} className={classNames('pointer ttu tracked', activeTab === TABS.WINDOWS && 'fw7')}>
Windows CMD
</button>
</div>
<div className='bg-black-70 snow pa2 f7 lh-copy monospace nowrap overflow-x-auto'>
{ activeTab === TABS.UNIX && (
<div>
<code className='db'><b className='no-select'>$ </b>ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '[{addOrigin && `"${origin}", `}"{defaultDomains.join('", "')}"]'</code>
<code className='db'><b className='no-select'>$ </b>ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "POST"]'</code>
</div>
)}
{ activeTab === TABS.POWERSHELL && (
<div>
<code className='db'><b className='no-select'>$ </b>ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '[{addOrigin && `\\"${origin}\\", `}\"{defaultDomains.join('\\", \\"')}\"]'</code>
<code className='db'><b className='no-select'>$ </b>ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '[\"PUT\", \"POST\"]'</code>
</div>
)}
{ activeTab === TABS.WINDOWS && (
<div>
<code className='db'><b className='no-select'>$ </b>ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "[{addOrigin && `"""${origin}""", `}"""{defaultDomains.join('""", """')}"""]"</code>
<code className='db'><b className='no-select'>$ </b>ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods "["""PUT""", """POST"""]"</code>
</div>
)}
</div>
</div>
</div>
)}
<Trans i18nKey='notConnected.paragraph4' t={t}>
<li className='mt4 mb3'>Is your Kubo RPC on a port other than 5001? If your node is configured with a <a className='link blue' href='https://github.com/ipfs/kubo/blob/master/docs/config.md#addresses' target='_blank' rel='noopener noreferrer'>custom RPC API address</a>, enter it here.</li>
</Trans>
<ApiAddressForm
t={t}
defaultValue={ipfsApiAddress || ''}
updateAddress={doUpdateIpfsApiAddress} />
</ol>
</Box>
)
}
export default connect(
'selectIpfsConnected',
'selectApiUrl',
withTranslation('welcome')(IsNotConnected)
)