<commit_before><commit_msg>blind pass at sidebar.vue<commit_after><style>
</style>

<script lang="coffee">
AppConfig      = require 'shared/services/app_config'
Session        = require 'shared/services/session'
Records        = require 'shared/services/records'
EventBus       = require 'shared/services/event_bus'
AbilityService = require 'shared/services/ability_service'
LmoUrlService  = require 'shared/services/lmo_url_service'
InboxService   = require 'shared/services/inbox_service'
ModalService   = require 'shared/services/modal_service'

module.exports =
  data: ->
    currentState: ""
    showSidebar: true
  created: ->
    InboxService.load()
    EventBus.listen @, 'toggleSidebar', (event, show) =>
      if !_.isUndefined(show)
        @showSidebar = show
      else
        @showSidebar = !@showSidebar

    EventBus.listen @, 'currentComponent', (el, component) =>
      @currentState = component
  computed:
    orderedGroups: ->
      _.sortBy @groups(), 'fullName'
  methods:
    canStartThreads: ->
      _.some Session.user().groups(), (group) => AbilityService.canStartThread(group)

    availableGroups: ->
      _.filter Session.user().groups(), (group) => group.type == 'FormalGroup'

    currentGroup: ->
      return _.head(availableGroups()) if availableGroups().length == 1
      _.find(availableGroups(), (g) => g.id == (AppConfig.currentGroup or {}).id) || Records.groups.build()

    onPage: (page, key, filter) ->
      switch page
        when 'groupPage' then @currentState.key == key
        when 'dashboardPage' then @currentState.page == page && @currentState.filter == filter
        else @currentState.page == page

    groupUrl: (group) ->
      LmoUrlService.group(group)

    unreadThreadCount: ->
      InboxService.unreadCount()

    canLockSidebar: -> $mdMedia("gt-sm")

    sidebarItemSelected: ->
      $mdSidenav('left').close() if !@canLockSidebar()

    groups: ->
      _.filter Session.user().groups().concat(Session.user().orphanParents()), (group) =>
        group.type == "FormalGroup"

    currentUser: ->
      Session.user()

    canStartGroup: -> AbilityService.canStartGroups()
    canViewPublicGroups: -> AbilityService.canViewPublicGroups()

    startGroup: ->
      ModalService.open 'GroupModal', group: => Records.groups.build()

    startThread: ->
      ModalService.open 'DiscussionStartModal', discussion: => Records.discussions.build(groupId: @currentGroup().id)
</script>

