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
10 files
+ 74
22
Compare changes
  • Side-by-side
  • Inline
Files
10
<script>
<script>
import { mapGetters } from 'vuex';
import { mapGetters } from 'vuex';
import { GlLoadingIcon, GlTooltipDirective, GlIcon } from '@gitlab/ui';
import { GlLoadingIcon, GlTooltipDirective, GlIcon } from '@gitlab/ui';
import { __ } from '~/locale';
import { __, sprintf } from '~/locale';
import resolvedStatusMixin from '~/batch_comments/mixins/resolved_status';
import resolvedStatusMixin from '~/batch_comments/mixins/resolved_status';
import ReplyButton from './note_actions/reply_button.vue';
import ReplyButton from './note_actions/reply_button.vue';
import eventHub from '~/sidebar/event_hub';
import eventHub from '~/sidebar/event_hub';
@@ -131,6 +131,9 @@ export default {
@@ -131,6 +131,9 @@ export default {
targetType() {
targetType() {
return this.getNoteableData.targetType;
return this.getNoteableData.targetType;
},
},
 
humanTargetType() {
 
return this.targetType.replaceAll('_', ' ');
 
},
assignees() {
assignees() {
return this.getNoteableData.assignees || [];
return this.getNoteableData.assignees || [];
},
},
@@ -140,6 +143,24 @@ export default {
@@ -140,6 +143,24 @@ 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() {
 
return sprintf(__('This user is the author of this %{noteable}.'), {
 
noteable: this.humanTargetType,
 
});
 
},
 
displayMemberBadgeText() {
 
return sprintf(__('This user is a member of the %{name} project.'), {
 
name: this.projectName,
 
});
 
},
 
displayContributorBadgeText() {
 
return sprintf(__('This user has previously committed to the %{name} project.'), {
 
name: this.projectName,
 
});
 
},
},
},
methods: {
methods: {
onEdit() {
onEdit() {
@@ -185,11 +206,24 @@ export default {
@@ -185,11 +206,24 @@ export default {
<template>
<template>
<div class="note-actions">
<div class="note-actions">
<span v-if="isAuthor" class="note-role user-access-role">{{ __('Author') }}</span>
<span
<span v-if="accessLevel" class="note-role user-access-role">{{ accessLevel }}</span>
v-if="isAuthor"
<span v-else-if="isContributor" class="note-role user-access-role">{{
class="note-role user-access-role has-tooltip"
__('Contributor')
title="displayAuthorBadgeText"
}}</span>
>{{ __('Author') }}</span
 
>
 
<span
 
v-if="accessLevel"
 
class="note-role user-access-role has-tooltip"
 
title="displayMemberBadgeText"
 
>{{ accessLevel }}</span
 
>
 
<span
 
v-else-if="isContributor"
 
class="note-role user-access-role has-tooltip"
 
title="displayContributorBadgeText"
 
>{{ __('Contributor') }}</span
 
>
<div v-if="canResolve" class="note-actions-item">
<div v-if="canResolve" class="note-actions-item">
<button
<button
ref="resolveButton"
ref="resolveButton"
Loading