BigW Consortium Gitlab

subscriptions.vue 1.22 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
<script>
import { __ } from '../../../locale';
import eventHub from '../../event_hub';
import loadingButton from '../../../vue_shared/components/loading_button.vue';

export default {
  props: {
    loading: {
      type: Boolean,
      required: false,
      default: false,
    },
    subscribed: {
      type: Boolean,
      required: false,
    },
  },
  components: {
    loadingButton,
  },
  computed: {
    buttonLabel() {
      let label;
      if (this.subscribed === false) {
        label = __('Subscribe');
      } else if (this.subscribed === true) {
        label = __('Unsubscribe');
      }

      return label;
    },
  },
  methods: {
    toggleSubscription() {
      eventHub.$emit('toggleSubscription');
    },
  },
};
</script>

<template>
  <div>
    <div class="sidebar-collapsed-icon">
      <i
        class="fa fa-rss"
        aria-hidden="true">
      </i>
    </div>
    <span class="issuable-header-text hide-collapsed pull-left">
      {{ __('Notifications') }}
    </span>
    <loading-button
      ref="loadingButton"
      class="btn btn-default pull-right hide-collapsed js-issuable-subscribe-button"
      :loading="loading"
      :label="buttonLabel"
      @click="toggleSubscription"
    />
  </div>
</template>