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-01-03 12:48:30 +05:30
|
|
|
import tooltip from '~/vue_shared/directives/tooltip';
|
|
|
|
import { GlLoadingIcon } from '@gitlab-org/gitlab-ui';
|
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,
|
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-01-03 12:48:30 +05:30
|
|
|
tooltip,
|
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
|
|
|
},
|
|
|
|
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');
|
|
|
|
},
|
|
|
|
resolveButtonTitle() {
|
|
|
|
let title = 'Mark as resolved';
|
2018-03-27 19:54:05 +05:30
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
if (this.resolvedBy) {
|
|
|
|
title = `Resolved by ${this.resolvedBy.name}`;
|
|
|
|
}
|
2018-03-27 19:54:05 +05:30
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
return title;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onEdit() {
|
|
|
|
this.$emit('handleEdit');
|
|
|
|
},
|
|
|
|
onDelete() {
|
|
|
|
this.$emit('handleDelete');
|
|
|
|
},
|
|
|
|
onResolve() {
|
|
|
|
this.$emit('handleResolve');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2018-03-17 18:26:18 +05:30
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="note-actions">
|
2019-01-03 12:48:30 +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-01-03 12:48:30 +05:30
|
|
|
v-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-01-03 12:48:30 +05:30
|
|
|
@click="onResolve">
|
2018-03-27 19:54:05 +05:30
|
|
|
<template v-if="!isResolving">
|
2018-12-13 13:39:08 +05:30
|
|
|
<icon name="check-circle" />
|
2018-03-27 19:54:05 +05:30
|
|
|
</template>
|
2019-01-03 12:48:30 +05:30
|
|
|
<gl-loading-icon
|
|
|
|
v-else
|
|
|
|
inline
|
|
|
|
/>
|
2018-03-27 19:54:05 +05:30
|
|
|
</button>
|
|
|
|
</div>
|
2019-01-03 12:48:30 +05:30
|
|
|
<div
|
|
|
|
v-if="canAwardEmoji"
|
|
|
|
class="note-actions-item">
|
2018-03-17 18:26:18 +05:30
|
|
|
<a
|
2019-01-03 12:48:30 +05:30
|
|
|
v-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"
|
|
|
|
data-position="right"
|
2019-01-03 12:48:30 +05:30
|
|
|
data-placement="bottom"
|
|
|
|
data-container="body"
|
2018-03-17 18:26:18 +05:30
|
|
|
href="#"
|
|
|
|
title="Add reaction"
|
|
|
|
>
|
2019-01-03 12:48:30 +05:30
|
|
|
<gl-loading-icon inline/>
|
2018-12-13 13:39:08 +05:30
|
|
|
<icon
|
|
|
|
css-classes="link-highlight award-control-icon-neutral"
|
|
|
|
name="emoji_slightly_smiling_face"
|
|
|
|
/>
|
2019-01-03 12:48:30 +05:30
|
|
|
<icon
|
|
|
|
css-classes="link-highlight award-control-icon-positive"
|
|
|
|
name="emoji_smiley"
|
|
|
|
/>
|
|
|
|
<icon
|
|
|
|
css-classes="link-highlight award-control-icon-super-positive"
|
|
|
|
name="emoji_smiley"
|
|
|
|
/>
|
2018-03-17 18:26:18 +05:30
|
|
|
</a>
|
|
|
|
</div>
|
2019-01-03 12:48:30 +05:30
|
|
|
<div
|
|
|
|
v-if="canEdit"
|
|
|
|
class="note-actions-item">
|
2018-03-17 18:26:18 +05:30
|
|
|
<button
|
2019-01-03 12:48:30 +05:30
|
|
|
v-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-01-03 12:48:30 +05:30
|
|
|
data-container="body"
|
|
|
|
data-placement="bottom"
|
|
|
|
@click="onEdit">
|
|
|
|
<icon
|
|
|
|
name="pencil"
|
|
|
|
css-classes="link-highlight"
|
|
|
|
/>
|
2018-03-17 18:26:18 +05:30
|
|
|
</button>
|
|
|
|
</div>
|
2019-01-03 12:48:30 +05:30
|
|
|
<div
|
|
|
|
v-if="showDeleteAction"
|
|
|
|
class="note-actions-item"
|
|
|
|
>
|
2018-12-05 23:21:45 +05:30
|
|
|
<button
|
2019-01-03 12:48:30 +05:30
|
|
|
v-tooltip
|
2018-12-05 23:21:45 +05:30
|
|
|
type="button"
|
|
|
|
title="Delete comment"
|
|
|
|
class="note-action-button js-note-delete btn btn-transparent"
|
2019-01-03 12:48:30 +05:30
|
|
|
data-container="body"
|
|
|
|
data-placement="bottom"
|
2018-12-05 23:21:45 +05:30
|
|
|
@click="onDelete"
|
|
|
|
>
|
2019-01-03 12:48:30 +05:30
|
|
|
<icon
|
|
|
|
name="remove"
|
|
|
|
class="link-highlight"
|
|
|
|
/>
|
2018-12-05 23:21:45 +05:30
|
|
|
</button>
|
|
|
|
</div>
|
2019-01-03 12:48:30 +05:30
|
|
|
<div
|
|
|
|
v-else-if="shouldShowActionsDropdown"
|
|
|
|
class="dropdown more-actions note-actions-item">
|
2018-03-17 18:26:18 +05:30
|
|
|
<button
|
2019-01-03 12:48:30 +05:30
|
|
|
v-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-01-03 12:48:30 +05:30
|
|
|
data-container="body"
|
|
|
|
data-placement="bottom">
|
|
|
|
<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-01-03 12:48:30 +05:30
|
|
|
<a :href="reportAbusePath">
|
|
|
|
{{ __('Report abuse to GitLab') }}
|
|
|
|
</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-01-03 12:48:30 +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>
|