Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke "Jared" Bennett <lbennett@gitlab.com>2017-08-07 15:10:28 +0300
committerLuke "Jared" Bennett <lbennett@gitlab.com>2017-08-07 15:10:28 +0300
commitf64a7c4780e7ebd092f5cb37e09cb674d093631a (patch)
tree0810c759a6f3c48f09f31b4e7b919ee043a7cfdb
parentec93e17ac58ca6b79cdfd2b1848e07dc93d5c6f7 (diff)
Remove repo_binary_viewer as it is no longer needed
-rw-r--r--app/assets/javascripts/repo/components/repo.vue3
-rw-r--r--app/assets/javascripts/repo/components/repo_binary_viewer.vue67
-rw-r--r--spec/javascripts/repo/components/repo_binary_viewer_spec.js89
3 files changed, 0 insertions, 159 deletions
diff --git a/app/assets/javascripts/repo/components/repo.vue b/app/assets/javascripts/repo/components/repo.vue
index 8c645465553..56a3c9479a2 100644
--- a/app/assets/javascripts/repo/components/repo.vue
+++ b/app/assets/javascripts/repo/components/repo.vue
@@ -3,7 +3,6 @@ import RepoSidebar from './repo_sidebar.vue';
import RepoCommitSection from './repo_commit_section.vue';
import RepoTabs from './repo_tabs.vue';
import RepoFileButtons from './repo_file_buttons.vue';
-import RepoBinaryViewer from './repo_binary_viewer.vue';
import RepoPreview from './repo_preview.vue';
import RepoMixin from '../mixins/repo_mixin';
import PopupDialog from '../../vue_shared/components/popup_dialog.vue';
@@ -18,7 +17,6 @@ export default {
'repo-sidebar': RepoSidebar,
'repo-tabs': RepoTabs,
'repo-file-buttons': RepoFileButtons,
- 'repo-binary-viewer': RepoBinaryViewer,
'repo-editor': MonacoLoaderHelper.repoEditorLoader,
'repo-commit-section': RepoCommitSection,
'popup-dialog': PopupDialog,
@@ -50,7 +48,6 @@ export default {
<repo-tabs/>
<component :is="currentBlobView" class="blob-viewer-container"></component>
<repo-file-buttons/>
- <!-- <repo-binary-viewer/> soon™ -->
</div>
<repo-commit-section/>
<popup-dialog
diff --git a/app/assets/javascripts/repo/components/repo_binary_viewer.vue b/app/assets/javascripts/repo/components/repo_binary_viewer.vue
deleted file mode 100644
index f843244950d..00000000000
--- a/app/assets/javascripts/repo/components/repo_binary_viewer.vue
+++ /dev/null
@@ -1,67 +0,0 @@
-<script>
-import Store from '../stores/repo_store';
-import Helper from '../helpers/repo_helper';
-
-const RepoBinaryViewer = {
- data: () => Store,
-
- computed: {
- pngBlobWithDataURI() {
- if (this.binaryTypes.png) {
- return `data:image/png;base64,${this.blobRaw}`;
- }
- return '';
- },
-
- svgBlobWithDataURI() {
- if (this.binaryTypes.svg) {
- return `data:image/svg+xml;utf8,${this.blobRaw}`;
- }
- return '';
- },
- },
-
- methods: {
- errored() {
- Store.binaryLoaded = false;
- },
-
- loaded() {
- Store.binaryLoaded = true;
- },
-
- getBinaryType() {
- if (Object.hasOwnProperty.call(this.binaryTypes, this.activeFile.extension)) {
- return this.activeFile.extension;
- }
- return 'unknown';
- },
- },
-
- watch: {
- blobRaw() {
- Store.resetBinaryTypes();
- if (Helper.isKindaBinary()) {
- this.activeFile.raw = false;
- // counts as binaryish so we use the binary viewer in this case.
- this.binary = true;
- }
- if (!this.binary) return;
- this.binaryTypes[this.getBinaryType()] = true;
- },
- },
-};
-
-export default RepoBinaryViewer;
-</script>
-
-<template>
-<div id="binary-viewer" v-if="binary && !activeFile.raw">
- <img v-show="binaryTypes.png && binaryLoaded" @error="errored" @load="loaded" :src="pngBlobWithDataURI" :alt="activeFile.name"/>
- <img v-show="binaryTypes.svg" @error="errored" @load="loaded" :src="svgBlobWithDataURI" :alt="activeFile.name"/>
- <div v-if="binaryTypes.md" v-html="activeFile.html"></div>
- <div class="binary-unknown" v-if="binaryTypes.unknown">
- <span>Binary file. No preview available.</span>
- </div>
-</div>
-</template>
diff --git a/spec/javascripts/repo/components/repo_binary_viewer_spec.js b/spec/javascripts/repo/components/repo_binary_viewer_spec.js
deleted file mode 100644
index 5441bb4f5a1..00000000000
--- a/spec/javascripts/repo/components/repo_binary_viewer_spec.js
+++ /dev/null
@@ -1,89 +0,0 @@
-import Vue from 'vue';
-import Store from '~/repo/stores/repo_store';
-import repoBinaryViewer from '~/repo/components/repo_binary_viewer.vue';
-
-describe('RepoBinaryViewer', () => {
- function createComponent() {
- const RepoBinaryViewer = Vue.extend(repoBinaryViewer);
-
- return new RepoBinaryViewer().$mount();
- }
-
- function createActiveFile(type, activeFile = {}) {
- const file = activeFile;
-
- switch (type) {
- case 'svg':
- case 'png':
- file.name = 'name';
- break;
- case 'md':
- file.html = 'html';
- break;
- default:
- break;
- }
-
- return file;
- }
-
- function setActiveBinary(type) {
- const binaryTypes = {};
- binaryTypes[type] = true;
-
- const activeFile = createActiveFile(type);
-
- const uri = 'uri';
- Store.binary = true;
- Store.binaryTypes = binaryTypes;
- Store.activeFile = activeFile;
- Store.pngBlobWithDataURI = uri;
-
- return {
- activeFile,
- uri,
- };
- }
-
- function assertBinaryImg(img, activeFile, uri) {
- expect(img.src).toMatch(`/${uri}`);
- expect(img.alt).toEqual(activeFile.name);
- }
-
- it('renders an img if its png', () => {
- const { activeFile, uri } = setActiveBinary('png');
- const vm = createComponent();
- const img = vm.$el.querySelector(':scope > img');
-
- assertBinaryImg(img, activeFile, uri);
- });
-
- it('renders an img if its svg', () => {
- const { activeFile, uri } = setActiveBinary('svg');
- const vm = createComponent();
- const img = vm.$el.querySelector(':scope > img');
-
- assertBinaryImg(img, activeFile, uri);
- });
-
- it('renders an div with content if its markdown', () => {
- const { activeFile } = setActiveBinary('md');
- const vm = createComponent();
-
- expect(vm.$el.querySelector(':scope > div').innerHTML).toEqual(activeFile.html);
- });
-
- it('renders no preview message if its unknown', () => {
- setActiveBinary('unknown');
- const vm = createComponent();
-
- expect(vm.$el.querySelector('.binary-unknown').textContent).toMatch('Binary file. No preview available.');
- });
-
- it('does not render if no binary', () => {
- Store.binary = false;
- const vm = createComponent();
-
- expect(vm.$el.innerHTML).toBeFalsy();
- });
-});