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

173 lines
5.3 KiB
Vue
Raw Normal View History

2017-09-10 17:25:29 +05:30
<script>
2020-11-24 15:15:51 +05:30
/* eslint-disable vue/no-v-html */
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
2020-06-23 00:09:42 +05:30
import { showLearnGitLabGroupItemPopover } from '~/onboarding_issues';
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
},
2020-06-23 00:09:42 +05:30
mounted() {
if (this.group.name === 'Learn GitLab') {
showLearnGitLabGroupItemPopover(this.group.id);
}
},
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
>
2020-07-28 23:09:34 +05:30
<div class="folder-toggle-wrap gl-mr-2 d-flex align-items-center">
2019-02-15 15:39:39 +05:30
<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"
2020-06-23 00:09:42 +05:30
class="d-none d-sm-inline-flex flex-shrink-0 gl-mr-3"
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">
2020-06-23 00:09:42 +05:30
<div class="d-flex align-items-center flex-wrap title namespace-title gl-mr-3">
2019-09-30 21:07:59 +05:30
<a
v-tooltip
:href="group.relativePath"
:title="group.fullName"
2020-06-23 00:09:42 +05:30
class="no-expand gl-mt-3 gl-mr-3 gl-text-gray-900!"
2019-09-30 21:07:59 +05:30
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"
2020-07-28 23:09:34 +05:30
css-class="item-visibility d-inline-flex align-items-center gl-mt-3 gl-mr-2 text-secondary"
2019-09-30 21:07:59 +05:30
/>
2020-06-23 00:09:42 +05:30
<span v-if="group.permission" class="user-access-role gl-mt-3">
2019-09-30 21:07:59 +05:30
{{ 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" />
2020-06-23 00:09:42 +05:30
<item-stats :item="group" class="group-stats gl-mt-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>