Skip to content
Snippets Groups Projects

Display Contributor and Author badges on notes

Merged Mycroft Kang requested to merge TaehyeokKang/gitlab:mycroft-note-badge into master
4 unresolved threads
Compare and Show latest version
21 files
+ 242
105
Compare changes
  • Side-by-side
  • Inline
Files
21
@@ -7,6 +7,7 @@ import ReplyButton from './note_actions/reply_button.vue';
@@ -7,6 +7,7 @@ import ReplyButton from './note_actions/reply_button.vue';
import eventHub from '~/sidebar/event_hub';
import eventHub from '~/sidebar/event_hub';
import Api from '~/api';
import Api from '~/api';
import { deprecatedCreateFlash as flash } from '~/flash';
import { deprecatedCreateFlash as flash } from '~/flash';
 
import { splitCamelCase } from '../../lib/utils/text_utility';
export default {
export default {
name: 'NoteActions',
name: 'NoteActions',
@@ -57,6 +58,16 @@ export default {
@@ -57,6 +58,16 @@ export default {
required: false,
required: false,
default: false,
default: false,
},
},
 
noteableType: {
 
type: String,
 
required: false,
 
default: null,
 
},
 
projectName: {
 
type: String,
 
required: false,
 
default: null,
 
},
showReply: {
showReply: {
type: Boolean,
type: Boolean,
required: true,
required: true,
@@ -131,8 +142,8 @@ export default {
@@ -131,8 +142,8 @@ export default {
targetType() {
targetType() {
return this.getNoteableData.targetType;
return this.getNoteableData.targetType;
},
},
humanTargetType() {
noteableDisplayName() {
return this.targetType.replaceAll('_', ' ');
return splitCamelCase(this.noteableType).toLowerCase();
},
},
assignees() {
assignees() {
return this.getNoteableData.assignees || [];
return this.getNoteableData.assignees || [];
@@ -143,16 +154,14 @@ export default {
@@ -143,16 +154,14 @@ export default {
canAssign() {
canAssign() {
return this.getNoteableData.current_user?.can_update && this.isIssue;
return this.getNoteableData.current_user?.can_update && this.isIssue;
},
},
projectName() {
return this.getNoteableData.project_name;
},
displayAuthorBadgeText() {
displayAuthorBadgeText() {
return sprintf(__('This user is the author of this %{noteable}.'), {
return sprintf(__('This user is the author of this %{noteable}.'), {
noteable: this.humanTargetType,
noteable: this.noteableDisplayName,
});
});
},
},
displayMemberBadgeText() {
displayMemberBadgeText() {
return sprintf(__('This user is a member of the %{name} project.'), {
return sprintf(__('This user is a %{access} of the %{name} project.'), {
 
access: this.accessLevel.toLowerCase(),
name: this.projectName,
name: this.projectName,
});
});
},
},
@@ -209,19 +218,19 @@ export default {
@@ -209,19 +218,19 @@ export default {
<span
<span
v-if="isAuthor"
v-if="isAuthor"
class="note-role user-access-role has-tooltip"
class="note-role user-access-role has-tooltip"
title="displayAuthorBadgeText"
:title="displayAuthorBadgeText"
>{{ __('Author') }}</span
>{{ __('Author') }}</span
>
>
<span
<span
v-if="accessLevel"
v-if="accessLevel"
class="note-role user-access-role has-tooltip"
class="note-role user-access-role has-tooltip"
title="displayMemberBadgeText"
:title="displayMemberBadgeText"
>{{ accessLevel }}</span
>{{ accessLevel }}</span
>
>
<span
<span
v-else-if="isContributor"
v-else-if="isContributor"
class="note-role user-access-role has-tooltip"
class="note-role user-access-role has-tooltip"
title="displayContributorBadgeText"
:title="displayContributorBadgeText"
>{{ __('Contributor') }}</span
>{{ __('Contributor') }}</span
>
>
<div v-if="canResolve" class="note-actions-item">
<div v-if="canResolve" class="note-actions-item">
Loading