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
2e025023
Unverified
Commit
2e025023
authored
Jul 15, 2017
by
Luke "Jared" Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix eslint warnings
parent
b2afa71d
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
191 additions
and
203 deletions
+191
-203
dispatcher.js
app/assets/javascripts/dispatcher.js
+5
-6
repo_binary_viewer.js
app/assets/javascripts/repo/repo_binary_viewer.js
+16
-12
repo_bundle.js
app/assets/javascripts/repo/repo_bundle.js
+8
-8
repo_editor.js
app/assets/javascripts/repo/repo_editor.js
+19
-20
repo_file.js
app/assets/javascripts/repo/repo_file.js
+4
-4
repo_helper.js
app/assets/javascripts/repo/repo_helper.js
+84
-89
repo_loading_file.js
app/assets/javascripts/repo/repo_loading_file.js
+4
-5
repo_mini_mixin.js
app/assets/javascripts/repo/repo_mini_mixin.js
+4
-5
repo_prev_directory.js
app/assets/javascripts/repo/repo_prev_directory.js
+5
-6
repo_service.js
app/assets/javascripts/repo/repo_service.js
+9
-10
repo_sidebar.js
app/assets/javascripts/repo/repo_sidebar.js
+14
-15
repo_store.js
app/assets/javascripts/repo/repo_store.js
+5
-5
repo_tab.js
app/assets/javascripts/repo/repo_tab.js
+5
-6
repo_tabs.js
app/assets/javascripts/repo/repo_tabs.js
+6
-7
repo_view_toggler.js
app/assets/javascripts/repo/repo_view_toggler.js
+3
-5
No files found.
app/assets/javascripts/dispatcher.js
View file @
2e025023
...
@@ -72,19 +72,18 @@ import RepoBundle from './repo/repo_bundle';
...
@@ -72,19 +72,18 @@ import RepoBundle from './repo/repo_bundle';
}
}
Dispatcher
.
prototype
.
initPageScripts
=
function
()
{
Dispatcher
.
prototype
.
initPageScripts
=
function
()
{
var
page
,
path
,
shortcut_handler
,
fileBlobPermalinkUrlElement
,
fileBlobPermalinkUrl
,
os
;
var
page
,
path
,
shortcut_handler
,
fileBlobPermalinkUrlElement
,
fileBlobPermalinkUrl
;
page
=
$
(
'body'
).
attr
(
'data-page'
);
page
=
$
(
'body'
).
attr
(
'data-page'
);
if
(
!
page
)
{
if
(
!
page
)
{
return
false
;
return
false
;
}
}
function
getScrollBarWidth
()
{
function
getScrollBarWidth
()
{
var
$outer
=
$
(
'<div>'
).
css
({
visibility
:
'hidden'
,
width
:
100
,
overflow
:
'scroll'
}).
appendTo
(
'body'
),
var
$outer
=
$
(
'<div>'
).
css
({
visibility
:
'hidden'
,
width
:
100
,
overflow
:
'scroll'
}).
appendTo
(
'body'
),
widthWithScroll
=
$
(
'<div>'
).
css
({
width
:
'100%'
}).
appendTo
(
$outer
).
outerWidth
();
widthWithScroll
=
$
(
'<div>'
).
css
({
width
:
'100%'
}).
appendTo
(
$outer
).
outerWidth
();
$outer
.
remove
();
$outer
.
remove
();
return
100
-
widthWithScroll
;
return
100
-
widthWithScroll
;
}
;
}
$
(
'body'
).
attr
(
'data-scroll-width'
,
getScrollBarWidth
());
$
(
'body'
).
attr
(
'data-scroll-width'
,
getScrollBarWidth
());
...
@@ -353,7 +352,7 @@ import RepoBundle from './repo/repo_bundle';
...
@@ -353,7 +352,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
();
...
...
app/assets/javascripts/repo/repo_binary_viewer.js
View file @
2e025023
import
Vue
from
'vue'
import
Vue
from
'vue'
;
import
Store
from
'./repo_store'
import
Store
from
'./repo_store'
;
import
Flash
from
'../flash'
;
export
default
class
RepoBinaryViewer
{
export
default
class
RepoBinaryViewer
{
constructor
(
url
)
{
constructor
()
{
this
.
initVue
();
this
.
initVue
();
}
}
...
@@ -15,19 +16,23 @@ export default class RepoBinaryViewer {
...
@@ -15,19 +16,23 @@ export default class RepoBinaryViewer {
computed
:
{
computed
:
{
pngBlobWithDataURI
()
{
pngBlobWithDataURI
()
{
return
`data:image/png;base64,
${
this
.
blobRaw
}
`
;
return
`data:image/png;base64,
${
this
.
blobRaw
}
`
;
}
}
,
},
},
watch
:
{
watch
:
{
blobRaw
()
{
blobRaw
()
{
if
(
!
this
.
binary
)
return
;
if
(
!
this
.
binary
)
return
;
switch
(
this
.
binaryMimeType
)
{
switch
(
this
.
binaryMimeType
)
{
case
'image/png'
:
case
'image/png'
:
this
.
binaryTypes
.
png
=
true
;
this
.
binaryTypes
.
png
=
true
;
break
;
break
;
}
default
:
}
new
Flash
(
'Blob could not be loaded'
);
// eslint-disable-line no-new
}
break
;
}
},
},
});
});
}
}
}
}
\ No newline at end of file
app/assets/javascripts/repo/repo_bundle.js
View file @
2e025023
import
Tabs
from
'./repo_tabs'
import
Tabs
from
'./repo_tabs'
;
import
Sidebar
from
'./repo_sidebar'
import
Sidebar
from
'./repo_sidebar'
;
import
Editor
from
'./repo_editor'
import
Editor
from
'./repo_editor'
;
import
BinaryViewer
from
'./repo_binary_viewer'
import
BinaryViewer
from
'./repo_binary_viewer'
;
import
ViewToggler
from
'./repo_view_toggler'
import
ViewToggler
from
'./repo_view_toggler'
;
import
Service
from
'./repo_service'
import
Service
from
'./repo_service'
;
import
Store
from
'./repo_store'
import
Store
from
'./repo_store'
;
import
Helper
from
'./repo_helper'
import
Helper
from
'./repo_helper'
;
export
default
class
RepoBundle
{
export
default
class
RepoBundle
{
constructor
()
{
constructor
()
{
...
...
app/assets/javascripts/repo/repo_editor.js
View file @
2e025023
/* global monaco */
/* global monaco */
import
Vue
from
'vue'
;
import
Vue
from
'vue'
;
import
Store
from
'./repo_store'
import
Store
from
'./repo_store'
;
import
Helper
from
'./repo_helper'
import
Helper
from
'./repo_helper'
;
export
default
class
RepoEditor
{
export
default
class
RepoEditor
{
constructor
()
{
constructor
()
{
...
@@ -15,9 +15,9 @@ export default class RepoEditor {
...
@@ -15,9 +15,9 @@ export default class RepoEditor {
this
.
monacoEditor
=
monaco
.
editor
this
.
monacoEditor
=
monaco
.
editor
.
create
(
.
create
(
document
.
getElementById
(
'ide'
),
{
document
.
getElementById
(
'ide'
),
{
model
:
null
model
:
null
,
}
}
,
)
)
;
Helper
.
monacoInstance
=
monaco
;
Helper
.
monacoInstance
=
monaco
;
this
.
initVue
();
this
.
initVue
();
monaco
.
languages
.
getLanguages
();
monaco
.
languages
.
getLanguages
();
...
@@ -29,20 +29,20 @@ export default class RepoEditor {
...
@@ -29,20 +29,20 @@ export default class RepoEditor {
const
monacoEditor
=
this
.
monacoEditor
;
const
monacoEditor
=
this
.
monacoEditor
;
this
.
vue
=
new
Vue
({
this
.
vue
=
new
Vue
({
data
:
()
=>
Store
,
data
:
()
=>
Store
,
created
()
{
created
()
{
if
(
this
.
blobRaw
!==
''
)
{
if
(
this
.
blobRaw
!==
''
)
{
monacoEditor
.
setModel
(
monacoEditor
.
setModel
(
monaco
.
editor
.
createModel
(
monaco
.
editor
.
createModel
(
this
.
blobRaw
,
this
.
blobRaw
,
'plain'
'plain'
,
)
)
,
);
);
}
}
},
},
watch
:
{
watch
:
{
isTree
()
{
isTree
()
{
if
(
this
.
isTree
||
!
this
.
openedFiles
.
length
)
{
if
(
this
.
isTree
||
!
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 +50,7 @@ export default class RepoEditor {
...
@@ -50,7 +50,7 @@ export default class RepoEditor {
},
},
openedFiles
()
{
openedFiles
()
{
if
((
this
.
isTree
||
!
this
.
openedFiles
.
length
)
||
this
.
binary
)
{
if
((
this
.
isTree
||
!
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'
;
...
@@ -58,21 +58,21 @@ export default class RepoEditor {
...
@@ -58,21 +58,21 @@ export default class RepoEditor {
},
},
blobRaw
()
{
blobRaw
()
{
if
(
this
.
binary
)
{
if
(
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'
;
}
}
if
(
!
this
.
isTree
)
{
if
(
!
this
.
isTree
)
{
self
.
monacoEditor
.
setModel
(
self
.
monacoEditor
.
setModel
(
monaco
.
editor
.
createModel
(
monaco
.
editor
.
createModel
(
this
.
blobRaw
,
this
.
blobRaw
,
this
.
activeFile
.
mime_type
this
.
activeFile
.
mime_type
,
)
)
,
);
);
}
}
}
}
,
}
}
,
});
});
}
}
}
}
\ No newline at end of file
app/assets/javascripts/repo/repo_file.js
View file @
2e025023
le
t
RepoFile
=
{
cons
t
RepoFile
=
{
template
:
`
template
:
`
<tr v-if='!loading.tree || hasFiles'>
<tr v-if='!loading.tree || hasFiles'>
<td>
<td>
...
@@ -19,13 +19,13 @@ let RepoFile = {
...
@@ -19,13 +19,13 @@ let RepoFile = {
isTree
:
Boolean
,
isTree
:
Boolean
,
isMini
:
Boolean
,
isMini
:
Boolean
,
loading
:
Object
,
loading
:
Object
,
hasFiles
:
Boolean
hasFiles
:
Boolean
,
},
},
methods
:
{
methods
:
{
linkClicked
(
file
)
{
linkClicked
(
file
)
{
this
.
$emit
(
'linkclicked'
,
file
);
this
.
$emit
(
'linkclicked'
,
file
);
}
}
,
}
}
,
};
};
export
default
RepoFile
;
export
default
RepoFile
;
app/assets/javascripts/repo/repo_helper.js
View file @
2e025023
import
Service
from
'./repo_service'
import
Service
from
'./repo_service'
;
import
Store
from
'./repo_store'
import
Store
from
'./repo_store'
;
import
Flash
from
'../flash'
;
le
t
RepoHelper
=
{
cons
t
RepoHelper
=
{
isTree
(
data
)
{
isTree
(
data
)
{
return
data
.
hasOwnProperty
(
'blobs'
);
return
Object
.
hasOwnProperty
.
call
(
data
,
'blobs'
);
},
},
monacoInstance
:
undefined
,
monacoInstance
:
undefined
,
...
@@ -14,17 +15,11 @@ let RepoHelper = {
...
@@ -14,17 +15,11 @@ let RepoHelper = {
:
Date
,
:
Date
,
getLanguagesForMimeType
(
mimetypeNeedle
)
{
getLanguagesForMimeType
(
mimetypeNeedle
)
{
const
langs
=
monaco
.
languages
.
getLanguages
();
const
langs
=
window
.
monaco
.
languages
.
getLanguages
();
let
lang
=
''
;
langs
.
map
((
lang
)
=>
{
langs
.
every
((
lang
)
=>
{
const
hasLang
=
lang
.
mimetypes
.
some
(
mimetype
=>
mimetypeNeedle
===
mimetype
);
const
hasLang
=
lang
.
mimetypes
.
some
((
mimetype
)
=>
{
if
(
hasLang
)
return
lang
.
id
;
return
mimetypeNeedle
===
mimetype
return
lang
;
});
if
(
hasLang
)
{
lang
=
lang
.
id
;
return
true
;
}
return
false
;
});
});
},
},
...
@@ -32,7 +27,7 @@ let RepoHelper = {
...
@@ -32,7 +27,7 @@ let RepoHelper = {
const
split
=
url
.
split
(
'/'
);
const
split
=
url
.
split
(
'/'
);
split
.
pop
();
split
.
pop
();
const
blobIndex
=
split
.
indexOf
(
'blob'
);
const
blobIndex
=
split
.
indexOf
(
'blob'
);
if
(
blobIndex
>
-
1
)
{
if
(
blobIndex
>
-
1
)
{
split
[
blobIndex
]
=
'tree'
;
split
[
blobIndex
]
=
'tree'
;
}
}
return
split
.
join
(
'/'
);
return
split
.
join
(
'/'
);
...
@@ -40,21 +35,22 @@ let RepoHelper = {
...
@@ -40,21 +35,22 @@ let RepoHelper = {
insertNewFilesIntoParentDir
(
inDirectory
,
oldList
,
newList
)
{
insertNewFilesIntoParentDir
(
inDirectory
,
oldList
,
newList
)
{
let
indexOfFile
;
let
indexOfFile
;
if
(
!
inDirectory
)
{
if
(
!
inDirectory
)
{
return
newList
;
return
newList
;
}
}
oldList
.
find
((
file
,
i
)
=>
{
oldList
.
find
((
file
,
i
)
=>
{
if
(
file
.
url
===
inDirectory
.
url
)
{
if
(
file
.
url
===
inDirectory
.
url
)
{
indexOfFile
=
i
+
1
;
indexOfFile
=
i
+
1
;
return
true
;
return
true
;
}
}
return
false
;
return
false
;
});
});
if
(
indexOfFile
)
{
if
(
indexOfFile
)
{
// insert new list into old list
// insert new list into old list
newList
.
forEach
((
newFile
)
=>
{
newList
.
forEach
((
newFile
)
=>
{
newFile
.
level
=
inDirectory
.
level
+
1
;
const
file
=
newFile
;
oldList
.
splice
(
indexOfFile
,
0
,
newFile
);
file
.
level
=
inDirectory
.
level
+
1
;
oldList
.
splice
(
indexOfFile
,
0
,
file
);
});
});
return
oldList
;
return
oldList
;
}
}
...
@@ -63,47 +59,45 @@ let RepoHelper = {
...
@@ -63,47 +59,45 @@ let RepoHelper = {
setActiveFile
(
file
)
{
setActiveFile
(
file
)
{
Store
.
openedFiles
=
Store
.
openedFiles
.
map
((
openedFile
)
=>
{
Store
.
openedFiles
=
Store
.
openedFiles
.
map
((
openedFile
)
=>
{
openedFile
.
active
=
file
.
url
===
openedFile
.
url
;
const
activeFile
=
openedFile
;
if
(
openedFile
.
active
)
{
activeFile
.
active
=
file
.
url
===
activeFile
.
url
;
// eslint-disable-line no-param-reassign
Store
.
activeFile
=
openedFile
;
if
(
activeFile
.
active
)
{
Store
.
activeFile
=
activeFile
;
}
}
return
opened
File
;
return
active
File
;
});
});
if
(
file
.
binary
)
{
if
(
file
.
binary
)
{
Store
.
blobRaw
=
file
.
base64
;
Store
.
blobRaw
=
file
.
base64
;
console
.
log
(
'binary'
,
file
)
}
else
{
}
else
{
Store
.
blobRaw
=
file
.
plain
;
Store
.
blobRaw
=
file
.
plain
;
}
}
if
(
!
file
.
loading
)
{
if
(
!
file
.
loading
)
{
this
.
toURL
(
file
.
url
);
this
.
toURL
(
file
.
url
);
}
}
Store
.
binary
=
file
.
binary
;
Store
.
binary
=
file
.
binary
;
},
},
removeFromOpenedFiles
(
file
)
{
removeFromOpenedFiles
(
file
)
{
console
.
log
(
'file remove'
,
file
)
if
(
file
.
type
===
'tree'
)
return
;
if
(
file
.
type
===
'tree'
)
return
;
Store
.
openedFiles
=
Store
.
openedFiles
.
filter
(
openedFile
=>
openedFile
.
url
!==
file
.
url
);
Store
.
openedFiles
=
Store
.
openedFiles
.
filter
((
openedFile
)
=>
{
return
openedFile
.
url
!==
file
.
url
;
});
},
},
addToOpenedFiles
(
file
)
{
addToOpenedFiles
(
file
)
{
const
openedFilesAlreadyExists
=
Store
.
openedFiles
.
some
((
openedFile
)
=>
{
const
openedFilesAlreadyExists
=
Store
.
openedFiles
return
openedFile
.
url
===
file
.
url
.
some
(
openedFile
=>
openedFile
.
url
===
file
.
url
);
});
if
(
!
openedFilesAlreadyExists
)
{
if
(
!
openedFilesAlreadyExists
)
{
Store
.
openedFiles
.
push
(
file
);
Store
.
openedFiles
.
push
(
file
);
}
}
},
},
/* eslint-disable no-param-reassign */
setDirectoryOpen
(
tree
)
{
setDirectoryOpen
(
tree
)
{
if
(
tree
)
{
if
(
tree
)
{
tree
.
opened
=
true
;
tree
.
opened
=
true
;
tree
.
icon
=
'fa-folder-open'
;
tree
.
icon
=
'fa-folder-open'
;
}
}
},
},
/* eslint-enable no-param-reassign */
getRawURLFromBlobURL
(
url
)
{
getRawURLFromBlobURL
(
url
)
{
return
url
.
replace
(
'blob'
,
'raw'
);
return
url
.
replace
(
'blob'
,
'raw'
);
...
@@ -113,58 +107,57 @@ let RepoHelper = {
...
@@ -113,58 +107,57 @@ let RepoHelper = {
Service
.
getBase64Content
(
url
)
Service
.
getBase64Content
(
url
)
.
then
((
response
)
=>
{
.
then
((
response
)
=>
{
Store
.
blobRaw
=
response
;
Store
.
blobRaw
=
response
;
file
.
base64
=
response
file
.
base64
=
response
;
// eslint-disable-line no-param-reassign
console
.
log
(
'file'
,
file
);
})
}
);
.
catch
(
this
.
loadingError
);
},
},
toggleFakeTab
(
loading
,
file
)
{
toggleFakeTab
(
loading
,
file
)
{
if
(
loading
)
{
if
(
loading
)
{
const
randomURL
=
this
.
Time
.
now
();
const
randomURL
=
this
.
Time
.
now
();
const
newFakeFile
=
{
const
newFakeFile
=
{
active
:
false
,
active
:
false
,
binary
:
true
,
binary
:
true
,
type
:
'blob'
,
type
:
'blob'
,
loading
:
true
,
loading
:
true
,
mime_type
:
'loading'
,
mime_type
:
'loading'
,
name
:
'loading'
,
name
:
'loading'
,
url
:
randomURL
url
:
randomURL
,
};
};
Store
.
openedFiles
.
push
(
newFakeFile
);
Store
.
openedFiles
.
push
(
newFakeFile
);
return
newFakeFile
;
return
newFakeFile
;
}
else
{
this
.
removeFromOpenedFiles
(
file
);
return
null
;
}
}
this
.
removeFromOpenedFiles
(
file
);
return
null
;
},
},
setLoading
(
loading
,
file
)
{
setLoading
(
loading
,
file
)
{
if
(
Service
.
url
.
indexOf
(
'tree'
)
>
-
1
)
{
if
(
Service
.
url
.
indexOf
(
'tree'
)
>
-
1
)
{
Store
.
loading
.
tree
=
loading
;
Store
.
loading
.
tree
=
loading
;
}
else
if
(
Service
.
url
.
indexOf
(
'blob'
)
>
-
1
)
{
}
else
if
(
Service
.
url
.
indexOf
(
'blob'
)
>
-
1
)
{
Store
.
loading
.
blob
=
loading
;
Store
.
loading
.
blob
=
loading
;
return
this
.
toggleFakeTab
(
loading
,
file
);
return
this
.
toggleFakeTab
(
loading
,
file
);
}
}
return
undefined
;
},
},
// 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'
)
const
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
);
if
(
!
Store
.
isTree
)
{
if
(
!
Store
.
isTree
)
{
// it's a blob
// it's a blob
Store
.
binary
=
data
.
binary
;
Store
.
binary
=
data
.
binary
;
if
(
data
.
binary
)
{
if
(
data
.
binary
)
{
Store
.
binaryMimeType
=
data
.
mime_type
;
Store
.
binaryMimeType
=
data
.
mime_type
;
this
.
setBinaryDataAsBase64
(
this
.
setBinaryDataAsBase64
(
this
.
getRawURLFromBlobURL
(
file
.
url
),
this
.
getRawURLFromBlobURL
(
file
.
url
),
data
data
,
);
);
data
.
binary
=
true
;
data
.
binary
=
true
;
data
.
url
=
file
.
url
;
data
.
url
=
file
.
url
;
...
@@ -177,20 +170,19 @@ let RepoHelper = {
...
@@ -177,20 +170,19 @@ let RepoHelper = {
data
.
url
=
file
.
url
;
data
.
url
=
file
.
url
;
data
.
binary
=
false
;
data
.
binary
=
false
;
this
.
addToOpenedFiles
(
data
);
this
.
addToOpenedFiles
(
data
);
this
.
setActiveFile
(
data
);
this
.
setActiveFile
(
data
);
}
}
}
else
{
}
else
{
// it's a tree
// it's a tree
this
.
setDirectoryOpen
(
file
);
this
.
setDirectoryOpen
(
file
);
le
t
newDirectory
=
this
.
dataToListOfFiles
(
data
);
cons
t
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
((
)
=>
{
this
.
setLoading
(
false
,
loadingData
);
this
.
setLoading
(
false
,
loadingData
);
new
Flash
(
'Unable to load the file at this time.'
)
this
.
loadingError
();
});
});
},
},
...
@@ -198,28 +190,28 @@ let RepoHelper = {
...
@@ -198,28 +190,28 @@ let RepoHelper = {
return
`fa-
${
icon
}
`
;
return
`fa-
${
icon
}
`
;
},
},
/* eslint-disable no-param-reassign */
removeChildFilesOfTree
(
tree
)
{
removeChildFilesOfTree
(
tree
)
{
let
foundTree
=
false
;
let
foundTree
=
false
;
Store
.
files
=
Store
.
files
.
filter
((
file
)
=>
{
Store
.
files
=
Store
.
files
.
filter
((
file
)
=>
{
if
(
file
.
url
===
tree
.
url
)
{
if
(
file
.
url
===
tree
.
url
)
{
foundTree
=
true
;
foundTree
=
true
;
}
}
if
(
foundTree
)
{
if
(
foundTree
)
{
return
file
.
level
<=
tree
.
level
return
file
.
level
<=
tree
.
level
;
}
else
{
return
true
;
}
}
return
true
;
});
});
tree
.
opened
=
false
;
tree
.
opened
=
false
;
tree
.
icon
=
'fa-folder'
;
tree
.
icon
=
'fa-folder'
;
},
},
/* eslint-enable no-param-reassign */
dataToListOfFiles
(
data
)
{
dataToListOfFiles
(
data
)
{
le
t
a
=
[];
cons
t
a
=
[];
//push in blobs
//
push in blobs
data
.
blobs
.
forEach
((
blob
)
=>
{
data
.
blobs
.
forEach
((
blob
)
=>
{
a
.
push
({
a
.
push
({
type
:
'blob'
,
type
:
'blob'
,
...
@@ -228,8 +220,8 @@ let RepoHelper = {
...
@@ -228,8 +220,8 @@ let RepoHelper = {
icon
:
this
.
toFA
(
blob
.
icon
),
icon
:
this
.
toFA
(
blob
.
icon
),
lastCommitMessage
:
blob
.
last_commit
.
message
,
lastCommitMessage
:
blob
.
last_commit
.
message
,
lastCommitUpdate
:
blob
.
last_commit
.
committed_date
,
lastCommitUpdate
:
blob
.
last_commit
.
committed_date
,
level
:
0
level
:
0
,
})
})
;
});
});
data
.
trees
.
forEach
((
tree
)
=>
{
data
.
trees
.
forEach
((
tree
)
=>
{
...
@@ -238,8 +230,8 @@ let RepoHelper = {
...
@@ -238,8 +230,8 @@ let RepoHelper = {
name
:
tree
.
name
,
name
:
tree
.
name
,
url
:
tree
.
url
,
url
:
tree
.
url
,
icon
:
this
.
toFA
(
tree
.
icon
),
icon
:
this
.
toFA
(
tree
.
icon
),
level
:
0
level
:
0
,
})
})
;
});
});
data
.
submodules
.
forEach
((
submodule
)
=>
{
data
.
submodules
.
forEach
((
submodule
)
=>
{
...
@@ -248,32 +240,36 @@ let RepoHelper = {
...
@@ -248,32 +240,36 @@ let RepoHelper = {
name
:
submodule
.
name
,
name
:
submodule
.
name
,
url
:
submodule
.
url
,
url
:
submodule
.
url
,
icon
:
this
.
toFA
(
submodule
.
icon
),
icon
:
this
.
toFA
(
submodule
.
icon
),
level
:
0
level
:
0
,
})
})
;
});
});
return
a
;
return
a
;
},
},
genKey
()
{
genKey
()
{
return
this
.
Time
.
now
().
toFixed
(
3
)
return
this
.
Time
.
now
().
toFixed
(
3
)
;
},
},
_
key
:
''
,
key
:
''
,
getStateKey
()
{
getStateKey
()
{
return
this
.
_key
return
this
.
key
;
},
},
setStateKey
(
key
)
{
setStateKey
(
key
)
{
this
.
_
key
=
key
;
this
.
key
=
key
;
},
},
toURL
(
url
)
{
toURL
(
url
)
{
var
history
=
window
.
history
;
const
history
=
window
.
history
;
this
.
_key
=
this
.
genKey
();
this
.
key
=
this
.
genKey
();
history
.
pushState
({
key
:
this
.
_key
},
''
,
url
);
history
.
pushState
({
key
:
this
.
key
},
''
,
url
);
}
},
loadingError
()
{
new
Flash
(
'Unable to load the file at this time.'
);
// eslint-disable-line no-new
},
};
};
export
default
RepoHelper
;
export
default
RepoHelper
;
\ No newline at end of file
app/assets/javascripts/repo/repo_loading_file.js
View file @
2e025023
le
t
RepoLoadingFile
=
{
cons
t
RepoLoadingFile
=
{
template
:
`
template
:
`
<tr v-if='loading.tree && !hasFiles'>
<tr v-if='loading.tree && !hasFiles'>
<td>
<td>
...
@@ -36,7 +36,7 @@ let RepoLoadingFile = {
...
@@ -36,7 +36,7 @@ let RepoLoadingFile = {
props
:
{
props
:
{
loading
:
Object
,
loading
:
Object
,
hasFiles
:
Boolean
,
hasFiles
:
Boolean
,
isMini
:
Boolean
isMini
:
Boolean
,
}
}
,
};
};
export
default
RepoLoadingFile
;
export
default
RepoLoadingFile
;
\ No newline at end of file
app/assets/javascripts/repo/repo_mini_mixin.js
View file @
2e025023
import
Store
from
'./repo_store'
import
Store
from
'./repo_store'
;
le
t
RepoMiniMixin
=
{
cons
t
RepoMiniMixin
=
{
computed
:
{
computed
:
{
isMini
()
{
isMini
()
{
return
!!
Store
.
openedFiles
.
length
;
return
!!
Store
.
openedFiles
.
length
;
}
}
,
},
},
};
};
export
default
RepoMiniMixin
;
export
default
RepoMiniMixin
;
\ No newline at end of file
app/assets/javascripts/repo/repo_prev_directory.js
View file @
2e025023
le
t
RepoPreviousDirectory
=
{
cons
t
RepoPreviousDirectory
=
{
template
:
`
template
:
`
<tr>
<tr>
<td colspan='3'>
<td colspan='3'>
...
@@ -8,13 +8,13 @@ let RepoPreviousDirectory = {
...
@@ -8,13 +8,13 @@ let RepoPreviousDirectory = {
`
,
`
,
props
:
{
props
:
{
name
:
'repo-previous-directory'
,
name
:
'repo-previous-directory'
,
prevurl
:
String
prevurl
:
String
,
},
},
methods
:
{
methods
:
{
linkClicked
(
file
)
{
linkClicked
(
file
)
{
this
.
$emit
(
'linkclicked'
,
file
);
this
.
$emit
(
'linkclicked'
,
file
);
}
}
,
}
}
,
};
};
export
default
RepoPreviousDirectory
;
export
default
RepoPreviousDirectory
;
\ No newline at end of file
app/assets/javascripts/repo/repo_service.js
View file @
2e025023
import
axios
from
'axios'
;
import
axios
from
'axios'
;
le
t
RepoService
=
{
cons
t
RepoService
=
{
url
:
''
,
url
:
''
,
params
:
{
params
:
{
params
:
{
params
:
{
format
:
'json'
format
:
'json'
,
}
}
,
},
},
setUrl
(
url
)
{
setUrl
(
url
)
{
...
@@ -13,8 +13,8 @@ let RepoService = {
...
@@ -13,8 +13,8 @@ let RepoService = {
},
},
getContent
(
url
)
{
getContent
(
url
)
{
if
(
url
)
{
if
(
url
)
{
return
axios
.
get
(
url
,
this
.
params
);
return
axios
.
get
(
url
,
this
.
params
);
}
}
return
axios
.
get
(
this
.
url
,
this
.
params
);
return
axios
.
get
(
this
.
url
,
this
.
params
);
},
},
...
@@ -22,10 +22,10 @@ let RepoService = {
...
@@ -22,10 +22,10 @@ let RepoService = {
getBase64Content
(
url
)
{
getBase64Content
(
url
)
{
return
axios
return
axios
.
get
(
url
,
{
.
get
(
url
,
{
responseType
:
'arraybuffer'
responseType
:
'arraybuffer'
,
})
})
.
then
(
response
=>
new
Buffer
(
response
.
data
,
'binary'
).
toString
(
'base64'
))
.
then
(
response
=>
new
Buffer
(
response
.
data
,
'binary'
).
toString
(
'base64'
))
;
}
}
,
};
};
export
default
RepoService
;
export
default
RepoService
;
\ No newline at end of file
app/assets/javascripts/repo/repo_sidebar.js
View file @
2e025023
import
Service
from
'./repo_service'
import
Vue
from
'vue'
;
import
Helper
from
'./repo_helper'
import
Service
from
'./repo_service'
;
import
Vue
from
'vue'
import
Helper
from
'./repo_helper'
;
import
Store
from
'./repo_store'
import
Store
from
'./repo_store'
;
import
RepoPreviousDirectory
from
'./repo_prev_directory'
import
RepoPreviousDirectory
from
'./repo_prev_directory'
;
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'
;
export
default
class
RepoSidebar
{
export
default
class
RepoSidebar
{
constructor
(
url
)
{
constructor
(
url
)
{
...
@@ -34,29 +34,29 @@ export default class RepoSidebar {
...
@@ -34,29 +34,29 @@ export default class RepoSidebar {
addPopEventListener
()
{
addPopEventListener
()
{
window
.
addEventListener
(
'popstate'
,
()
=>
{
window
.
addEventListener
(
'popstate'
,
()
=>
{
this
.
linkClicked
({
this
.
linkClicked
({
url
:
location
.
href
url
:
location
.
href
,
});
});
});
});
},
},
linkClicked
(
file
)
{
linkClicked
(
file
)
{
let
url
=
''
;
let
url
=
''
;
if
(
typeof
file
===
'string'
)
{
if
(
typeof
file
===
'string'
)
{
// go back
// go back
url
=
file
;
url
=
file
;
}
else
{
}
else
{
url
=
file
.
url
;
url
=
file
.
url
;
}
}
Service
.
url
=
url
;
Service
.
url
=
url
;
if
(
typeof
file
===
'object'
)
{
if
(
typeof
file
===
'object'
)
{
if
(
file
.
type
===
'tree'
&&
file
.
opened
)
{
if
(
file
.
type
===
'tree'
&&
file
.
opened
)
{
Helper
.
removeChildFilesOfTree
(
file
);
Helper
.
removeChildFilesOfTree
(
file
);
return
;
return
;
}
}
Helper
.
getContent
(
file
);
Helper
.
getContent
(
file
);
}
}
}
}
,
},
},
});
});
}
}
}
}
\ No newline at end of file
app/assets/javascripts/repo/repo_store.js
View file @
2e025023
le
t
RepoStore
=
{
cons
t
RepoStore
=
{
service
:
''
,
service
:
''
,
editor
:
''
,
editor
:
''
,
sidebar
:
''
,
sidebar
:
''
,
...
@@ -14,14 +14,14 @@ let RepoStore = {
...
@@ -14,14 +14,14 @@ let RepoStore = {
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
,
},
},
loading
:
{
loading
:
{
tree
:
false
,
tree
:
false
,
blob
:
false
blob
:
false
,
}
}
,
};
};
export
default
RepoStore
;
export
default
RepoStore
;
app/assets/javascripts/repo/repo_tab.js
View file @
2e025023
import
RepoHelper
from
'./repo_helper'
import
RepoHelper
from
'./repo_helper'
;
le
t
RepoTab
=
{
cons
t
RepoTab
=
{
template
:
`
template
:
`
<li>
<li>
<a href='#' @click.prevent='xClicked(tab)' v-if='!tab.loading'>
<a href='#' @click.prevent='xClicked(tab)' v-if='!tab.loading'>
...
@@ -23,7 +23,7 @@ let RepoTab = {
...
@@ -23,7 +23,7 @@ let RepoTab = {
xClicked
(
file
)
{
xClicked
(
file
)
{
RepoHelper
.
removeFromOpenedFiles
(
file
);
RepoHelper
.
removeFromOpenedFiles
(
file
);
}
}
,
}
}
,
};
};
export
default
RepoTab
;
export
default
RepoTab
;
\ No newline at end of file
app/assets/javascripts/repo/repo_tabs.js
View file @
2e025023
import
Vue
from
'vue'
;
import
Vue
from
'vue'
;
import
Store
from
'./repo_store'
import
Store
from
'./repo_store'
;
import
RepoTab
from
'./repo_tab'
import
RepoTab
from
'./repo_tab'
;
import
RepoMiniMixin
from
'./repo_mini_mixin'
import
RepoMiniMixin
from
'./repo_mini_mixin'
;
export
default
class
RepoTabs
{
export
default
class
RepoTabs
{
constructor
()
{
constructor
()
{
thi
s
.
styleTabsForWindows
();
RepoTab
s
.
styleTabsForWindows
();
this
.
initVue
();
this
.
initVue
();
}
}
...
@@ -20,8 +20,8 @@ export default class RepoTabs {
...
@@ -20,8 +20,8 @@ export default class RepoTabs {
});
});
}
}
styleTabsForWindows
()
{
st
atic
st
yleTabsForWindows
()
{
const
scrollWidth
=
Number
(
document
.
body
.
dataset
.
scrollWidth
);
const
scrollWidth
=
Number
(
document
.
body
.
dataset
.
scrollWidth
);
Store
.
scrollWidth
=
scrollWidth
;
Store
.
scrollWidth
=
scrollWidth
;
}
}
}
}
\ No newline at end of file
app/assets/javascripts/repo/repo_view_toggler.js
View file @
2e025023
import
Service
from
'./repo_service'
import
Vue
from
'vue'
;
import
Vue
from
'vue'
import
Store
from
'./repo_store'
;
import
Store
from
'./repo_store'
export
default
class
RepoViewToggler
{
export
default
class
RepoViewToggler
{
constructor
()
{
constructor
()
{
...
@@ -14,4 +13,4 @@ export default class RepoViewToggler {
...
@@ -14,4 +13,4 @@ export default class RepoViewToggler {
data
:
()
=>
Store
,
data
:
()
=>
Store
,
});
});
}
}
}
}
\ No newline at end of file
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