Commit bf4322ef authored by Simon Knox's avatar Simon Knox

Merge branch 'psimyn-issue-note-refac' of gitlab.com:gitlab-org/gitlab-ce into...

Merge branch 'psimyn-issue-note-refac' of gitlab.com:gitlab-org/gitlab-ce into ee-psimyn-issue-note-refac
parents c97b60cb 1b50640d
<script> <script>
import Icon from '../../vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import Issuable from '~/vue_shared/mixins/issuable';
export default { export default {
component: { mixins: [
Issuable,
],
components: {
Icon, Icon,
}, },
}; };
...@@ -16,7 +20,7 @@ ...@@ -16,7 +20,7 @@
:size="16" :size="16"
class="icon"> class="icon">
</icon> </icon>
<span>This issue is locked. Only <b>project members</b> can comment.</span> <span>This {{ issuableDisplayName }} is locked. Only <b>project members</b> can comment.</span>
</span> </span>
</div> </div>
</template> </template>
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
import * as constants from '../constants'; import * as constants from '../constants';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
import issueWarning from '../../vue_shared/components/issue/issue_warning.vue'; import issueWarning from '../../vue_shared/components/issue/issue_warning.vue';
import issueNoteSignedOutWidget from './issue_note_signed_out_widget.vue'; import noteSignedOutWidget from './note_signed_out_widget.vue';
import issueDiscussionLockedWidget from './issue_discussion_locked_widget.vue'; import discussionLockedWidget from './discussion_locked_widget.vue';
import markdownField from '../../vue_shared/components/markdown/field.vue'; import markdownField from '../../vue_shared/components/markdown/field.vue';
import userAvatarLink from '../../vue_shared/components/user_avatar/user_avatar_link.vue'; import userAvatarLink from '../../vue_shared/components/user_avatar/user_avatar_link.vue';
import issuableStateMixin from '../mixins/issuable_state'; import issuableStateMixin from '../mixins/issuable_state';
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
}, },
components: { components: {
issueWarning, issueWarning,
issueNoteSignedOutWidget, noteSignedOutWidget,
issueDiscussionLockedWidget, discussionLockedWidget,
markdownField, markdownField,
userAvatarLink, userAvatarLink,
}, },
...@@ -240,8 +240,11 @@ ...@@ -240,8 +240,11 @@
<template> <template>
<div> <div>
<issue-note-signed-out-widget v-if="!isLoggedIn" /> <note-signed-out-widget v-if="!isLoggedIn" />
<issue-discussion-locked-widget v-else-if="!canCreateNote" /> <discussion-locked-widget
issuable-type="issue"
v-else-if="!canCreateNote"
/>
<ul <ul
v-else v-else
class="notes notes-form timeline"> class="notes notes-form timeline">
......
...@@ -4,10 +4,9 @@ ...@@ -4,10 +4,9 @@
import { SYSTEM_NOTE } from '../constants'; import { SYSTEM_NOTE } from '../constants';
import issueNote from './issue_note.vue'; import issueNote from './issue_note.vue';
import userAvatarLink from '../../vue_shared/components/user_avatar/user_avatar_link.vue'; import userAvatarLink from '../../vue_shared/components/user_avatar/user_avatar_link.vue';
import issueNoteHeader from './issue_note_header.vue'; import noteHeader from './note_header.vue';
import issueNoteActions from './issue_note_actions.vue'; import noteSignedOutWidget from './note_signed_out_widget.vue';
import issueNoteSignedOutWidget from './issue_note_signed_out_widget.vue'; import noteEditedText from './note_edited_text.vue';
import issueNoteEditedText from './issue_note_edited_text.vue';
import issueNoteForm from './issue_note_form.vue'; import issueNoteForm from './issue_note_form.vue';
import placeholderNote from '../../vue_shared/components/notes/placeholder_note.vue'; import placeholderNote from '../../vue_shared/components/notes/placeholder_note.vue';
import placeholderSystemNote from '../../vue_shared/components/notes/placeholder_system_note.vue'; import placeholderSystemNote from '../../vue_shared/components/notes/placeholder_system_note.vue';
...@@ -28,10 +27,9 @@ ...@@ -28,10 +27,9 @@
components: { components: {
issueNote, issueNote,
userAvatarLink, userAvatarLink,
issueNoteHeader, noteHeader,
issueNoteActions, noteSignedOutWidget,
issueNoteSignedOutWidget, noteEditedText,
issueNoteEditedText,
issueNoteForm, issueNoteForm,
placeholderNote, placeholderNote,
placeholderSystemNote, placeholderSystemNote,
...@@ -171,7 +169,7 @@ ...@@ -171,7 +169,7 @@
<div class="timeline-content"> <div class="timeline-content">
<div class="discussion"> <div class="discussion">
<div class="discussion-header"> <div class="discussion-header">
<issue-note-header <note-header
:author="author" :author="author"
:created-at="discussion.created_at" :created-at="discussion.created_at"
:note-id="discussion.id" :note-id="discussion.id"
...@@ -180,7 +178,7 @@ ...@@ -180,7 +178,7 @@
action-text="started a discussion" action-text="started a discussion"
class="discussion" class="discussion"
/> />
<issue-note-edited-text <note-edited-text
v-if="lastUpdatedAt" v-if="lastUpdatedAt"
:edited-at="lastUpdatedAt" :edited-at="lastUpdatedAt"
:edited-by="lastUpdatedBy" :edited-by="lastUpdatedBy"
...@@ -220,7 +218,7 @@ ...@@ -220,7 +218,7 @@
@cancelFormEdition="cancelReplyForm" @cancelFormEdition="cancelReplyForm"
ref="noteForm" ref="noteForm"
/> />
<issue-note-signed-out-widget v-if="!canReply" /> <note-signed-out-widget v-if="!canReply" />
</div> </div>
</div> </div>
</div> </div>
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
import { mapGetters, mapActions } from 'vuex'; import { mapGetters, mapActions } from 'vuex';
import Flash from '../../flash'; import Flash from '../../flash';
import userAvatarLink from '../../vue_shared/components/user_avatar/user_avatar_link.vue'; import userAvatarLink from '../../vue_shared/components/user_avatar/user_avatar_link.vue';
import issueNoteHeader from './issue_note_header.vue'; import noteHeader from './note_header.vue';
import issueNoteActions from './issue_note_actions.vue'; import noteActions from './note_actions.vue';
import issueNoteBody from './issue_note_body.vue'; import issueNoteBody from './issue_note_body.vue';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
}, },
components: { components: {
userAvatarLink, userAvatarLink,
issueNoteHeader, noteHeader,
issueNoteActions, noteActions,
issueNoteBody, issueNoteBody,
}, },
computed: { computed: {
...@@ -155,13 +155,13 @@ ...@@ -155,13 +155,13 @@
</div> </div>
<div class="timeline-content"> <div class="timeline-content">
<div class="note-header"> <div class="note-header">
<issue-note-header <note-header
:author="author" :author="author"
:created-at="note.created_at" :created-at="note.created_at"
:note-id="note.id" :note-id="note.id"
action-text="commented" action-text="commented"
/> />
<issue-note-actions <note-actions
:author-id="author.id" :author-id="author.id"
:note-id="note.id" :note-id="note.id"
:access-level="note.human_access" :access-level="note.human_access"
......
<script> <script>
import issueNoteEditedText from './issue_note_edited_text.vue'; import noteEditedText from './note_edited_text.vue';
import issueNoteAwardsList from './issue_note_awards_list.vue'; import noteAwardsList from './note_awards_list.vue';
import issueNoteAttachment from './issue_note_attachment.vue'; import noteAttachment from './note_attachment.vue';
import issueNoteForm from './issue_note_form.vue'; import issueNoteForm from './issue_note_form.vue';
import TaskList from '../../task_list'; import TaskList from '../../task_list';
import autosave from '../mixins/autosave'; import autosave from '../mixins/autosave';
...@@ -26,9 +26,9 @@ ...@@ -26,9 +26,9 @@
autosave, autosave,
], ],
components: { components: {
issueNoteEditedText, noteEditedText,
issueNoteAwardsList, noteAwardsList,
issueNoteAttachment, noteAttachment,
issueNoteForm, issueNoteForm,
}, },
computed: { computed: {
...@@ -101,20 +101,20 @@ ...@@ -101,20 +101,20 @@
v-model="note.note" v-model="note.note"
:data-update-url="note.path" :data-update-url="note.path"
class="hidden js-task-list-field"></textarea> class="hidden js-task-list-field"></textarea>
<issue-note-edited-text <note-edited-text
v-if="note.last_edited_at" v-if="note.last_edited_at"
:edited-at="note.last_edited_at" :edited-at="note.last_edited_at"
:edited-by="note.last_edited_by" :edited-by="note.last_edited_by"
action-text="Edited" action-text="Edited"
/> />
<issue-note-awards-list <note-awards-list
v-if="note.award_emoji.length" v-if="note.award_emoji.length"
:note-id="note.id" :note-id="note.id"
:note-author-id="note.author.id" :note-author-id="note.author.id"
:awards="note.award_emoji" :awards="note.award_emoji"
:toggle-award-path="note.toggle_award_path" :toggle-award-path="note.toggle_award_path"
/> />
<issue-note-attachment <note-attachment
v-if="note.attachment" v-if="note.attachment"
:attachment="note.attachment" :attachment="note.attachment"
/> />
......
...@@ -5,11 +5,11 @@ ...@@ -5,11 +5,11 @@
import emojiSmiley from 'icons/_emoji_smiley.svg'; import emojiSmiley from 'icons/_emoji_smiley.svg';
import editSvg from 'icons/_icon_pencil.svg'; import editSvg from 'icons/_icon_pencil.svg';
import ellipsisSvg from 'icons/_ellipsis_v.svg'; import ellipsisSvg from 'icons/_ellipsis_v.svg';
import loadingIcon from '../../vue_shared/components/loading_icon.vue'; import loadingIcon from '~/vue_shared/components/loading_icon.vue';
import tooltip from '../../vue_shared/directives/tooltip'; import tooltip from '~/vue_shared/directives/tooltip';
export default { export default {
name: 'issueNoteActions', name: 'noteActions',
props: { props: {
authorId: { authorId: {
type: Number, type: Number,
......
<script> <script>
export default { export default {
name: 'issueNoteAttachment', name: 'noteAttachment',
props: { props: {
attachment: { attachment: {
type: Object, type: Object,
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
export default { export default {
name: 'singInLinksNotes',
computed: { computed: {
...mapGetters([ ...mapGetters([
'getNotesDataByProp', 'getNotesDataByProp',
......
...@@ -18,11 +18,6 @@ export default { ...@@ -18,11 +18,6 @@ export default {
required: true, required: true,
type: Function, type: Function,
}, },
issuableType: {
required: true,
type: String,
},
}, },
mixins: [ mixins: [
...@@ -39,13 +34,13 @@ export default { ...@@ -39,13 +34,13 @@ export default {
<div class="dropdown open"> <div class="dropdown open">
<div class="dropdown-menu sidebar-item-warning-message"> <div class="dropdown-menu sidebar-item-warning-message">
<p class="text" v-if="isLocked"> <p class="text" v-if="isLocked">
Unlock this {{ issuableDisplayName(issuableType) }}? Unlock this {{ issuableDisplayName }}?
<strong>Everyone</strong> <strong>Everyone</strong>
will be able to comment. will be able to comment.
</p> </p>
<p class="text" v-else> <p class="text" v-else>
Lock this {{ issuableDisplayName(issuableType) }}? Lock this {{ issuableDisplayName }}?
Only Only
<strong>project members</strong> <strong>project members</strong>
will be able to comment. will be able to comment.
......
...@@ -23,11 +23,6 @@ export default { ...@@ -23,11 +23,6 @@ export default {
return mediatorObject.service && mediatorObject.service.update && mediatorObject.store; return mediatorObject.service && mediatorObject.service.update && mediatorObject.store;
}, },
}, },
issuableType: {
required: true,
type: String,
},
}, },
mixins: [ mixins: [
...@@ -59,7 +54,7 @@ export default { ...@@ -59,7 +54,7 @@ export default {
discussion_locked: locked, discussion_locked: locked,
}) })
.then(() => location.reload()) .then(() => location.reload())
.catch(() => Flash(this.__(`Something went wrong trying to change the locked state of this ${this.issuableDisplayName(this.issuableType)}`))); .catch(() => Flash(this.__(`Something went wrong trying to change the locked state of this ${this.issuableDisplayName}`)));
}, },
}, },
}; };
...@@ -77,7 +72,7 @@ export default { ...@@ -77,7 +72,7 @@ export default {
</div> </div>
<div class="title hide-collapsed"> <div class="title hide-collapsed">
Lock {{issuableDisplayName(issuableType) }} Lock {{ issuableDisplayName }}
<button <button
v-if="isEditable" v-if="isEditable"
class="pull-right lock-edit btn btn-blank" class="pull-right lock-edit btn btn-blank"
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
size: { size: {
type: Number, type: Number,
required: false, required: false,
default: 0, default: 16,
}, },
cssClasses: { cssClasses: {
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* /> * />
*/ */
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import issueNoteHeader from '../../../notes/components/issue_note_header.vue'; import noteHeader from '~/notes/components/note_header.vue';
import { spriteIcon } from '../../../lib/utils/common_utils'; import { spriteIcon } from '../../../lib/utils/common_utils';
export default { export default {
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
}, },
}, },
components: { components: {
issueNoteHeader, noteHeader,
}, },
computed: { computed: {
...mapGetters([ ...mapGetters([
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
</div> </div>
<div class="timeline-content"> <div class="timeline-content">
<div class="note-header"> <div class="note-header">
<issue-note-header <note-header
:author="note.author" :author="note.author"
:created-at="note.created_at" :created-at="note.created_at"
:note-id="note.id" :note-id="note.id"
......
export default { export default {
methods: { props: {
issuableDisplayName(issuableType) { issuableType: {
const displayName = issuableType.replace(/_/, ' '); required: true,
type: String,
},
},
return this.__ ? this.__(displayName) : displayName; computed: {
issuableDisplayName() {
return this.issuableType.replace(/_/g, ' ');
}, },
}, },
}; };
import Vue from 'vue'; import Vue from 'vue';
import store from '~/notes/stores'; import store from '~/notes/stores';
import issueActions from '~/notes/components/issue_note_actions.vue'; import noteActions from '~/notes/components/note_actions.vue';
import { userDataMock } from '../mock_data'; import { userDataMock } from '../mock_data';
describe('issse_note_actions component', () => { describe('issse_note_actions component', () => {
...@@ -8,7 +8,7 @@ describe('issse_note_actions component', () => { ...@@ -8,7 +8,7 @@ describe('issse_note_actions component', () => {
let Component; let Component;
beforeEach(() => { beforeEach(() => {
Component = Vue.extend(issueActions); Component = Vue.extend(noteActions);
}); });
afterEach(() => { afterEach(() => {
......
import Vue from 'vue'; import Vue from 'vue';
import issueNoteAttachment from '~/notes/components/issue_note_attachment.vue'; import noteAttachment from '~/notes/components/note_attachment.vue';
describe('issue note attachment', () => { describe('issue note attachment', () => {
it('should render properly', () => { it('should render properly', () => {
...@@ -11,7 +11,7 @@ describe('issue note attachment', () => { ...@@ -11,7 +11,7 @@ describe('issue note attachment', () => {
}, },
}; };
const Component = Vue.extend(issueNoteAttachment); const Component = Vue.extend(noteAttachment);
const vm = new Component({ const vm = new Component({
propsData: props, propsData: props,
}).$mount(); }).$mount();
......
import Vue from 'vue'; import Vue from 'vue';
import store from '~/notes/stores'; import store from '~/notes/stores';
import awardsNote from '~/notes/components/issue_note_awards_list.vue'; import awardsNote from '~/notes/components/note_awards_list.vue';
import { issueDataMock, notesDataMock } from '../mock_data'; import { issueDataMock, notesDataMock } from '../mock_data';
describe('issue_note_awards_list component', () => { describe('note_awards_list component', () => {
let vm; let vm;
let awardsMock; let awardsMock;
......
import Vue from 'vue'; import Vue from 'vue';
import issueNoteEditedText from '~/notes/components/issue_note_edited_text.vue'; import noteEditedText from '~/notes/components/note_edited_text.vue';
describe('issue_note_edited_text', () => { describe('note_edited_text', () => {
let vm; let vm;
let props; let props;
beforeEach(() => { beforeEach(() => {
const Component = Vue.extend(issueNoteEditedText); const Component = Vue.extend(noteEditedText);
props = { props = {
actionText: 'Edited', actionText: 'Edited',
className: 'foo-bar', className: 'foo-bar',
......
import Vue from 'vue'; import Vue from 'vue';
import issueNoteHeader from '~/notes/components/issue_note_header.vue'; import noteHeader from '~/notes/components/note_header.vue';
import store from '~/notes/stores'; import store from '~/notes/stores';
describe('issue_note_header component', () => { describe('note_header component', () => {
let vm; let vm;
let Component; let Component;
beforeEach(() => { beforeEach(() => {
Component = Vue.extend(issueNoteHeader); Component = Vue.extend(noteHeader);
}); });
afterEach(() => { afterEach(() => {
......
import Vue from 'vue'; import Vue from 'vue';
import issueNoteSignedOut from '~/notes/components/issue_note_signed_out_widget.vue'; import noteSignedOut from '~/notes/components/note_signed_out_widget.vue';
import store from '~/notes/stores'; import store from '~/notes/stores';
import { notesDataMock } from '../mock_data'; import { notesDataMock } from '../mock_data';
describe('issue_note_signed_out_widget component', () => { describe('note_signed_out_widget component', () => {
let vm; let vm;
beforeEach(() => { beforeEach(() => {
const Component = Vue.extend(issueNoteSignedOut); const Component = Vue.extend(noteSignedOut);
store.dispatch('setNotesData', notesDataMock); store.dispatch('setNotesData', notesDataMock);
vm = new Component({ vm = new Component({
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment