Skip to content
Snippets Groups Projects
Commit f8efaf1b authored by Simon Knox's avatar Simon Knox Committed by Fatih Acet
Browse files

issue note store

parent 3a8d646f
No related branches found
No related tags found
No related merge requests found
Showing
with 52 additions and 52 deletions
Loading
Loading
@@ -22,7 +22,7 @@
noteType: constants.COMMENT,
// Can't use mapGetters,
// this needs to be in the data object because it belongs to the state
issueState: this.$store.getters.getIssueData.state,
issueState: this.$store.getters.getNoteableData.state,
isSubmitting: false,
isSubmitButtonDisabled: true,
};
Loading
Loading
@@ -46,7 +46,7 @@
...mapGetters([
'getCurrentUserLastNote',
'getUserData',
'getIssueData',
'getNoteableData',
'getNotesData',
]),
isLoggedIn() {
Loading
Loading
@@ -59,7 +59,7 @@
return this.issueState === constants.OPENED || this.issueState === constants.REOPENED;
},
canCreateNote() {
return this.getIssueData.current_user.can_create_note;
return this.getNoteableData.current_user.can_create_note;
},
issueActionButtonTitle() {
if (this.note.length) {
Loading
Loading
@@ -85,16 +85,16 @@
return this.getNotesData.quickActionsDocsPath;
},
markdownPreviewPath() {
return this.getIssueData.preview_note_path;
return this.getNoteableData.preview_note_path;
},
author() {
return this.getUserData;
},
canUpdateIssue() {
return this.getIssueData.current_user.can_update;
return this.getNoteableData.current_user.can_update;
},
endpoint() {
return this.getIssueData.create_note_path;
return this.getNoteableData.create_note_path;
},
},
methods: {
Loading
Loading
@@ -119,7 +119,7 @@
data: {
note: {
noteable_type: constants.NOTEABLE_TYPE,
noteable_id: this.getIssueData.id,
noteable_id: this.getNoteableData.id,
note: this.note,
},
},
Loading
Loading
@@ -207,7 +207,7 @@
},
initAutoSave() {
if (this.isLoggedIn) {
this.autosave = new Autosave($(this.$refs.textarea), ['Note', 'Issue', this.getIssueData.id], 'issue');
this.autosave = new Autosave($(this.$refs.textarea), ['Note', 'Issue', this.getNoteableData.id], 'issue');
}
},
initTaskList() {
Loading
Loading
@@ -266,9 +266,9 @@
<div class="error-alert"></div>
 
<issue-warning
v-if="hasWarning(getIssueData)"
:is-locked="isLocked(getIssueData)"
:is-confidential="isConfidential(getIssueData)"
v-if="hasWarning(getNoteableData)"
:is-locked="isLocked(getNoteableData)"
:is-confidential="isConfidential(getNoteableData)"
/>
 
<markdown-field
Loading
Loading
Loading
Loading
@@ -41,7 +41,7 @@
],
computed: {
...mapGetters([
'getIssueData',
'getNoteableData',
]),
discussion() {
return this.note.notes[0];
Loading
Loading
@@ -50,10 +50,10 @@
return this.discussion.author;
},
canReply() {
return this.getIssueData.current_user.can_create_note;
return this.getNoteableData.current_user.can_create_note;
},
newNotePath() {
return this.getIssueData.create_note_path;
return this.getNoteableData.create_note_path;
},
lastUpdatedBy() {
const { notes } = this.note;
Loading
Loading
Loading
Loading
@@ -46,8 +46,8 @@
computed: {
...mapGetters([
'getDiscussionLastNote',
'getIssueData',
'getIssueDataByProp',
'getNoteableData',
'getNoteableDataByProp',
'getNotesDataByProp',
'getUserDataByProp',
]),
Loading
Loading
@@ -55,7 +55,7 @@
return `#note_${this.noteId}`;
},
markdownPreviewPath() {
return this.getIssueDataByProp('preview_note_path');
return this.getNoteableDataByProp('preview_note_path');
},
markdownDocsPath() {
return this.getNotesDataByProp('markdownDocsPath');
Loading
Loading
@@ -129,9 +129,9 @@
class="edit-note common-note-form js-quick-submit gfm-form">
 
<issue-warning
v-if="hasWarning(getIssueData)"
:is-locked="isLocked(getIssueData)"
:is-confidential="isConfidential(getIssueData)"
v-if="hasWarning(getNoteableData)"
:is-locked="isLocked(getNoteableData)"
:is-confidential="isConfidential(getNoteableData)"
/>
 
<markdown-field
Loading
Loading
Loading
Loading
@@ -14,7 +14,7 @@
export default {
name: 'issueNotesApp',
props: {
issueData: {
noteableData: {
type: Object,
required: true,
},
Loading
Loading
@@ -56,7 +56,7 @@
actionToggleAward: 'toggleAward',
scrollToNoteIfNeeded: 'scrollToNoteIfNeeded',
setNotesData: 'setNotesData',
setIssueData: 'setIssueData',
setNoteableData: 'setNoteableData',
setUserData: 'setUserData',
setLastFetchedAt: 'setLastFetchedAt',
setTargetNoteHash: 'setTargetNoteHash',
Loading
Loading
@@ -106,7 +106,7 @@
},
created() {
this.setNotesData(this.notesData);
this.setIssueData(this.issueData);
this.setNoteableData(this.noteableData);
this.setUserData(this.userData);
},
mounted() {
Loading
Loading
Loading
Loading
@@ -10,7 +10,7 @@ document.addEventListener('DOMContentLoaded', () => new Vue({
const notesDataset = document.getElementById('js-vue-notes').dataset;
 
return {
issueData: JSON.parse(notesDataset.issueData),
noteableData: JSON.parse(notesDataset.noteableData),
currentUserData: JSON.parse(notesDataset.currentUserData),
notesData: {
lastFetchedAt: notesDataset.lastFetchedAt,
Loading
Loading
@@ -26,7 +26,7 @@ document.addEventListener('DOMContentLoaded', () => new Vue({
render(createElement) {
return createElement('issue-notes-app', {
props: {
issueData: this.issueData,
noteableData: this.noteableData,
notesData: this.notesData,
userData: this.currentUserData,
},
Loading
Loading
Loading
Loading
@@ -4,7 +4,7 @@ import Poll from '../../lib/utils/poll';
import * as types from './mutation_types';
import * as utils from './utils';
import * as constants from '../constants';
import service from '../services/issue_notes_service';
import service from '../services/notes_service';
import loadAwardsHandler from '../../awards_handler';
import sidebarTimeTrackingEventHub from '../../sidebar/event_hub';
import { isInViewport, scrollToElement } from '../../lib/utils/common_utils';
Loading
Loading
@@ -12,7 +12,7 @@ import { isInViewport, scrollToElement } from '../../lib/utils/common_utils';
let eTagPoll;
 
export const setNotesData = ({ commit }, data) => commit(types.SET_NOTES_DATA, data);
export const setIssueData = ({ commit }, data) => commit(types.SET_ISSUE_DATA, data);
export const setNoteableData = ({ commit }, data) => commit(types.SET_NOTEABLE_DATA, data);
export const setUserData = ({ commit }, data) => commit(types.SET_USER_DATA, data);
export const setLastFetchedAt = ({ commit }, data) => commit(types.SET_LAST_FETCHED_AT, data);
export const setInitialNotes = ({ commit }, data) => commit(types.SET_INITIAL_NOTES, data);
Loading
Loading
Loading
Loading
@@ -6,8 +6,8 @@ export const targetNoteHash = state => state.targetNoteHash;
export const getNotesData = state => state.notesData;
export const getNotesDataByProp = state => prop => state.notesData[prop];
 
export const getIssueData = state => state.issueData;
export const getIssueDataByProp = state => prop => state.issueData[prop];
export const getNoteableData = state => state.noteableData;
export const getNoteableDataByProp = state => prop => state.noteableData[prop];
 
export const getUserData = state => state.userData || {};
export const getUserDataByProp = state => prop => state.userData && state.userData[prop];
Loading
Loading
Loading
Loading
@@ -15,7 +15,7 @@ export default new Vuex.Store({
// holds endpoints and permissions provided through haml
notesData: {},
userData: {},
issueData: {},
noteableData: {},
},
actions,
getters,
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@ export const ADD_NEW_REPLY_TO_DISCUSSION = 'ADD_NEW_REPLY_TO_DISCUSSION';
export const DELETE_NOTE = 'DELETE_NOTE';
export const REMOVE_PLACEHOLDER_NOTES = 'REMOVE_PLACEHOLDER_NOTES';
export const SET_NOTES_DATA = 'SET_NOTES_DATA';
export const SET_ISSUE_DATA = 'SET_ISSUE_DATA';
export const SET_NOTEABLE_DATA = 'SET_NOTEABLE_DATA';
export const SET_USER_DATA = 'SET_USER_DATA';
export const SET_INITIAL_NOTES = 'SET_INITIAL_NOTES';
export const SET_LAST_FETCHED_AT = 'SET_LAST_FETCHED_AT';
Loading
Loading
Loading
Loading
@@ -66,8 +66,8 @@ export default {
Object.assign(state, { notesData: data });
},
 
[types.SET_ISSUE_DATA](state, data) {
Object.assign(state, { issueData: data });
[types.SET_NOTEABLE_DATA](state, data) {
Object.assign(state, { noteableData: data });
},
 
[types.SET_USER_DATA](state, data) {
Loading
Loading
Loading
Loading
@@ -13,5 +13,5 @@
quick_actions_docs_path: help_page_path('user/project/quick_actions'),
notes_path: notes_url,
last_fetched_at: Time.now.to_i,
issue_data: serialize_issuable(@issue),
noteable_data: serialize_issuable(@issue),
current_user_data: UserSerializer.new.represent(current_user).to_json } }
Loading
Loading
@@ -14,7 +14,7 @@ describe 'Discussion Lock', :js do
project.add_developer(user)
end
 
context 'when the discussion is unlocked' do
context 'when the discussion is unlocked' do
it 'the user can lock the issue' do
visit project_issue_path(project, issue)
 
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@ import Vue from 'vue';
import Autosize from 'autosize';
import store from '~/notes/stores';
import issueCommentForm from '~/notes/components/issue_comment_form.vue';
import { loggedOutIssueData, notesDataMock, userDataMock, issueDataMock } from '../mock_data';
import { loggedOutnoteableData, notesDataMock, userDataMock, noteableDataMock } from '../mock_data';
import { keyboardDownEvent } from '../../issue_show/helpers';
 
describe('issue_comment_form component', () => {
Loading
Loading
@@ -23,7 +23,7 @@ describe('issue_comment_form component', () => {
describe('user is logged in', () => {
beforeEach(() => {
store.dispatch('setUserData', userDataMock);
store.dispatch('setIssueData', issueDataMock);
store.dispatch('setNoteableData', noteableDataMock);
store.dispatch('setNotesData', notesDataMock);
 
vm = mountComponent();
Loading
Loading
@@ -178,7 +178,7 @@ describe('issue_comment_form component', () => {
 
describe('issue is confidential', () => {
it('shows information warning', (done) => {
store.dispatch('setIssueData', Object.assign(issueDataMock, { confidential: true }));
store.dispatch('setNoteableData', Object.assign(noteableDataMock, { confidential: true }));
Vue.nextTick(() => {
expect(vm.$el.querySelector('.confidential-issue-warning')).toBeDefined();
done();
Loading
Loading
@@ -190,7 +190,7 @@ describe('issue_comment_form component', () => {
describe('user is not logged in', () => {
beforeEach(() => {
store.dispatch('setUserData', null);
store.dispatch('setIssueData', loggedOutIssueData);
store.dispatch('setNoteableData', loggedOutnoteableData);
store.dispatch('setNotesData', notesDataMock);
 
vm = mountComponent();
Loading
Loading
import Vue from 'vue';
import store from '~/notes/stores';
import issueDiscussion from '~/notes/components/issue_discussion.vue';
import { issueDataMock, discussionMock, notesDataMock } from '../mock_data';
import { noteableDataMock, discussionMock, notesDataMock } from '../mock_data';
 
describe('issue_discussion component', () => {
let vm;
Loading
Loading
@@ -9,7 +9,7 @@ describe('issue_discussion component', () => {
beforeEach(() => {
const Component = Vue.extend(issueDiscussion);
 
store.dispatch('setIssueData', issueDataMock);
store.dispatch('setNoteableData', noteableDataMock);
store.dispatch('setNotesData', notesDataMock);
 
vm = new Component({
Loading
Loading
import Vue from 'vue';
import issueNotesApp from '~/notes/components/issue_notes_app.vue';
import service from '~/notes/services/issue_notes_service';
import service from '~/notes/services/notes_service';
import * as mockData from '../mock_data';
 
describe('issue_note_app', () => {
Loading
Loading
@@ -24,7 +24,7 @@ describe('issue_note_app', () => {
 
mountComponent = (data) => {
const props = data || {
issueData: mockData.issueDataMock,
noteableData: mockData.noteableDataMock,
notesData: mockData.notesDataMock,
userData: mockData.userDataMock,
};
Loading
Loading
@@ -60,7 +60,7 @@ describe('issue_note_app', () => {
});
 
it('should set issue data', () => {
expect(vm.$store.state.issueData).toEqual(mockData.issueDataMock);
expect(vm.$store.state.noteableData).toEqual(mockData.noteableDataMock);
});
 
it('should set user data', () => {
Loading
Loading
import Vue from 'vue';
import store from '~/notes/stores';
import awardsNote from '~/notes/components/issue_note_awards_list.vue';
import { issueDataMock, notesDataMock } from '../mock_data';
import { noteableDataMock, notesDataMock } from '../mock_data';
 
describe('issue_note_awards_list component', () => {
let vm;
Loading
Loading
@@ -10,7 +10,7 @@ describe('issue_note_awards_list component', () => {
beforeEach(() => {
const Component = Vue.extend(awardsNote);
 
store.dispatch('setIssueData', issueDataMock);
store.dispatch('setNoteableData', noteableDataMock);
store.dispatch('setNotesData', notesDataMock);
awardsMock = [
{
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
import Vue from 'vue';
import store from '~/notes/stores';
import noteBody from '~/notes/components/issue_note_body.vue';
import { issueDataMock, notesDataMock, note } from '../mock_data';
import { noteableDataMock, notesDataMock, note } from '../mock_data';
 
describe('issue_note_body component', () => {
let vm;
Loading
Loading
@@ -10,7 +10,7 @@ describe('issue_note_body component', () => {
beforeEach(() => {
const Component = Vue.extend(noteBody);
 
store.dispatch('setIssueData', issueDataMock);
store.dispatch('setNoteableData', noteableDataMock);
store.dispatch('setNotesData', notesDataMock);
 
vm = new Component({
Loading
Loading
import Vue from 'vue';
import store from '~/notes/stores';
import issueNoteForm from '~/notes/components/issue_note_form.vue';
import { issueDataMock, notesDataMock } from '../mock_data';
import { noteableDataMock, notesDataMock } from '../mock_data';
import { keyboardDownEvent } from '../../issue_show/helpers';
 
describe('issue_note_form component', () => {
Loading
Loading
@@ -11,7 +11,7 @@ describe('issue_note_form component', () => {
beforeEach(() => {
const Component = Vue.extend(issueNoteForm);
 
store.dispatch('setIssueData', issueDataMock);
store.dispatch('setNoteableData', noteableDataMock);
store.dispatch('setNotesData', notesDataMock);
 
props = {
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
import Vue from 'vue';
import store from '~/notes/stores';
import issueNote from '~/notes/components/issue_note.vue';
import { issueDataMock, notesDataMock, note } from '../mock_data';
import { noteableDataMock, notesDataMock, note } from '../mock_data';
 
describe('issue_note', () => {
let vm;
Loading
Loading
@@ -10,7 +10,7 @@ describe('issue_note', () => {
beforeEach(() => {
const Component = Vue.extend(issueNote);
 
store.dispatch('setIssueData', issueDataMock);
store.dispatch('setNoteableData', noteableDataMock);
store.dispatch('setNotesData', notesDataMock);
 
vm = new Component({
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment