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

72 lines
1.6 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 {
RICH_BLOB_VIEWER,
RICH_BLOB_VIEWER_TITLE,
SIMPLE_BLOB_VIEWER,
SIMPLE_BLOB_VIEWER_TITLE,
} from './constants';
export default {
components: {
GlButtonGroup,
2020-07-28 23:09:34 +05:30
GlButton,
2020-03-13 15:44:24 +05:30
},
directives: {
GlTooltip: GlTooltipDirective,
},
props: {
value: {
type: String,
default: SIMPLE_BLOB_VIEWER,
required: false,
},
},
computed: {
isSimpleViewer() {
return this.value === SIMPLE_BLOB_VIEWER;
},
isRichViewer() {
return this.value === RICH_BLOB_VIEWER;
},
},
methods: {
switchToViewer(viewer) {
if (viewer !== this.value) {
this.$emit('input', viewer);
}
},
},
SIMPLE_BLOB_VIEWER,
RICH_BLOB_VIEWER,
SIMPLE_BLOB_VIEWER_TITLE,
RICH_BLOB_VIEWER_TITLE,
};
</script>
<template>
2020-05-24 23:13:21 +05:30
<gl-button-group class="js-blob-viewer-switcher mx-2">
2020-07-28 23:09:34 +05:30
<gl-button
2020-03-13 15:44:24 +05:30
v-gl-tooltip.hover
:aria-label="$options.SIMPLE_BLOB_VIEWER_TITLE"
:title="$options.SIMPLE_BLOB_VIEWER_TITLE"
:selected="isSimpleViewer"
:class="{ active: isSimpleViewer }"
2020-10-24 23:57:45 +05:30
icon="code"
category="primary"
variant="default"
2020-03-13 15:44:24 +05:30
@click="switchToViewer($options.SIMPLE_BLOB_VIEWER)"
2020-10-24 23:57:45 +05:30
/>
2020-07-28 23:09:34 +05:30
<gl-button
2020-03-13 15:44:24 +05:30
v-gl-tooltip.hover
:aria-label="$options.RICH_BLOB_VIEWER_TITLE"
:title="$options.RICH_BLOB_VIEWER_TITLE"
:selected="isRichViewer"
:class="{ active: isRichViewer }"
2020-10-24 23:57:45 +05:30
icon="document"
category="primary"
variant="default"
2020-03-13 15:44:24 +05:30
@click="switchToViewer($options.RICH_BLOB_VIEWER)"
2020-10-24 23:57:45 +05:30
/>
2020-03-13 15:44:24 +05:30
</gl-button-group>
</template>