summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/notes/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/notes/index.js')
-rw-r--r--app/assets/javascripts/notes/index.js53
1 files changed, 29 insertions, 24 deletions
diff --git a/app/assets/javascripts/notes/index.js b/app/assets/javascripts/notes/index.js
index defcb0533b7..95263e666b2 100644
--- a/app/assets/javascripts/notes/index.js
+++ b/app/assets/javascripts/notes/index.js
@@ -1,5 +1,6 @@
import Vue from 'vue';
import { parseBoolean } from '~/lib/utils/common_utils';
+import { getLocationHash } from '~/lib/utils/url_utility';
import NotesApp from './components/notes_app.vue';
import { store } from './stores';
import { getNotesFilterData } from './utils/get_notes_filter_data';
@@ -13,6 +14,34 @@ export default () => {
const notesFilterProps = getNotesFilterData(el);
const showTimelineViewToggle = parseBoolean(el.dataset.showTimelineViewToggle);
+ const notesDataset = el.dataset;
+ const parsedUserData = JSON.parse(notesDataset.currentUserData);
+ const noteableData = JSON.parse(notesDataset.noteableData);
+ let currentUserData = {};
+
+ noteableData.noteableType = notesDataset.noteableType;
+ noteableData.targetType = notesDataset.targetType;
+ noteableData.discussion_locked = parseBoolean(noteableData.discussion_locked);
+
+ if (parsedUserData) {
+ currentUserData = {
+ id: parsedUserData.id,
+ name: parsedUserData.name,
+ username: parsedUserData.username,
+ avatar_url: parsedUserData.avatar_path || parsedUserData.avatar_url,
+ path: parsedUserData.path,
+ can_add_timeline_events: parseBoolean(notesDataset.canAddTimelineEvents),
+ };
+ }
+
+ const notesData = JSON.parse(notesDataset.notesData);
+
+ store.dispatch('setNotesData', notesData);
+ store.dispatch('setNoteableData', noteableData);
+ store.dispatch('setUserData', currentUserData);
+ store.dispatch('setTargetNoteHash', getLocationHash());
+ store.dispatch('fetchNotes');
+
// eslint-disable-next-line no-new
new Vue({
el,
@@ -25,30 +54,6 @@ export default () => {
showTimelineViewToggle,
},
data() {
- const notesDataset = el.dataset;
- const parsedUserData = JSON.parse(notesDataset.currentUserData);
- const noteableData = JSON.parse(notesDataset.noteableData);
- let currentUserData = {};
-
- noteableData.noteableType = notesDataset.noteableType;
- noteableData.targetType = notesDataset.targetType;
- if (noteableData.discussion_locked === null) {
- // discussion_locked has never been set for this issuable.
- // set to `false` for safety.
- noteableData.discussion_locked = false;
- }
-
- if (parsedUserData) {
- currentUserData = {
- id: parsedUserData.id,
- name: parsedUserData.name,
- username: parsedUserData.username,
- avatar_url: parsedUserData.avatar_path || parsedUserData.avatar_url,
- path: parsedUserData.path,
- can_add_timeline_events: parseBoolean(notesDataset.canAddTimelineEvents),
- };
- }
-
return {
noteableData,
currentUserData,