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

90 lines
2.2 KiB
Vue
Raw Normal View History

2018-03-17 18:26:18 +05:30
<script>
2022-04-04 11:22:00 +05:30
import { GlTooltipDirective, GlDropdown, GlDropdownItem } from '@gitlab/ui';
2018-03-17 18:26:18 +05:30
import { COMMON_STR } from '../constants';
2021-03-11 19:13:27 +05:30
import eventHub from '../event_hub';
2018-03-17 18:26:18 +05:30
2022-04-04 11:22:00 +05:30
const { LEAVE_BTN_TITLE, EDIT_BTN_TITLE, REMOVE_BTN_TITLE, OPTIONS_DROPDOWN_TITLE } = COMMON_STR;
2018-03-17 18:26:18 +05:30
export default {
components: {
2022-04-04 11:22:00 +05:30
GlDropdown,
GlDropdownItem,
2018-03-17 18:26:18 +05:30
},
directives: {
2021-01-29 00:20:46 +05:30
GlTooltip: GlTooltipDirective,
2018-03-17 18:26:18 +05:30
},
props: {
parentGroup: {
type: Object,
required: false,
default: () => ({}),
},
group: {
type: Object,
required: true,
},
2018-11-20 20:47:30 +05:30
action: {
type: String,
required: false,
default: '',
},
2018-03-17 18:26:18 +05:30
},
computed: {
2022-04-04 11:22:00 +05:30
removeButtonHref() {
return `${this.group.editPath}#js-remove-group-form`;
2018-03-17 18:26:18 +05:30
},
},
methods: {
onLeaveGroup() {
2018-11-20 20:47:30 +05:30
eventHub.$emit(`${this.action}showLeaveGroupModal`, this.group, this.parentGroup);
2018-03-17 18:26:18 +05:30
},
},
2022-04-04 11:22:00 +05:30
i18n: {
leaveBtnTitle: LEAVE_BTN_TITLE,
editBtnTitle: EDIT_BTN_TITLE,
removeBtnTitle: REMOVE_BTN_TITLE,
optionsDropdownTitle: OPTIONS_DROPDOWN_TITLE,
},
2018-03-17 18:26:18 +05:30
};
</script>
<template>
2022-04-04 11:22:00 +05:30
<div class="gl-display-flex gl-justify-content-end gl-ml-5">
<gl-dropdown
v-gl-tooltip.hover.focus="$options.i18n.optionsDropdownTitle"
right
category="tertiary"
icon="ellipsis_v"
no-caret
:data-testid="`group-${group.id}-dropdown-button`"
data-qa-selector="group_dropdown_button"
:data-qa-group-id="group.id"
>
<gl-dropdown-item
v-if="group.canEdit"
:data-testid="`edit-group-${group.id}-btn`"
:href="group.editPath"
@click.stop
>
{{ $options.i18n.editBtnTitle }}
</gl-dropdown-item>
<gl-dropdown-item
v-if="group.canLeave"
:data-testid="`leave-group-${group.id}-btn`"
@click.stop="onLeaveGroup"
>
{{ $options.i18n.leaveBtnTitle }}
</gl-dropdown-item>
<gl-dropdown-item
v-if="group.canRemove"
:href="removeButtonHref"
:data-testid="`remove-group-${group.id}-btn`"
variant="danger"
@click.stop
>
{{ $options.i18n.removeBtnTitle }}
</gl-dropdown-item>
</gl-dropdown>
2018-03-17 18:26:18 +05:30
</div>
</template>