debian-mirror-gitlab/app/assets/javascripts/groups/components/group_item.vue

129 lines
3.7 KiB
Vue
Raw Normal View History

2017-09-10 17:25:29 +05:30
<script>
2018-03-17 18:26:18 +05:30
import { visitUrl } from '../../lib/utils/url_utility';
import tooltip from '../../vue_shared/directives/tooltip';
import identicon from '../../vue_shared/components/identicon.vue';
2017-09-10 17:25:29 +05:30
import eventHub from '../event_hub';
2018-03-17 18:26:18 +05:30
import itemCaret from './item_caret.vue';
import itemTypeIcon from './item_type_icon.vue';
import itemStats from './item_stats.vue';
import itemActions from './item_actions.vue';
2017-09-10 17:25:29 +05:30
export default {
2018-03-17 18:26:18 +05:30
directives: {
tooltip,
},
2017-09-10 17:25:29 +05:30
components: {
2018-03-17 18:26:18 +05:30
identicon,
itemCaret,
itemTypeIcon,
itemStats,
itemActions,
2017-09-10 17:25:29 +05:30
},
props: {
2018-03-17 18:26:18 +05:30
parentGroup: {
2017-09-10 17:25:29 +05:30
type: Object,
required: false,
default: () => ({}),
},
2018-03-17 18:26:18 +05:30
group: {
2017-09-10 17:25:29 +05:30
type: Object,
2018-03-17 18:26:18 +05:30
required: true,
2017-09-10 17:25:29 +05:30
},
2018-11-20 20:47:30 +05:30
action: {
type: String,
required: false,
default: '',
},
2017-09-10 17:25:29 +05:30
},
computed: {
groupDomId() {
return `group-${this.group.id}`;
},
rowClass() {
return {
'is-open': this.group.isOpen,
2018-03-17 18:26:18 +05:30
'has-children': this.hasChildren,
'has-description': this.group.description,
'being-removed': this.group.isBeingRemoved,
2017-09-10 17:25:29 +05:30
};
},
2018-03-17 18:26:18 +05:30
hasChildren() {
return this.group.childrenCount > 0;
2017-09-10 17:25:29 +05:30
},
2018-03-17 18:26:18 +05:30
hasAvatar() {
return this.group.avatarUrl !== null;
},
isGroup() {
return this.group.type === 'group';
},
},
methods: {
onClickRowGroup(e) {
const NO_EXPAND_CLS = 'no-expand';
2018-11-20 20:47:30 +05:30
const targetClasses = e.target.classList;
const parentElClasses = e.target.parentElement.classList;
if (!(targetClasses.contains(NO_EXPAND_CLS) || parentElClasses.contains(NO_EXPAND_CLS))) {
2018-03-17 18:26:18 +05:30
if (this.hasChildren) {
2018-11-20 20:47:30 +05:30
eventHub.$emit(`${this.action}toggleChildren`, this.group);
2017-09-10 17:25:29 +05:30
} else {
2018-03-17 18:26:18 +05:30
visitUrl(this.group.relativePath);
2017-09-10 17:25:29 +05:30
}
}
},
},
};
</script>
<template>
2018-12-23 12:14:25 +05:30
<li :id="groupDomId" :class="rowClass" class="group-row" @click.stop="onClickRowGroup">
2017-09-10 17:25:29 +05:30
<div
2018-11-08 19:23:39 +05:30
:class="{ 'project-row-contents': !isGroup }"
2018-11-18 11:00:15 +05:30
class="group-row-contents d-flex justify-content-end align-items-center"
>
2018-12-23 12:14:25 +05:30
<div class="folder-toggle-wrap append-right-4 d-flex align-items-center">
<item-caret :is-group-open="group.isOpen" />
<item-type-icon :item-type="group.type" :is-group-open="group.isOpen" />
2017-09-10 17:25:29 +05:30
</div>
<div
2018-03-17 18:26:18 +05:30
:class="{ 'content-loading': group.isChildrenLoading }"
2018-11-20 20:47:30 +05:30
class="avatar-container s24 d-none d-sm-flex"
2018-03-17 18:26:18 +05:30
>
2018-12-23 12:14:25 +05:30
<a :href="group.relativePath" class="no-expand">
<img v-if="hasAvatar" :src="group.avatarUrl" class="avatar s24" />
<identicon v-else :entity-id="group.id" :entity-name="group.name" size-class="s24" />
2017-09-10 17:25:29 +05:30
</a>
</div>
2018-12-23 12:14:25 +05:30
<div class="group-text flex-grow">
<div class="title namespace-title append-right-8">
2018-11-18 11:00:15 +05:30
<a
v-tooltip
:href="group.relativePath"
:title="group.fullName"
class="no-expand"
data-placement="bottom"
2018-12-23 12:14:25 +05:30
>{{
// ending bracket must be by closing tag to prevent
// link hover text-decoration from over-extending
group.name
}}</a
2018-11-18 11:00:15 +05:30
>
2018-12-23 12:14:25 +05:30
<span v-if="group.permission" class="user-access-role"> {{ group.permission }} </span>
2018-11-18 11:00:15 +05:30
</div>
2018-12-23 12:14:25 +05:30
<div v-if="group.description" class="description">
<span v-html="group.description"> </span>
2018-11-18 11:00:15 +05:30
</div>
2018-03-17 18:26:18 +05:30
</div>
2018-12-23 12:14:25 +05:30
<item-stats :item="group" class="group-stats prepend-top-2" />
<item-actions v-if="isGroup" :group="group" :parent-group="parentGroup" />
2017-09-10 17:25:29 +05:30
</div>
<group-folder
2018-03-17 18:26:18 +05:30
v-if="group.isOpen && hasChildren"
:parent-group="group"
:groups="group.children"
2018-11-20 20:47:30 +05:30
:action="action"
2017-09-10 17:25:29 +05:30
/>
</li>
</template>