Commit e361ed1e authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett

[ci skip] formalise repo_preview component and logic

parent a70e53b4
...@@ -4,6 +4,7 @@ import RepoCommitSection from './repo_commit_section.vue'; ...@@ -4,6 +4,7 @@ import RepoCommitSection from './repo_commit_section.vue';
import RepoTabs from './repo_tabs.vue'; import RepoTabs from './repo_tabs.vue';
import RepoFileButtons from './repo_file_buttons.vue'; import RepoFileButtons from './repo_file_buttons.vue';
import RepoBinaryViewer from './repo_binary_viewer.vue'; import RepoBinaryViewer from './repo_binary_viewer.vue';
import RepoPreview from './repo_preview.vue';
import RepoMixin from '../mixins/repo_mixin'; import RepoMixin from '../mixins/repo_mixin';
import PopupDialog from '../../vue_shared/components/popup_dialog.vue'; import PopupDialog from '../../vue_shared/components/popup_dialog.vue';
import Store from '../stores/repo_store'; import Store from '../stores/repo_store';
...@@ -21,16 +22,11 @@ export default { ...@@ -21,16 +22,11 @@ export default {
'repo-editor': MonacoLoaderHelper.repoEditorLoader, 'repo-editor': MonacoLoaderHelper.repoEditorLoader,
'repo-commit-section': RepoCommitSection, 'repo-commit-section': RepoCommitSection,
'popup-dialog': PopupDialog, 'popup-dialog': PopupDialog,
preview: { // POC 'repo-preview': RepoPreview,
data: () => Store,
template: '<div v-html="activeFile.html"></div>',
},
}, },
mounted() { mounted() {
RepoHelper.getContent().then(() => { RepoHelper.getContent().catch(RepoHelper.loadingError);
}).catch(RepoHelper.loadingError);
}, },
methods: { methods: {
......
<script>
import RepoStore from '../stores/repo_store';
export default {
data: () => RepoStore,
}
</script>
<template>
<div v-html="activeFile.html"></div>
</template>
...@@ -165,9 +165,9 @@ const RepoHelper = { ...@@ -165,9 +165,9 @@ const RepoHelper = {
// file might be undefined // file might be undefined
const rawUrl = RepoHelper.getRawURLFromBlobURL(file.url || Service.url); const rawUrl = RepoHelper.getRawURLFromBlobURL(file.url || Service.url);
RepoHelper.setBinaryDataAsBase64(rawUrl, data); RepoHelper.setBinaryDataAsBase64(rawUrl, data);
Store.currentBlobView = 'preview'; Store.setViewToPreview();
} else { } else {
if (Store.currentBlobView !== 'preview') { if (!Store.isPreviewView()) {
Service.getRaw(data.raw_path) Service.getRaw(data.raw_path)
.then((rawResponse) => { .then((rawResponse) => {
Store.blobRaw = rawResponse.data; Store.blobRaw = rawResponse.data;
......
...@@ -20,7 +20,7 @@ const RepoStore = { ...@@ -20,7 +20,7 @@ const RepoStore = {
submodules: [], submodules: [],
blobRaw: '', blobRaw: '',
blobRendered: '', blobRendered: '',
currentBlobView: 'preview', currentBlobView: 'repo-preview',
openedFiles: [], openedFiles: [],
tabSize: 100, tabSize: 100,
defaultTabSize: 100, defaultTabSize: 100,
...@@ -211,7 +211,11 @@ const RepoStore = { ...@@ -211,7 +211,11 @@ const RepoStore = {
}, },
toggleBlobView() { toggleBlobView() {
RepoStore.currentBlobView = RepoStore.currentBlobView === 'preview' ? 'repo-editor' : 'preview'; RepoStore.currentBlobView = RepoStore.isPreviewView() ? 'repo-editor' : 'repo-preview';
},
setViewToPreview() {
RepoStore.currentBlobView = 'repo-preview';
}, },
// getters // getters
...@@ -219,5 +223,9 @@ const RepoStore = { ...@@ -219,5 +223,9 @@ const RepoStore = {
isActiveFile(file) { isActiveFile(file) {
return file && file.url === RepoStore.activeFile.url; return file && file.url === RepoStore.activeFile.url;
}, },
isPreviewView() {
return RepoStore.currentBlobView === 'repo-preview';
},
}; };
export default RepoStore; export default RepoStore;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment