Commit b219dcd0 authored by Filipa Lacerda's avatar Filipa Lacerda

Adds confidential issue information

parent a6445299
...@@ -3,13 +3,14 @@ ...@@ -3,13 +3,14 @@
import { mapActions, mapGetters } from 'vuex'; import { mapActions, mapGetters } from 'vuex';
import _ from 'underscore'; import _ from 'underscore';
import userAvatarLink from '../../vue_shared/components/user_avatar/user_avatar_link.vue';
import markdownField from '../../vue_shared/components/markdown/field.vue';
import issueNoteSignedOutWidget from './issue_note_signed_out_widget.vue';
import eventHub from '../event_hub';
import * as constants from '../constants';
import '../../autosave'; import '../../autosave';
import TaskList from '../../task_list'; import TaskList from '../../task_list';
import * as constants from '../constants';
import eventHub from '../event_hub';
import confidentialIssue from '../../vue_shared/components/issue/confidential_issue_warning.vue';
import issueNoteSignedOutWidget from './issue_note_signed_out_widget.vue';
import markdownField from '../../vue_shared/components/markdown/field.vue';
import userAvatarLink from '../../vue_shared/components/user_avatar/user_avatar_link.vue';
export default { export default {
name: 'issueCommentForm', name: 'issueCommentForm',
...@@ -25,9 +26,10 @@ ...@@ -25,9 +26,10 @@
}; };
}, },
components: { components: {
userAvatarLink, confidentialIssue,
markdownField,
issueNoteSignedOutWidget, issueNoteSignedOutWidget,
markdownField,
userAvatarLink,
}, },
watch: { watch: {
note(newNote) { note(newNote) {
...@@ -88,6 +90,9 @@ ...@@ -88,6 +90,9 @@
endpoint() { endpoint() {
return this.getIssueData.create_note_path; return this.getIssueData.create_note_path;
}, },
isConfidentialIssue() {
return this.getIssueData.confidential;
},
}, },
methods: { methods: {
...mapActions([ ...mapActions([
...@@ -195,7 +200,7 @@ ...@@ -195,7 +200,7 @@
fieldName: 'note', fieldName: 'note',
selector: '.notes', selector: '.notes',
}); });
} },
}, },
mounted() { mounted() {
// jQuery is needed here because it is a custom event being dispatched with jQuery. // jQuery is needed here because it is a custom event being dispatched with jQuery.
...@@ -231,11 +236,14 @@ ...@@ -231,11 +236,14 @@
<form <form
class="js-main-target-form timeline-content timeline-content-form common-note-form" class="js-main-target-form timeline-content timeline-content-form common-note-form"
@submit="handleSave(true)"> @submit="handleSave(true)">
<confidentialIssue v-if="isConfidentialIssue" />
<markdown-field <markdown-field
:markdown-preview-url="markdownPreviewUrl" :markdown-preview-url="markdownPreviewUrl"
:markdown-docs="markdownDocsUrl" :markdown-docs="markdownDocsUrl"
:quick-actions-docs="quickActionsDocsUrl" :quick-actions-docs="quickActionsDocsUrl"
:add-spacing-classes="false"> :add-spacing-classes="false"
:is-confidential-issue="isConfidentialIssue">
<textarea <textarea
id="note-body" id="note-body"
name="note[note]" name="note[note]"
......
<script> <script>
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import markdownField from '../../vue_shared/components/markdown/field.vue';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
import confidentialIssue from '../../vue_shared/components/issue/confidential_issue_warning.vue';
import markdownField from '../../vue_shared/components/markdown/field.vue';
export default { export default {
name: 'issueNoteForm',
props: { props: {
noteBody: { noteBody: {
type: String, type: String,
...@@ -37,6 +39,7 @@ ...@@ -37,6 +39,7 @@
}; };
}, },
components: { components: {
confidentialIssue,
markdownField, markdownField,
}, },
computed: { computed: {
...@@ -64,6 +67,9 @@ ...@@ -64,6 +67,9 @@
isDisabled() { isDisabled() {
return !this.note.length || this.isSubmitting; return !this.note.length || this.isSubmitting;
}, },
isConfidentialIssue() {
return this.getIssueDataByProp('confidential');
},
}, },
methods: { methods: {
handleUpdate() { handleUpdate() {
...@@ -116,6 +122,7 @@ ...@@ -116,6 +122,7 @@
<div class="flash-container timeline-content"></div> <div class="flash-container timeline-content"></div>
<form <form
class="edit-note common-note-form"> class="edit-note common-note-form">
<confidentialIssue v-if="isConfidentialIssue" />
<markdown-field <markdown-field
:markdown-preview-url="markdownPreviewUrl" :markdown-preview-url="markdownPreviewUrl"
:markdown-docs="markdownDocsUrl" :markdown-docs="markdownDocsUrl"
......
<script>
export default {
name: 'confidentialIssueWarning',
};
</script>
<template>
<div class="confidential-issue-warning">
<i
aria-hidden="true"
class="fa fa-eye-slash">
</i>
<span>
This is a confidential issue. Your comment will not be visible to the public.
</span>
</div>
</template>
- referenced_users = local_assigns.fetch(:referenced_users, nil) - referenced_users = local_assigns.fetch(:referenced_users, nil)
- if defined?(@issue) && @issue.confidential?
%li.confidential-issue-warning
= confidential_icon(@issue)
%span This is a confidential issue. Your comment will not be visible to the public.
- else
%li.confidential-issue-warning.not-confidential
.md-area .md-area
.md-header .md-header
%ul.nav-links.clearfix %ul.nav-links.clearfix
......
...@@ -16,5 +16,3 @@ ...@@ -16,5 +16,3 @@
- content_for :page_specific_javascripts do - content_for :page_specific_javascripts do
= webpack_bundle_tag 'common_vue' = webpack_bundle_tag 'common_vue'
= webpack_bundle_tag 'notes' = webpack_bundle_tag 'notes'
= render "layouts/init_auto_complete"
...@@ -102,6 +102,16 @@ describe('issue_comment_form component', () => { ...@@ -102,6 +102,16 @@ describe('issue_comment_form component', () => {
}); });
}); });
}); });
describe('issue is confidential', () => {
it('shows information warning', (done) => {
store.dispatch('setIssueData', Object.assign(issueDataMock, { confidential: true }));
Vue.nextTick(() => {
expect(vm.$el.querySelector('.confidential-issue-warning')).toBeDefined();
done();
});
});
});
}); });
describe('user is not logged in', () => { describe('user is not logged in', () => {
......
import Vue from 'vue';
import confidentialIssue from '~/vue_shared/components/issue/confidential_issue_warning.vue';
describe('Confidential Issue Warning Component', () => {
let vm;
beforeEach(() => {
const Component = Vue.extend(confidentialIssue);
vm = new Component().$mount();
});
afterEach(() => {
vm.$destroy();
});
it('should render confidential issue warning information', () => {
expect(vm.$el.querySelector('i').className).toEqual('fa fa-eye-slash');
expect(vm.$el.querySelector('span').textContent.trim()).toEqual('This is a confidential issue. Your comment will not be visible to the public.');
});
});
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