Commit 56af0631 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'refactor/move-assignees-vue-component' into 'master'

Move (Multiple) Assignees vue component

See merge request gitlab-org/gitlab-ce!16952
parents fcf34e28 514f22c4
...@@ -6,7 +6,7 @@ import { __ } from '../../locale'; ...@@ -6,7 +6,7 @@ import { __ } from '../../locale';
import Sidebar from '../../right_sidebar'; import Sidebar from '../../right_sidebar';
import eventHub from '../../sidebar/event_hub'; import eventHub from '../../sidebar/event_hub';
import assigneeTitle from '../../sidebar/components/assignees/assignee_title'; import assigneeTitle from '../../sidebar/components/assignees/assignee_title';
import assignees from '../../sidebar/components/assignees/assignees'; import assignees from '../../sidebar/components/assignees/assignees.vue';
import DueDateSelectors from '../../due_date_select'; import DueDateSelectors from '../../due_date_select';
import './sidebar/remove_issue'; import './sidebar/remove_issue';
import IssuableContext from '../../issuable_context'; import IssuableContext from '../../issuable_context';
......
<script>
export default { export default {
name: 'Assignees', name: 'Assignees',
data() {
return {
defaultRenderCount: 5,
defaultMaxCounter: 99,
showLess: true,
};
},
props: { props: {
rootPath: { rootPath: {
type: String, type: String,
...@@ -21,6 +15,13 @@ export default { ...@@ -21,6 +15,13 @@ export default {
required: true, required: true,
}, },
}, },
data() {
return {
defaultRenderCount: 5,
defaultMaxCounter: 99,
showLess: true,
};
},
computed: { computed: {
firstUser() { firstUser() {
return this.users[0]; return this.users[0];
...@@ -101,124 +102,130 @@ export default { ...@@ -101,124 +102,130 @@ export default {
return index === 0 || firstTwo; return index === 0 || firstTwo;
}, },
}, },
template: ` };
<div> </script>
<div
class="sidebar-collapsed-icon sidebar-collapsed-user" <template>
:class="{ 'multiple-users': hasMoreThanOneAssignee, 'has-tooltip': hasAssignees }" <div>
data-container="body" <div
data-placement="left" class="sidebar-collapsed-icon sidebar-collapsed-user"
:title="collapsedTooltipTitle" :class="{ 'multiple-users': hasMoreThanOneAssignee, 'has-tooltip': hasAssignees }"
data-container="body"
data-placement="left"
:title="collapsedTooltipTitle"
>
<i
v-if="hasNoUsers"
aria-label="No Assignee"
class="fa fa-user"
> >
<i </i>
v-if="hasNoUsers" <button
aria-label="No Assignee" type="button"
class="fa fa-user" class="btn-link"
v-for="(user, index) in users"
v-if="shouldRenderCollapsedAssignee(index)"
:key="user.id"
>
<img
width="24"
class="avatar avatar-inline s24"
:alt="assigneeAlt(user)"
:src="avatarUrl(user)"
/> />
<button <span class="author">
type="button" {{ user.name }}
class="btn-link" </span>
v-for="(user, index) in users" </button>
v-if="shouldRenderCollapsedAssignee(index)" <button
v-if="hasMoreThanTwoAssignees"
class="btn-link"
type="button"
>
<span
class="avatar-counter sidebar-avatar-counter"
>
{{ sidebarAvatarCounter }}
</span>
</button>
</div>
<div class="value hide-collapsed">
<template v-if="hasNoUsers">
<span class="assign-yourself no-value">
No assignee
<template v-if="editable">
-
<button
type="button"
class="btn-link"
@click="assignSelf"
>
assign yourself
</button>
</template>
</span>
</template>
<template v-else-if="hasOneUser">
<a
class="author_link bold"
:href="assigneeUrl(firstUser)"
> >
<img <img
width="24" width="32"
class="avatar avatar-inline s24" class="avatar avatar-inline s32"
:alt="assigneeAlt(user)" :alt="assigneeAlt(firstUser)"
:src="avatarUrl(user)" :src="avatarUrl(firstUser)"
/> />
<span class="author"> <span class="author">
{{ user.name }} {{ firstUser.name }}
</span> </span>
</button> <span class="username">
<button {{ assigneeUsername(firstUser) }}
v-if="hasMoreThanTwoAssignees"
class="btn-link"
type="button"
>
<span
class="avatar-counter sidebar-avatar-counter"
>
{{ sidebarAvatarCounter }}
</span> </span>
</button> </a>
</div> </template>
<div class="value hide-collapsed"> <template v-else>
<template v-if="hasNoUsers"> <div class="user-list">
<span class="assign-yourself no-value">
No assignee
<template v-if="editable">
-
<button
type="button"
class="btn-link"
@click="assignSelf"
>
assign yourself
</button>
</template>
</span>
</template>
<template v-else-if="hasOneUser">
<a
class="author_link bold"
:href="assigneeUrl(firstUser)"
>
<img
width="32"
class="avatar avatar-inline s32"
:alt="assigneeAlt(firstUser)"
:src="avatarUrl(firstUser)"
/>
<span class="author">
{{ firstUser.name }}
</span>
<span class="username">
{{ assigneeUsername(firstUser) }}
</span>
</a>
</template>
<template v-else>
<div class="user-list">
<div
class="user-item"
v-for="(user, index) in users"
v-if="renderAssignee(index)"
>
<a
class="user-link has-tooltip"
data-placement="bottom"
:href="assigneeUrl(user)"
:data-title="user.name"
>
<img
width="32"
class="avatar avatar-inline s32"
:alt="assigneeAlt(user)"
:src="avatarUrl(user)"
/>
</a>
</div>
</div>
<div <div
v-if="renderShowMoreSection" class="user-item"
class="user-list-more" v-for="(user, index) in users"
v-if="renderAssignee(index)"
:key="user.id"
> >
<button <a
type="button" class="user-link has-tooltip"
class="btn-link" data-placement="bottom"
@click="toggleShowLess" :href="assigneeUrl(user)"
:data-title="user.name"
> >
<template v-if="showLess"> <img
{{ hiddenAssigneesLabel }} width="32"
</template> class="avatar avatar-inline s32"
<template v-else> :alt="assigneeAlt(user)"
- show less :src="avatarUrl(user)"
</template> />
</button> </a>
</div> </div>
</template> </div>
</div> <div
v-if="renderShowMoreSection"
class="user-list-more"
>
<button
type="button"
class="btn-link"
@click="toggleShowLess"
>
<template v-if="showLess">
{{ hiddenAssigneesLabel }}
</template>
<template v-else>
- show less
</template>
</button>
</div>
</template>
</div> </div>
`, </div>
}; </template>
import Flash from '../../../flash'; import Flash from '../../../flash';
import AssigneeTitle from './assignee_title'; import AssigneeTitle from './assignee_title';
import Assignees from './assignees'; import Assignees from './assignees.vue';
import Store from '../../stores/sidebar_store'; import Store from '../../stores/sidebar_store';
import eventHub from '../../event_hub'; import eventHub from '../../event_hub';
...@@ -28,8 +28,8 @@ export default { ...@@ -28,8 +28,8 @@ export default {
}, },
}, },
components: { components: {
'assignee-title': AssigneeTitle, AssigneeTitle,
assignees: Assignees, Assignees,
}, },
methods: { methods: {
assignSelf() { assignSelf() {
......
---
title: Move Assignees vue component
merge_request: 16952
author: George Tsiolis
type: performance
import Vue from 'vue'; import Vue from 'vue';
import Assignee from '~/sidebar/components/assignees/assignees'; import Assignee from '~/sidebar/components/assignees/assignees.vue';
import UsersMock from './mock_data'; import UsersMock from './mock_data';
import UsersMockHelper from '../helpers/user_mock_data_helper'; import UsersMockHelper from '../helpers/user_mock_data_helper';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment