@@ -58,9 +58,12 @@ interface ViewPageProps {
5858}
5959
6060const ViewPageKeyboardShortcuts = ( props : {
61+ isPaidUser : boolean ,
6162 selectedEvent : CollectedEvent | undefined ,
6263 moveSelection : ( distance : number ) => void ,
6364 onPin : ( event : HttpExchange ) => void ,
65+ onResend : ( event : HttpExchange ) => void ,
66+ onMockRequest : ( event : HttpExchange ) => void ,
6467 onDelete : ( event : CollectedEvent ) => void ,
6568 onClear : ( ) => void ,
6669 onStartSearch : ( ) => void
@@ -82,6 +85,20 @@ const ViewPageKeyboardShortcuts = (props: {
8285 }
8386 } , [ props . selectedEvent , props . onPin ] ) ;
8487
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+
85102 useHotkeys ( 'Ctrl+Delete, Cmd+Delete' , ( event ) => {
86103 if ( isEditable ( event . target ) ) return ;
87104
@@ -271,6 +288,7 @@ class ViewPage extends React.Component<ViewPageProps> {
271288 render ( ) : JSX . Element {
272289 const { isPaused, events } = this . props . eventsStore ;
273290 const { certPath } = this . props . proxyStore ;
291+ const { isPaidUser } = this . props . accountStore ;
274292
275293 const { filteredEvents, filteredEventCount } = this . filteredEventState ;
276294
@@ -338,9 +356,12 @@ class ViewPage extends React.Component<ViewPageProps> {
338356
339357 return < div className = { this . props . className } >
340358 < ViewPageKeyboardShortcuts
359+ isPaidUser = { isPaidUser }
341360 selectedEvent = { this . selectedEvent }
342361 moveSelection = { this . moveSelection }
343362 onPin = { this . onPin }
363+ onResend = { this . onPrepareToResendRequest }
364+ onMockRequest = { this . onBuildRuleFromExchange }
344365 onDelete = { this . onDelete }
345366 onClear = { this . onForceClear }
346367 onStartSearch = { this . onStartSearch }
@@ -440,6 +461,8 @@ class ViewPage extends React.Component<ViewPageProps> {
440461 onBuildRuleFromExchange ( exchange : HttpExchange ) {
441462 const { rulesStore, navigate } = this . props ;
442463
464+ if ( ! this . props . accountStore ! . isPaidUser ) return ;
465+
443466 const rule = buildRuleFromExchange ( exchange ) ;
444467 rulesStore ! . draftRules . items . unshift ( rule ) ;
445468 navigate ( `/mock/${ rule . id } ` ) ;
@@ -448,6 +471,9 @@ class ViewPage extends React.Component<ViewPageProps> {
448471 @action . bound
449472 async onPrepareToResendRequest ( exchange : HttpExchange ) {
450473 const { sendStore, navigate } = this . props ;
474+
475+ if ( ! this . props . accountStore ! . isPaidUser ) return ;
476+
451477 await sendStore . addRequestInputFromExchange ( exchange ) ;
452478 navigate ( `/send` ) ;
453479 }
0 commit comments