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
636b2425
Unverified
Commit
636b2425
authored
Jul 21, 2017
by
Luke "Jared" Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
access repo object over this
parent
528a8ddd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
51 deletions
+51
-51
repo_helper.js
app/assets/javascripts/repo/repo_helper.js
+24
-24
repo_store.js
app/assets/javascripts/repo/repo_store.js
+26
-26
repo_tab.vue
app/assets/javascripts/repo/repo_tab.vue
+1
-1
No files found.
app/assets/javascripts/repo/repo_helper.js
View file @
636b2425
...
...
@@ -17,7 +17,7 @@ const RepoHelper = {
getLanguageIDForFile
(
file
,
langs
)
{
const
ext
=
file
.
name
.
split
(
'.'
).
pop
();
const
foundLang
=
this
.
findLanguage
(
ext
,
langs
);
const
foundLang
=
RepoHelper
.
findLanguage
(
ext
,
langs
);
return
foundLang
?
foundLang
.
id
:
'plaintext'
;
},
...
...
@@ -53,7 +53,7 @@ const RepoHelper = {
Store
.
blobRaw
=
response
;
file
.
base64
=
response
;
// eslint-disable-line no-param-reassign
})
.
catch
(
this
.
loadingError
);
.
catch
(
RepoHelper
.
loadingError
);
},
toggleFakeTab
(
loading
,
file
)
{
...
...
@@ -64,7 +64,7 @@ const RepoHelper = {
setLoading
(
loading
,
file
)
{
if
(
Service
.
url
.
indexOf
(
'blob'
)
>
-
1
)
{
Store
.
loading
.
blob
=
loading
;
return
this
.
toggleFakeTab
(
loading
,
file
);
return
RepoHelper
.
toggleFakeTab
(
loading
,
file
);
}
if
(
Service
.
url
.
indexOf
(
'tree'
)
>
-
1
)
Store
.
loading
.
tree
=
loading
;
...
...
@@ -79,7 +79,7 @@ const RepoHelper = {
if
(
!
indexOfFile
)
return
newList
;
return
this
.
mergeNewListToOldList
(
newList
,
currentList
,
inDirectory
,
indexOfFile
);
return
RepoHelper
.
mergeNewListToOldList
(
newList
,
currentList
,
inDirectory
,
indexOfFile
);
},
mergeNewListToOldList
(
newList
,
oldList
,
inDirectory
,
indexOfFile
)
{
...
...
@@ -100,16 +100,16 @@ const RepoHelper = {
Service
.
getContent
()
.
then
((
response
)
=>
{
const
data
=
response
.
data
;
this
.
setLoading
(
false
,
loadingData
);
Store
.
isTree
=
this
.
isTree
(
data
);
RepoHelper
.
setLoading
(
false
,
loadingData
);
Store
.
isTree
=
RepoHelper
.
isTree
(
data
);
if
(
!
Store
.
isTree
)
{
if
(
!
file
)
file
=
data
;
Store
.
binary
=
data
.
binary
;
if
(
data
.
binary
)
{
Store
.
binaryMimeType
=
data
.
mime_type
;
const
rawUrl
=
this
.
getRawURLFromBlobURL
(
file
.
url
);
this
.
setBinaryDataAsBase64
(
rawUrl
,
data
);
const
rawUrl
=
RepoHelper
.
getRawURLFromBlobURL
(
file
.
url
);
RepoHelper
.
setBinaryDataAsBase64
(
rawUrl
,
data
);
data
.
binary
=
true
;
}
else
{
Store
.
blobRaw
=
data
.
plain
;
...
...
@@ -128,19 +128,19 @@ const RepoHelper = {
if
(
Store
.
files
.
length
===
0
)
{
const
parentURL
=
Service
.
blobURLtoParentTree
(
Service
.
url
);
Service
.
url
=
parentURL
;
this
.
getContent
();
RepoHelper
.
getContent
();
}
}
else
{
// it's a tree
this
.
setDirectoryOpen
(
file
);
RepoHelper
.
setDirectoryOpen
(
file
);
const
newDirectory
=
this
.
dataToListOfFiles
(
data
);
Store
.
addFilesToDirectory
(
file
,
Store
.
files
,
newDirectory
);
Store
.
prevURL
=
Service
.
blobURLtoParentTree
(
Service
.
url
);
}
})
.
catch
(()
=>
{
this
.
setLoading
(
false
,
loadingData
);
this
.
loadingError
();
RepoHelper
.
setLoading
(
false
,
loadingData
);
RepoHelper
.
loadingError
();
});
},
...
...
@@ -149,7 +149,7 @@ const RepoHelper = {
},
serializeBlob
(
blob
)
{
const
simpleBlob
=
this
.
serializeRepoEntity
(
'blob'
,
blob
);
const
simpleBlob
=
RepoHelper
.
serializeRepoEntity
(
'blob'
,
blob
);
simpleBlob
.
lastCommitMessage
=
blob
.
last_commit
.
message
;
simpleBlob
.
lastCommitUpdate
=
blob
.
last_commit
.
committed_date
;
...
...
@@ -157,11 +157,11 @@ const RepoHelper = {
},
serializeTree
(
tree
)
{
return
this
.
serializeRepoEntity
(
'tree'
,
tree
);
return
RepoHelper
.
serializeRepoEntity
(
'tree'
,
tree
);
},
serializeSubmodule
(
submodule
)
{
return
this
.
serializeRepoEntity
(
'submodule'
,
submodule
);
return
RepoHelper
.
serializeRepoEntity
(
'submodule'
,
submodule
);
},
serializeRepoEntity
(
type
,
entity
)
{
...
...
@@ -171,7 +171,7 @@ const RepoHelper = {
type
,
name
,
url
,
icon
:
this
.
toFA
(
icon
),
icon
:
RepoHelper
.
toFA
(
icon
),
level
:
0
,
};
},
...
...
@@ -181,38 +181,38 @@ const RepoHelper = {
// push in blobs
data
.
blobs
.
forEach
((
blob
)
=>
{
a
.
push
(
this
.
serializeBlob
(
blob
));
a
.
push
(
RepoHelper
.
serializeBlob
(
blob
));
});
data
.
trees
.
forEach
((
tree
)
=>
{
a
.
push
(
this
.
serializeTree
(
tree
));
a
.
push
(
RepoHelper
.
serializeTree
(
tree
));
});
data
.
submodules
.
forEach
((
submodule
)
=>
{
a
.
push
(
this
.
serializeSubmodule
(
submodule
));
a
.
push
(
RepoHelper
.
serializeSubmodule
(
submodule
));
});
return
a
;
},
genKey
()
{
return
this
.
Time
.
now
().
toFixed
(
3
);
return
RepoHelper
.
Time
.
now
().
toFixed
(
3
);
},
getStateKey
()
{
return
this
.
key
;
return
RepoHelper
.
key
;
},
setStateKey
(
key
)
{
this
.
key
=
key
;
RepoHelper
.
key
=
key
;
},
toURL
(
url
)
{
const
history
=
window
.
history
;
this
.
key
=
this
.
genKey
();
RepoHelper
.
key
=
RepoHelper
.
genKey
();
history
.
pushState
({
key
:
this
.
key
},
''
,
url
);
history
.
pushState
({
key
:
RepoHelper
.
key
},
''
,
url
);
},
loadingError
()
{
...
...
app/assets/javascripts/repo/repo_store.js
View file @
636b2425
...
...
@@ -50,55 +50,55 @@ const RepoStore = {
// mutations
addFilesToDirectory
(
inDirectory
,
currentList
,
newList
)
{
this
.
files
=
RepoHelper
.
getNewMergedList
(
inDirectory
,
currentList
,
newList
);
RepoStore
.
files
=
RepoHelper
.
getNewMergedList
(
inDirectory
,
currentList
,
newList
);
},
toggleRawPreview
()
{
this
.
activeFile
.
raw
=
!
this
.
activeFile
.
raw
;
this
.
activeFileLabel
=
this
.
activeFile
.
raw
?
'Display rendered file'
:
'Display source'
;
RepoStore
.
activeFile
.
raw
=
!
RepoStore
.
activeFile
.
raw
;
RepoStore
.
activeFileLabel
=
RepoStore
.
activeFile
.
raw
?
'Display rendered file'
:
'Display source'
;
},
setActiveFiles
(
file
)
{
if
(
this
.
isActiveFile
(
file
))
return
;
if
(
RepoStore
.
isActiveFile
(
file
))
return
;
this
.
openedFiles
=
this
.
openedFiles
.
map
((
openedFile
,
i
)
=>
this
.
setFileToActive
(
openedFile
,
i
));
RepoStore
.
openedFiles
=
RepoStore
.
openedFiles
.
map
((
openedFile
,
i
)
=>
RepoStore
.
w
(
openedFile
,
i
));
this
.
setActiveToRaw
();
RepoStore
.
setActiveToRaw
();
if
(
file
.
binary
)
{
this
.
blobRaw
=
file
.
base64
;
RepoStore
.
blobRaw
=
file
.
base64
;
}
else
{
this
.
blobRaw
=
file
.
plain
;
RepoStore
.
blobRaw
=
file
.
plain
;
}
if
(
!
file
.
loading
)
RepoHelper
.
toURL
(
file
.
url
);
this
.
binary
=
file
.
binary
;
RepoStore
.
binary
=
file
.
binary
;
},
setFileToActive
(
file
,
i
)
{
w
(
file
,
i
)
{
const
activeFile
=
file
;
activeFile
.
active
=
activeFile
.
url
===
activeFile
.
url
;
if
(
activeFile
.
active
)
this
.
setActiveFile
(
activeFile
,
i
);
if
(
activeFile
.
active
)
RepoStore
.
setActiveFile
(
activeFile
,
i
);
return
activeFile
;
},
setActiveFile
(
activeFile
,
i
)
{
this
.
activeFile
=
activeFile
;
this
.
activeFileIndex
=
i
;
RepoStore
.
activeFile
=
activeFile
;
RepoStore
.
activeFileIndex
=
i
;
},
setActiveToRaw
()
{
this
.
activeFile
.
raw
=
false
;
// can't get vue to listen to raw for some reason so
this
for now.
this
.
activeFileLabel
=
'Display source'
;
RepoStore
.
activeFile
.
raw
=
false
;
// can't get vue to listen to raw for some reason so
RepoStore
for now.
RepoStore
.
activeFileLabel
=
'Display source'
;
},
/* eslint-disable no-param-reassign */
removeChildFilesOfTree
(
tree
)
{
let
foundTree
=
false
;
this
.
files
=
this
.
files
.
filter
((
file
)
=>
{
RepoStore
.
files
=
RepoStore
.
files
.
filter
((
file
)
=>
{
if
(
file
.
url
===
tree
.
url
)
foundTree
=
true
;
if
(
foundTree
)
return
file
.
level
<=
tree
.
level
;
...
...
@@ -113,7 +113,7 @@ const RepoStore = {
removeFromOpenedFiles
(
file
)
{
if
(
file
.
type
===
'tree'
)
return
;
this
.
openedFiles
=
this
.
openedFiles
.
filter
(
openedFile
=>
openedFile
.
url
!==
file
.
url
);
RepoStore
.
openedFiles
=
RepoStore
.
openedFiles
.
filter
(
openedFile
=>
openedFile
.
url
!==
file
.
url
);
},
addPlaceholderFile
()
{
...
...
@@ -128,7 +128,7 @@ const RepoStore = {
url
:
randomURL
,
};
this
.
openedFiles
.
push
(
newFakeFile
);
RepoStore
.
openedFiles
.
push
(
newFakeFile
);
return
newFakeFile
;
},
...
...
@@ -136,27 +136,27 @@ const RepoStore = {
addToOpenedFiles
(
file
)
{
const
openFile
=
file
;
const
openedFilesAlreadyExists
=
this
.
openedFiles
const
openedFilesAlreadyExists
=
RepoStore
.
openedFiles
.
some
(
openedFile
=>
openedFile
.
url
===
openFile
.
url
);
if
(
openedFilesAlreadyExists
)
return
;
openFile
.
changed
=
false
;
this
.
openedFiles
.
push
(
openFile
);
RepoStore
.
openedFiles
.
push
(
openFile
);
},
setActiveFileContents
(
contents
)
{
if
(
!
this
.
editMode
)
return
;
if
(
!
RepoStore
.
editMode
)
return
;
this
.
activeFile
.
newContent
=
contents
;
this
.
activeFile
.
changed
=
this
.
activeFile
.
plain
!==
this
.
activeFile
.
newContent
;
this
.
openedFiles
[
this
.
activeFileIndex
].
changed
=
this
.
activeFile
.
changed
;
RepoStore
.
activeFile
.
newContent
=
contents
;
RepoStore
.
activeFile
.
changed
=
RepoStore
.
activeFile
.
plain
!==
RepoStore
.
activeFile
.
newContent
;
RepoStore
.
openedFiles
[
RepoStore
.
activeFileIndex
].
changed
=
RepoStore
.
activeFile
.
changed
;
},
// getters
isActiveFile
(
file
)
{
return
file
&&
file
.
url
===
this
.
activeFile
.
url
;
return
file
&&
file
.
url
===
RepoStore
.
activeFile
.
url
;
},
};
export
default
RepoStore
;
app/assets/javascripts/repo/repo_tab.vue
View file @
636b2425
...
...
@@ -20,7 +20,7 @@ const RepoTab = {
},
methods
:
{
tabClicked
:
RepoStore
.
setActiveFiles
.
bind
(
RepoStore
)
,
tabClicked
:
RepoStore
.
setActiveFiles
,
xClicked
(
file
)
{
if
(
file
.
changed
)
return
;
...
...
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