diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-07-27 21:24:05 +0100 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-07-27 21:25:02 +0100 |
commit | d34c620fae23597e0130474fe20883f0718ded58 (patch) | |
tree | da89ba9fc2dcbc731fb3fd1e98dc25ad063455f8 /app/assets/javascripts/notes/index.js | |
parent | 487ed06f444892abce47a6e21aaea79c9ca9c800 (diff) | |
download | gitlab-ce-d34c620fae23597e0130474fe20883f0718ded58.tar.gz |
[ci skip] Add issue data and notes data provided through haml to the store to stop querying the DOM everywhere
Diffstat (limited to 'app/assets/javascripts/notes/index.js')
-rw-r--r-- | app/assets/javascripts/notes/index.js | 58 |
1 files changed, 36 insertions, 22 deletions
diff --git a/app/assets/javascripts/notes/index.js b/app/assets/javascripts/notes/index.js index 914e08ff112..0bf52b551f4 100644 --- a/app/assets/javascripts/notes/index.js +++ b/app/assets/javascripts/notes/index.js @@ -1,25 +1,39 @@ import Vue from 'vue'; -import issueNotes from './components/issue_notes.vue'; -import '../vue_shared/vue_resource_interceptor'; +import issueNotesApp from './components/issue_notes_app.vue'; -document.addEventListener('DOMContentLoaded', () => { - const vm = new Vue({ - el: '#js-notes', - components: { - issueNotes, - }, - render(createElement) { - return createElement('issue-notes', { - attrs: { - ref: 'notes', - }, - }); - }, - }); +document.addEventListener('DOMContentLoaded', () => new Vue({ + el: '#js-vue-notes', + components: { + issueNotesApp, + }, + data() { + const notesDataset = document.getElementById('js-vue-notes').dataset; - window.issueNotes = { - refresh() { - vm.$refs.notes.$store.dispatch('poll'); - }, - }; -}); + return { + issueData: JSON.parse(notesDataset.issueData), + currentUserData: JSON.parse(notesDataset.currentUserData), + notesData: { + lastFetchedAt: notesDataset.lastFetchedAt, + discussionsPath: notesDataset.discussionsPath, + }, + }; + }, + render(createElement) { + return createElement('issue-notes-app', { + attrs: { + ref: 'notes', + }, + props: { + issueData: this.issueData, + notesData: this.notesData, + }, + }); + }, +})); + + // // TODO: FILIPA: FIX THIS + // window.issueNotes = { + // refresh() { + // vm.$refs.notes.$store.dispatch('poll'); + // }, + // }; |