<commit_before><script lang="coffee">

import AppConfig         from '@/shared/services/app_config'
import Session           from '@/shared/services/session'
import Records           from '@/shared/services/records'
import EventBus          from '@/shared/services/event_bus'
import AbilityService    from '@/shared/services/ability_service'
import LmoUrlService     from '@/shared/services/lmo_url_service'
import { subscribeTo }   from '@/shared/helpers/cable'
import {compact, head, includes, filter} from 'lodash-es'
import ahoy from 'ahoy.js'

export default
  data: ->
    group: null
    activeTab: ''
    groupFetchError: null

  created: ->
    @init()
    EventBus.$on 'signedIn', @init

  beforeDestroy: ->
    EventBus.$off 'signedIn', @init

  watch:
    '$route.params.key': 'init'

  computed:
    canEditGroup: ->
      AbilityService.canEditGroup(@group)

    tabs: ->
      return unless @group
      query = ''
      query = '?subgroups='+@$route.query.subgroups if @$route.query.subgroups

      [
        {id: 0, name: 'threads',   route: @urlFor(@group, null)+query}
        {id: 1, name: 'polls',     route: @urlFor(@group, 'polls')+query},
        {id: 2, name: 'members',   route: @urlFor(@group, 'members')+query},
        {id: 4, name: 'files',     route: @urlFor(@group, 'files')+query}
        {id: 5, name: 'subgroups',  route: @urlFor(@group, 'subgroups')+query}
        {id: 6, name: 'settings',  route: @urlFor(@group, 'settings')}
      ].filter (obj) => !(obj.name == "subgroups" && @group.parent())

    coverImageSrc: ->
      if @group
        @group.coverUrl()
      else
        ''

  methods:
    init: ->
      Records.samlProviders.authenticateForGroup(@$route.params.key)
      Records.groups.findOrFetch(@$route.params.key)
      .then (group) =>
        @group = group
        ahoy.trackView
          groupId: @group.id
          organisationId: @group.parentOrSelf().id
          pageType: 'groupPage'
        subscribeTo(@group)
      .catch (error) =>
        EventBus.$emit 'pageError', error
        EventBus.$emit 'openAuthModal' if error.status == 403 && !Session.isSignedIn()

    titleVisible: (visible) ->
      EventBus.$emit('content-title-visible', visible)

    openGroupSettingsModal: ->
      return null unless @canEditGroup
      EventBus.$emit 'openModal',
        component: 'GroupForm'
        props:
          group: @group

</script>

<template lang="pug">
v-main
  loading(v-if="!group")
  v-container.group-page.max-width-1024(v-if="group")
    v-img(style="border-radius: 8px" :src="coverImageSrc" eager)
    h1.display-1.my-4(v-observe-visibility="{callback: titleVisible}")
      span(v-if="group && group.parent()")
        router-link(:to="urlFor(group.parent())") {{group.parent().name}}
        space
        span.grey--text.text--lighten-1 &gt;
        space
      span.group-page__name.mr-4
        | {{group.name}}
    join-group-button(:group='group')
    trial-banner(:group="group")
    group-onboarding-card(:group="group")
    formatted-text.group-page__description(v-if="group" :model="group" column="description")
    document-list(:model='group')
    attachment-list(:attachments="group.attachments" :edit="canEditGroup && openGroupSettingsModal")
    v-divider.mt-4
    v-tabs(v-model="activeTab" center-active background-color="transparent" centered grow show-arrows)
      v-tabs-slider
      v-tab(v-for="tab of tabs" :key="tab.id" :to="tab.route" :class="'group-page-' + tab.name + '-tab' " exact)
        span(v-t="'group_page.'+tab.name")
    router-view
</template>

<style lang="sass">
.group-page-tabs
	.v-tab<commit_msg>move join group button to below the group description<commit_after><script lang="coffee">

