<commit_before>kd                         = require 'kd'
AppController              = require 'app/appcontroller'
AdminAppView               = require './adminappview'
AdminMembersView           = require './views/members/adminmembersview'
AdministrationView         = require './views/administrationview'
CustomViewsManager         = require './views/customviews/customviewsmanager'
TopicModerationView        = require './views/moderation/topicmoderationview'
GroupStackSettings         = require './views/groupstacksettings'
OnboardingAdminView        = require './views/onboarding/onboardingadminview'
AdminInvitationsView       = require './views/invitations/admininvitationsview'
GroupPermissionsView       = require './views/grouppermissionsview'
GroupsBlockedUserView      = require './views/groupsblockeduserview'
AdminIntegrationsView      = require './views/integrations/adminintegrationsview'
GroupGeneralSettingsView   = require './views/groupgeneralsettingsview'
AdminIntegrationParentView = require './views/integrations/adminintegrationparentview'


require('./routehandler')()


module.exports = class AdminAppController extends AppController

  @options     =
    name       : 'Admin'
    background : yes

  NAV_ITEMS    =
    teams      :
      title    : 'Team Settings'
      items    : [
        { slug : 'Settings',       title : 'Settings',          viewClass : GroupGeneralSettingsView }
        { slug : 'Members',        title : 'Members',           viewClass : AdminMembersView         }
        { slug : 'Invitations',    title : 'Invitations',       viewClass : AdminInvitationsView     }
        { slug : 'Permissions',    title : 'Permissions',       viewClass : GroupPermissionsView     }
        {
          slug      : 'Integrations'
          title     : 'Integrations'
          viewClass : AdminIntegrationsView,
          subTabs   : [
            { title : 'Add',        action: 'Add',              viewClass : AdminIntegrationParentView }
            { title : 'Configure',  action: 'Configure',        viewClass : AdminIntegrationParentView }
          ]
        }
        { slug : 'Stacks',         title : 'Compute Stacks',    viewClass : GroupStackSettings       }
      ]
    koding     :
      title    : 'Koding Administration'
      items    : [
        { slug : 'Blocked',        title : 'Blocked Users',     viewClass : GroupsBlockedUserView    }
        { slug : 'Widgets',        title : 'Custom Views',      viewClass : CustomViewsManager       }
        { slug : 'Onboarding',     title : 'Onboarding',        viewClass : OnboardingAdminView      }
        { slug : 'Moderation',     title : 'Topic Moderation',  viewClass : TopicModerationView      }
        { slug : 'Administration', title : 'Administration',    viewClass : AdministrationView       }
      ]


  constructor: (options = {}, data) ->

    data       or= kd.singletons.groupsController.getCurrentGroup()
    options.view = new AdminAppView
      title      : 'Team Dashboard'
      cssClass   : 'AppModal AppModal--admin'
      width      : 1000
      height     : '100%'
      overlay    : yes
      tabData    : NAV_ITEMS
    , data

    super options, data


  openSection: (section, query, action, identifier) ->

    targetPane = null

    @mainView.ready =>
      @mainView.tabs.panes.forEach (pane) ->
        paneAction = pane.getOption 'action'
        paneSlug   = pane.getOption 'slug'

        if action is paneAction
          targetPane = pane
        else if paneSlug is section
          targetPane = pane

      if targetPane
        @mainView.tabs.showPane targetPane
        targetPane.getMainView().handleIdentifier? identifier  if identifier
      else
        kd.singletons.router.handleRoute '/Admin/Settings'


  loadView: (modal) ->

    modal.once 'KDObjectWillBeDestroyed', ->
      { router } = kd.singletons
      previousRoutes = router.visitedRoutes.filter (route) -> not /^\/Admin.*/.test(route)
      if previousRoutes.length > 0
      then router.handleRoute previousRoutes.last
      else router.handleRoute router.getDefaultRoute()
