<commit_before>null

### @ngInject ###
global.cobudgetApp.directive 'bucketPageToolbar', () ->
    restrict: 'E'
    template: require('./bucket-page-toolbar.html')
    replace: true
    controller: (Dialog, LoadBar, $location, $scope, Toast) ->

      $scope.edit = ->
        $location.path("/buckets/#{$scope.bucket.id}/edit")

      $scope.userCanEditBucket = ->
        $scope.bucket && $scope.userCanStartFunding()

      $scope.archiveBucketAndRedirect = ->
        LoadBar.start()
        $scope.bucket.archive()
          .then ->
            groupId = $scope.bucket.groupId
            $location.path("/groups/#{groupId}")
          .catch ->
            Dialog.alert({title: "Error!"})
            LoadBar.stop()

      $scope.archive = ->
        if $scope.bucket.status == 'live'
          archiveBucketDialog = require('./../../components/archive-bucket-dialog/archive-bucket-dialog.coffee')({
            scope: $scope
          })
          Dialog.open(archiveBucketDialog)
        else
          $scope.archiveBucketAndRedirect()

      return<commit_msg>user cant edit archived bucket<commit_after>null

### @ngInject ###
global.cobudgetApp.directive 'bucketPageToolbar', () ->
    restrict: 'E'
    template: require('./bucket-page-toolbar.html')
    replace: true
    controller: (Dialog, LoadBar, $location, $scope, Toast) ->

      $scope.edit = ->
        $location.path("/buckets/#{$scope.bucket.id}/edit")

      $scope.userCanEditBucket = ->
        $scope.bucket && !$scope.bucket.isArchived() && $scope.userCanStartFunding()

      $scope.archiveBucketAndRedirect = ->
        LoadBar.start()
        $scope.bucket.archive()
          .then ->
            groupId = $scope.bucket.groupId
            $location.path("/groups/#{groupId}")
          .catch ->
            Dialog.alert({title: "Error!"})
            LoadBar.stop()

      $scope.archive = ->
        if $scope.bucket.status == 'live'
          archiveBucketDialog = require('./../../components/archive-bucket-dialog/archive-bucket-dialog.coffee')({
            scope: $scope
          })
          Dialog.open(archiveBucketDialog)
        else
          $scope.archiveBucketAndRedirect()

      return
{'fraction_non_alphanumeric': 0.15693430656934307, 'fraction_numerical': 0.0, 'mean_word_length': 2.1736613603473227, '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': '415848', 'n_tokens_mistral': 629, 'n_tokens_neox': 614, 'n_words': 92}