diff options
Diffstat (limited to 'app/assets/javascripts/repo/components/repo_file_buttons.vue')
-rw-r--r-- | app/assets/javascripts/repo/components/repo_file_buttons.vue | 53 |
1 files changed, 20 insertions, 33 deletions
diff --git a/app/assets/javascripts/repo/components/repo_file_buttons.vue b/app/assets/javascripts/repo/components/repo_file_buttons.vue index e43ef366f47..dd948ee84fb 100644 --- a/app/assets/javascripts/repo/components/repo_file_buttons.vue +++ b/app/assets/javascripts/repo/components/repo_file_buttons.vue @@ -1,40 +1,35 @@ <script> -import Store from '../stores/repo_store'; -import Helper from '../helpers/repo_helper'; -import RepoMixin from '../mixins/repo_mixin'; - -const RepoFileButtons = { - data: () => Store, - - mixins: [RepoMixin], +import { mapGetters } from 'vuex'; +export default { computed: { - - rawDownloadButtonLabel() { - return this.binary ? 'Download' : 'Raw'; + ...mapGetters([ + 'activeFile', + ]), + showButtons() { + return this.activeFile.rawPath || + this.activeFile.blamePath || + this.activeFile.commitsPath || + this.activeFile.permalink; }, - - canPreview() { - return Helper.isRenderable(); + rawDownloadButtonLabel() { + return this.activeFile.binary ? 'Download' : 'Raw'; }, }, - - methods: { - rawPreviewToggle: Store.toggleRawPreview, - }, }; - -export default RepoFileButtons; </script> <template> - <div id="repo-file-buttons"> + <div + v-if="showButtons" + class="repo-file-buttons" + > <a - :href="activeFile.raw_path" + :href="activeFile.rawPath" target="_blank" class="btn btn-default raw" rel="noopener noreferrer"> - {{rawDownloadButtonLabel}} + {{ rawDownloadButtonLabel }} </a> <div @@ -42,12 +37,12 @@ export default RepoFileButtons; role="group" aria-label="File actions"> <a - :href="activeFile.blame_path" + :href="activeFile.blamePath" class="btn btn-default blame"> Blame </a> <a - :href="activeFile.commits_path" + :href="activeFile.commitsPath" class="btn btn-default history"> History </a> @@ -57,13 +52,5 @@ export default RepoFileButtons; Permalink </a> </div> - - <a - v-if="canPreview" - href="#" - @click.prevent="rawPreviewToggle" - class="btn btn-default preview"> - {{activeFileLabel}} - </a> </div> </template> |