<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 AbilityService from '@/shared/services/ability_service'
import ModalService   from '@/shared/services/modal_service'

export default
  props:
    group: Object
  data: ->
    isGroupExportModalOpen: false
    isLeaveGroupModalOpen: false
    isArchiveGroupModalOpen: false
  methods:
    openChangeVolumeForm: ->
      ModalService.open 'ChangeVolumeForm', model: => @group.membershipFor(Session.user())

    editGroup: ->
      ModalService.open 'GroupModal', group: => @group

    addSubgroup: ->
      ModalService.open 'GroupModal', group: => Records.groups.build(parentId: @group.id)

    openGroupExportModal: ->
      @isGroupExportModalOpen = true
    closeGroupExportModal: ->
      @isGroupExportModalOpen = false
    openLeaveGroupModal: ->
      @isLeaveGroupModalOpen = true
    closeLeaveGroupModal: ->
      @isLeaveGroupModalOpen = false
    openArchiveGroupModal: ->
      @isArchiveGroupModalOpen = true
    closeArchiveGroupModal: ->
      @isArchiveGroupModalOpen = false

  computed:
    groupExportModalConfirmOpts: ->
      submit: @group.export
      text:
        title:    'group_export_modal.title'
        helptext: 'group_export_modal.body'
        submit:   'group_export_modal.submit'
        flash:    'group_export_modal.flash'

    leaveGroupModalConfirmOpts: ->
      submit:  Session.user().membershipFor(@group).destroy
      text:
        title:    'leave_group_form.title'
        helptext: 'leave_group_form.question'
        confirm:  'leave_group_form.submit'
        flash:    'group_page.messages.leave_group_success'
      redirect: 'dashboard'

    archiveGroupModalConfirmOpts: ->
      submit:     @group.archive
      text:
        title:    'archive_group_form.title'
        helptext: 'archive_group_form.question'
        flash:    'group_page.messages.archive_group_success'
      redirect:   'dashboard'

    canExportData: ->
      Session.user().isMemberOf(@group)

    canAdministerGroup: ->
      AbilityService.canAdministerGroup(@group)

    canEditGroup: ->
      AbilityService.canEditGroup(@group)

    canAddSubgroup: ->
      AbilityService.canCreateSubgroups(@group)

    canArchiveGroup: ->
      AbilityService.canArchiveGroup(@group)

    canLeaveGroup: ->
      AbilityService.canRemoveMembership(@group.membershipFor(Session.user()))

    canChangeVolume: ->
      AbilityService.canChangeGroupVolume(@group)
</script>

<template lang="pug">
v-menu.group-page-actions.lmo-no-print(offset-y)
  v-btn.group-page-actions__button(flat slot='activator')
    span(v-t="'group_page.options.label'")
    v-icon mdi-chevron-down
  v-list.group-actions-dropdown__menu-content
    v-list-tile.group-page-actions__edit-group-link(v-if='canEditGroup', @click='editGroup()' v-t="'group_page.options.edit_group'")
      v-list-tile-title(v-t="'group_page.options.edit_group'")
    v-list-tile.group-page-actions__change-volume-link(v-if='canChangeVolume', @click='openChangeVolumeForm()')
      v-list-tile-title(v-t="'group_page.options.email_settings'")
      //- <outlet name="after-group-actions-manage-memberships" model="group"></outlet>
      //- <outlet name="after-group-actions-manage-memberships-2" model="group"></outlet>
    v-list-tile.group-page-actions__export-json(v-if='canExportData', @click='openGroupExportModal()')
      v-list-tile-title(v-t="'group_page.options.export_data'")
    v-dialog(v-model="isGroupExportModalOpen", lazy persistent)
      confirm-modal(:confirm="groupExportModalConfirmOpts", :close="closeGroupExportModal")

    v-list-tile.group-page-actions__leave-group(v-if='canLeaveGroup', @click='openLeaveGroupModal()')
      v-list-tile-title(v-t="'group_page.options.leave_group'")
    v-dialog(v-model="isLeaveGroupModalOpen", lazy persistent)
      confirm-modal(:confirm="leaveGroupModalConfirmOpts", :close="closeLeaveGroupModal")

    v-list-tile.group-page-actions__archive-group(v-if='canArchiveGroup', @click='openArchiveGroupModal()')
      v-list-tile-title(v-t="'group_page.options.deactivate_group'")
    v-dialog(v-model="isArchiveGroupModalOpen", lazy persistent)
      confirm-modal(:confirm="archiveGroupModalConfirmOpts", :close="closeArchiveGroupModal")
