2017-06-08 22:50:11 +00:00
|
|
|
import Vue from 'vue';
|
2017-12-08 20:24:52 +00:00
|
|
|
import notesApp from './components/notes_app.vue';
|
2018-10-23 09:49:45 +00:00
|
|
|
import initDiscussionFilters from './discussion_filters';
|
2020-03-26 09:07:52 +00:00
|
|
|
import initSortDiscussions from './sort_discussions';
|
2020-05-08 15:09:28 +00:00
|
|
|
import { store } from './stores';
|
2021-02-14 18:09:20 +00:00
|
|
|
import initTimelineToggle from './timeline';
|
2017-06-08 22:50:11 +00:00
|
|
|
|
2021-07-28 18:10:23 +00:00
|
|
|
export default () => {
|
|
|
|
const el = document.getElementById('js-vue-notes');
|
|
|
|
if (!el) {
|
|
|
|
return;
|
|
|
|
}
|
2020-09-22 15:09:37 +00:00
|
|
|
|
2019-03-13 10:00:29 +00:00
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
2020-09-22 15:09:37 +00:00
|
|
|
el,
|
2018-06-21 12:22:40 +00:00
|
|
|
components: {
|
|
|
|
notesApp,
|
|
|
|
},
|
|
|
|
store,
|
2020-05-07 21:09:26 +00:00
|
|
|
data() {
|
2020-09-22 15:09:37 +00:00
|
|
|
const notesDataset = el.dataset;
|
2020-05-07 21:09:26 +00:00
|
|
|
const parsedUserData = JSON.parse(notesDataset.currentUserData);
|
|
|
|
const noteableData = JSON.parse(notesDataset.noteableData);
|
|
|
|
let currentUserData = {};
|
2018-04-03 16:03:00 +00:00
|
|
|
|
2020-05-07 21:09:26 +00:00
|
|
|
noteableData.noteableType = notesDataset.noteableType;
|
|
|
|
noteableData.targetType = notesDataset.targetType;
|
2020-07-29 15:09:39 +00:00
|
|
|
if (noteableData.discussion_locked === null) {
|
|
|
|
// discussion_locked has never been set for this issuable.
|
|
|
|
// set to `false` for safety.
|
|
|
|
noteableData.discussion_locked = false;
|
|
|
|
}
|
2017-07-27 20:24:05 +00:00
|
|
|
|
2020-05-07 21:09:26 +00:00
|
|
|
if (parsedUserData) {
|
|
|
|
currentUserData = {
|
|
|
|
id: parsedUserData.id,
|
|
|
|
name: parsedUserData.name,
|
|
|
|
username: parsedUserData.username,
|
|
|
|
avatar_url: parsedUserData.avatar_path || parsedUserData.avatar_url,
|
|
|
|
path: parsedUserData.path,
|
2020-05-06 15:09:42 +00:00
|
|
|
};
|
2020-05-07 21:09:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
noteableData,
|
|
|
|
currentUserData,
|
|
|
|
notesData: JSON.parse(notesDataset.notesData),
|
|
|
|
};
|
2018-06-21 12:22:40 +00:00
|
|
|
},
|
|
|
|
render(createElement) {
|
|
|
|
return createElement('notes-app', {
|
2020-05-07 21:09:26 +00:00
|
|
|
props: {
|
|
|
|
noteableData: this.noteableData,
|
|
|
|
notesData: this.notesData,
|
|
|
|
userData: this.currentUserData,
|
|
|
|
},
|
2018-06-21 12:22:40 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
2019-03-13 10:00:29 +00:00
|
|
|
|
|
|
|
initDiscussionFilters(store);
|
2020-03-26 09:07:52 +00:00
|
|
|
initSortDiscussions(store);
|
2020-10-05 15:08:56 +00:00
|
|
|
initTimelineToggle(store);
|
2021-07-28 18:10:23 +00:00
|
|
|
};
|