debian-mirror-gitlab/app/assets/javascripts/sidebar/components/assignees/assignees.vue
2020-05-25 16:23:42 +05:30

76 lines
1.8 KiB
Vue

<script>
import CollapsedAssigneeList from './collapsed_assignee_list.vue';
import UncollapsedAssigneeList from './uncollapsed_assignee_list.vue';
export default {
// name: 'Assignees' is a false positive: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/26#possible-false-positives
// eslint-disable-next-line @gitlab/require-i18n-strings
name: 'Assignees',
components: {
CollapsedAssigneeList,
UncollapsedAssigneeList,
},
props: {
rootPath: {
type: String,
required: true,
},
users: {
type: Array,
required: true,
},
editable: {
type: Boolean,
required: true,
},
issuableType: {
type: String,
required: false,
default: 'issue',
},
},
computed: {
hasNoUsers() {
return !this.users.length;
},
sortedAssigness() {
const canMergeUsers = this.users.filter(user => user.can_merge);
const canNotMergeUsers = this.users.filter(user => !user.can_merge);
return [...canMergeUsers, ...canNotMergeUsers];
},
},
methods: {
assignSelf() {
this.$emit('assign-self');
},
},
};
</script>
<template>
<div>
<collapsed-assignee-list :users="sortedAssigness" :issuable-type="issuableType" />
<div class="value hide-collapsed">
<template v-if="hasNoUsers">
<span class="assign-yourself no-value qa-assign-yourself">
{{ __('None') }}
<template v-if="editable">
-
<button type="button" class="btn-link" @click="assignSelf">
{{ __('assign yourself') }}
</button>
</template>
</span>
</template>
<uncollapsed-assignee-list
v-else
:users="sortedAssigness"
:root-path="rootPath"
:issuable-type="issuableType"
/>
</div>
</div>
</template>