<commit_before>class SidebarController extends KDViewController

  constructor:->
    super

    mainController = @getSingleton 'mainController'
    mainController.on 'ManageRemotes', -> new ManageRemotesModal
    mainController.on 'ManageDatabases', -> new ManageDatabasesModal
    mainController.on 'AccountChanged', @bound 'accountChanged'

    groupsController = @getSingleton 'groupsController'
    groupsController.on 'GroupChanged', @bound 'resetGroupSettingsItem'

    mainController.ready @bound 'accountChanged'

  accountChanged:(account)->
    account or= KD.whoami()
    {profile} = account
    sidebar   = @getView()

    {
     avatar, finderHeader, navController
     avatarAreaIconMenu, finderController
     footerMenuController
    } = sidebar

    avatar.setData account
    finderHeader.setData account
    # temp fix
    # this should be done on framework level
    # check comments on KDObject::setData
    avatar.render()
    finderHeader.render()

    navController.reset()
    footerMenuController.reset()
    @resetAdminNavItems()

    avatarAreaIconMenu.accountChanged account

    finderController.reset()

  resetAdminNavItems:->
    return unless KD.isLoggedIn()

    KD.whoami().fetchRole? (err, role)=>
      if role is "super-admin"
        @getView().navController.addItem
          title    : "Admin Panel"
          type     : "admin"
          loggedIn : yes
          callback : -> new AdminModal

      @resetGroupSettingsItem()

  resetGroupSettingsItem:->
    return unless KD.isLoggedIn()

    if 'admin' in KD.config.roles
      {navController} = @getView()
      {slug} = KD.config.entryPoint or {slug:'koding'}

      navController.removeItemByTitle 'Group Settings'
      navController.addItem
        title     : 'Group Settings'
        type      : 'admin'
        loggedIn  : yes
        callback  : ->
          slug = if slug is 'koding' then '/' else "/#{slug}/"
          KD.getSingleton('router').handleRoute "#{slug}Dashboard"<commit_msg> Fix Settings link<commit_after>class SidebarController extends KDViewController

  constructor:->
    super

    mainController = @getSingleton 'mainController'
    mainController.on 'ManageRemotes', -> new ManageRemotesModal
    mainController.on 'ManageDatabases', -> new ManageDatabasesModal
    mainController.on 'AccountChanged', @bound 'accountChanged'

    groupsController = @getSingleton 'groupsController'
    groupsController.on 'GroupChanged', @bound 'resetGroupSettingsItem'

    mainController.ready @bound 'accountChanged'

  accountChanged:(account)->
    account or= KD.whoami()
    {profile} = account
    sidebar   = @getView()

    {
     avatar, finderHeader, navController
     avatarAreaIconMenu, finderController
     footerMenuController
    } = sidebar

    avatar.setData account
    finderHeader.setData account
    # temp fix
    # this should be done on framework level
    # check comments on KDObject::setData
    avatar.render()
    finderHeader.render()

    navController.reset()
    footerMenuController.reset()
    @resetAdminNavItems()

    avatarAreaIconMenu.accountChanged account

    finderController.reset()

  resetAdminNavItems:->
    return unless KD.isLoggedIn()

    KD.whoami().fetchRole? (err, role)=>
      if role is "super-admin"
        @getView().navController.addItem
          title    : "Admin Panel"
          type     : "admin"
          loggedIn : yes
          callback : -> new AdminModal

      @resetGroupSettingsItem()

  resetGroupSettingsItem:->
    return unless KD.isLoggedIn()

    if 'admin' in KD.config.roles
      {navController} = @getView()
      {slug} = KD.config.entryPoint or {slug:'koding'}

      navController.removeItemByTitle 'Group Settings'
      navController.addItem
        title     : 'Group Settings'
        type      : 'admin'
        loggedIn  : yes
        callback  : ->
          slug = if slug in ['koding', ''] then '/' else "/#{slug}/"
          KD.getSingleton('router').handleRoute "#{slug}Dashboard"
{'fraction_non_alphanumeric': 0.09777444361090272, 'fraction_numerical': 0.0, 'mean_word_length': 2.933136676499508, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3313018', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1106, 'n_words': 262}