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

165 lines
5.1 KiB
Vue
Raw Normal View History

2017-09-10 17:25:29 +05:30
<script>
2020-03-13 15:44:24 +05:30
import { GlLoadingIcon, GlBadge } from '@gitlab/ui';
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';
2019-09-30 21:07:59 +05:30
import { VISIBILITY_TYPE_ICON, GROUP_VISIBILITY_TYPE } from '../constants';
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';
2019-09-30 21:07:59 +05:30
import itemStatsValue from './item_stats_value.vue';
2018-03-17 18:26:18 +05:30
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: {
2020-03-13 15:44:24 +05:30
GlBadge,
2019-09-30 21:07:59 +05:30
GlLoadingIcon,
2018-03-17 18:26:18 +05:30
identicon,
itemCaret,
itemTypeIcon,
itemStats,
2019-09-30 21:07:59 +05:30
itemStatsValue,
2018-03-17 18:26:18 +05:30
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';
},
2020-03-13 15:44:24 +05:30
isGroupPendingRemoval() {
return this.group.type === 'group' && this.group.pendingRemoval;
},
2019-09-30 21:07:59 +05:30
visibilityIcon() {
return VISIBILITY_TYPE_ICON[this.group.visibility];
},
visibilityTooltip() {
return GROUP_VISIBILITY_TYPE[this.group.visibility];
},
2018-03-17 18:26:18 +05:30
},
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>
2019-02-15 15:39:39 +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 }"
2020-04-08 14:13:33 +05:30
class="group-row-contents d-flex align-items-center py-2 pr-3"
2018-11-18 11:00:15 +05:30
>
2019-02-15 15:39:39 +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>
2019-09-30 21:07:59 +05:30
<gl-loading-icon
v-if="group.isChildrenLoading"
2020-04-08 14:13:33 +05:30
size="lg"
class="d-none d-sm-inline-flex flex-shrink-0 append-right-8"
2019-09-30 21:07:59 +05:30
/>
2017-09-10 17:25:29 +05:30
<div
2019-09-30 21:07:59 +05:30
:class="{ 'd-sm-flex': !group.isChildrenLoading }"
2020-03-13 15:44:24 +05:30
class="avatar-container rect-avatar s32 d-none flex-grow-0 flex-shrink-0 "
2018-03-17 18:26:18 +05:30
>
2019-02-15 15:39:39 +05:30
<a :href="group.relativePath" class="no-expand">
2019-12-21 20:55:43 +05:30
<img v-if="hasAvatar" :src="group.avatarUrl" class="avatar s40" />
<identicon v-else :entity-id="group.id" :entity-name="group.name" size-class="s40" />
2017-09-10 17:25:29 +05:30
</a>
</div>
2019-09-30 21:07:59 +05:30
<div class="group-text-container d-flex flex-fill align-items-center">
<div class="group-text flex-grow-1 flex-shrink-1">
<div class="d-flex align-items-center flex-wrap title namespace-title append-right-8">
<a
v-tooltip
:href="group.relativePath"
:title="group.fullName"
class="no-expand prepend-top-8 append-right-8"
data-placement="bottom"
>{{
// ending bracket must be by closing tag to prevent
// link hover text-decoration from over-extending
group.name
}}</a
>
<item-stats-value
:icon-name="visibilityIcon"
:title="visibilityTooltip"
2019-10-12 21:52:04 +05:30
css-class="item-visibility d-inline-flex align-items-center prepend-top-8 append-right-4 text-secondary"
2019-09-30 21:07:59 +05:30
/>
<span v-if="group.permission" class="user-access-role prepend-top-8">
{{ group.permission }}
</span>
</div>
<div v-if="group.description" class="description">
<span v-html="group.description"> </span>
</div>
2018-11-18 11:00:15 +05:30
</div>
2020-03-13 15:44:24 +05:30
<div v-if="isGroupPendingRemoval">
<gl-badge variant="warning">{{ __('pending removal') }}</gl-badge>
</div>
2019-09-30 21:07:59 +05:30
<div
class="metadata align-items-md-center d-flex flex-grow-1 flex-shrink-0 flex-wrap justify-content-md-between"
>
<item-actions v-if="isGroup" :group="group" :parent-group="parentGroup" />
<item-stats :item="group" class="group-stats prepend-top-2 d-none d-md-flex" />
2018-11-18 11:00:15 +05:30
</div>
2018-03-17 18:26:18 +05:30
</div>
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>