-
Notifications
You must be signed in to change notification settings - Fork 967
Expand file tree
/
Copy pathRootModals.tsx
More file actions
74 lines (68 loc) · 1.9 KB
/
RootModals.tsx
File metadata and controls
74 lines (68 loc) · 1.9 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
import React, { useContext } from "react"
import {
DispatchActionModal,
SubscriptionAddModal,
ReactotronContext,
StateContext,
DiagnosticModal,
} from "reactotron-core-ui"
import configStore from "./config"
import StandaloneContext from "./contexts/Standalone"
import { getServerStatusData } from "./components/SideBar/Sidebar"
function RootModals() {
const {
sendCommand,
// Dispatch Modal
isDispatchModalOpen,
dispatchModalInitialAction,
closeDispatchModal,
// Subscription Modal
isSubscriptionModalOpen,
closeSubscriptionModal,
// Diagnostic Modal
isDiagnosticModalOpen,
closeDiagnosticModal,
} = useContext(ReactotronContext)
const { addSubscription } = useContext(StateContext)
const { serverStatus } = useContext(StandaloneContext)
const { serverStatusText } = getServerStatusData(serverStatus)
const dispatchAction = (action: any) => {
sendCommand("state.action.dispatch", { action })
}
return (
<>
<DispatchActionModal
isOpen={isDispatchModalOpen}
initialValue={dispatchModalInitialAction}
onClose={() => {
closeDispatchModal()
}}
onDispatchAction={dispatchAction}
isDarwin={window.process.platform === "darwin"}
/>
<SubscriptionAddModal
isOpen={isSubscriptionModalOpen}
onClose={() => {
closeSubscriptionModal()
}}
onAddSubscription={(path: string) => {
// TODO: Get this out of here.
closeSubscriptionModal()
addSubscription(path)
}}
/>
<DiagnosticModal
isOpen={isDiagnosticModalOpen}
onClose={() => {
closeDiagnosticModal()
}}
port={configStore.get("serverPort") as string}
serverStatusText={serverStatusText}
onRefresh={() => {
window.location.reload()
}}
/>
</>
)
}
export default RootModals