<template>
  <v-navigation-drawer role="navigation" md-component-id="left" :md-is-open="showSidebar" :md-is-locked-open="canLockSidebar() && showSidebar" md-whiteframe="4" aria-label="$t('sidebar.aria_labels.heading')" aria-hidden="!showSidebar" class="md-sidenav-left lmo-no-print">
    <div md_content layout="column" @click="sidebarItemSelected()" role="navigation" class="sidebar__content lmo-no-print">
      <v-divider class="sidebar__divider"></v-divider>
      <v-list layout="column" aria-label="$t('sidebar.aria_labels.threads_list')" class="sidebar__list sidebar__threads">
        <v-list-tile href="/polls" lmo-href="/polls" @click="isActive()" aria-label="$t('sidebar.my_decisions')" :class="{'sidebar__list-item--selected': onPage('pollsPage')}" class="sidebar__list-item-button sidebar__list-item-button--decisions">
          <v-list-tile-action class="sidebar__list-item-icon mdi mdi-thumbs-up-down"></v-list-tile-action>
          <span v-t="'common.decisions'"></span>
        </v-list-tile>
        <v-list-tile href="/dashboard" lmo-href="/dashboard" @click="isActive()" aria-label="$t('sidebar.recent')" :class="{'sidebar__list-item--selected': onPage('dashboardPage')}" class="sidebar__list-item-button sidebar__list-item-button--recent">
          <i class="sidebar__list-item-icon mdi mdi-forum"></i>
          <span v-t="'sidebar.recent_threads'"></span>
        </v-list-tile>
        <v-list-tile href="/inbox" lmo-href="/inbox" @click="isActive()" aria-label="$t('sidebar.unread')" :class="{'sidebar__list-item--selected': onPage('inboxPage')}" class="sidebar__list-item-button sidebar__list-item-button--unread">
          <i class="sidebar__list-item-icon mdi mdi-inbox"></i>
          <span v-t="{ path: 'sidebar.unread_threads', args: { count: unreadThreadCount() } }"></span>
        </v-list-tile>
        <v-list-tile href="/dashboard/show_muted" lmo-href="/dashboard/show_muted" @click="isActive()" aria-label="$t('sidebar.muted')" :class="{'sidebar__list-item--selected': onPage('dashboardPage', nil, 'show_muted')}" class="sidebar__list-item-button sidebar__list-item-button--muted">
          <i class="sidebar__list-item-icon mdi mdi-volume-mute"></i>
          <span v-t="'sidebar.muted_threads'"></span>
        </v-list-tile>
        <v-list-tile v-if="canStartThreads()" @click="startThread()" aria-label="$t('sidebar.start_thread')" class="sidebar__list-item-button sidebar__list-item-button--start-thread">
          <i class="sidebar__list-item-icon mdi mdi-plus"></i>
          <span v-t="'sidebar.start_thread'"></span>
        </v-list-tile>
      </v-list>
      <v-divider class="sidebar__divider"></v-divider>
      <v-list-tile v-t="'common.groups'" class="sidebar__list-subhead"></v-list-tile>
      <v-list :class="{'sidebar__no-groups': groups().length < 1}" aria-label="$t('sidebar.aria_labels.groups_list')" class="sidebar__list sidebar__groups">
        <div v-for="group in orderedGroups" :key="group.id">
          <v-list-tile :href="groupUrl(group)" lmo-href="groupUrl(group)" :aria-label="group.name" v-if="group.isParent()" :class="{'sidebar__list-item--selected': onPage('groupPage', group.key)}" class="sidebar__list-item-button sidebar__list-item-button--group">
            <img :src="group.logoUrl()" class="md-avatar lmo-box--tiny sidebar__list-item-group-logo">
            <span>{{group.name}}</span>
          </v-list-tile>
          <v-list-tile :href="groupUrl(group)" lmo-href="groupUrl(group)" v-if="!group.isParent()" :class="{'sidebar__list-item--selected': onPage('groupPage', group.key)}" class="sidebar__list-item-button--subgroup lmo-flex">{{group.name}}</v-list-tile>
          <div class="sidebar__list-item-padding"></div>
        </div>
        <v-list-tile v-if="canViewPublicGroups()" href="/explore" lmo-href="/explore" aria-label="$t('sidebar.explore')" :class="{'sidebar__list-item--selected': onPage('explorePage')}" class="sidebar__list-item-button sidebar__list-item-button--explore">
          <i class="sidebar__list-item-icon mdi mdi-earth"></i>
          <span v-t="'sidebar.explore'"></span>
        </v-list-tile>
        <v-list-tile v-if="canStartGroup()" @click="startGroup()" aria-label="$t('sidebar.start_group')" class="sidebar__list-item-button sidebar__list-item-button--start-group">
          <i class="sidebar__list-item-icon mdi mdi-plus"></i>
          <span v-t="'sidebar.start_group'"></span>
        </v-list-tile>
      </v-list>
    </div>
  </v-navigation-drawer>
</template>

{'fraction_non_alphanumeric': 0.1824722981723989, 'fraction_numerical': 0.00043171679378327816, 'mean_word_length': 3.8703573931324455, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 101, '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': '2479836', 'n_tokens_mistral': 2261, 'n_tokens_neox': 2209, 'n_words': 332}