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

92 lines
2.1 KiB
Vue
Raw Normal View History

<script>
2018-01-08 15:45:34 -05:00
import { s__ } from '~/locale';
import tooltip from '~/vue_shared/directives/tooltip';
import icon from '~/vue_shared/components/icon.vue';
import modal from '~/vue_shared/components/modal.vue';
import eventHub from '../event_hub';
import { COMMON_STR } from '../constants';
2018-01-08 15:45:34 -05:00
export default {
components: {
icon,
modal,
},
2018-01-08 15:45:34 -05:00
directives: {
tooltip,
},
2018-01-08 15:45:34 -05:00
props: {
parentGroup: {
type: Object,
required: false,
default: () => ({}),
},
group: {
type: Object,
required: true,
},
},
2018-01-08 15:45:34 -05:00
data() {
return {
modalStatus: false,
};
},
2018-01-08 15:45:34 -05:00
computed: {
leaveBtnTitle() {
return COMMON_STR.LEAVE_BTN_TITLE;
},
editBtnTitle() {
return COMMON_STR.EDIT_BTN_TITLE;
},
leaveConfirmationMessage() {
return s__(`GroupsTree|Are you sure you want to leave the "${this.group.fullName}" group?`);
},
},
2018-01-08 15:45:34 -05:00
methods: {
onLeaveGroup() {
this.modalStatus = true;
},
leaveGroup() {
this.modalStatus = false;
eventHub.$emit('leaveGroup', this.group, this.parentGroup);
},
},
2018-01-08 15:45:34 -05:00
};
</script>
<template>
<div class="controls">
<a
v-tooltip
v-if="group.canEdit"
:href="group.editPath"
:title="editBtnTitle"
:aria-label="editBtnTitle"
data-container="body"
data-placement="bottom"
class="edit-group btn no-expand">
2017-12-22 02:00:07 -05:00
<icon name="settings"/>
</a>
<a
v-tooltip
v-if="group.canLeave"
@click.prevent="onLeaveGroup"
:href="group.leavePath"
:title="leaveBtnTitle"
:aria-label="leaveBtnTitle"
data-container="body"
data-placement="bottom"
class="leave-group btn no-expand">
2017-12-22 02:00:07 -05:00
<icon name="leave"/>
</a>
2017-12-11 13:43:28 -05:00
<modal
v-show="modalStatus"
:primary-button-label="__('Leave')"
kind="warning"
:title="__('Are you sure?')"
:text="__('Are you sure you want to leave this group?')"
:body="leaveConfirmationMessage"
@submit="leaveGroup"
/>
</div>
</template>