Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
60ce5155
Commit
60ce5155
authored
Oct 19, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed bug with tabs not switching correctly
clears all tmp files after cancelling edit mode
parent
10dcaea1
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
54 additions
and
13 deletions
+54
-13
app/assets/javascripts/repo/components/new_dropdown/modal.vue
...assets/javascripts/repo/components/new_dropdown/modal.vue
+15
-4
app/assets/javascripts/repo/components/repo.vue
app/assets/javascripts/repo/components/repo.vue
+3
-0
app/assets/javascripts/repo/components/repo_commit_section.vue
...ssets/javascripts/repo/components/repo_commit_section.vue
+3
-1
app/assets/javascripts/repo/helpers/repo_helper.js
app/assets/javascripts/repo/helpers/repo_helper.js
+22
-2
app/assets/javascripts/repo/stores/repo_store.js
app/assets/javascripts/repo/stores/repo_store.js
+9
-5
app/controllers/projects/blob_controller.rb
app/controllers/projects/blob_controller.rb
+1
-0
spec/javascripts/repo/components/repo_file_buttons_spec.js
spec/javascripts/repo/components/repo_file_buttons_spec.js
+1
-1
No files found.
app/assets/javascripts/repo/components/new_dropdown/modal.vue
View file @
60ce5155
...
@@ -21,13 +21,22 @@
...
@@ -21,13 +21,22 @@
},
},
methods
:
{
methods
:
{
createEntryInStore
()
{
createEntryInStore
()
{
if
(
this
.
entryName
===
''
)
return
;
const
originalPath
=
RepoStore
.
path
;
let
entryName
=
this
.
entryName
;
const
fileName
=
this
.
type
===
'
tree
'
?
'
.gitkeep
'
:
this
.
entryName
;
if
(
entryName
.
indexOf
(
`
${
RepoStore
.
path
}
/`
)
!==
0
)
{
RepoStore
.
path
=
''
;
}
else
{
entryName
=
entryName
.
replace
(
`
${
RepoStore
.
path
}
/`
,
''
);
}
if
(
entryName
===
''
)
return
;
const
fileName
=
this
.
type
===
'
tree
'
?
'
.gitkeep
'
:
entryName
;
let
tree
=
RepoStore
;
let
tree
=
RepoStore
;
if
(
this
.
type
===
'
tree
'
)
{
if
(
this
.
type
===
'
tree
'
)
{
const
dirNames
=
this
.
entryName
.
split
(
'
/
'
);
const
dirNames
=
entryName
.
split
(
'
/
'
);
dirNames
.
forEach
((
dirName
)
=>
{
dirNames
.
forEach
((
dirName
)
=>
{
if
(
dirName
===
''
)
return
;
if
(
dirName
===
''
)
return
;
...
@@ -43,11 +52,13 @@
...
@@ -43,11 +52,13 @@
RepoHelper
.
setFile
(
file
.
entry
,
file
.
entry
);
RepoHelper
.
setFile
(
file
.
entry
,
file
.
entry
);
RepoStore
.
editMode
=
true
;
RepoStore
.
editMode
=
true
;
RepoStore
.
toggleBlobView
()
;
RepoStore
.
currentBlobView
=
'
repo-editor
'
;
}
}
}
}
this
.
toggleModalOpen
();
this
.
toggleModalOpen
();
RepoStore
.
path
=
originalPath
;
},
},
toggleModalOpen
()
{
toggleModalOpen
()
{
this
.
$emit
(
'
toggle
'
);
this
.
$emit
(
'
toggle
'
);
...
...
app/assets/javascripts/repo/components/repo.vue
View file @
60ce5155
...
@@ -37,6 +37,9 @@ export default {
...
@@ -37,6 +37,9 @@ export default {
dialogSubmitted
(
status
)
{
dialogSubmitted
(
status
)
{
this
.
toggleDialogOpen
(
false
);
this
.
toggleDialogOpen
(
false
);
this
.
dialog
.
status
=
status
;
this
.
dialog
.
status
=
status
;
// remove tmp files
Helper
.
removeAllTmpFiles
();
},
},
toggleBlobView
:
Store
.
toggleBlobView
,
toggleBlobView
:
Store
.
toggleBlobView
,
...
...
app/assets/javascripts/repo/components/repo_commit_section.vue
View file @
60ce5155
...
@@ -62,7 +62,6 @@ export default {
...
@@ -62,7 +62,6 @@ export default {
if
(
newBranch
)
{
if
(
newBranch
)
{
payload
.
start_branch
=
this
.
currentBranch
;
payload
.
start_branch
=
this
.
currentBranch
;
}
}
this
.
submitCommitsLoading
=
true
;
Service
.
commitFiles
(
payload
)
Service
.
commitFiles
(
payload
)
.
then
(()
=>
{
.
then
(()
=>
{
this
.
resetCommitState
();
this
.
resetCommitState
();
...
@@ -78,6 +77,8 @@ export default {
...
@@ -78,6 +77,8 @@ export default {
},
},
tryCommit
(
e
,
skipBranchCheck
=
false
,
newBranch
=
false
)
{
tryCommit
(
e
,
skipBranchCheck
=
false
,
newBranch
=
false
)
{
this
.
submitCommitsLoading
=
true
;
if
(
skipBranchCheck
)
{
if
(
skipBranchCheck
)
{
this
.
makeCommit
(
newBranch
);
this
.
makeCommit
(
newBranch
);
}
else
{
}
else
{
...
@@ -90,6 +91,7 @@ export default {
...
@@ -90,6 +91,7 @@ export default {
this
.
makeCommit
(
newBranch
);
this
.
makeCommit
(
newBranch
);
})
})
.
catch
(()
=>
{
.
catch
(()
=>
{
this
.
submitCommitsLoading
=
false
;
Flash
(
'
An error occurred while committing your changes
'
);
Flash
(
'
An error occurred while committing your changes
'
);
});
});
}
}
...
...
app/assets/javascripts/repo/helpers/repo_helper.js
View file @
60ce5155
...
@@ -62,6 +62,7 @@ const RepoHelper = {
...
@@ -62,6 +62,7 @@ const RepoHelper = {
});
});
RepoHelper
.
updateHistoryEntry
(
tree
.
url
,
title
);
RepoHelper
.
updateHistoryEntry
(
tree
.
url
,
title
);
Store
.
path
=
tree
.
path
;
},
},
setDirectoryToClosed
(
entry
)
{
setDirectoryToClosed
(
entry
)
{
...
@@ -157,7 +158,18 @@ const RepoHelper = {
...
@@ -157,7 +158,18 @@ const RepoHelper = {
},
},
serializeRepoEntity
(
type
,
entity
,
level
=
0
)
{
serializeRepoEntity
(
type
,
entity
,
level
=
0
)
{
const
{
id
,
url
,
name
,
icon
,
last_commit
,
tree_url
,
path
,
tempFile
,
opened
=
false
}
=
entity
;
const
{
id
,
url
,
name
,
icon
,
last_commit
,
tree_url
,
path
,
tempFile
,
active
,
opened
,
}
=
entity
;
return
{
return
{
id
,
id
,
...
@@ -172,6 +184,7 @@ const RepoHelper = {
...
@@ -172,6 +184,7 @@ const RepoHelper = {
files
:
[],
files
:
[],
loading
:
false
,
loading
:
false
,
opened
,
opened
,
active
,
// eslint-disable-next-line camelcase
// eslint-disable-next-line camelcase
lastCommit
:
last_commit
?
{
lastCommit
:
last_commit
?
{
url
:
`
${
Store
.
projectUrl
}
/commit/
${
last_commit
.
id
}
`
,
url
:
`
${
Store
.
projectUrl
}
/commit/
${
last_commit
.
id
}
`
,
...
@@ -215,7 +228,7 @@ const RepoHelper = {
...
@@ -215,7 +228,7 @@ const RepoHelper = {
},
},
findOpenedFileFromActive
()
{
findOpenedFileFromActive
()
{
return
Store
.
openedFiles
.
find
(
openedFile
=>
Store
.
activeFile
.
url
===
openedFile
.
url
);
return
Store
.
openedFiles
.
find
(
openedFile
=>
Store
.
activeFile
.
id
===
openedFile
.
id
);
},
},
getFileFromPath
(
path
)
{
getFileFromPath
(
path
)
{
...
@@ -232,11 +245,13 @@ const RepoHelper = {
...
@@ -232,11 +245,13 @@ const RepoHelper = {
if
(
!
foundEntry
)
{
if
(
!
foundEntry
)
{
foundEntry
=
RepoHelper
.
serializeRepoEntity
(
type
,
{
foundEntry
=
RepoHelper
.
serializeRepoEntity
(
type
,
{
id
:
name
,
name
,
name
,
path
:
tree
.
path
?
`
${
tree
.
path
}
/
${
name
}
`
:
name
,
path
:
tree
.
path
?
`
${
tree
.
path
}
/
${
name
}
`
:
name
,
icon
:
type
===
'
tree
'
?
'
folder
'
:
'
file-text-o
'
,
icon
:
type
===
'
tree
'
?
'
folder
'
:
'
file-text-o
'
,
tempFile
:
true
,
tempFile
:
true
,
opened
:
true
,
opened
:
true
,
active
:
true
,
},
tree
.
level
!==
undefined
?
tree
.
level
+
1
:
0
);
},
tree
.
level
!==
undefined
?
tree
.
level
+
1
:
0
);
exists
=
false
;
exists
=
false
;
...
@@ -248,6 +263,11 @@ const RepoHelper = {
...
@@ -248,6 +263,11 @@ const RepoHelper = {
exists
,
exists
,
};
};
},
},
removeAllTmpFiles
()
{
Store
.
openedFiles
=
Store
.
openedFiles
.
filter
(
f
=>
!
f
.
tempFile
);
Store
.
files
=
Store
.
files
.
filter
(
f
=>
!
f
.
tempFile
);
},
};
};
export
default
RepoHelper
;
export
default
RepoHelper
;
app/assets/javascripts/repo/stores/repo_store.js
View file @
60ce5155
...
@@ -76,7 +76,7 @@ const RepoStore = {
...
@@ -76,7 +76,7 @@ const RepoStore = {
RepoStore
.
blobRaw
=
file
.
base64
;
RepoStore
.
blobRaw
=
file
.
base64
;
}
else
if
(
file
.
newContent
||
file
.
plain
)
{
}
else
if
(
file
.
newContent
||
file
.
plain
)
{
RepoStore
.
blobRaw
=
file
.
newContent
||
file
.
plain
;
RepoStore
.
blobRaw
=
file
.
newContent
||
file
.
plain
;
}
else
if
(
!
file
.
tempFile
)
{
}
else
{
Service
.
getRaw
(
file
)
Service
.
getRaw
(
file
)
.
then
((
rawResponse
)
=>
{
.
then
((
rawResponse
)
=>
{
RepoStore
.
blobRaw
=
rawResponse
.
data
;
RepoStore
.
blobRaw
=
rawResponse
.
data
;
...
@@ -84,14 +84,16 @@ const RepoStore = {
...
@@ -84,14 +84,16 @@ const RepoStore = {
}).
catch
(
Helper
.
loadingError
);
}).
catch
(
Helper
.
loadingError
);
}
}
if
(
!
file
.
loading
)
Helper
.
updateHistoryEntry
(
file
.
url
,
file
.
pageTitle
||
file
.
name
);
if
(
!
file
.
loading
&&
!
file
.
tempFile
)
{
Helper
.
updateHistoryEntry
(
file
.
url
,
file
.
pageTitle
||
file
.
name
);
}
RepoStore
.
binary
=
file
.
binary
;
RepoStore
.
binary
=
file
.
binary
;
RepoStore
.
setActiveLine
(
-
1
);
RepoStore
.
setActiveLine
(
-
1
);
},
},
setFileActivity
(
file
,
openedFile
,
i
)
{
setFileActivity
(
file
,
openedFile
,
i
)
{
const
activeFile
=
openedFile
;
const
activeFile
=
openedFile
;
activeFile
.
active
=
file
.
url
===
activeFile
.
url
;
activeFile
.
active
=
file
.
id
===
activeFile
.
id
;
if
(
activeFile
.
active
)
RepoStore
.
setActiveFile
(
activeFile
,
i
);
if
(
activeFile
.
active
)
RepoStore
.
setActiveFile
(
activeFile
,
i
);
...
@@ -99,7 +101,7 @@ const RepoStore = {
...
@@ -99,7 +101,7 @@ const RepoStore = {
},
},
setActiveFile
(
activeFile
,
i
)
{
setActiveFile
(
activeFile
,
i
)
{
RepoStore
.
activeFile
=
Object
.
assign
({},
RepoStore
.
activeFile
,
activeFile
);
RepoStore
.
activeFile
=
Object
.
assign
({},
Helper
.
getDefaultActiveFile
()
,
activeFile
);
RepoStore
.
activeFileIndex
=
i
;
RepoStore
.
activeFileIndex
=
i
;
},
},
...
@@ -175,7 +177,7 @@ const RepoStore = {
...
@@ -175,7 +177,7 @@ const RepoStore = {
// getters
// getters
isActiveFile
(
file
)
{
isActiveFile
(
file
)
{
return
file
&&
file
.
url
===
RepoStore
.
activeFile
.
url
;
return
file
&&
file
.
id
===
RepoStore
.
activeFile
.
id
;
},
},
isPreviewView
()
{
isPreviewView
()
{
...
@@ -183,4 +185,6 @@ const RepoStore = {
...
@@ -183,4 +185,6 @@ const RepoStore = {
},
},
};
};
window
.
RepoStore
=
RepoStore
;
export
default
RepoStore
;
export
default
RepoStore
;
app/controllers/projects/blob_controller.rb
View file @
60ce5155
...
@@ -205,6 +205,7 @@ class Projects::BlobController < Projects::ApplicationController
...
@@ -205,6 +205,7 @@ class Projects::BlobController < Projects::ApplicationController
tree_path
=
path_segments
.
join
(
'/'
)
tree_path
=
path_segments
.
join
(
'/'
)
render
json:
json
.
merge
(
render
json:
json
.
merge
(
id:
@blob
.
id
,
path:
blob
.
path
,
path:
blob
.
path
,
name:
blob
.
name
,
name:
blob
.
name
,
extension:
blob
.
extension
,
extension:
blob
.
extension
,
...
...
spec/javascripts/repo/components/repo_file_buttons_spec.js
View file @
60ce5155
...
@@ -2,7 +2,7 @@ import Vue from 'vue';
...
@@ -2,7 +2,7 @@ import Vue from 'vue';
import
repoFileButtons
from
'
~/repo/components/repo_file_buttons.vue
'
;
import
repoFileButtons
from
'
~/repo/components/repo_file_buttons.vue
'
;
import
RepoStore
from
'
~/repo/stores/repo_store
'
;
import
RepoStore
from
'
~/repo/stores/repo_store
'
;
f
describe
(
'
RepoFileButtons
'
,
()
=>
{
describe
(
'
RepoFileButtons
'
,
()
=>
{
const
activeFile
=
{
const
activeFile
=
{
extension
:
'
md
'
,
extension
:
'
md
'
,
url
:
'
url
'
,
url
:
'
url
'
,
...
...
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