Disable comment form when discussion locked for user

This commit is contained in:
Jarka Kadlecova 2017-09-07 17:14:21 +02:00
parent 142bbd900b
commit 360c147057
4 changed files with 26 additions and 5 deletions

View file

@ -9,6 +9,7 @@
import eventHub from '../event_hub';
import issueWarning from '../../vue_shared/components/issue/issue_warning.vue';
import issueNoteSignedOutWidget from './issue_note_signed_out_widget.vue';
import issueDiscussionLockedWidget from './issue_discussion_locked_widget.vue';
import markdownField from '../../vue_shared/components/markdown/field.vue';
import userAvatarLink from '../../vue_shared/components/user_avatar/user_avatar_link.vue';
import issuableStateMixin from '../mixins/issuable_state';
@ -29,6 +30,7 @@
components: {
issueWarning,
issueNoteSignedOutWidget,
issueDiscussionLockedWidget,
markdownField,
userAvatarLink,
},
@ -239,6 +241,7 @@
<template>
<div>
<issue-note-signed-out-widget v-if="!isLoggedIn" />
<issue-discussion-locked-widget v-else-if="!canCreate" />
<ul
v-else
class="notes notes-form timeline">

View file

@ -0,0 +1,16 @@
<script>
import { mapGetters } from 'vuex';
export default {
name: 'discussionLockedWidget',
};
</script>
<template>
<div class="disabled-comment text-center">
<span class="issuable-note-warning">
This issue is locked. Only <b>project members</b> can comment.
</span>
</div>
</template>

View file

@ -15,7 +15,7 @@ class IssueEntity < IssuableEntity
expose :current_user do
expose :can_create_note do |issue|
can?(request.current_user, :create_note, issue.project)
can?(request.current_user, :create_note, issue)
end
expose :can_update do |issue|

View file

@ -25,9 +25,11 @@
= link_to "sign in", new_session_path(:user, redirect_to_referer: 'yes'), class: 'js-sign-in-link'
to comment
- elsif discussion_locked
.discussion_locked
%span
.disabled-comment.text-center.prepend-top-default
%span.issuable-note-warning
This
= issuable.class.to_s
has been locked. Posting comments has been restricted to project members.
= issuable.class.to_s.titleize
is locked. Only
%b project members
can comment.
%script.js-notes-data{ type: "application/json" }= initial_notes_data(autocomplete).to_json.html_safe