debian-mirror-gitlab/app/assets/javascripts/notes/index.js

63 lines
1.7 KiB
JavaScript
Raw Normal View History

2018-03-17 18:26:18 +05:30
import Vue from 'vue';
import notesApp from './components/notes_app.vue';
2018-12-13 13:39:08 +05:30
import initDiscussionFilters from './discussion_filters';
2020-04-22 19:07:51 +05:30
import initSortDiscussions from './sort_discussions';
2021-01-03 14:25:43 +05:30
import initTimelineToggle from './timeline';
2020-05-24 23:13:21 +05:30
import { store } from './stores';
2018-03-17 18:26:18 +05:30
2021-01-03 14:25:43 +05:30
const el = document.getElementById('js-vue-notes');
if (el) {
2019-07-07 11:18:12 +05:30
// eslint-disable-next-line no-new
new Vue({
2021-01-03 14:25:43 +05:30
el,
2018-11-08 19:23:39 +05:30
components: {
notesApp,
},
store,
data() {
2021-01-03 14:25:43 +05:30
const notesDataset = el.dataset;
2018-11-08 19:23:39 +05:30
const parsedUserData = JSON.parse(notesDataset.currentUserData);
const noteableData = JSON.parse(notesDataset.noteableData);
let currentUserData = {};
2018-03-17 18:26:18 +05:30
2018-11-08 19:23:39 +05:30
noteableData.noteableType = notesDataset.noteableType;
noteableData.targetType = notesDataset.targetType;
2020-10-24 23:57:45 +05:30
if (noteableData.discussion_locked === null) {
// discussion_locked has never been set for this issuable.
// set to `false` for safety.
noteableData.discussion_locked = false;
}
2018-05-09 12:01:36 +05:30
2018-11-08 19:23:39 +05:30
if (parsedUserData) {
currentUserData = {
id: parsedUserData.id,
name: parsedUserData.name,
username: parsedUserData.username,
avatar_url: parsedUserData.avatar_path || parsedUserData.avatar_url,
path: parsedUserData.path,
2018-05-09 12:01:36 +05:30
};
2018-11-08 19:23:39 +05:30
}
return {
noteableData,
currentUserData,
notesData: JSON.parse(notesDataset.notesData),
};
},
render(createElement) {
return createElement('notes-app', {
props: {
noteableData: this.noteableData,
notesData: this.notesData,
userData: this.currentUserData,
},
});
},
});
2019-07-07 11:18:12 +05:30
initDiscussionFilters(store);
2020-04-22 19:07:51 +05:30
initSortDiscussions(store);
2021-01-03 14:25:43 +05:30
initTimelineToggle(store);
}