debian-mirror-gitlab/app/assets/javascripts/members/components/modals/leave_modal.vue

71 lines
1.7 KiB
Vue
Raw Normal View History

2021-01-03 14:25:43 +05:30
<script>
import { mapState } from 'vuex';
import { GlModal, GlForm, GlSprintf, GlTooltipDirective } from '@gitlab/ui';
import csrf from '~/lib/utils/csrf';
import { __, s__, sprintf } from '~/locale';
2021-02-22 17:27:13 +05:30
import { LEAVE_MODAL_ID } from '../../constants';
2021-01-03 14:25:43 +05:30
export default {
name: 'LeaveModal',
actionCancel: {
text: __('Cancel'),
},
actionPrimary: {
text: __('Leave'),
attributes: {
variant: 'danger',
},
},
csrf,
modalId: LEAVE_MODAL_ID,
modalContent: s__('Members|Are you sure you want to leave "%{source}"?'),
components: { GlModal, GlForm, GlSprintf },
directives: {
GlTooltip: GlTooltipDirective,
},
props: {
member: {
type: Object,
required: true,
},
},
computed: {
...mapState(['memberPath']),
leavePath() {
return this.memberPath.replace(/:id$/, 'leave');
},
modalTitle() {
2021-03-08 18:12:59 +05:30
return sprintf(s__('Members|Leave "%{source}"'), { source: this.member.source.fullName });
2021-01-03 14:25:43 +05:30
},
},
methods: {
handlePrimary() {
this.$refs.form.$el.submit();
},
},
};
</script>
<template>
<gl-modal
v-bind="$attrs"
:modal-id="$options.modalId"
:title="modalTitle"
:action-primary="$options.actionPrimary"
:action-cancel="$options.actionCancel"
size="sm"
@primary="handlePrimary"
>
<gl-form ref="form" :action="leavePath" method="post">
<p>
<gl-sprintf :message="$options.modalContent">
2021-03-08 18:12:59 +05:30
<template #source>{{ member.source.fullName }}</template>
2021-01-03 14:25:43 +05:30
</gl-sprintf>
</p>
<input type="hidden" name="_method" value="delete" />
<input :value="$options.csrf.token" type="hidden" name="authenticity_token" />
</gl-form>
</gl-modal>
</template>