gitlab-org--gitlab-foss/app/assets/javascripts/diffs/components/edit_button.vue

50 lines
950 B
Vue
Raw Normal View History

2018-06-21 08:22:40 -04:00
<script>
import { GlTooltipDirective, GlDeprecatedButton } from '@gitlab/ui';
import Icon from '~/vue_shared/components/icon.vue';
2018-06-21 08:22:40 -04:00
export default {
components: {
GlDeprecatedButton,
Icon,
},
directives: {
GlTooltip: GlTooltipDirective,
},
2018-06-21 08:22:40 -04:00
props: {
editPath: {
type: String,
required: true,
},
canCurrentUserFork: {
type: Boolean,
2018-06-21 08:22:40 -04:00
required: true,
},
canModifyBlob: {
type: Boolean,
required: false,
default: false,
},
},
methods: {
handleEditClick(evt) {
if (this.canCurrentUserFork && !this.canModifyBlob) {
2018-06-21 08:22:40 -04:00
evt.preventDefault();
this.$emit('showForkMessage');
}
},
},
};
</script>
<template>
<gl-deprecated-button
v-gl-tooltip.top
:href="editPath"
:title="__('Edit file')"
class="js-edit-blob"
@click.native="handleEditClick"
>
<icon name="pencil" />
</gl-deprecated-button>
2018-06-21 08:22:40 -04:00
</template>