Commit 66f4af5c authored by Fatih Acet's avatar Fatih Acet

IssueNotesRefactor: Refactor toggle to work with delegated handler.

parent c77b2649
......@@ -43,6 +43,13 @@ export default {
this.signInLink = signInLink.getAttribute('href');
}
},
methods: {
toggleDiscussion() {
this.$store.commit('toggleDiscussion', {
discussionId: this.note.id,
});
}
},
};
</script>
......@@ -64,7 +71,7 @@ export default {
:createdAt="discussion.created_at"
:notePath="discussion.path"
:includeToggle="true"
:discussionId="note.id"
:toggleHandler="toggleDiscussion"
actionText="started a discussion" />
<issue-note-edited-text
v-if="note.last_updated_by"
......
......@@ -30,21 +30,14 @@ export default {
required: false,
default: false,
},
discussionId: {
type: String,
toggleHandler: {
type: Function,
required: false,
},
},
components: {
TimeAgoTooltip,
},
methods: {
toggle() {
this.$store.commit('toggleDiscussion', {
discussionId: this.discussionId,
});
},
},
};
</script>
......@@ -78,7 +71,7 @@ export default {
v-if="includeToggle"
class="discussion-actions">
<button
@click="toggle"
@click="toggleHandler"
class="note-action-button discussion-toggle-button js-toggle-button"
type="button">
<i
......
......@@ -3,6 +3,10 @@
import service from '../services/issue_notes_service';
const findNoteObjectById = (notes, id) => {
return notes.filter(n => n.id === id)[0];
};
const state = {
notes: [],
};
......@@ -18,7 +22,7 @@ const mutations = {
storeState.notes = notes;
},
toggleDiscussion(storeState, { discussionId }) {
const [discussion] = storeState.notes.filter(note => note.id === discussionId);
const discussion = findNoteObjectById(storeState.notes, discussionId);
discussion.expanded = !discussion.expanded;
},
......
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