-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathindex.tsx
More file actions
90 lines (73 loc) · 1.95 KB
/
index.tsx
File metadata and controls
90 lines (73 loc) · 1.95 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
// Libraries
import React, {PureComponent, Suspense} from 'react'
import {render} from 'react-dom'
import {Provider} from 'react-redux'
import {Route} from 'react-router-dom'
import {ConnectedRouter} from 'connected-react-router'
// Stores
import {getStore} from 'src/store/configureStore'
import {history} from 'src/store/history'
// Components
import {Setup} from 'src/Setup'
import PageSpinner from 'src/perf/components/PageSpinner'
// Utilities
import {getRootNode} from 'src/utils/nodes'
import {
updateReportingContext,
updateCampaignInfo,
} from 'src/cloud/utils/reporting'
// Constants
import {CLOUD} from 'src/shared/constants'
// Actions
import {disablePresentationMode} from 'src/shared/actions/app'
// Styles
import 'src/style/chronograf.scss'
import '@influxdata/clockface/dist/index.css'
import '@docsearch/css'
const rootNode = getRootNode()
const SESSION_KEY = 'session'
const cookieSession = document.cookie.match(
new RegExp('(^| )' + SESSION_KEY + '=([^;]+)')
)
updateReportingContext({
session: cookieSession ? cookieSession[2].slice(5) : '',
})
if (CLOUD) {
updateCampaignInfo(window.location.search)
}
const {dispatch} = getStore()
if (window['Cypress']) {
window['store'] = getStore()
}
history.listen(() => {
dispatch(disablePresentationMode())
})
declare global {
interface Window {
basepath: string
dataLayer: any[]
}
}
window.addEventListener('keyup', event => {
const escapeKeyCode = 27
// fallback for browsers that don't support event.key
if (event.key === 'Escape' || event.keyCode === escapeKeyCode) {
dispatch(disablePresentationMode())
}
})
class Root extends PureComponent {
public render() {
return (
<Provider store={getStore()}>
<ConnectedRouter history={history}>
<Suspense fallback={<PageSpinner />}>
<Route component={Setup} />
</Suspense>
</ConnectedRouter>
</Provider>
)
}
}
if (rootNode) {
render(<Root />, rootNode)
}