<commit_msg>Admin: Integrations: Pass identifier to handler method.<commit_after>kd                         = require 'kd'
AppController              = require 'app/appcontroller'
AdminAppView               = require './adminappview'
AdminMembersView           = require './views/members/adminmembersview'
AdministrationView         = require './views/administrationview'
CustomViewsManager         = require './views/customviews/customviewsmanager'
TopicModerationView        = require './views/moderation/topicmoderationview'
GroupStackSettings         = require './views/groupstacksettings'
OnboardingAdminView        = require './views/onboarding/onboardingadminview'
AdminInvitationsView       = require './views/invitations/admininvitationsview'
GroupPermissionsView       = require './views/grouppermissionsview'
GroupsBlockedUserView      = require './views/groupsblockeduserview'
AdminIntegrationsView      = require './views/integrations/adminintegrationsview'
GroupGeneralSettingsView   = require './views/groupgeneralsettingsview'
AdminIntegrationParentView = require './views/integrations/adminintegrationparentview'


require('./routehandler')()


module.exports = class AdminAppController extends AppController

  @options     =
    name       : 'Admin'
    background : yes

  NAV_ITEMS    =
    teams      :
      title    : 'Team Settings'
      items    : [
        { slug : 'Settings',       title : 'Settings',          viewClass : GroupGeneralSettingsView }
        { slug : 'Members',        title : 'Members',           viewClass : AdminMembersView         }
        { slug : 'Invitations',    title : 'Invitations',       viewClass : AdminInvitationsView     }
        { slug : 'Permissions',    title : 'Permissions',       viewClass : GroupPermissionsView     }
        {
          slug      : 'Integrations'
          title     : 'Integrations'
          viewClass : AdminIntegrationsView,
          subTabs   : [
            { title : 'Add',        action: 'Add',              viewClass : AdminIntegrationParentView }
            { title : 'Configure',  action: 'Configure',        viewClass : AdminIntegrationParentView }
          ]
        }
        { slug : 'Stacks',         title : 'Compute Stacks',    viewClass : GroupStackSettings       }
      ]
    koding     :
      title    : 'Koding Administration'
      items    : [
        { slug : 'Blocked',        title : 'Blocked Users',     viewClass : GroupsBlockedUserView    }
        { slug : 'Widgets',        title : 'Custom Views',      viewClass : CustomViewsManager       }
        { slug : 'Onboarding',     title : 'Onboarding',        viewClass : OnboardingAdminView      }
        { slug : 'Moderation',     title : 'Topic Moderation',  viewClass : TopicModerationView      }
        { slug : 'Administration', title : 'Administration',    viewClass : AdministrationView       }
      ]


  constructor: (options = {}, data) ->

    data       or= kd.singletons.groupsController.getCurrentGroup()
    options.view = new AdminAppView
      title      : 'Team Dashboard'
      cssClass   : 'AppModal AppModal--admin'
      width      : 1000
      height     : '100%'
      overlay    : yes
      tabData    : NAV_ITEMS
    , data

    super options, data


  openSection: (section, query, action, identifier) ->

    targetPane = null

    @mainView.ready =>
      @mainView.tabs.panes.forEach (pane) ->
        paneAction = pane.getOption 'action'
        paneSlug   = pane.getOption 'slug'

        if action is paneAction
          targetPane = pane
        else if paneSlug is section
          targetPane = pane

      if targetPane
        @mainView.tabs.showPane targetPane
        if identifier
          targetPane.getMainView().handleIdentifier? identifier, action
      else
        kd.singletons.router.handleRoute '/Admin/Settings'


  loadView: (modal) ->

    modal.once 'KDObjectWillBeDestroyed', ->
      { router } = kd.singletons
      previousRoutes = router.visitedRoutes.filter (route) -> not /^\/Admin.*/.test(route)
      if previousRoutes.length > 0
      then router.handleRoute previousRoutes.last
      else router.handleRoute router.getDefaultRoute()

{'fraction_non_alphanumeric': 0.09481194824041601, 'fraction_numerical': 0.0019349377191921636, 'mean_word_length': 2.2405956112852663, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '790368', 'n_tokens_mistral': 2241, 'n_tokens_neox': 2130, 'n_words': 481}