summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/mr_notes/index.js
blob: a0c49ead77e0a8d96b79ef9ee4c9332feca71e8a (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import Vue from 'vue';
import notesApp from '../notes/components/notes_app.vue';
import discussionCounter from '../notes/components/discussion_counter.vue';
import store from '../notes/stores';

document.addEventListener('DOMContentLoaded', () => {
  new Vue({ // eslint-disable-line
    el: '#js-vue-mr-discussions',
    components: {
      notesApp,
    },
    data() {
      const notesDataset = document.getElementById('js-vue-mr-discussions').dataset;
      return {
        issueData: JSON.parse(notesDataset.issueData),
        currentUserData: JSON.parse(notesDataset.currentUserData),
        notesData: {
          lastFetchedAt: notesDataset.lastFetchedAt,
          discussionsPath: notesDataset.discussionsPath,
          newSessionPath: notesDataset.newSessionPath,
          registerPath: notesDataset.registerPath,
          notesPath: notesDataset.notesPath,
          markdownDocsPath: notesDataset.markdownDocsPath,
          quickActionsDocsPath: notesDataset.quickActionsDocsPath,
        },
      };
    },
    render(createElement) {
      return createElement('notes-app', {
        props: {
          noteableData: this.issueData,
          notesData: this.notesData,
          userData: this.currentUserData,
        },
      });
    },
  });

  new Vue({ // eslint-disable-line
    el: '#js-vue-discussion-counter',
    components: {
      discussionCounter,
    },
    store,
    render(createElement) {
      return createElement('discussion-counter');
    },
  });
});