     data    = @getData()
     tabView = new kd.TabView hideHandleCloseIcons: yes
 
-    tabView.tabHandleContainer.addSubView new kd.ButtonView
+    @addNewButton = tabView.tabHandleContainer.addSubView new kd.ButtonView
       cssClass : 'solid compact green add-new'
       title    : 'Add new API Token'
       callback : =>


    super options, data

    @createSwitch()
    @createTabView()


  createSwitch: ->

    @addSubView @settingsView = new kd.CustomHTMLView
      partial: 'Enable API Access'
      cssClass: 'settings-row'

    @settingsView.addSubView @apiSwitch = new KodingSwitch
      callback      : (state) ->
        getGroup().modify { isApiEnabled : state }, (err) ->
          showError err  if err


  createTabView: ->

          return showError err  if err
          kd.utils.defer =>
            @apiTokenListView.listController.addItem apiToken

    if @initialAPIAccessState
    then @addNewButton.enable()
    else @addNewButton.disable()

    tabView.addPane apiTokens = new kd.TabPaneView name: 'API Tokens'

