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