     @childWindow.focus()
 
   onUndo: ->
-    @getCurrentView()?.undo()
+    @getCurrentView()?.undo?()
 
   onRedo: ->
-    @getCurrentView()?.redo()
+    @getCurrentView()?.redo?()
 
   getCurrentView: ->
-    tabText = $('li.active')[0]?.textContent.toLowerCase()
-    currentView = @subViews[tabText + 'Tab' ]
+    tabText = _.string.underscored $('li.active')[0]?.textContent
+    currentView = @subviews["editor_level_#{tabText}_tab_view"]
+    if tabText is 'patches' then currentView = @patchesView
+    if tabText is 'documentation' then currentView = @subviews.docs_components_view
     currentView
 
   startPatchingLevel: (e) ->

    return unless @supermodel.finished()
    @$el.find('a[data-toggle="tab"]').on 'shown.bs.tab', (e) =>
      Backbone.Mediator.publish 'level:view-switched', e
    @subViews['thangsTab'] = @insertSubView new ThangsTabView world: @world, supermodel: @supermodel, level: @level
    @subViews['settingsTab'] = @insertSubView new SettingsTabView supermodel: @supermodel
    @subViews['scriptsTab'] = @insertSubView new ScriptsTabView world: @world, supermodel: @supermodel, files: @files
    @subViews['componentsTab'] = @insertSubView new ComponentsTabView supermodel: @supermodel
    @subViews['systemsTab'] = @insertSubView new SystemsTabView supermodel: @supermodel
    @subViews['componentsDocsTab'] = @insertSubView new ComponentDocsView supermodel: @supermodel
    
    Backbone.Mediator.publish 'level-loaded', level: @level
    @showReadOnly() if me.get('anonymous')
    @patchesView = @insertSubView(new PatchesView(@level), @$el.find('.patches-view'))

    'click #undo-button': 'onUndo'
    'click #redo-button': 'onRedo'
    'click #patches-tab': -> @patchesView.load()
    'click #components-tab': -> @subviews.editor_level_components_tab_view.refreshLevelThangsTreema @level.get('thangs')
    'click #level-patch-button': 'startPatchingLevel'
    'click #level-watch-button': 'toggleWatchLevel'
    'click #pop-level-i18n-button': -> @level.populateI18N()
