debian-mirror-gitlab/app/assets/javascripts/notes/components/note_actions.vue

222 lines
5.7 KiB
Vue
Raw Normal View History

2018-03-17 18:26:18 +05:30
<script>
2018-05-09 12:01:36 +05:30
import { mapGetters } from 'vuex';
2018-12-05 23:21:45 +05:30
import Icon from '~/vue_shared/components/icon.vue';
2019-02-15 15:39:39 +05:30
import { GlLoadingIcon, GlTooltipDirective } from '@gitlab/ui';
2019-07-31 22:56:46 +05:30
import resolvedStatusMixin from 'ee_else_ce/batch_comments/mixins/resolved_status';
2019-03-02 22:35:43 +05:30
import ReplyButton from './note_actions/reply_button.vue';
2018-03-17 18:26:18 +05:30
2018-05-09 12:01:36 +05:30
export default {
name: 'NoteActions',
2018-12-05 23:21:45 +05:30
components: {
Icon,
2019-03-02 22:35:43 +05:30
ReplyButton,
2018-12-13 13:39:08 +05:30
GlLoadingIcon,
2018-12-05 23:21:45 +05:30
},
2018-05-09 12:01:36 +05:30
directives: {
2019-02-15 15:39:39 +05:30
GlTooltip: GlTooltipDirective,
2018-05-09 12:01:36 +05:30
},
2019-07-31 22:56:46 +05:30
mixins: [resolvedStatusMixin],
2018-05-09 12:01:36 +05:30
props: {
authorId: {
type: Number,
required: true,
},
noteId: {
2018-12-05 23:21:45 +05:30
type: [String, Number],
2018-05-09 12:01:36 +05:30
required: true,
},
2018-11-08 19:23:39 +05:30
noteUrl: {
type: String,
2018-11-20 20:47:30 +05:30
required: false,
default: '',
2018-11-08 19:23:39 +05:30
},
2018-05-09 12:01:36 +05:30
accessLevel: {
type: String,
required: false,
default: '',
},
reportAbusePath: {
type: String,
2018-12-05 23:21:45 +05:30
required: false,
default: null,
2018-05-09 12:01:36 +05:30
},
2019-03-02 22:35:43 +05:30
showReply: {
type: Boolean,
required: true,
},
2018-05-09 12:01:36 +05:30
canEdit: {
type: Boolean,
required: true,
},
canAwardEmoji: {
type: Boolean,
required: true,
},
canDelete: {
type: Boolean,
required: true,
},
2018-11-08 19:23:39 +05:30
canResolve: {
type: Boolean,
required: false,
default: false,
},
2018-05-09 12:01:36 +05:30
resolvable: {
type: Boolean,
required: false,
default: false,
},
isResolved: {
type: Boolean,
required: false,
default: false,
},
isResolving: {
type: Boolean,
required: false,
default: false,
},
resolvedBy: {
type: Object,
required: false,
default: () => ({}),
},
canReportAsAbuse: {
type: Boolean,
required: true,
},
},
computed: {
...mapGetters(['getUserDataByProp']),
shouldShowActionsDropdown() {
return this.currentUserId && (this.canEdit || this.canReportAsAbuse);
},
2018-12-05 23:21:45 +05:30
showDeleteAction() {
return this.canDelete && !this.canReportAsAbuse && !this.noteUrl;
},
2018-05-09 12:01:36 +05:30
isAuthoredByCurrentUser() {
return this.authorId === this.currentUserId;
},
currentUserId() {
return this.getUserDataByProp('id');
},
},
methods: {
onEdit() {
this.$emit('handleEdit');
},
onDelete() {
this.$emit('handleDelete');
},
onResolve() {
this.$emit('handleResolve');
},
2019-07-07 11:18:12 +05:30
closeTooltip() {
this.$nextTick(() => {
this.$root.$emit('bv::hide::tooltip');
});
},
2018-05-09 12:01:36 +05:30
},
};
2018-03-17 18:26:18 +05:30
</script>
<template>
<div class="note-actions">
2019-02-15 15:39:39 +05:30
<span v-if="accessLevel" class="note-role user-access-role">{{ accessLevel }}</span>
<div v-if="canResolve" class="note-actions-item">
2018-03-27 19:54:05 +05:30
<button
2019-07-07 11:18:12 +05:30
ref="resolveButton"
2019-02-15 15:39:39 +05:30
v-gl-tooltip
2018-03-27 19:54:05 +05:30
:class="{ 'is-disabled': !resolvable, 'is-active': isResolved }"
:title="resolveButtonTitle"
:aria-label="resolveButtonTitle"
type="button"
2018-11-08 19:23:39 +05:30
class="line-resolve-btn note-action-button"
2019-02-15 15:39:39 +05:30
@click="onResolve"
>
2018-03-27 19:54:05 +05:30
<template v-if="!isResolving">
2019-09-04 21:01:54 +05:30
<icon :name="isResolved ? 'check-circle-filled' : 'check-circle'" />
2018-03-27 19:54:05 +05:30
</template>
2019-02-15 15:39:39 +05:30
<gl-loading-icon v-else inline />
2018-03-27 19:54:05 +05:30
</button>
</div>
2019-02-15 15:39:39 +05:30
<div v-if="canAwardEmoji" class="note-actions-item">
2018-03-17 18:26:18 +05:30
<a
2019-03-02 22:35:43 +05:30
v-gl-tooltip
2018-03-17 18:26:18 +05:30
:class="{ 'js-user-authored': isAuthoredByCurrentUser }"
class="note-action-button note-emoji-button js-add-award js-note-emoji"
href="#"
title="Add reaction"
2019-09-04 21:01:54 +05:30
data-position="right"
2018-03-17 18:26:18 +05:30
>
2019-09-04 21:01:54 +05:30
<icon css-classes="link-highlight award-control-icon-neutral" name="slight-smile" />
<icon css-classes="link-highlight award-control-icon-positive" name="smiley" />
<icon css-classes="link-highlight award-control-icon-super-positive" name="smiley" />
2018-03-17 18:26:18 +05:30
</a>
</div>
2019-03-02 22:35:43 +05:30
<reply-button
2019-07-07 11:18:12 +05:30
v-if="showReply"
2019-03-02 22:35:43 +05:30
ref="replyButton"
class="js-reply-button"
2019-07-07 11:18:12 +05:30
@startReplying="$emit('startReplying')"
2019-03-02 22:35:43 +05:30
/>
2019-02-15 15:39:39 +05:30
<div v-if="canEdit" class="note-actions-item">
2018-03-17 18:26:18 +05:30
<button
2019-03-02 22:35:43 +05:30
v-gl-tooltip
2018-03-17 18:26:18 +05:30
type="button"
title="Edit comment"
class="note-action-button js-note-edit btn btn-transparent"
2019-02-15 15:39:39 +05:30
@click="onEdit"
>
<icon name="pencil" css-classes="link-highlight" />
2018-03-17 18:26:18 +05:30
</button>
</div>
2019-02-15 15:39:39 +05:30
<div v-if="showDeleteAction" class="note-actions-item">
2018-12-05 23:21:45 +05:30
<button
2019-03-02 22:35:43 +05:30
v-gl-tooltip
2018-12-05 23:21:45 +05:30
type="button"
title="Delete comment"
class="note-action-button js-note-delete btn btn-transparent"
@click="onDelete"
>
2019-02-15 15:39:39 +05:30
<icon name="remove" class="link-highlight" />
2018-12-05 23:21:45 +05:30
</button>
</div>
2019-02-15 15:39:39 +05:30
<div v-else-if="shouldShowActionsDropdown" class="dropdown more-actions note-actions-item">
2018-03-17 18:26:18 +05:30
<button
2019-03-02 22:35:43 +05:30
v-gl-tooltip
2018-03-17 18:26:18 +05:30
type="button"
title="More actions"
class="note-action-button more-actions-toggle btn btn-transparent"
data-toggle="dropdown"
2019-07-07 11:18:12 +05:30
@click="closeTooltip"
2019-02-15 15:39:39 +05:30
>
<icon css-classes="icon" name="ellipsis_v" />
2018-03-17 18:26:18 +05:30
</button>
<ul class="dropdown-menu more-actions-dropdown dropdown-open-left">
<li v-if="canReportAsAbuse">
2019-09-04 21:01:54 +05:30
<a :href="reportAbusePath">{{ __('Report abuse to admin') }}</a>
2018-03-17 18:26:18 +05:30
</li>
2018-11-20 20:47:30 +05:30
<li v-if="noteUrl">
2018-11-08 19:23:39 +05:30
<button
:data-clipboard-text="noteUrl"
type="button"
2018-11-20 20:47:30 +05:30
class="btn-default btn-transparent js-btn-copy-note-link"
2018-11-08 19:23:39 +05:30
>
2018-12-13 13:39:08 +05:30
{{ __('Copy link') }}
2018-11-08 19:23:39 +05:30
</button>
</li>
2018-03-17 18:26:18 +05:30
<li v-if="canEdit">
<button
class="btn btn-transparent js-note-delete js-note-delete"
2018-11-08 19:23:39 +05:30
type="button"
2019-02-15 15:39:39 +05:30
@click.prevent="onDelete"
>
<span class="text-danger">{{ __('Delete comment') }}</span>
2018-03-17 18:26:18 +05:30
</button>
</li>
</ul>
</div>
</div>
</template>