<commit_before>class SidebarController extends KDViewController

  constructor:->
    super

    mainController = @getSingleton 'mainController'

    mainController.on 'ManageRemotes', -> new ManageRemotesModal
    mainController.on 'ManageDatabases', -> new ManageDatabasesModal

  loadView:->

    @accountChanged KD.whoami()

  accountChanged:(account)->

    {profile} = account
    sidebar   = @getView()
    account or= KD.whoami()

    {
     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

    do =>
      {navController} = @getView()
      groupsController = @getSingleton 'groupsController'
      groupsController.on 'GroupChanged', ->
        group = groupsController.getCurrentGroup()

        # We need to fix that, it happens when you logged-in from groupEntryPoint
        return unless group

        group.fetchMyRoles (err, roles)=>
          if err
            console.warn err
          else if 'admin' in roles
            navController.removeItem dashboardLink  if @dashboardLink?
            @dashboardLink = navController.addItem
              title     : 'Admin dashboard'
              type      : 'admin'
              loggedIn  : yes
              callback  : ->
                KD.getSingleton('router').handleRoute "/#{group.slug}/Dashboard"<commit_msg>groups: Admin dashboard link changed to group settings<commit_after>class SidebarController extends KDViewController

  constructor:->
    super

    mainController = @getSingleton 'mainController'

    mainController.on 'ManageRemotes', -> new ManageRemotesModal
    mainController.on 'ManageDatabases', -> new ManageDatabasesModal

  loadView:->

    @accountChanged KD.whoami()

  accountChanged:(account)->

    {profile} = account
    sidebar   = @getView()
    account or= KD.whoami()

    {
     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

    do =>
      {navController} = @getView()
      groupsController = @getSingleton 'groupsController'
      groupsController.on 'GroupChanged', ->
        group = groupsController.getCurrentGroup()

        # We need to fix that, it happens when you logged-in from groupEntryPoint
        return unless group

        group.fetchMyRoles (err, roles)=>
          if err
            console.warn err
          else if 'admin' in roles
            navController.removeItem dashboardLink  if @dashboardLink?
            @dashboardLink = navController.addItem
              title     : 'Group Settings'
              type      : 'admin'
              loggedIn  : yes
              callback  : ->
                KD.getSingleton('router').handleRoute "/#{group.slug}/Dashboard"
{'fraction_non_alphanumeric': 0.08565153733528551, 'fraction_numerical': 0.0, 'mean_word_length': 2.427257525083612, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, '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': '6741443', 'n_tokens_mistral': 1133, 'n_tokens_neox': 1072, 'n_words': 276}