Commit 923a0623 authored by Filipa Lacerda's avatar Filipa Lacerda

[ci skip] Disable slash commands in edit mode

parent 7b093581
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
issueNoteSignedOutWidget, issueNoteSignedOutWidget,
}, },
computed: { computed: {
...mapGetters([ ...mapGetters([
'getCurrentUserLastNote', 'getCurrentUserLastNote',
]), ]),
isLoggedIn() { isLoggedIn() {
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
}, },
methods: { methods: {
...mapActions([ ...mapActions([
'saveNote' 'saveNote',
]), ]),
handleSave(withIssueAction) { handleSave(withIssueAction) {
if (this.note.length) { if (this.note.length) {
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
if (res.errors.commands_only) { if (res.errors.commands_only) {
this.discard(); this.discard();
} else { } else {
return Flash('Something went wrong while adding your comment. Please try again.'); Flash('Something went wrong while adding your comment. Please try again.');
} }
} else { } else {
this.discard(); this.discard();
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
if (this.isIssueOpen) { if (this.isIssueOpen) {
this.issueState = constants.CLOSED; this.issueState = constants.CLOSED;
} else { } else {
this.issueState =constants.REOPENED; this.issueState = constants.REOPENED;
} }
gl.issueData.state = this.issueState; gl.issueData.state = this.issueState;
...@@ -149,7 +149,7 @@ ...@@ -149,7 +149,7 @@
destroyed() { destroyed() {
eventHub.$off('issueStateChanged'); eventHub.$off('issueStateChanged');
} },
}; };
</script> </script>
...@@ -182,7 +182,6 @@ ...@@ -182,7 +182,6 @@
id="note-body" id="note-body"
name="note[note]" name="note[note]"
class="note-textarea js-gfm-input markdown-area" class="note-textarea js-gfm-input markdown-area"
data-supports-slash-commands="true"
data-supports-quick-actions="true" data-supports-quick-actions="true"
aria-label="Description" aria-label="Description"
v-model="note" v-model="note"
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
methods: { methods: {
...mapActions([ ...mapActions([
'saveNote', 'saveNote',
'toggleDiscussion' 'toggleDiscussion',
]), ]),
componentName(note) { componentName(note) {
if (note.isPlaceholderNote) { if (note.isPlaceholderNote) {
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
this.isReplying = false; this.isReplying = false;
}, },
saveReply(note) { saveReply(noteText) {
const replyData = { const replyData = {
endpoint: this.newNotePath, endpoint: this.newNotePath,
flashContainer: this.$el, flashContainer: this.$el,
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
in_reply_to_discussion_id: this.note.reply_id, in_reply_to_discussion_id: this.note.reply_id,
target_type: 'issue', target_type: 'issue',
target_id: this.discussion.noteable_id, target_id: this.discussion.noteable_id,
note: { note: note }, note: { note: noteText },
full_data: true, full_data: true,
}, },
}; };
...@@ -162,6 +162,7 @@ ...@@ -162,6 +162,7 @@
v-if="isReplying" v-if="isReplying"
saveButtonTitle="Comment" saveButtonTitle="Comment"
:discussion="note" :discussion="note"
:is-editing="false"
@handleFormUpdate="saveReply" @handleFormUpdate="saveReply"
@cancelFormEdition="cancelReplyForm" @cancelFormEdition="cancelReplyForm"
ref="noteForm" ref="noteForm"
......
<script> <script>
import { mapGetters } from 'vuex';
import emojiSmiling from 'icons/_emoji_slightly_smiling_face.svg'; import emojiSmiling from 'icons/_emoji_slightly_smiling_face.svg';
import emojiSmile from 'icons/_emoji_smile.svg'; import emojiSmile from 'icons/_emoji_smile.svg';
import emojiSmiley from 'icons/_emoji_smiley.svg'; import emojiSmiley from 'icons/_emoji_smiley.svg';
...@@ -53,13 +54,15 @@ ...@@ -53,13 +54,15 @@
emojiSmiling, emojiSmiling,
emojiSmile, emojiSmile,
emojiSmiley, emojiSmiley,
currentUserId: window.gon.current_user_id,
}; };
}, },
components: { components: {
loadingIcon, loadingIcon,
}, },
computed: { computed: {
...mapGetters([
'getUserDataByProp',
]),
shouldShowActionsDropdown() { shouldShowActionsDropdown() {
return this.currentUserId && (this.canEdit || this.canReportAsAbuse); return this.currentUserId && (this.canEdit || this.canReportAsAbuse);
}, },
...@@ -67,8 +70,11 @@ ...@@ -67,8 +70,11 @@
return this.currentUserId; return this.currentUserId;
}, },
isAuthoredByCurrentUser() { isAuthoredByCurrentUser() {
return this.authorId === this.currentUserId return this.authorId === this.currentUserId;
}, },
currentUserId() {
return this.getUserDataByProp('id');
}
}, },
}; };
</script> </script>
......
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
ref="noteForm" ref="noteForm"
@handleFormUpdate="handleFormUpdate" @handleFormUpdate="handleFormUpdate"
@cancelFormEdition="formCancelHandler" @cancelFormEdition="formCancelHandler"
:is-editing="isEditing"
:note-body="noteBody" :note-body="noteBody"
:note-id="note.id" :note-id="note.id"
/> />
......
...@@ -22,17 +22,16 @@ ...@@ -22,17 +22,16 @@
discussion: { discussion: {
type: Object, type: Object,
required: false, required: false,
} },
isEditing: {
type: Boolean,
required: true,
},
}, },
data() { data() {
const { getIssueData, getNotesData } = this.$store.getters;
return { return {
initialNote: this.noteBody, initialNote: this.noteBody,
note: this.noteBody, note: this.noteBody,
markdownPreviewUrl: getIssueData.preview_note_path,
markdownDocsUrl: getNotesData.markdownDocs,
quickActionsDocsUrl: getNotesData.quickActionsDocs,
conflictWhileEditing: false, conflictWhileEditing: false,
}; };
}, },
...@@ -42,10 +41,25 @@ ...@@ -42,10 +41,25 @@
computed: { computed: {
...mapGetters([ ...mapGetters([
'getDiscussionLastNote', 'getDiscussionLastNote',
'getIssueDataByProp',
'getNotesDataByProp',
'getUserDataByProp',
]), ]),
noteHash() { noteHash() {
return `#note_${this.noteId}`; return `#note_${this.noteId}`;
}, },
markdownPreviewUrl() {
return this.getIssueDataByProp('preview_note_path');
},
markdownDocsUrl() {
return this.getNotesDataByProp('markdownDocs');
},
quickActionsDocsUrl() {
return this.getNotesDataByProp('quickActionsDocs');
},
currentUserId() {
return this.getUserDataByProp('id');
}
}, },
methods: { methods: {
handleUpdate() { handleUpdate() {
...@@ -53,7 +67,7 @@ ...@@ -53,7 +67,7 @@
}, },
editMyLastNote() { editMyLastNote() {
if (this.note === '') { if (this.note === '') {
const lastNoteInDiscussion = this.getDiscussionLastNote(this.discussion, window.gon.current_user_id); const lastNoteInDiscussion = this.getDiscussionLastNote(this.discussion, this.currentUserId);
if (lastNoteInDiscussion) { if (lastNoteInDiscussion) {
eventHub.$emit('enterEditMode', { eventHub.$emit('enterEditMode', {
...@@ -105,8 +119,7 @@ ...@@ -105,8 +119,7 @@
id="note-body" id="note-body"
name="note[note]" name="note[note]"
class="note-textarea js-gfm-input js-autosize markdown-area" class="note-textarea js-gfm-input js-autosize markdown-area"
data-supports-slash-commands="true" :data-supports-quick-actions="!isEditing"
data-supports-quick-actions="true"
aria-label="Description" aria-label="Description"
v-model="note" v-model="note"
ref="textarea" ref="textarea"
......
<script> <script>
/* global Flash */ /* global Flash */
import Vue from 'vue'; import { mapGetters, mapActions } from 'vuex';
import { mapGetters, mapActions, mapMutations } from 'vuex';
import store from '../stores/'; import store from '../stores/';
import * as constants from '../constants' import * as constants from '../constants';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
import issueNote from './issue_note.vue'; import issueNote from './issue_note.vue';
import issueDiscussion from './issue_discussion.vue'; import issueDiscussion from './issue_discussion.vue';
......
...@@ -8,7 +8,7 @@ export const getIssueData = state => state.issueData; ...@@ -8,7 +8,7 @@ export const getIssueData = state => state.issueData;
export const getIssueDataByProp = state => prop => state.issueData[prop]; export const getIssueDataByProp = state => prop => state.issueData[prop];
export const getUserData = state => state.userData; export const getUserData = state => state.userData;
export const getUserDataByProp = state => prop => state.notesData[prop]; export const getUserDataByProp = state => prop => state.userData[prop];
export const notesById = state => state.notes.reduce((acc, note) => { export const notesById = state => state.notes.reduce((acc, note) => {
note.notes.every(n => Object.assign(acc, { [n.id]: n })); note.notes.every(n => Object.assign(acc, { [n.id]: n }));
......
...@@ -59,26 +59,26 @@ export default { ...@@ -59,26 +59,26 @@ export default {
}, },
[types.SET_NOTES_DATA](state, data) { [types.SET_NOTES_DATA](state, data) {
state.notesData = data; Object.assign(state, { notesData: data });
}, },
[types.SET_ISSUE_DATA](state, data) { [types.SET_ISSUE_DATA](state, data) {
state.issueData = data; Object.assign(state, { issueData: data });
}, },
[types.SET_USER_DATA](state, data) { [types.SET_USER_DATA](state, data) {
state.userData = data; Object.assign(state, { userData: data });
}, },
[types.SET_INITAL_NOTES](state, notes) { [types.SET_INITAL_NOTES](state, notesData) {
state.notes = notes; Object.assign(state, { notes: notesData });
}, },
[types.SET_LAST_FETCHED_AT](state, fetchedAt) { [types.SET_LAST_FETCHED_AT](state, fetchedAt) {
state.lastFetchedAt = fetchedAt; Object.assign(state, { lastFetchedAt: fetchedAt });
}, },
[types.SET_TARGET_NOTE_HASH](state, hash) { [types.SET_TARGET_NOTE_HASH](state, hash) {
state.targetNoteHash = hash; Object.assign(state, { targetNoteHash: hash });
}, },
[types.SHOW_PLACEHOLDER_NOTE](state, data) { [types.SHOW_PLACEHOLDER_NOTE](state, data) {
......
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