-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathOps.tsx
More file actions
122 lines (114 loc) · 3.78 KB
/
Ops.tsx
File metadata and controls
122 lines (114 loc) · 3.78 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import { useCallback } from 'react';
import * as need from 'lib/need';
import { Box, Row, Button, Icon } from '@tlon/indigo-react';
import { useRollerStore } from 'store/rollerStore';
import { usePointCursor } from 'store/pointCursor';
import { useLocalRouter } from 'lib/LocalRouter';
import { isGalaxy } from 'lib/utils/point';
import Window from 'components/L2/Window/Window';
import HeaderPane from 'components/L2/Window/HeaderPane';
import BodyPane from 'components/L2/Window/BodyPane';
import View from 'components/View';
import L2BackHeader from 'components/L2/Headers/L2BackHeader';
import './Ops.scss';
export const Ops = () => {
const { pop, push, popAndPush, names }: any = useLocalRouter();
const { pointCursor }: any = usePointCursor();
const { point } = useRollerStore();
const _point = need.point(pointCursor);
const goSenate = useCallback(() => push(names.SENATE), [push, names]);
const goResidents = useCallback(() => push(names.RESIDENTS), [push, names]);
const goRequests = useCallback(() => push(names.REQUESTS), [push, names]);
const goIssuePoint = useCallback(() => push(names.ISSUE_CHILD), [
names.ISSUE_CHILD,
push,
]);
const goUrbitOS = useCallback(() => popAndPush(names.URBIT_OS), [
names.URBIT_OS,
popAndPush,
]);
const getButtonContent = () => {
if (!point.couldSpawn) {
return null;
} else if (point.networkKeysSet) {
return (
<Button onClick={goIssuePoint} className="header-button">
<Icon icon="Node" /> Spawn
{isGalaxy(_point) ? 'Stars' : 'Planets'}
</Button>
);
}
return (
<Button onClick={goUrbitOS} className="header-button">
Set Network Keys
</Button>
);
};
return (
<View
pop={pop}
inset
hideBack
className="ops"
header={<L2BackHeader hideBalance back={pop} />}>
<Window className="id-ops">
<HeaderPane>
<Row className="header-row">
<h5>{isGalaxy(_point) ? 'Galaxy' : 'Star'} Ops</h5>
{getButtonContent()}
</Row>
</HeaderPane>
<BodyPane>
<Row className={"between-row management" +
(point.canManage ? "" : " disabled")}
>
<Box>
<Box className="section-title">Residents</Box>
<Box className="subtitle">
{isGalaxy(_point) ? 'Stars' : 'Planets'} that you route packets
for
</Box>
</Box>
<Button className="secondary"
onClick={point.canManage ? goResidents : undefined}
>
View
</Button>
</Row>
<Row className={"between-row management" +
(point.canManage ? "" : " disabled")}
>
<Box>
<Box className="section-title">Requests</Box>
<Box className="subtitle">
{isGalaxy(_point) ? 'Stars' : 'Planets'} requesting your
sponsorship
</Box>
</Box>
<Button className="secondary"
onClick={point.canManage ? goRequests : undefined}
>
View
</Button>
</Row>
{point.isGalaxy && (
<Row className={"between-row management" +
(point.canVote ? "" : " disabled")}
>
<Box >
<Box className="section-title">Proposals</Box>
<Box className="subtitle">
View or vote on proposals in the Senate
</Box>
</Box>
<Button className="secondary"
onClick={point.canVote ? goSenate : undefined}>
View
</Button>
</Row>
)}
</BodyPane>
</Window>
</View>
);
};