@@ -271,6 +271,26 @@ export default class EventsFunctionsList extends React.Component<Props, State> {
271271 this . _editName ( newEventsFunction ) ;
272272 } ;
273273
274+ _duplicateEventsFunction = (
275+ eventsFunction : gdEventsFunction ,
276+ newFunctionIndex : number
277+ ) => {
278+ const { eventsFunctionsContainer } = this . props ;
279+ const newName = newNameGenerator ( eventsFunction . getName ( ) , name =>
280+ eventsFunctionsContainer . hasEventsFunctionNamed ( name )
281+ ) ;
282+ const newEventsFunction = eventsFunctionsContainer . insertEventsFunction (
283+ eventsFunction ,
284+ newFunctionIndex
285+ ) ;
286+ newEventsFunction . setName ( newName ) ;
287+ this . props . onEventsFunctionAdded ( newEventsFunction ) ;
288+
289+ this . _onEventsFunctionModified ( ) ;
290+ this . props . onSelectEventsFunction ( newEventsFunction ) ;
291+ this . _editName ( newEventsFunction ) ;
292+ } ;
293+
274294 _onEventsFunctionModified ( ) {
275295 if ( this . props . unsavedChanges )
276296 this . props . unsavedChanges . triggerUnsavedChanges ( ) ;
@@ -315,7 +335,11 @@ export default class EventsFunctionsList extends React.Component<Props, State> {
315335 {
316336 label : i18n . _ ( t `Paste` ) ,
317337 enabled : Clipboard . has ( EVENTS_FUNCTION_CLIPBOARD_KIND ) ,
318- click : ( ) => this . _pasteEventsFunction ( index ) ,
338+ click : ( ) => this . _pasteEventsFunction ( index + 1 ) ,
339+ } ,
340+ {
341+ label : i18n . _ ( t `Duplicate` ) ,
342+ click : ( ) => this . _duplicateEventsFunction ( eventsFunction , index + 1 ) ,
319343 } ,
320344 ] ;
321345 } ;
0 commit comments