gitlab-org--gitlab-foss/app/assets/javascripts/ide/components/repo_edit_button.vue

58 lines
1.2 KiB
Vue
Raw Normal View History

<script>
import { mapGetters, mapActions, mapState } from 'vuex';
2017-12-11 13:43:28 -05:00
import modal from '../../vue_shared/components/modal.vue';
export default {
components: {
2017-12-11 13:43:28 -05:00
modal,
},
computed: {
...mapState([
'editMode',
'discardPopupOpen',
]),
...mapGetters([
'canEditFile',
]),
buttonLabel() {
return this.editMode ? this.__('Cancel edit') : this.__('Edit');
},
},
methods: {
...mapActions([
'toggleEditMode',
'closeDiscardPopup',
]),
2017-08-15 14:16:42 -04:00
},
2017-08-04 08:13:32 -04:00
};
</script>
<template>
<div class="editable-mode">
<button
v-if="canEditFile"
class="btn btn-default"
type="button"
@click.prevent="toggleEditMode()">
<i
v-if="!editMode"
class="fa fa-pencil"
aria-hidden="true">
</i>
<span>
{{buttonLabel}}
</span>
</button>
2017-12-11 13:43:28 -05:00
<modal
v-if="discardPopupOpen"
class="text-left"
:primary-button-label="__('Discard changes')"
kind="warning"
:title="__('Are you sure?')"
:text="__('Are you sure you want to discard your changes?')"
@cancel="closeDiscardPopup"
@submit="toggleEditMode(true)"
/>
</div>
</template>