gitlab-org--gitlab-foss/app/assets/javascripts/sidebar/components/confidential/edit_form_buttons.vue

53 lines
1.1 KiB
Vue

<script>
import $ from 'jquery';
import eventHub from '../../event_hub';
import { __ } from '~/locale';
export default {
props: {
isConfidential: {
required: true,
type: Boolean,
},
updateConfidentialAttribute: {
required: true,
type: Function,
},
},
computed: {
toggleButtonText() {
return this.isConfidential ? __('Turn Off') : __('Turn On');
},
updateConfidentialBool() {
return !this.isConfidential;
},
},
methods: {
closeForm() {
eventHub.$emit('closeConfidentialityForm');
$(this.$el).trigger('hidden.gl.dropdown');
},
submitForm() {
this.closeForm();
this.updateConfidentialAttribute(this.updateConfidentialBool);
},
},
};
</script>
<template>
<div class="sidebar-item-warning-message-actions">
<button type="button" class="btn btn-default append-right-10" @click="closeForm">
{{ __('Cancel') }}
</button>
<button
type="button"
class="btn btn-close"
data-testid="confidential-toggle"
@click.prevent="submitForm"
>
{{ toggleButtonText }}
</button>
</div>
</template>