2017-10-04 10:10:24 -04:00
|
|
|
<script>
|
2022-02-11 13:18:58 -05:00
|
|
|
import { GlTooltipDirective, GlDropdown, GlDropdownItem } from '@gitlab/ui';
|
2018-01-10 02:25:41 -05:00
|
|
|
import { COMMON_STR } from '../constants';
|
2021-02-14 13:09:20 -05:00
|
|
|
import eventHub from '../event_hub';
|
2017-10-04 10:10:24 -04:00
|
|
|
|
2022-02-11 13:18:58 -05:00
|
|
|
const { LEAVE_BTN_TITLE, EDIT_BTN_TITLE, REMOVE_BTN_TITLE, OPTIONS_DROPDOWN_TITLE } = COMMON_STR;
|
|
|
|
|
2018-01-10 02:25:41 -05:00
|
|
|
export default {
|
|
|
|
components: {
|
2022-02-11 13:18:58 -05:00
|
|
|
GlDropdown,
|
|
|
|
GlDropdownItem,
|
2018-01-10 02:25:41 -05:00
|
|
|
},
|
|
|
|
directives: {
|
2020-10-22 02:08:26 -04:00
|
|
|
GlTooltip: GlTooltipDirective,
|
2018-01-10 02:25:41 -05:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
parentGroup: {
|
|
|
|
type: Object,
|
|
|
|
required: false,
|
|
|
|
default: () => ({}),
|
2017-10-04 10:10:24 -04:00
|
|
|
},
|
2018-01-10 02:25:41 -05:00
|
|
|
group: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
2017-10-04 10:10:24 -04:00
|
|
|
},
|
2018-09-07 02:09:13 -04:00
|
|
|
action: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
|
|
|
},
|
2018-01-10 02:25:41 -05:00
|
|
|
},
|
|
|
|
computed: {
|
2022-02-11 13:18:58 -05:00
|
|
|
removeButtonHref() {
|
|
|
|
return `${this.group.editPath}#js-remove-group-form`;
|
2017-10-04 10:10:24 -04:00
|
|
|
},
|
2018-01-10 02:25:41 -05:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onLeaveGroup() {
|
2020-06-22 20:08:58 -04:00
|
|
|
eventHub.$emit(`${this.action}showLeaveGroupModal`, this.group, this.parentGroup);
|
2017-10-04 10:10:24 -04:00
|
|
|
},
|
2018-01-10 02:25:41 -05:00
|
|
|
},
|
2022-02-11 13:18:58 -05:00
|
|
|
i18n: {
|
|
|
|
leaveBtnTitle: LEAVE_BTN_TITLE,
|
|
|
|
editBtnTitle: EDIT_BTN_TITLE,
|
|
|
|
removeBtnTitle: REMOVE_BTN_TITLE,
|
|
|
|
optionsDropdownTitle: OPTIONS_DROPDOWN_TITLE,
|
|
|
|
},
|
2018-01-10 02:25:41 -05:00
|
|
|
};
|
2017-10-04 10:10:24 -04:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2022-02-11 13:18:58 -05:00
|
|
|
<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>
|
2017-10-04 10:10:24 -04:00
|
|
|
</div>
|
|
|
|
</template>
|