debian-mirror-gitlab/app/assets/javascripts/blob/components/blob_header_default_actions.vue

84 lines
1.8 KiB
Vue
Raw Normal View History

2020-03-13 15:44:24 +05:30
<script>
2020-10-24 23:57:45 +05:30
import { GlButton, GlButtonGroup, GlTooltipDirective } from '@gitlab/ui';
2020-03-13 15:44:24 +05:30
import {
BTN_COPY_CONTENTS_TITLE,
BTN_DOWNLOAD_TITLE,
BTN_RAW_TITLE,
RICH_BLOB_VIEWER,
SIMPLE_BLOB_VIEWER,
} from './constants';
export default {
components: {
GlButtonGroup,
2020-10-24 23:57:45 +05:30
GlButton,
2020-03-13 15:44:24 +05:30
},
directives: {
GlTooltip: GlTooltipDirective,
},
props: {
rawPath: {
type: String,
required: true,
},
activeViewer: {
type: String,
default: SIMPLE_BLOB_VIEWER,
required: false,
},
2020-06-23 00:09:42 +05:30
hasRenderError: {
type: Boolean,
required: false,
default: false,
},
2020-03-13 15:44:24 +05:30
},
computed: {
downloadUrl() {
return `${this.rawPath}?inline=false`;
},
copyDisabled() {
return this.activeViewer === RICH_BLOB_VIEWER;
},
},
BTN_COPY_CONTENTS_TITLE,
BTN_DOWNLOAD_TITLE,
BTN_RAW_TITLE,
};
</script>
<template>
<gl-button-group>
2020-10-24 23:57:45 +05:30
<gl-button
2020-06-23 00:09:42 +05:30
v-if="!hasRenderError"
2020-03-13 15:44:24 +05:30
v-gl-tooltip.hover
:aria-label="$options.BTN_COPY_CONTENTS_TITLE"
:title="$options.BTN_COPY_CONTENTS_TITLE"
:disabled="copyDisabled"
data-clipboard-target="#blob-code-content"
2020-06-23 00:09:42 +05:30
data-testid="copyContentsButton"
2020-10-24 23:57:45 +05:30
icon="copy-to-clipboard"
category="primary"
variant="default"
/>
<gl-button
2020-03-13 15:44:24 +05:30
v-gl-tooltip.hover
:aria-label="$options.BTN_RAW_TITLE"
:title="$options.BTN_RAW_TITLE"
:href="rawPath"
target="_blank"
2020-10-24 23:57:45 +05:30
icon="doc-code"
category="primary"
variant="default"
/>
<gl-button
2020-03-13 15:44:24 +05:30
v-gl-tooltip.hover
:aria-label="$options.BTN_DOWNLOAD_TITLE"
:title="$options.BTN_DOWNLOAD_TITLE"
:href="downloadUrl"
target="_blank"
2020-10-24 23:57:45 +05:30
icon="download"
category="primary"
variant="default"
/>
2020-03-13 15:44:24 +05:30
</gl-button-group>
</template>