BigW Consortium Gitlab

Commit 714dac67 by Jacob Schatz

Fixes bugs in implementation and adds new/folder buttons

parent b2afa71d
...@@ -18,9 +18,27 @@ export default class RepoBinaryViewer { ...@@ -18,9 +18,27 @@ export default class RepoBinaryViewer {
} }
}, },
methods: {
supportedNonBinaryFileType(fileExt) {
switch(fileExt) {
case 'md':
this.binaryTypes.markdown = true;
return true;
break;
default:
return false;
}
}
},
watch: { watch: {
blobRaw() { blobRaw() {
if(!this.binary) return; if(!this.binary) return;
let supported = supportedNonBinaryFileType();
if(supported) {
return;
}
switch(this.binaryMimeType) { switch(this.binaryMimeType) {
case 'image/png': case 'image/png':
this.binaryTypes.png = true; this.binaryTypes.png = true;
......
...@@ -15,7 +15,8 @@ export default class RepoEditor { ...@@ -15,7 +15,8 @@ export default class RepoEditor {
this.monacoEditor = monaco.editor this.monacoEditor = monaco.editor
.create( .create(
document.getElementById('ide'), { document.getElementById('ide'), {
model: null model: null,
readOnly: true
} }
) )
Helper.monacoInstance = monaco; Helper.monacoInstance = monaco;
...@@ -42,7 +43,7 @@ export default class RepoEditor { ...@@ -42,7 +43,7 @@ export default class RepoEditor {
watch: { watch: {
isTree() { isTree() {
if(this.isTree || !this.openedFiles.length) { if(!this.openedFiles.length) {
self.el.style.display = 'none'; self.el.style.display = 'none';
} else { } else {
self.el.style.display = 'inline-block'; self.el.style.display = 'inline-block';
...@@ -50,7 +51,7 @@ export default class RepoEditor { ...@@ -50,7 +51,7 @@ export default class RepoEditor {
}, },
openedFiles() { openedFiles() {
if((this.isTree || !this.openedFiles.length) || this.binary) { if((!this.openedFiles.length) || this.binary) {
self.el.style.display = 'none'; self.el.style.display = 'none';
} else { } else {
self.el.style.display = 'inline-block'; self.el.style.display = 'inline-block';
......
let RepoFile = { let RepoFile = {
template: ` template: `
<tr v-if='!loading.tree || hasFiles'> <tr v-if='!loading.tree || hasFiles' :class='{"active": activeFile.url === file.url}'>
<td> <td>
<i class='fa' :class='file.icon' :style='{"margin-left": file.level * 10 + "px"}'></i> <i class='fa' :class='file.icon' :style='{"margin-left": file.level * 10 + "px"}'></i>
<a :href='file.url' @click.prevent='linkClicked(file)' :title='file.url'>{{file.name}}</a> <a :href='file.url' @click.prevent='linkClicked(file)' class='repo-file-name' :title='file.url'>{{file.name}}</a>
</td> </td>
<td v-if='!isMini'> <td v-if='!isMini' class='hidden-sm hidden-xs'>
<div class='ellipsis'>{{file.lastCommitMessage}}</div> <div class='commit-message'>{{file.lastCommitMessage}}</div>
</td> </td>
<td v-if='!isMini'> <td v-if='!isMini' class='hidden-xs'>
<span>{{file.lastCommitUpdate}}</span> <span>{{file.lastCommitUpdate}}</span>
</td> </td>
</tr> </tr>
...@@ -19,7 +19,8 @@ let RepoFile = { ...@@ -19,7 +19,8 @@ let RepoFile = {
isTree: Boolean, isTree: Boolean,
isMini: Boolean, isMini: Boolean,
loading: Object, loading: Object,
hasFiles: Boolean hasFiles: Boolean,
activeFile: Object
}, },
methods: { methods: {
......
let RepoFileOptions = {
template: `
<tr v-if='isMini' class='repo-file-options'>
<td>
<span class='title'>{{projectName}}</span>
<ul>
<li>
<a href='#' title='New File'>
<i class='fa fa-file-o'></i>
</a>
</li>
<li>
<a href='#' title='New Folder'>
<i class='fa fa-folder-o'></i>
</a>
</li>
</ul>
</td>
</tr>
`,
props: {
name: 'repo-file-options',
isMini: Boolean,
projectName: String
}
}
export default RepoFileOptions;
\ No newline at end of file
...@@ -61,6 +61,13 @@ let RepoHelper = { ...@@ -61,6 +61,13 @@ let RepoHelper = {
return newList; return newList;
}, },
resetBinaryTypes() {
let s = '';
for(s in Store.binaryTypes) {
Store.binaryTypes[s] = false;
}
},
setActiveFile(file) { setActiveFile(file) {
Store.openedFiles = Store.openedFiles.map((openedFile) => { Store.openedFiles = Store.openedFiles.map((openedFile) => {
openedFile.active = file.url === openedFile.url; openedFile.active = file.url === openedFile.url;
...@@ -73,6 +80,7 @@ let RepoHelper = { ...@@ -73,6 +80,7 @@ let RepoHelper = {
Store.blobRaw = file.base64; Store.blobRaw = file.base64;
console.log('binary', file) console.log('binary', file)
} else { } else {
console.log('f', file)
Store.blobRaw = file.plain; Store.blobRaw = file.plain;
} }
if(!file.loading){ if(!file.loading){
...@@ -150,10 +158,8 @@ let RepoHelper = { ...@@ -150,10 +158,8 @@ let RepoHelper = {
// may be tree or file. // may be tree or file.
getContent(file) { getContent(file) {
const loadingData = this.setLoading(true); const loadingData = this.setLoading(true);
console.log('loading data', loadingData)
Service.getContent() Service.getContent()
.then((response) => { .then((response) => {
console.log('loadddd')
let data = response.data; let data = response.data;
this.setLoading(false, loadingData); this.setLoading(false, loadingData);
Store.isTree = this.isTree(data); Store.isTree = this.isTree(data);
...@@ -185,7 +191,6 @@ let RepoHelper = { ...@@ -185,7 +191,6 @@ let RepoHelper = {
let newDirectory = this.dataToListOfFiles(data); let newDirectory = this.dataToListOfFiles(data);
Store.files = this.insertNewFilesIntoParentDir(file, Store.files, newDirectory); Store.files = this.insertNewFilesIntoParentDir(file, Store.files, newDirectory);
Store.prevURL = this.blobURLtoParent(Service.url); Store.prevURL = this.blobURLtoParent(Service.url);
console.log('Store.prevURL',Store.prevURL);
} }
}) })
.catch((response)=> { .catch((response)=> {
......
...@@ -3,36 +3,28 @@ let RepoLoadingFile = { ...@@ -3,36 +3,28 @@ let RepoLoadingFile = {
<tr v-if='loading.tree && !hasFiles'> <tr v-if='loading.tree && !hasFiles'>
<td> <td>
<div class="animation-container animation-container-small"> <div class="animation-container animation-container-small">
<div class="line-of-code-1"></div> <div v-for="n in 6" :class="lineOfCode(n)"></div>
<div class="line-of-code-2"></div>
<div class="line-of-code-3"></div>
<div class="line-of-code-4"></div>
<div class="line-of-code-5"></div>
<div class="line-of-code-6"></div>
</div> </div>
</td> </td>
<td v-if="!isMini"> <td v-if="!isMini" class='hidden-sm hidden-xs'>
<div class="animation-container"> <div class="animation-container">
<div class="line-of-code-1"></div> <div v-for="n in 6" :class="lineOfCode(n)"></div>
<div class="line-of-code-2"></div>
<div class="line-of-code-3"></div>
<div class="line-of-code-4"></div>
<div class="line-of-code-5"></div>
<div class="line-of-code-6"></div>
</div> </div>
</td> </td>
<td v-if="!isMini"> <td v-if="!isMini" class='hidden-xs'>
<div class="animation-container animation-container-small"> <div class="animation-container animation-container-small">
<div class="line-of-code-1"></div> <div v-for="n in 6" :class="lineOfCode(n)"></div>
<div class="line-of-code-2"></div>
<div class="line-of-code-3"></div>
<div class="line-of-code-4"></div>
<div class="line-of-code-5"></div>
<div class="line-of-code-6"></div>
</div> </div>
</td> </td>
</tr> </tr>
`, `,
methods: {
lineOfCode(n) {
return `line-of-code-${n}`;
}
},
props: { props: {
loading: Object, loading: Object,
hasFiles: Boolean, hasFiles: Boolean,
......
...@@ -3,6 +3,7 @@ import Helper from './repo_helper' ...@@ -3,6 +3,7 @@ import Helper from './repo_helper'
import Vue from 'vue' import Vue from 'vue'
import Store from './repo_store' import Store from './repo_store'
import RepoPreviousDirectory from './repo_prev_directory' import RepoPreviousDirectory from './repo_prev_directory'
import RepoFileOptions from './repo_file_options'
import RepoFile from './repo_file' import RepoFile from './repo_file'
import RepoLoadingFile from './repo_loading_file' import RepoLoadingFile from './repo_loading_file'
import RepoMiniMixin from './repo_mini_mixin' import RepoMiniMixin from './repo_mini_mixin'
...@@ -19,6 +20,7 @@ export default class RepoSidebar { ...@@ -19,6 +20,7 @@ export default class RepoSidebar {
el: '#sidebar', el: '#sidebar',
mixins: [RepoMiniMixin], mixins: [RepoMiniMixin],
components: { components: {
'repo-file-options': RepoFileOptions,
'repo-previous-directory': RepoPreviousDirectory, 'repo-previous-directory': RepoPreviousDirectory,
'repo-file': RepoFile, 'repo-file': RepoFile,
'repo-loading-file': RepoLoadingFile, 'repo-loading-file': RepoLoadingFile,
......
...@@ -10,14 +10,15 @@ let RepoStore = { ...@@ -10,14 +10,15 @@ let RepoStore = {
blobRaw: '', blobRaw: '',
blobRendered: '', blobRendered: '',
openedFiles: [], openedFiles: [],
activeFile: '', activeFile: {},
files: [], files: [],
binary: false, binary: false,
binaryMimeType: '', binaryMimeType: '',
//scroll bar space for windows //scroll bar space for windows
scrollWidth: 0, scrollWidth: 0,
binaryTypes: { binaryTypes: {
png: false png: false,
markdown: false
}, },
loading: { loading: {
tree: false, tree: false,
......
...@@ -120,3 +120,9 @@ of the body element here, we negate cascading side effects but allow momentum sc ...@@ -120,3 +120,9 @@ of the body element here, we negate cascading side effects but allow momentum sc
.page-with-sidebar { .page-with-sidebar {
-webkit-overflow-scrolling: auto; -webkit-overflow-scrolling: auto;
} }
.truncate {
width: 250px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
\ No newline at end of file
...@@ -118,3 +118,10 @@ ...@@ -118,3 +118,10 @@
@content; @content;
} }
} }
@mixin truncate($width: 250px) {
width: $width;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
...@@ -2,20 +2,18 @@ ...@@ -2,20 +2,18 @@
display: none; display: none;
} }
.ellipsis {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 300px;
}
.fade-enter-active, .fade-leave-active { .fade-enter-active, .fade-leave-active {
transition: opacity .5s transition: opacity .5s
} }
.fade-enter, .fade-leave-to /* .fade-leave-active in <2.1.8 */ { .fade-enter, .fade-leave-to /* .fade-leave-active in <2.1.8 */ {
opacity: 0 opacity: 0
} }
.commit-message {
@include truncate(250px);
}
.tree-content-holder { .tree-content-holder {
border: 1px solid $border-color; border: 1px solid $border-color;
border-radius: $border-radius-default; border-radius: $border-radius-default;
...@@ -98,15 +96,66 @@ header { ...@@ -98,15 +96,66 @@ header {
tr { tr {
-webkit-animation: fadein 0.5s; -webkit-animation: fadein 0.5s;
&.repo-file-options td {
padding: 0;
border-top: none;
background: $gray-light;
width: 190px;
display: inline-block;
border-top: none;
&:hover {
.title {
width: 105px;
}
ul {
display: inline-block;
}
}
.title {
display: inline-block;
font-size: 10px;
text-transform: uppercase;
font-weight: bold;
color: $gray-darkest;
width: 185px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
vertical-align: middle;
padding: 2px 16px;
}
ul {
display: none;
float: right;
margin: 0 10px 0 0;
padding: 1px 0;
li {
display: inline-block;
padding: 0px 2px;
border-bottom: none;
}
}
}
.fa {
margin-right: 5px;
}
} }
a { a {
color: $almost-black; color: $almost-black;
display: inline-block;
vertical-align: middle;
} }
ul { ul {
list-style-type: none; list-style-type: none;
padding: 0; padding: 0;
li { li {
border-bottom: 1px solid $border-gray-normal; border-bottom: 1px solid $border-gray-normal;
padding: 10px 20px; padding: 10px 20px;
......
...@@ -11,8 +11,9 @@ module RendersBlob ...@@ -11,8 +11,9 @@ module RendersBlob
else else
blob.simple_viewer blob.simple_viewer
end end
return render_404 unless viewer return render_404 unless viewer
puts blob
if blob.binary? if blob.binary?
render json: { render json: {
binary: true, binary: true,
......
...@@ -11,4 +11,10 @@ ...@@ -11,4 +11,10 @@
- else - else
- viewer.prepare! - viewer.prepare!
= render 'projects/tree/tree_content' -# In the rare case where the first kilobyte of the file looks like text,
-# but the file turns out to actually be binary after loading all data,
-# we fall back on the binary Download viewer.
- viewer = BlobViewer::Download.new(viewer.blob) if viewer.binary_detected_after_load?
= render viewer.partial_path, viewer: viewer
...@@ -6,14 +6,15 @@ ...@@ -6,14 +6,15 @@
Name Name
%th{"v-else" => "1"} %th{"v-else" => "1"}
Project Project
%th{"v-if" => "!isMini"} %th.hidden-sm.hidden-xs{"v-if" => "!isMini"}
Last Commit Last Commit
%th{"v-if" => "!isMini"} %th.hidden-xs{"v-if" => "!isMini"}
Last Update Last Update
%tbody %tbody
%tr{ is: "repo-file-options", ":is-mini" => "isMini", "project-name" => @project.name }
%tr{ is: "repo-previous-directory", ":prevurl" => "prevURL", "@linkclicked" => "linkClicked" } %tr{ is: "repo-previous-directory", ":prevurl" => "prevURL", "@linkclicked" => "linkClicked" }
%tr{ is: "repo-loading-file", "v-for" => "n in 5", ":loading" => "loading", ":has-files" => "!!files.length", ":is-mini" => "isMini"} %tr{ is: "repo-loading-file", "v-for" => "n in 5", ":loading" => "loading", ":has-files" => "!!files.length", ":is-mini" => "isMini"}
%tr{ is: "repo-file", "v-for" => "file in files", ":key" => "file.id", ":file" => "file",":is-mini" => "isMini", "@linkclicked" => "linkClicked(file)", ":is-tree" => "isTree", ":loading" => "loading", ":has-files" => "!!files.length" } %tr{ is: "repo-file", "v-for" => "file in files", ":key" => "file.id", ":file" => "file",":is-mini" => "isMini", "@linkclicked" => "linkClicked(file)", ":is-tree" => "isTree", ":loading" => "loading", ":has-files" => "!!files.length", ":active-file" => "activeFile" }
.panel-right> .panel-right>
%ul#tabs{"v-if" => "isMini", ":style" => "{height: 41 + scrollWidth + 'px'}", "v-cloak" => "1"} %ul#tabs{"v-if" => "isMini", ":style" => "{height: 41 + scrollWidth + 'px'}", "v-cloak" => "1"}
%li{ is: "repo-tab", "v-for" => "tab in openedFiles", ":key" => "tab.id", ":tab" => "tab", ":class" => "{'active' : tab.active}" } %li{ is: "repo-tab", "v-for" => "tab in openedFiles", ":key" => "tab.id", ":tab" => "tab", ":class" => "{'active' : tab.active}" }
......
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