import AppConfig         from '@/shared/services/app_config'
import Session           from '@/shared/services/session'
import Records           from '@/shared/services/records'
import EventBus          from '@/shared/services/event_bus'
import AbilityService    from '@/shared/services/ability_service'
import LmoUrlService     from '@/shared/services/lmo_url_service'
import { subscribeTo }   from '@/shared/helpers/cable'
import {compact, head, includes, filter} from 'lodash-es'
import ahoy from 'ahoy.js'

export default
  data: ->
    group: null
    activeTab: ''
    groupFetchError: null

  created: ->
    @init()
    EventBus.$on 'signedIn', @init

  beforeDestroy: ->
    EventBus.$off 'signedIn', @init

  watch:
    '$route.params.key': 'init'

  computed:
    canEditGroup: ->
      AbilityService.canEditGroup(@group)

    tabs: ->
      return unless @group
      query = ''
      query = '?subgroups='+@$route.query.subgroups if @$route.query.subgroups

      [
        {id: 0, name: 'threads',   route: @urlFor(@group, null)+query}
        {id: 1, name: 'polls',     route: @urlFor(@group, 'polls')+query},
        {id: 2, name: 'members',   route: @urlFor(@group, 'members')+query},
        {id: 4, name: 'files',     route: @urlFor(@group, 'files')+query}
        {id: 5, name: 'subgroups',  route: @urlFor(@group, 'subgroups')+query}
        {id: 6, name: 'settings',  route: @urlFor(@group, 'settings')}
      ].filter (obj) => !(obj.name == "subgroups" && @group.parent())

    coverImageSrc: ->
      if @group
        @group.coverUrl()
      else
        ''

  methods:
    init: ->
      Records.samlProviders.authenticateForGroup(@$route.params.key)
      Records.groups.findOrFetch(@$route.params.key)
      .then (group) =>
        @group = group
        ahoy.trackView
          groupId: @group.id
          organisationId: @group.parentOrSelf().id
          pageType: 'groupPage'
        subscribeTo(@group)
      .catch (error) =>
        EventBus.$emit 'pageError', error
        EventBus.$emit 'openAuthModal' if error.status == 403 && !Session.isSignedIn()

    titleVisible: (visible) ->
      EventBus.$emit('content-title-visible', visible)

    openGroupSettingsModal: ->
      return null unless @canEditGroup
      EventBus.$emit 'openModal',
        component: 'GroupForm'
        props:
          group: @group

</script>

<template lang="pug">
v-main
  loading(v-if="!group")
  v-container.group-page.max-width-1024(v-if="group")
    v-img(style="border-radius: 8px" :src="coverImageSrc" eager)
    h1.display-1.my-4(v-observe-visibility="{callback: titleVisible}")
      span(v-if="group && group.parent()")
        router-link(:to="urlFor(group.parent())") {{group.parent().name}}
        space
        span.grey--text.text--lighten-1 &gt;
        space
      span.group-page__name.mr-4
        | {{group.name}}
    trial-banner(:group="group")
    group-onboarding-card(:group="group")
    formatted-text.group-page__description(v-if="group" :model="group" column="description")
    join-group-button(:group='group')
    document-list(:model='group')
    attachment-list(:attachments="group.attachments" :edit="canEditGroup && openGroupSettingsModal")
    v-divider.mt-4
    v-tabs(v-model="activeTab" center-active background-color="transparent" centered grow show-arrows)
      v-tabs-slider
      v-tab(v-for="tab of tabs" :key="tab.id" :to="tab.route" :class="'group-page-' + tab.name + '-tab' " exact)
        span(v-t="'group_page.'+tab.name")
    router-view
</template>

<style lang="sass">
.group-page-tabs
	.v-tab
{'fraction_non_alphanumeric': 0.16341664377918155, 'fraction_numerical': 0.005492996429552321, 'mean_word_length': 2.9950630828304994, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 37, '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': '1863622', 'n_tokens_mistral': 2411, 'n_tokens_neox': 2340, 'n_words': 455}