gitlab-org--gitlab-foss/app/assets/javascripts/groups/components/group_item.vue

172 lines
4 KiB
Vue
Raw Normal View History

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