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