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

67 lines
1.8 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';
2020-05-24 23:13:21 +05:30
import { store } from './stores';
2021-03-11 19:13:27 +05:30
import initTimelineToggle from './timeline';
2018-03-17 18:26:18 +05:30
2021-10-27 15:23:28 +05:30
export default () => {
const el = document.getElementById('js-vue-notes');
if (!el) {
return;
}
2021-01-03 14:25:43 +05:30
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,
2022-04-04 11:22:00 +05:30
name: 'NotesRoot',
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);
2021-10-27 15:23:28 +05:30
};