Commit 6190c39e authored by Jacob Schatz's avatar Jacob Schatz

Functionality to move between files.

To show file and to start to go back.
parent c2e34bab
...@@ -342,7 +342,7 @@ import RepoBundle from './repo/repo_bundle'; ...@@ -342,7 +342,7 @@ import RepoBundle from './repo/repo_bundle';
shortcut_handler = true; shortcut_handler = true;
break; break;
case 'projects:blob:show': case 'projects:blob:show':
new RepoBundle(); new RepoBundle();
break; break;
case 'projects:blame:show': case 'projects:blame:show':
initBlob(); initBlob();
......
...@@ -6,6 +6,7 @@ import Helper from './repo_helper' ...@@ -6,6 +6,7 @@ import Helper from './repo_helper'
export default class RepoBundle { export default class RepoBundle {
constructor() { constructor() {
console.log(document.getElementById('ide'))
const url = document.getElementById('ide').dataset.url; const url = document.getElementById('ide').dataset.url;
Store.service = Service; Store.service = Service;
Store.service.url = url; Store.service.url = url;
......
...@@ -35,20 +35,26 @@ export default class RepoEditor { ...@@ -35,20 +35,26 @@ export default class RepoEditor {
) )
); );
} }
if(this.isTree) {
self.el.styles = 'display: none';
} else {
self.el.styles = 'display: inline-block';
}
}, },
watch: { watch: {
isTree() {
if(this.isTree) {
self.el.style.display = 'none';
} else {
self.el.style.display = 'inline-block';
}
},
blobRaw() { blobRaw() {
if(this.isTree) { if(this.isTree) {
} else { } else {
// this.blobRaw self.monacoEditor.setModel(
// console.log('models', editor.getModels()) monaco.editor.createModel(
this.blobRaw,
'plain'
)
);
} }
} }
} }
......
let RepoFile = { let RepoFile = {
template: ` template: `
<li> <tr>
<div class='col-md-4'> <td>
<i class='fa' :class='file.icon'></i> <i class='fa' :class='file.icon'></i>
<a :href='file.url' @click.prevent='linkClicked(file)'>{{file.name}}</a> <a :href='file.url' @click.prevent='linkClicked(file)'>{{file.name}}</a>
</div> </td>
<div class="col-md-4"> <td v-if='isTree'>
<span>{{JSON.stringify(file)}}</span> <div class='ellipsis'>{{file.lastCommitMessage}}</div>
</div> </td>
</li> <td v-if='isTree'>
<span>{{file.lastCommitUpdate}}</span>
</td>
</tr>
`, `,
props: { props: {
name: 'repo-file', name: 'repo-file',
file: Object, file: Object,
isTree: Boolean
}, },
methods: { methods: {
linkClicked(file) { linkClicked(file) {
console.log(this.isTree)
this.$emit('linkclicked', file); this.$emit('linkclicked', file);
} }
} }
......
...@@ -11,6 +11,21 @@ let RepoHelper = { ...@@ -11,6 +11,21 @@ let RepoHelper = {
? window.performance ? window.performance
: Date, : Date,
getLanguagesForMimeType(mimetypeNeedle, monaco) {
const langs = monaco.languages.getLanguages();
let lang = '';
langs.every((lang) => {
const hasLang = lang.mimetypes.some((mimetype) => {
return mimetypeNeedle === mimetype
});
if(hasLang) {
lang = lang.id;
return true;
}
return false;
});
},
blobURLtoParent(url) { blobURLtoParent(url) {
const split = url.split('/'); const split = url.split('/');
split.pop(); split.pop();
...@@ -24,7 +39,7 @@ let RepoHelper = { ...@@ -24,7 +39,7 @@ let RepoHelper = {
// may be tree or file. // may be tree or file.
getContent() { getContent() {
Service.getContent() Service.getContent()
.then((response)=> { .then((response) => {
let data = response.data; let data = response.data;
Store.isTree = this.isTree(data); Store.isTree = this.isTree(data);
if(!Store.isTree) { if(!Store.isTree) {
...@@ -32,10 +47,10 @@ let RepoHelper = { ...@@ -32,10 +47,10 @@ let RepoHelper = {
const parentURL = this.blobURLtoParent(Service.url); const parentURL = this.blobURLtoParent(Service.url);
Store.blobRaw = data.plain; Store.blobRaw = data.plain;
Service.getContent(parentURL) Service.getContent(parentURL)
.then((response)=> { .then((response) => {
console.log(response.data) Store.files = this.dataToListOfFiles(response.data);
}) })
.catch((response)=> { .catch((response) => {
}); });
} else { } else {
...@@ -61,7 +76,9 @@ let RepoHelper = { ...@@ -61,7 +76,9 @@ let RepoHelper = {
type: 'blob', type: 'blob',
name: blob.name, name: blob.name,
url: blob.url, url: blob.url,
icon: this.toFA(blob.icon) icon: this.toFA(blob.icon),
lastCommitMessage: blob.last_commit.message,
lastCommitUpdate: blob.last_commit.committed_date
}) })
}); });
...@@ -104,7 +121,6 @@ let RepoHelper = { ...@@ -104,7 +121,6 @@ let RepoHelper = {
var history = window.history; var history = window.history;
this._key = this.genKey(); this._key = this.genKey();
history.pushState({ key: this._key }, '', url); history.pushState({ key: this._key }, '', url);
window.scrollTo(0, 0);
} }
}; };
......
let RepoPreviousDirectory = {
template: `
<tr>
<td colspan='3'>
<a href='#' @click.prevent='linkClicked("prev")'>..</a>
</td>
</tr>
`,
props: {
name: 'repo-previous-directory',
},
methods: {
linkClicked(file) {
console.log(this.isTree)
this.$emit('linkclicked', file);
}
}
};
export default RepoPreviousDirectory;
\ No newline at end of file
...@@ -2,6 +2,7 @@ import Service from './repo_service' ...@@ -2,6 +2,7 @@ import Service from './repo_service'
import Helper from './repo_helper' 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 RepoFile from './repo_file' import RepoFile from './repo_file'
export default class RepoSidebar { export default class RepoSidebar {
...@@ -9,13 +10,15 @@ export default class RepoSidebar { ...@@ -9,13 +10,15 @@ export default class RepoSidebar {
this.url = url; this.url = url;
this.initVue(); this.initVue();
this.el = document.getElementById('ide'); this.el = document.getElementById('ide');
console.log(document.getElementById('sidebar'))
} }
initVue() { initVue() {
this.vue = new Vue({ this.vue = new Vue({
el: '#sidebar', el: '#sidebar',
components: { components: {
'repo-file':RepoFile, 'repo-previous-directory': RepoPreviousDirectory,
'repo-file': RepoFile,
}, },
created() { created() {
...@@ -34,11 +37,16 @@ export default class RepoSidebar { ...@@ -34,11 +37,16 @@ export default class RepoSidebar {
}, },
linkClicked(file) { linkClicked(file) {
Service.url = file.url; if(file === 'prev'){
Helper.getContent();
Helper.toURL(file.url); } else {
Service.url = file.url;
Helper.getContent();
Helper.toURL(file.url);
}
} }
} },
}); });
} }
} }
\ No newline at end of file
...@@ -2,7 +2,6 @@ let RepoStore = { ...@@ -2,7 +2,6 @@ let RepoStore = {
service: '', service: '',
editor: '', editor: '',
sidebar: '', sidebar: '',
isTree: false, isTree: false,
trees: [], trees: [],
blobs: [], blobs: [],
......
...@@ -2,6 +2,13 @@ ...@@ -2,6 +2,13 @@
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
} }
...@@ -16,12 +23,22 @@ ...@@ -16,12 +23,22 @@
header { header {
background: $gray-light; background: $gray-light;
padding: 10px 25px; padding: 10px 15px;
border-bottom: 1px solid $border-color; }
font-size: $code_font_size;
#ide {
display: inline-block;
width: 85%;
} }
#sidebar { #sidebar {
&.sidebar-mini {
display: inline-block;
vertical-align: top;
width: 15%;
border-right: 1px solid $white-normal;
}
ul { ul {
list-style-type: none; list-style-type: none;
padding: 0; padding: 0;
......
...@@ -8,5 +8,3 @@ ...@@ -8,5 +8,3 @@
= render "projects/blob/auxiliary_viewer", blob: blob = render "projects/blob/auxiliary_viewer", blob: blob
#blob-content-holder.blob-content-holder #blob-content-holder.blob-content-holder
#sidebar
#ide{ data: { url: repo_url }, style: "height:400px;" }
.tree-content-holder .tree-content-holder
%header %header
Project Project
#sidebar #sidebar.isworking{ ":class" => "{'sidebar-mini' : !isTree}" }<
%ul %table.table
%repo-file{ "v-for" => "file in files", ":key" => "file.id", ":file" => "file","@linkclicked" => "linkClicked(file)" } %thead{"v-if" => "isTree"}
#ide{ data: { url: repo_url }, style: "height:400px;" } %th
Name
- if tree.readme %th{"v-if" => "isTree"}
= render "projects/tree/readme", readme: tree.readme Last Commit
%th{"v-if" => "isTree"}
Last Update
%tr{ is: "repo-previous-directory" }
%tr{ is: "repo-file", "v-for" => "file in files", ":key" => "file.id", ":file" => "file","@linkclicked" => "linkClicked(file)", ":is-tree" => "isTree" }
#ide{ data: { url: repo_url }, style: "height:400px;" }>
- if can_edit_tree? - if can_edit_tree?
= render 'projects/blob/upload', title: _('Upload New File'), placeholder: _('Upload New File'), button_title: _('Upload file'), form_path: namespace_project_create_blob_path(@project.namespace, @project, @id), method: :post = render 'projects/blob/upload', title: _('Upload New File'), placeholder: _('Upload New File'), button_title: _('Upload file'), form_path: namespace_project_create_blob_path(@project.namespace, @project, @id), method: :post
......
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