BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
6a43c200
Commit
6a43c200
authored
Jun 20, 2017
by
Jacob Schatz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Navigate to new tree.
parent
7e9100fc
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
172 additions
and
38 deletions
+172
-38
repo_bundle.js
app/assets/javascripts/repo/repo_bundle.js
+2
-1
repo_editor.js
app/assets/javascripts/repo/repo_editor.js
+8
-2
repo_file.js
app/assets/javascripts/repo/repo_file.js
+19
-0
repo_helper.js
app/assets/javascripts/repo/repo_helper.js
+94
-0
repo_service.js
app/assets/javascripts/repo/repo_service.js
+7
-2
repo_sidebar.js
app/assets/javascripts/repo/repo_sidebar.js
+18
-24
repo_store.js
app/assets/javascripts/repo/repo_store.js
+3
-1
repo.scss
app/assets/stylesheets/pages/repo.scss
+15
-0
renders_blob.rb
app/controllers/concerns/renders_blob.rb
+1
-1
tree_helper.rb
app/helpers/tree_helper.rb
+1
-1
_files.html.haml
app/views/projects/_files.html.haml
+0
-6
_blob.html.haml
app/views/projects/blob/_blob.html.haml
+1
-0
_tree_content.html.haml
app/views/projects/tree/_tree_content.html.haml
+3
-0
No files found.
app/assets/javascripts/repo/repo_bundle.js
View file @
6a43c200
...
...
@@ -2,6 +2,7 @@ import Sidebar from './repo_sidebar'
import
Editor
from
'./repo_editor'
import
Service
from
'./repo_service'
import
Store
from
'./repo_store'
import
Helper
from
'./repo_helper'
export
default
class
RepoBundle
{
constructor
()
{
...
...
@@ -10,6 +11,6 @@ export default class RepoBundle {
Store
.
service
.
url
=
url
;
Store
.
sidebar
=
new
Sidebar
(
url
);
Store
.
editor
=
new
Editor
();
Store
.
sideba
r
.
getContent
();
Helpe
r
.
getContent
();
}
}
app/assets/javascripts/repo/repo_editor.js
View file @
6a43c200
...
...
@@ -5,6 +5,7 @@ import Store from './repo_store'
export
default
class
RepoEditor
{
constructor
()
{
this
.
initMonaco
();
this
.
el
=
document
.
getElementById
(
'ide'
);
}
initMonaco
()
{
...
...
@@ -21,13 +22,12 @@ export default class RepoEditor {
}
initVue
()
{
const
self
=
this
;
const
monacoEditor
=
this
.
monacoEditor
;
this
.
vue
=
new
Vue
({
data
:
()
=>
Store
,
created
()
{
if
(
this
.
blobRaw
!==
''
){
console
.
log
(
monacoEditor
)
monacoEditor
.
setModel
(
monaco
.
editor
.
createModel
(
this
.
blobRaw
,
...
...
@@ -35,6 +35,12 @@ export default class RepoEditor {
)
);
}
if
(
this
.
isTree
)
{
self
.
el
.
styles
=
'display: none'
;
}
else
{
self
.
el
.
styles
=
'display: inline-block'
;
}
},
watch
:
{
...
...
app/assets/javascripts/repo/repo_file.js
0 → 100644
View file @
6a43c200
let
RepoFile
=
{
template
:
`
<li>
<i class='fa' :class='file.icon'></i>
<a :href='file.url' @click.prevent='linkClicked(file)'>{{file.name}}</a>
</li>
`
,
props
:
{
name
:
'repo-file'
,
file
:
Object
,
},
methods
:
{
linkClicked
(
file
)
{
this
.
$emit
(
'linkclicked'
,
file
);
}
}
};
export
default
RepoFile
;
app/assets/javascripts/repo/repo_helper.js
View file @
6a43c200
import
Service
from
'./repo_service'
import
Store
from
'./repo_store'
let
RepoHelper
=
{
isTree
(
data
)
{
return
data
.
hasOwnProperty
(
'blobs'
);
},
Time
:
window
.
performance
&&
window
.
performance
.
now
?
window
.
performance
:
Date
,
blobURLtoParent
(
url
)
{
const
split
=
url
.
split
(
'/'
);
split
.
pop
();
...
...
@@ -11,6 +19,92 @@ let RepoHelper = {
split
[
blobIndex
]
=
'tree'
;
}
return
split
.
join
(
'/'
);
},
// may be tree or file.
getContent
()
{
Service
.
getContent
()
.
then
((
response
)
=>
{
let
data
=
response
.
data
;
Store
.
isTree
=
this
.
isTree
(
data
);
if
(
!
Store
.
isTree
)
{
// it's a blob
const
parentURL
=
this
.
blobURLtoParent
(
Service
.
url
);
Store
.
blobRaw
=
data
.
plain
;
Service
.
getContent
(
parentURL
)
.
then
((
response
)
=>
{
console
.
log
(
response
.
data
)
})
.
catch
((
response
)
=>
{
});
}
else
{
// it's a tree
Store
.
files
=
this
.
dataToListOfFiles
(
data
);
}
})
.
catch
((
response
)
=>
{
console
.
log
(
'error response'
,
response
);
});
},
toFA
(
icon
)
{
return
`fa-
${
icon
}
`
},
dataToListOfFiles
(
data
)
{
let
a
=
[];
//push in blobs
data
.
blobs
.
forEach
((
blob
)
=>
{
a
.
push
({
type
:
'blob'
,
name
:
blob
.
name
,
url
:
blob
.
url
,
icon
:
this
.
toFA
(
blob
.
icon
)
})
});
data
.
trees
.
forEach
((
tree
)
=>
{
a
.
push
({
type
:
'tree'
,
name
:
tree
.
name
,
url
:
tree
.
url
,
icon
:
this
.
toFA
(
tree
.
icon
)
})
});
data
.
submodules
.
forEach
((
submodule
)
=>
{
a
.
push
({
type
:
'submodule'
,
name
:
submodule
.
name
,
url
:
submodule
.
url
,
icon
:
this
.
toFA
(
submodule
.
icon
)
})
});
return
a
;
},
genKey
()
{
return
this
.
Time
.
now
().
toFixed
(
3
)
},
_key
:
''
,
getStateKey
()
{
return
this
.
_key
},
setStateKey
(
key
)
{
this
.
_key
=
key
;
},
toURL
(
url
)
{
var
history
=
window
.
history
;
this
.
_key
=
this
.
genKey
();
history
.
pushState
({
key
:
this
.
_key
},
''
,
url
);
window
.
scrollTo
(
0
,
0
);
}
};
...
...
app/assets/javascripts/repo/repo_service.js
View file @
6a43c200
...
...
@@ -2,6 +2,11 @@ import axios from 'axios';
let
RepoService
=
{
url
:
''
,
params
:
{
params
:
{
format
:
'json'
}
},
setUrl
(
url
)
{
this
.
url
=
url
;
...
...
@@ -9,9 +14,9 @@ let RepoService = {
getContent
(
url
)
{
if
(
url
){
return
axios
.
get
(
url
);
return
axios
.
get
(
url
,
this
.
params
);
}
return
axios
.
get
(
this
.
url
);
return
axios
.
get
(
this
.
url
,
this
.
params
);
}
};
...
...
app/assets/javascripts/repo/repo_sidebar.js
View file @
6a43c200
import
Service
from
'./repo_service'
import
Helper
from
'./repo_helper'
import
Vue
from
'vue'
;
import
Vue
from
'vue'
import
Store
from
'./repo_store'
import
RepoFile
from
'./repo_file'
export
default
class
RepoSidebar
{
constructor
(
url
)
{
this
.
url
=
url
;
this
.
initVue
();
this
.
el
=
document
.
getElementById
(
'ide'
);
}
// may be tree or file.
getContent
()
{
Service
.
getContent
()
.
then
((
response
)
=>
{
let
data
=
response
.
data
;
Store
.
isTree
=
Helper
.
isTree
(
data
);
if
(
!
Store
.
isTree
)
{
// it's a blob
const
parentURL
=
Helper
.
blobURLtoParent
(
Service
.
url
);
Store
.
blobRaw
=
data
.
plain
;
Service
.
getContent
(
parentURL
+
'/?format=json'
)
.
then
((
response
)
=>
{
console
.
log
(
response
.
data
)
})
.
catch
((
response
)
=>
{
initVue
()
{
this
.
vue
=
new
Vue
({
el
:
'#sidebar'
,
components
:
{
'repo-file'
:
RepoFile
,
},
});
}
else
{
data
:
()
=>
Store
,
methods
:
{
linkClicked
(
file
)
{
Service
.
url
=
file
.
url
;
Helper
.
getContent
();
Helper
.
toURL
(
file
.
url
);
}
}
})
.
catch
((
response
)
=>
{
console
.
log
(
'error response'
,
response
);
});
}
initVue
()
{}
}
\ No newline at end of file
app/assets/javascripts/repo/repo_store.js
View file @
6a43c200
...
...
@@ -8,6 +8,8 @@ let RepoStore = {
blobs
:
[],
submodules
:
[],
blobRaw
:
''
,
blobRendered
:
''
blobRendered
:
''
,
files
:
[]
};
export
default
RepoStore
;
app/assets/stylesheets/pages/repo.scss
0 → 100644
View file @
6a43c200
[
v-cloak
]
{
display
:
none
;
}
#sidebar
{
ul
{
list-style-type
:
none
;
padding
:
0
;
li
{
border-bottom
:
1px
solid
$border-gray-normal
;
padding
:
10px
20px
;
}
}
}
\ No newline at end of file
app/controllers/concerns/renders_blob.rb
View file @
6a43c200
...
...
@@ -12,7 +12,7 @@ module RendersBlob
blob
.
simple_viewer
end
return
render_404
unless
viewer
puts
blob
render
json:
{
html:
view_to_html_string
(
"projects/blob/_viewer"
,
viewer:
viewer
,
load_async:
false
),
plain:
blob
.
data
,
...
...
app/helpers/tree_helper.rb
View file @
6a43c200
...
...
@@ -13,7 +13,7 @@ module TreeHelper
end
def
repo_url
()
url_for
(
params
.
merge
(
format: :json
))
request
.
original_url
end
# Return an image icon depending on the file type and mode
...
...
app/views/projects/_files.html.haml
View file @
6a43c200
...
...
@@ -5,10 +5,4 @@
.nav-block
=
render
'projects/tree/tree_header'
,
tree:
@tree
-
if
commit
.info-well.hidden-xs.project-last-commit.append-bottom-default
.well-segment
%ul
.blob-commit-info
=
render
'projects/commits/commit'
,
commit:
commit
,
ref:
ref
,
project:
project
=
render
'projects/tree/tree_content'
,
tree:
@tree
app/views/projects/blob/_blob.html.haml
View file @
6a43c200
...
...
@@ -8,4 +8,5 @@
=
render
"projects/blob/auxiliary_viewer"
,
blob:
blob
#blob-content-holder
.blob-content-holder
#sidebar
#ide
{
data:
{
url:
repo_url
},
style:
"height:400px;"
}
app/views/projects/tree/_tree_content.html.haml
View file @
6a43c200
.tree-content-holder
#sidebar
%ul
%repo-file
{
"v-for"
=>
"file in files"
,
":file"
=>
"file"
,
"@linkclicked"
=>
"linkClicked(file)"
}
#ide
{
data:
{
url:
repo_url
},
style:
"height:400px;"
}
-
if
tree
.
readme
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment