@@ -9,7 +9,11 @@ import {
9
9
import toast from 'react-hot-toast'
10
10
import Loadbar from '../loaders/Loadbar'
11
11
import Spinner from '../common/Spinner'
12
- import { LazerState , LazerFeed , LazerPublisher } from '@pythnetwork/xc-admin-common/src/programs/types'
12
+ import {
13
+ LazerState ,
14
+ LazerFeed ,
15
+ LazerPublisher ,
16
+ } from '@pythnetwork/xc-admin-common/src/programs/types'
13
17
import { capitalizeFirstLetter } from '../../utils/capitalizeFirstLetter'
14
18
15
19
interface PythLazerProps {
@@ -70,42 +74,52 @@ const ShardChangesRows: React.FC<ShardChangesRowsProps> = ({ changes }) => {
70
74
71
75
return (
72
76
< >
73
- { Object . entries ( changes . new ) . map ( ( [ key , newValue ] ) =>
74
- ( isNewShard || ( changes . prev && changes . prev [ key as keyof typeof changes . prev ] !== newValue ) ) && (
75
- < tr key = { key } >
76
- < td className = "base16 py-4 pl-6 pr-2 lg:pl-6" >
77
- { key
78
- . split ( / (? = [ A - Z ] ) / )
79
- . join ( ' ' )
80
- . split ( '_' )
81
- . map ( ( word ) => capitalizeFirstLetter ( word ) )
82
- . join ( ' ' ) }
83
- </ td >
84
- < td className = "base16 py-4 pl-1 pr-2 lg:pl-6" >
85
- { ! isNewShard && changes . prev ? (
86
- < >
87
- < s > { String ( changes . prev [ key as keyof typeof changes . prev ] ) } </ s >
88
- < br />
89
- </ >
90
- ) : null }
91
- { String ( newValue ) }
92
- </ td >
93
- </ tr >
94
- )
77
+ { Object . entries ( changes . new ) . map (
78
+ ( [ key , newValue ] ) =>
79
+ ( isNewShard ||
80
+ ( changes . prev &&
81
+ changes . prev [ key as keyof typeof changes . prev ] !== newValue ) ) && (
82
+ < tr key = { key } >
83
+ < td className = "base16 py-4 pl-6 pr-2 lg:pl-6" >
84
+ { key
85
+ . split ( / (? = [ A - Z ] ) / )
86
+ . join ( ' ' )
87
+ . split ( '_' )
88
+ . map ( ( word ) => capitalizeFirstLetter ( word ) )
89
+ . join ( ' ' ) }
90
+ </ td >
91
+ < td className = "base16 py-4 pl-1 pr-2 lg:pl-6" >
92
+ { ! isNewShard && changes . prev ? (
93
+ < >
94
+ < s >
95
+ { String ( changes . prev [ key as keyof typeof changes . prev ] ) }
96
+ </ s >
97
+ < br />
98
+ </ >
99
+ ) : null }
100
+ { String ( newValue ) }
101
+ </ td >
102
+ </ tr >
103
+ )
95
104
) }
96
105
</ >
97
106
)
98
107
}
99
108
100
- const FeedChangesRows : React . FC < FeedChangesRowsProps > = ( { changes, feedId } ) => {
109
+ const FeedChangesRows : React . FC < FeedChangesRowsProps > = ( {
110
+ changes,
111
+ feedId,
112
+ } ) => {
101
113
const isNewFeed = ! changes . prev && changes . new
102
114
const isDeletedFeed = changes . prev && ! changes . new
103
115
104
116
if ( isDeletedFeed ) {
105
117
return (
106
118
< tr >
107
119
< td className = "base16 py-4 pl-6 pr-2 lg:pl-6" > Feed ID</ td >
108
- < td className = "base16 py-4 pl-1 pr-2 lg:pl-6" > { feedId . replace ( 'feed_' , '' ) } </ td >
120
+ < td className = "base16 py-4 pl-1 pr-2 lg:pl-6" >
121
+ { feedId . replace ( 'feed_' , '' ) }
122
+ </ td >
109
123
</ tr >
110
124
)
111
125
}
@@ -116,7 +130,8 @@ const FeedChangesRows: React.FC<FeedChangesRowsProps> = ({ changes, feedId }) =>
116
130
if ( ! changes . new ?. metadata ) return null
117
131
118
132
return Object . entries ( changes . new . metadata ) . map ( ( [ key , newValue ] ) => {
119
- const prevValue = changes . prev ?. metadata ?. [ key as keyof typeof changes . prev . metadata ]
133
+ const prevValue =
134
+ changes . prev ?. metadata ?. [ key as keyof typeof changes . prev . metadata ]
120
135
const hasChanged = isNewFeed || prevValue !== newValue
121
136
122
137
if ( ! hasChanged ) return null
@@ -146,13 +161,20 @@ const FeedChangesRows: React.FC<FeedChangesRowsProps> = ({ changes, feedId }) =>
146
161
}
147
162
148
163
const renderPendingActivationChanges = ( ) => {
149
- if ( changes . new ?. pendingActivation !== undefined || changes . prev ?. pendingActivation !== undefined ) {
150
- const hasChanged = isNewFeed || changes . prev ?. pendingActivation !== changes . new ?. pendingActivation
164
+ if (
165
+ changes . new ?. pendingActivation !== undefined ||
166
+ changes . prev ?. pendingActivation !== undefined
167
+ ) {
168
+ const hasChanged =
169
+ isNewFeed ||
170
+ changes . prev ?. pendingActivation !== changes . new ?. pendingActivation
151
171
152
172
if ( hasChanged ) {
153
173
return (
154
174
< tr key = "pendingActivation" >
155
- < td className = "base16 py-4 pl-6 pr-2 lg:pl-6" > Pending Activation</ td >
175
+ < td className = "base16 py-4 pl-6 pr-2 lg:pl-6" >
176
+ Pending Activation
177
+ </ td >
156
178
< td className = "base16 py-4 pl-1 pr-2 lg:pl-6" >
157
179
{ ! isNewFeed && changes . prev ?. pendingActivation ? (
158
180
< >
@@ -177,15 +199,20 @@ const FeedChangesRows: React.FC<FeedChangesRowsProps> = ({ changes, feedId }) =>
177
199
)
178
200
}
179
201
180
- const PublisherChangesRows : React . FC < PublisherChangesRowsProps > = ( { changes, publisherId } ) => {
202
+ const PublisherChangesRows : React . FC < PublisherChangesRowsProps > = ( {
203
+ changes,
204
+ publisherId,
205
+ } ) => {
181
206
const isNewPublisher = ! changes . prev && changes . new
182
207
const isDeletedPublisher = changes . prev && ! changes . new
183
208
184
209
if ( isDeletedPublisher ) {
185
210
return (
186
211
< tr >
187
212
< td className = "base16 py-4 pl-6 pr-2 lg:pl-6" > Publisher ID</ td >
188
- < td className = "base16 py-4 pl-1 pr-2 lg:pl-6" > { publisherId . replace ( 'publisher_' , '' ) } </ td >
213
+ < td className = "base16 py-4 pl-1 pr-2 lg:pl-6" >
214
+ { publisherId . replace ( 'publisher_' , '' ) }
215
+ </ td >
189
216
</ tr >
190
217
)
191
218
}
@@ -196,7 +223,9 @@ const PublisherChangesRows: React.FC<PublisherChangesRowsProps> = ({ changes, pu
196
223
< >
197
224
{ Object . entries ( changes . new ) . map ( ( [ key , newValue ] ) => {
198
225
const prevValue = changes . prev ?. [ key as keyof LazerPublisher ]
199
- const hasChanged = isNewPublisher || JSON . stringify ( prevValue ) !== JSON . stringify ( newValue )
226
+ const hasChanged =
227
+ isNewPublisher ||
228
+ JSON . stringify ( prevValue ) !== JSON . stringify ( newValue )
200
229
201
230
if ( ! hasChanged ) return null
202
231
@@ -213,7 +242,11 @@ const PublisherChangesRows: React.FC<PublisherChangesRowsProps> = ({ changes, pu
213
242
< td className = "base16 py-4 pl-1 pr-2 lg:pl-6" >
214
243
{ ! isNewPublisher && prevValue !== undefined ? (
215
244
< >
216
- < s > { Array . isArray ( prevValue ) ? prevValue . join ( ', ' ) : String ( prevValue ) } </ s >
245
+ < s >
246
+ { Array . isArray ( prevValue )
247
+ ? prevValue . join ( ', ' )
248
+ : String ( prevValue ) }
249
+ </ s >
217
250
< br />
218
251
</ >
219
252
) : null }
@@ -242,13 +275,25 @@ const ModalContent: React.FC<ModalContentProps> = ({
242
275
243
276
let title = key
244
277
if ( key === 'shard' ) {
245
- title = isAddition ? 'Add New Shard' : isDeletion ? 'Delete Shard' : 'Shard Configuration'
278
+ title = isAddition
279
+ ? 'Add New Shard'
280
+ : isDeletion
281
+ ? 'Delete Shard'
282
+ : 'Shard Configuration'
246
283
} else if ( key . startsWith ( 'feed_' ) ) {
247
284
const feedId = key . replace ( 'feed_' , '' )
248
- title = isAddition ? `Add New Feed (ID: ${ feedId } )` : isDeletion ? `Delete Feed (ID: ${ feedId } )` : `Feed ${ feedId } `
285
+ title = isAddition
286
+ ? `Add New Feed (ID: ${ feedId } )`
287
+ : isDeletion
288
+ ? `Delete Feed (ID: ${ feedId } )`
289
+ : `Feed ${ feedId } `
249
290
} else if ( key . startsWith ( 'publisher_' ) ) {
250
291
const publisherId = key . replace ( 'publisher_' , '' )
251
- title = isAddition ? `Add New Publisher (ID: ${ publisherId } )` : isDeletion ? `Delete Publisher (ID: ${ publisherId } )` : `Publisher ${ publisherId } `
292
+ title = isAddition
293
+ ? `Add New Publisher (ID: ${ publisherId } )`
294
+ : isDeletion
295
+ ? `Delete Publisher (ID: ${ publisherId } )`
296
+ : `Publisher ${ publisherId } `
252
297
}
253
298
254
299
return (
@@ -287,7 +332,8 @@ const ModalContent: React.FC<ModalContentProps> = ({
287
332
/>
288
333
) : null }
289
334
290
- { Object . keys ( changes ) . indexOf ( key ) !== Object . keys ( changes ) . length - 1 ? (
335
+ { Object . keys ( changes ) . indexOf ( key ) !==
336
+ Object . keys ( changes ) . length - 1 ? (
291
337
< tr >
292
338
< td className = "base16 py-4 pl-6 pr-6" colSpan = { 2 } >
293
339
< hr className = "border-gray-700" />
0 commit comments