summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/batch_comments/index.js
blob: 65fd34dcb0027955c76bc0021b8d1c9d70d3c9a4 (plain)
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
import Vue from 'vue';
import { mapActions, mapGetters } from 'vuex';
import store from '~/mr_notes/stores';

export const initReviewBar = () => {
  const el = document.getElementById('js-review-bar');

  // eslint-disable-next-line no-new
  new Vue({
    el,
    store,
    components: {
      ReviewBar: () => import('./components/review_bar.vue'),
    },
    computed: {
      ...mapGetters('batchComments', ['draftsCount']),
    },
    mounted() {
      this.fetchDrafts();
    },
    methods: {
      ...mapActions('batchComments', ['fetchDrafts']),
    },
    render(createElement) {
      if (this.draftsCount === 0) return null;

      return createElement('review-bar');
    },
  });
};