</template><commit_msg>feat(modals): group dropdown action modals<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 AbilityService from '@/shared/services/ability_service'
import ModalService   from '@/shared/services/modal_service'
import ConfirmModalMixin from '@/mixins/confirm_modal'

export default
  mixins: [
    ConfirmModalMixin
  ]
  props:
    group: Object
  methods:
    openChangeVolumeForm: ->
      ModalService.open 'ChangeVolumeForm', model: => @group.membershipFor(Session.user())

    editGroup: ->
      ModalService.open 'GroupModal', group: => @group

    addSubgroup: ->
      ModalService.open 'GroupModal', group: => Records.groups.build(parentId: @group.id)

    openGroupExportModal: ->
      @openConfirmModal(@groupExportModalConfirmOpts)

    openLeaveGroupModal: ->
      @openConfirmModal(@leaveGroupModalConfirmOpts)

    openArchiveGroupModal: ->
      @openConfirmModal(@archiveGroupModalConfirmOpts)

  computed:
    groupExportModalConfirmOpts: ->
      submit: @group.export
      text:
        title:    'group_export_modal.title'
        helptext: 'group_export_modal.body'
        submit:   'group_export_modal.submit'
        flash:    'group_export_modal.flash'

    leaveGroupModalConfirmOpts: ->
      submit:  Session.user().membershipFor(@group).destroy
      text:
        title:    'leave_group_form.title'
        helptext: 'leave_group_form.question'
        confirm:  'leave_group_form.submit'
        flash:    'group_page.messages.leave_group_success'
      redirect: 'dashboard'

    archiveGroupModalConfirmOpts: ->
      submit:     @group.archive
      text:
        title:    'archive_group_form.title'
        helptext: 'archive_group_form.question'
        flash:    'group_page.messages.archive_group_success'
      redirect:   'dashboard'

    canExportData: ->
      Session.user().isMemberOf(@group)

    canAdministerGroup: ->
      AbilityService.canAdministerGroup(@group)

    canEditGroup: ->
      AbilityService.canEditGroup(@group)

    canAddSubgroup: ->
      AbilityService.canCreateSubgroups(@group)

    canArchiveGroup: ->
      AbilityService.canArchiveGroup(@group)

    canLeaveGroup: ->
      AbilityService.canRemoveMembership(@group.membershipFor(Session.user()))

    canChangeVolume: ->
      AbilityService.canChangeGroupVolume(@group)
</script>

<template lang="pug">
v-menu.group-page-actions.lmo-no-print(offset-y)
  v-btn.group-page-actions__button(flat slot='activator')
    span(v-t="'group_page.options.label'")
    v-icon mdi-chevron-down
  v-list.group-actions-dropdown__menu-content
    v-list-tile.group-page-actions__edit-group-link(v-if='canEditGroup', @click='editGroup()' v-t="'group_page.options.edit_group'")
      v-list-tile-title(v-t="'group_page.options.edit_group'")

    v-list-tile.group-page-actions__change-volume-link(v-if='canChangeVolume', @click='openChangeVolumeForm()')
      v-list-tile-title(v-t="'group_page.options.email_settings'")

    v-list-tile.group-page-actions__export-json(v-if='canExportData', @click='openGroupExportModal()')
      v-list-tile-title(v-t="'group_page.options.export_data'")

    v-list-tile.group-page-actions__leave-group(v-if='canLeaveGroup', @click='openLeaveGroupModal()')
      v-list-tile-title(v-t="'group_page.options.leave_group'")

    v-list-tile.group-page-actions__archive-group(v-if='canArchiveGroup', @click='openArchiveGroupModal()')
      v-list-tile-title(v-t="'group_page.options.deactivate_group'")
</template>
{'fraction_non_alphanumeric': 0.13070022427111885, 'fraction_numerical': 0.000124595066035385, 'mean_word_length': 3.8737097753491194, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 57, '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': '2358698', 'n_tokens_mistral': 2533, 'n_tokens_neox': 2476, 'n_words': 309}