@@ -58,9 +58,12 @@ interface ViewPageProps {
58
58
}
59
59
60
60
const ViewPageKeyboardShortcuts = ( props : {
61
+ isPaidUser : boolean ,
61
62
selectedEvent : CollectedEvent | undefined ,
62
63
moveSelection : ( distance : number ) => void ,
63
64
onPin : ( event : HttpExchange ) => void ,
65
+ onResend : ( event : HttpExchange ) => void ,
66
+ onMockRequest : ( event : HttpExchange ) => void ,
64
67
onDelete : ( event : CollectedEvent ) => void ,
65
68
onClear : ( ) => void ,
66
69
onStartSearch : ( ) => void
@@ -82,6 +85,20 @@ const ViewPageKeyboardShortcuts = (props: {
82
85
}
83
86
} , [ props . selectedEvent , props . onPin ] ) ;
84
87
88
+ useHotkeys ( 'Ctrl+r, Cmd+r' , ( event ) => {
89
+ if ( props . isPaidUser && props . selectedEvent ?. isHttp ( ) ) {
90
+ props . onResend ( props . selectedEvent ) ;
91
+ event . preventDefault ( ) ;
92
+ }
93
+ } , [ props . selectedEvent , props . onResend , props . isPaidUser ] ) ;
94
+
95
+ useHotkeys ( 'Ctrl+m, Cmd+m' , ( event ) => {
96
+ if ( props . isPaidUser && props . selectedEvent ?. isHttp ( ) ) {
97
+ props . onMockRequest ( props . selectedEvent ) ;
98
+ event . preventDefault ( ) ;
99
+ }
100
+ } , [ props . selectedEvent , props . onMockRequest , props . isPaidUser ] ) ;
101
+
85
102
useHotkeys ( 'Ctrl+Delete, Cmd+Delete' , ( event ) => {
86
103
if ( isEditable ( event . target ) ) return ;
87
104
@@ -271,6 +288,7 @@ class ViewPage extends React.Component<ViewPageProps> {
271
288
render ( ) : JSX . Element {
272
289
const { isPaused, events } = this . props . eventsStore ;
273
290
const { certPath } = this . props . proxyStore ;
291
+ const { isPaidUser } = this . props . accountStore ;
274
292
275
293
const { filteredEvents, filteredEventCount } = this . filteredEventState ;
276
294
@@ -338,9 +356,12 @@ class ViewPage extends React.Component<ViewPageProps> {
338
356
339
357
return < div className = { this . props . className } >
340
358
< ViewPageKeyboardShortcuts
359
+ isPaidUser = { isPaidUser }
341
360
selectedEvent = { this . selectedEvent }
342
361
moveSelection = { this . moveSelection }
343
362
onPin = { this . onPin }
363
+ onResend = { this . onPrepareToResendRequest }
364
+ onMockRequest = { this . onBuildRuleFromExchange }
344
365
onDelete = { this . onDelete }
345
366
onClear = { this . onForceClear }
346
367
onStartSearch = { this . onStartSearch }
@@ -440,6 +461,8 @@ class ViewPage extends React.Component<ViewPageProps> {
440
461
onBuildRuleFromExchange ( exchange : HttpExchange ) {
441
462
const { rulesStore, navigate } = this . props ;
442
463
464
+ if ( ! this . props . accountStore ! . isPaidUser ) return ;
465
+
443
466
const rule = buildRuleFromExchange ( exchange ) ;
444
467
rulesStore ! . draftRules . items . unshift ( rule ) ;
445
468
navigate ( `/mock/${ rule . id } ` ) ;
@@ -448,6 +471,9 @@ class ViewPage extends React.Component<ViewPageProps> {
448
471
@action . bound
449
472
async onPrepareToResendRequest ( exchange : HttpExchange ) {
450
473
const { sendStore, navigate } = this . props ;
474
+
475
+ if ( ! this . props . accountStore ! . isPaidUser ) return ;
476
+
451
477
await sendStore . addRequestInputFromExchange ( exchange ) ;
452
478
navigate ( `/send` ) ;
453
479
}
0 commit comments