2018-06-21 12:22:40 +00:00
|
|
|
<script>
|
2020-04-03 09:09:31 +00:00
|
|
|
import { GlTooltipDirective, GlDeprecatedButton } from '@gitlab/ui';
|
2020-05-12 12:09:47 +00:00
|
|
|
import { __ } from '~/locale';
|
2019-02-28 14:14:15 +00:00
|
|
|
import Icon from '~/vue_shared/components/icon.vue';
|
|
|
|
|
2018-06-21 12:22:40 +00:00
|
|
|
export default {
|
2019-02-28 14:14:15 +00:00
|
|
|
components: {
|
2020-04-03 09:09:31 +00:00
|
|
|
GlDeprecatedButton,
|
2019-02-28 14:14:15 +00:00
|
|
|
Icon,
|
|
|
|
},
|
|
|
|
directives: {
|
|
|
|
GlTooltip: GlTooltipDirective,
|
|
|
|
},
|
2018-06-21 12:22:40 +00:00
|
|
|
props: {
|
|
|
|
editPath: {
|
|
|
|
type: String,
|
2020-05-12 12:09:47 +00:00
|
|
|
required: false,
|
|
|
|
default: '',
|
2018-06-21 12:22:40 +00:00
|
|
|
},
|
2018-07-17 15:47:02 +00:00
|
|
|
canCurrentUserFork: {
|
|
|
|
type: Boolean,
|
2018-06-21 12:22:40 +00:00
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
canModifyBlob: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
},
|
2020-05-12 12:09:47 +00:00
|
|
|
computed: {
|
|
|
|
tooltipTitle() {
|
|
|
|
if (this.isDisabled) {
|
|
|
|
return __("Can't edit as source branch was deleted");
|
|
|
|
}
|
|
|
|
|
|
|
|
return __('Edit file');
|
|
|
|
},
|
|
|
|
isDisabled() {
|
|
|
|
return !this.editPath;
|
|
|
|
},
|
|
|
|
},
|
2018-06-21 12:22:40 +00:00
|
|
|
methods: {
|
|
|
|
handleEditClick(evt) {
|
2019-02-28 08:23:17 +00:00
|
|
|
if (this.canCurrentUserFork && !this.canModifyBlob) {
|
2018-06-21 12:22:40 +00:00
|
|
|
evt.preventDefault();
|
|
|
|
this.$emit('showForkMessage');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2020-05-12 12:09:47 +00:00
|
|
|
<span v-gl-tooltip.top :title="tooltipTitle">
|
|
|
|
<gl-deprecated-button
|
|
|
|
:href="editPath"
|
|
|
|
:disabled="isDisabled"
|
|
|
|
:class="{ 'cursor-not-allowed': isDisabled }"
|
|
|
|
class="rounded-0 js-edit-blob"
|
|
|
|
@click.native="handleEditClick"
|
|
|
|
>
|
|
|
|
<icon name="pencil" />
|
|
|
|
</gl-deprecated-button>
|
|
|
|
</span>
|
2018-06-21 12:22:40 +00:00
|
|
|
</template>
|