on master help sign in
Disable "send invites" action when prefix not participating
4ef142dFang
src/bridge/views/Point.js+28−7
@@ -49,9 +49,12 @@ class Point extends React.Component {
49 contracts.chain(ctrcs =>
49 contracts.chain(ctrcs =>
50 pointCursor.chain(point => {
50 pointCursor.chain(point => {
51 azimuth.azimuth.getPoint(ctrcs, point)
51 azimuth.azimuth.getPoint(ctrcs, point)
52− .then(details => addToPointCache({ [point]: details }))
52+ .then(details => addToPointCache({ [point]: details }));
53+ const prefix = azimuth.azimuth.getPrefix(point);
54+ azimuth.azimuth.getPoint(ctrcs, point)
55+ .then(details => addToPointCache({ [prefix]: details }));
53− this.updateSpawned(ctrcs, point)
56+ this.updateSpawned(ctrcs, point);
54− })))
57+ })));
55 }
58 }
56
59
57 updateSpawned = contracts => {
60 updateSpawned = contracts => {
@@ -69,9 +72,10 @@ class Point extends React.Component {
69
72
70 render() {
73 render() {
71
74
75+ const {
72− const { web3, popRoute, pushRoute, wallet } = this.props
76+ web3, popRoute, pushRoute, wallet, contracts,
73− const { setPointCursor } = this.props
74− const { pointCursor, pointCache } = this.props
77+ setPointCursor, pointCursor, pointCache
78+ } = this.props;
75
79
76 const { spawned } = this.state
80 const { spawned } = this.state
77
81
@@ -88,6 +92,16 @@ class Point extends React.Component {
88 ? Just(pointCache[point])
92 ? Just(pointCache[point])
89 : Nothing()
93 : Nothing()
90
94
95+ const prefix = azimuth.azimuth.getPrefix(point);
96+ const prefixDetails =
97+ prefix in pointCache
98+ ? Just(pointCache[prefix])
99+ : Nothing();
100+ const delegatedSending = contracts.matchWith({
101+ Nothing: () => '0x',
102+ Just: (c) => c.value.delegatedSending.address
103+ })
104+
91 const name = ob.patp(point)
105 const name = ob.patp(point)
92
106
93 const sigil = pour({
107 const sigil = pour({
@@ -129,7 +143,14 @@ class Point extends React.Component {
129 <H1><code>{ name }</code></H1>
143 <H1><code>{ name }</code></H1>
130 {
144 {
131 authenticated
145 authenticated
146+ ? <Actions
147+ pushRoute={ pushRoute }
148+ online={ online }
149+ wallet={ wallet }
150+ delegatedSending={ delegatedSending }
151+ point={ point }
132− ? <Actions pushRoute={ pushRoute } online={ online } point={ point } pointDetails={ pointDetails } wallet={ wallet }/>
152+ pointDetails={ pointDetails }
153+ prefixDetails={ prefixDetails } />
133 : null
154 : null
134 }
155 }
135
156
src/bridge/views/Point/Actions.js+11−2
@@ -17,7 +17,10 @@ const isStar = point =>
17 (azimuth.getPointSize(point) === azimuth.PointSize.Star);
17 (azimuth.getPointSize(point) === azimuth.PointSize.Star);
18
18
19const Actions = (props) => {
19const Actions = (props) => {
20+ const {
21+ pushRoute, online, wallet, delegatedSending,
20− const { pushRoute, online, point, pointDetails, wallet } = props
22+ point, pointDetails, prefixDetails
23+ } = props
21
24
22 const addr = wallet.matchWith({
25 const addr = wallet.matchWith({
23 Just: (wal) => addressFromSecp256k1Public(wal.value.publicKey),
26 Just: (wal) => addressFromSecp256k1Public(wal.value.publicKey),
@@ -61,6 +64,12 @@ const Actions = (props) => {
61 }
64 }
62 })
65 })
63
66
67+ const prefixHasDelegatedSending =
68+ prefixDetails.matchWith({
69+ Nothing: () => false,
70+ Just: (details) => eqAddr(details.value.spawnProxy, delegatedSending)
71+ });
72+
64 const planet = isPlanet(point)
73 const planet = isPlanet(point)
65 const star = isStar(point)
74 const star = isStar(point)
66
75
@@ -114,7 +123,7 @@ const Actions = (props) => {
114 if (planet) {
123 if (planet) {
115 invites = (
124 invites = (
116 <Button
125 <Button
117− disabled={(!isActiveOwner || !online)}
126+ disabled={(!isActiveOwner || !online || !prefixHasDelegatedSending)}
118 prop-size={'sm'}
127 prop-size={'sm'}
119 prop-type={'link'}
128 prop-type={'link'}
120 onClick={ () => {
129 onClick={ () => {