2018-03-27 19:54:05 +05:30
|
|
|
<script>
|
2020-05-24 23:13:21 +05:30
|
|
|
import CollapsedAssigneeList from './collapsed_assignee_list.vue';
|
|
|
|
import UncollapsedAssigneeList from './uncollapsed_assignee_list.vue';
|
2018-10-15 14:42:47 +05:30
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
export default {
|
2019-10-12 21:52:04 +05:30
|
|
|
// name: 'Assignees' is a false positive: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/26#possible-false-positives
|
2020-04-22 19:07:51 +05:30
|
|
|
// eslint-disable-next-line @gitlab/require-i18n-strings
|
2018-03-27 19:54:05 +05:30
|
|
|
name: 'Assignees',
|
2019-12-04 20:38:33 +05:30
|
|
|
components: {
|
|
|
|
CollapsedAssigneeList,
|
|
|
|
UncollapsedAssigneeList,
|
2018-10-15 14:42:47 +05:30
|
|
|
},
|
2018-03-27 19:54:05 +05:30
|
|
|
props: {
|
|
|
|
users: {
|
|
|
|
type: Array,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
editable: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
},
|
2018-10-15 14:42:47 +05:30
|
|
|
issuableType: {
|
|
|
|
type: String,
|
2019-12-04 20:38:33 +05:30
|
|
|
required: false,
|
2018-10-15 14:42:47 +05:30
|
|
|
default: 'issue',
|
|
|
|
},
|
2018-03-27 19:54:05 +05:30
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
hasNoUsers() {
|
|
|
|
return !this.users.length;
|
|
|
|
},
|
2019-12-04 20:38:33 +05:30
|
|
|
sortedAssigness() {
|
2021-03-08 18:12:59 +05:30
|
|
|
const canMergeUsers = this.users.filter((user) => user.can_merge);
|
|
|
|
const canNotMergeUsers = this.users.filter((user) => !user.can_merge);
|
2019-12-04 20:38:33 +05:30
|
|
|
return [...canMergeUsers, ...canNotMergeUsers];
|
2019-07-31 22:56:46 +05:30
|
|
|
},
|
2018-03-27 19:54:05 +05:30
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
assignSelf() {
|
|
|
|
this.$emit('assign-self');
|
|
|
|
},
|
2021-12-11 22:18:48 +05:30
|
|
|
toggleAttentionRequested(data) {
|
|
|
|
this.$emit('toggle-attention-requested', data);
|
|
|
|
},
|
2018-03-27 19:54:05 +05:30
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div>
|
2019-12-04 20:38:33 +05:30
|
|
|
<collapsed-assignee-list :users="sortedAssigness" :issuable-type="issuableType" />
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
<div data-testid="expanded-assignee" class="value hide-collapsed">
|
2021-09-04 01:27:46 +05:30
|
|
|
<span v-if="hasNoUsers" class="no-value" data-testid="no-value">
|
|
|
|
{{ __('None') }}
|
|
|
|
<template v-if="editable">
|
|
|
|
-
|
|
|
|
<button type="button" class="btn-link" data-testid="assign-yourself" @click="assignSelf">
|
|
|
|
{{ __('assign yourself') }}
|
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
</span>
|
2019-12-04 20:38:33 +05:30
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
<uncollapsed-assignee-list
|
|
|
|
v-else
|
|
|
|
:users="sortedAssigness"
|
|
|
|
:issuable-type="issuableType"
|
|
|
|
@toggle-attention-requested="toggleAttentionRequested"
|
|
|
|
/>
|
2018-03-27 19:54:05 +05:30
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|