@@ -9,7 +9,7 @@ import NetworkError from 'components/ResponsePane/NetworkError';
9
9
import NewRequest from 'components/Sidebar/NewRequest' ;
10
10
import { sendRequest , saveRequest } from 'providers/ReduxStore/slices/collections/actions' ;
11
11
import { findCollectionByUid , findItemInCollection } from 'utils/collections' ;
12
- import { closeTabs } from 'providers/ReduxStore/slices/tabs' ;
12
+ import { closeTabs , cloneRequest , renameRequest } from 'providers/ReduxStore/slices/tabs' ;
13
13
14
14
export const HotkeysContext = React . createContext ( ) ;
15
15
@@ -154,6 +154,50 @@ export const HotkeysProvider = (props) => {
154
154
} ;
155
155
} , [ activeTabUid ] ) ;
156
156
157
+ // clone request (ctrl/cmd + d)
158
+ useEffect ( ( ) => {
159
+ Mousetrap . bind ( [ 'command+d' , 'ctrl+d' ] , ( e ) => {
160
+ const activeTab = find ( tabs , ( t ) => t . uid === activeTabUid ) ;
161
+ if ( activeTab ) {
162
+ const collection = findCollectionByUid ( collections , activeTab . collectionUid ) ;
163
+ if ( collection ) {
164
+ const item = findItemInCollection ( collection , activeTab . uid ) ;
165
+ if ( item && item . uid ) {
166
+ dispatch ( cloneRequest ( item . uid , activeTab . collectionUid ) ) ;
167
+ }
168
+ }
169
+ }
170
+
171
+ return false ; // this stops the event bubbling
172
+ } ) ;
173
+
174
+ return ( ) => {
175
+ Mousetrap . unbind ( [ 'command+d' , 'ctrl+d' ] ) ;
176
+ } ;
177
+ } , [ activeTabUid , tabs , collections ] ) ;
178
+
179
+ // rename request (ctrl/cmd + e)
180
+ useEffect ( ( ) => {
181
+ Mousetrap . bind ( [ 'command+e' , 'ctrl+e' ] , ( e ) => {
182
+ const activeTab = find ( tabs , ( t ) => t . uid === activeTabUid ) ;
183
+ if ( activeTab ) {
184
+ const collection = findCollectionByUid ( collections , activeTab . collectionUid ) ;
185
+ if ( collection ) {
186
+ const item = findItemInCollection ( collection , activeTab . uid ) ;
187
+ if ( item && item . uid ) {
188
+ dispatch ( renameRequest ( item . uid , activeTab . collectionUid ) ) ;
189
+ }
190
+ }
191
+ }
192
+
193
+ return false ; // this stops the event bubbling
194
+ } ) ;
195
+
196
+ return ( ) => {
197
+ Mousetrap . unbind ( [ 'command+e' , 'ctrl+e' ] ) ;
198
+ } ;
199
+ } , [ activeTabUid , tabs , collections ] ) ;
200
+
157
201
return (
158
202
< HotkeysContext . Provider { ...props } value = "hotkey" >
159
203
{ showSaveRequestModal && (
0 commit comments