     @addSubView tabView
 
 
-  viewAppended: ->
-
-    super
-    status = getGroup().isApiEnabled is yes
-    @apiSwitch.setDefaultValue status
-
-

    data    = @getData()
    tabView = new kd.TabView hideHandleCloseIcons: yes

    tabView.tabHandleContainer.addSubView new kd.ButtonView
      cssClass : 'solid compact green add-new'
      title    : 'Add new API Token'
      callback : =>


    super options, data

    @initialAPIAccessState = getGroup().isApiEnabled is yes
    @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) =>
          if err
            showError err
            # revert switch state in case of error
            if state
            then apiSwitch.setOff no
            else apiSwitch.setOn no

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

    apiSwitch.setDefaultValue @initialAPIAccessState


  createTabView: ->
