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
Jérome Perrin
gitlab-ce
Commits
8056a77d
Commit
8056a77d
authored
May 23, 2018
by
Tim Zallmann
Committed by
Douwe Maan
May 23, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Web IDE doesn't work for branches with slashes"
parent
3a3f542d
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
40 additions
and
21 deletions
+40
-21
app/assets/javascripts/ide/ide_router.js
app/assets/javascripts/ide/ide_router.js
+12
-8
app/assets/javascripts/ide/stores/actions/file.js
app/assets/javascripts/ide/stores/actions/file.js
+3
-1
app/assets/javascripts/ide/stores/modules/commit/actions.js
app/assets/javascripts/ide/stores/modules/commit/actions.js
+11
-5
app/assets/javascripts/ide/stores/workers/files_decorator_worker.js
.../javascripts/ide/stores/workers/files_decorator_worker.js
+2
-2
app/helpers/blob_helper.rb
app/helpers/blob_helper.rb
+3
-2
app/views/projects/tree/_tree_header.html.haml
app/views/projects/tree/_tree_header.html.haml
+1
-1
spec/helpers/blob_helper_spec.rb
spec/helpers/blob_helper_spec.rb
+8
-2
No files found.
app/assets/javascripts/ide/ide_router.js
View file @
8056a77d
...
@@ -41,7 +41,7 @@ const router = new VueRouter({
...
@@ -41,7 +41,7 @@ const router = new VueRouter({
component
:
EmptyRouterComponent
,
component
:
EmptyRouterComponent
,
children
:
[
children
:
[
{
{
path
:
'
:targetmode(edit|tree|blob)/
:branch/
*
'
,
path
:
'
:targetmode(edit|tree|blob)/*
'
,
component
:
EmptyRouterComponent
,
component
:
EmptyRouterComponent
,
},
},
{
{
...
@@ -63,23 +63,27 @@ router.beforeEach((to, from, next) => {
...
@@ -63,23 +63,27 @@ router.beforeEach((to, from, next) => {
.
then
(()
=>
{
.
then
(()
=>
{
const
fullProjectId
=
`
${
to
.
params
.
namespace
}
/
${
to
.
params
.
project
}
`
;
const
fullProjectId
=
`
${
to
.
params
.
namespace
}
/
${
to
.
params
.
project
}
`
;
if
(
to
.
params
.
branch
)
{
const
baseSplit
=
to
.
params
[
0
].
split
(
'
/-/
'
);
store
.
dispatch
(
'
setCurrentBranchId
'
,
to
.
params
.
branch
);
const
branchId
=
baseSplit
[
0
].
slice
(
-
1
)
===
'
/
'
?
baseSplit
[
0
].
slice
(
0
,
-
1
)
:
baseSplit
[
0
];
if
(
branchId
)
{
const
basePath
=
baseSplit
.
length
>
1
?
baseSplit
[
1
]
:
''
;
store
.
dispatch
(
'
setCurrentBranchId
'
,
branchId
);
store
.
dispatch
(
'
getBranchData
'
,
{
store
.
dispatch
(
'
getBranchData
'
,
{
projectId
:
fullProjectId
,
projectId
:
fullProjectId
,
branchId
:
to
.
params
.
branch
,
branchId
,
});
});
store
store
.
dispatch
(
'
getFiles
'
,
{
.
dispatch
(
'
getFiles
'
,
{
projectId
:
fullProjectId
,
projectId
:
fullProjectId
,
branchId
:
to
.
params
.
branch
,
branchId
,
})
})
.
then
(()
=>
{
.
then
(()
=>
{
if
(
to
.
params
[
0
])
{
if
(
basePath
)
{
const
path
=
const
path
=
basePath
.
slice
(
-
1
)
===
'
/
'
?
basePath
.
slice
(
0
,
-
1
)
:
basePath
;
to
.
params
[
0
].
slice
(
-
1
)
===
'
/
'
?
to
.
params
[
0
].
slice
(
0
,
-
1
)
:
to
.
params
[
0
];
const
treeEntryKey
=
Object
.
keys
(
store
.
state
.
entries
).
find
(
const
treeEntryKey
=
Object
.
keys
(
store
.
state
.
entries
).
find
(
key
=>
key
===
path
&&
!
store
.
state
.
entries
[
key
].
pending
,
key
=>
key
===
path
&&
!
store
.
state
.
entries
[
key
].
pending
,
);
);
...
...
app/assets/javascripts/ide/stores/actions/file.js
View file @
8056a77d
...
@@ -63,7 +63,9 @@ export const getFileData = ({ state, commit, dispatch }, { path, makeFileActive
...
@@ -63,7 +63,9 @@ export const getFileData = ({ state, commit, dispatch }, { path, makeFileActive
const
file
=
state
.
entries
[
path
];
const
file
=
state
.
entries
[
path
];
commit
(
types
.
TOGGLE_LOADING
,
{
entry
:
file
});
commit
(
types
.
TOGGLE_LOADING
,
{
entry
:
file
});
return
service
return
service
.
getFileData
(
`
${
gon
.
relative_url_root
?
gon
.
relative_url_root
:
''
}${
file
.
url
}
`
)
.
getFileData
(
`
${
gon
.
relative_url_root
?
gon
.
relative_url_root
:
''
}${
file
.
url
.
replace
(
'
/-/
'
,
'
/
'
)}
`
,
)
.
then
(
res
=>
{
.
then
(
res
=>
{
const
pageTitle
=
decodeURI
(
normalizeHeaders
(
res
.
headers
)[
'
PAGE-TITLE
'
]);
const
pageTitle
=
decodeURI
(
normalizeHeaders
(
res
.
headers
)[
'
PAGE-TITLE
'
]);
setPageTitle
(
pageTitle
);
setPageTitle
(
pageTitle
);
...
...
app/assets/javascripts/ide/stores/modules/commit/actions.js
View file @
8056a77d
...
@@ -204,17 +204,23 @@ export const commitChanges = ({ commit, state, getters, dispatch, rootState, roo
...
@@ -204,17 +204,23 @@ export const commitChanges = ({ commit, state, getters, dispatch, rootState, roo
dispatch
(
'
updateViewer
'
,
'
editor
'
,
{
root
:
true
});
dispatch
(
'
updateViewer
'
,
'
editor
'
,
{
root
:
true
});
router
.
push
(
router
.
push
(
`/project/
${
rootState
.
currentProjectId
}
/blob/
${
getters
.
branchName
}
/
${
`/project/
${
rootState
.
currentProjectId
}
/blob/
${
getters
.
branchName
}
/
-/
${
rootGetters
.
activeFile
.
path
rootGetters
.
activeFile
.
path
}
`
,
}
`
,
);
);
}
}
})
})
.
then
(()
=>
dispatch
(
'
updateCommitAction
'
,
consts
.
COMMIT_TO_CURRENT_BRANCH
))
.
then
(()
=>
dispatch
(
'
updateCommitAction
'
,
consts
.
COMMIT_TO_CURRENT_BRANCH
))
.
then
(()
=>
dispatch
(
'
refreshLastCommitData
'
,
{
.
then
(()
=>
projectId
:
rootState
.
currentProjectId
,
dispatch
(
branchId
:
rootState
.
currentBranchId
,
'
refreshLastCommitData
'
,
},
{
root
:
true
}));
{
projectId
:
rootState
.
currentProjectId
,
branchId
:
rootState
.
currentBranchId
,
},
{
root
:
true
},
),
);
})
})
.
catch
(
err
=>
{
.
catch
(
err
=>
{
let
errMsg
=
__
(
'
Error committing changes. Please try again.
'
);
let
errMsg
=
__
(
'
Error committing changes. Please try again.
'
);
...
...
app/assets/javascripts/ide/stores/workers/files_decorator_worker.js
View file @
8056a77d
...
@@ -26,7 +26,7 @@ self.addEventListener('message', e => {
...
@@ -26,7 +26,7 @@ self.addEventListener('message', e => {
id
:
folderPath
,
id
:
folderPath
,
name
:
folderName
,
name
:
folderName
,
path
:
folderPath
,
path
:
folderPath
,
url
:
`/
${
projectId
}
/tree/
${
branchId
}
/
${
folderPath
}
/`
,
url
:
`/
${
projectId
}
/tree/
${
branchId
}
/
-/
${
folderPath
}
/`
,
type
:
'
tree
'
,
type
:
'
tree
'
,
parentTreeUrl
:
parentFolder
?
parentFolder
.
url
:
`/
${
projectId
}
/tree/
${
branchId
}
/`
,
parentTreeUrl
:
parentFolder
?
parentFolder
.
url
:
`/
${
projectId
}
/tree/
${
branchId
}
/`
,
tempFile
,
tempFile
,
...
@@ -64,7 +64,7 @@ self.addEventListener('message', e => {
...
@@ -64,7 +64,7 @@ self.addEventListener('message', e => {
id
:
path
,
id
:
path
,
name
:
blobName
,
name
:
blobName
,
path
,
path
,
url
:
`/
${
projectId
}
/blob/
${
branchId
}
/
${
path
}
`
,
url
:
`/
${
projectId
}
/blob/
${
branchId
}
/
-/
${
path
}
`
,
type
:
'
blob
'
,
type
:
'
blob
'
,
parentTreeUrl
:
fileFolder
?
fileFolder
.
url
:
`/
${
projectId
}
/blob/
${
branchId
}
`
,
parentTreeUrl
:
fileFolder
?
fileFolder
.
url
:
`/
${
projectId
}
/blob/
${
branchId
}
`
,
tempFile
,
tempFile
,
...
...
app/helpers/blob_helper.rb
View file @
8056a77d
...
@@ -17,7 +17,9 @@ module BlobHelper
...
@@ -17,7 +17,9 @@ module BlobHelper
end
end
def
ide_edit_path
(
project
=
@project
,
ref
=
@ref
,
path
=
@path
,
options
=
{})
def
ide_edit_path
(
project
=
@project
,
ref
=
@ref
,
path
=
@path
,
options
=
{})
"
#{
ide_path
}
/project
#{
url_for
([
project
,
"edit"
,
"blob"
,
id:
[
ref
,
path
],
script_name:
"/"
])
}
"
segments
=
[
ide_path
,
'project'
,
project
.
full_path
,
'edit'
,
ref
]
segments
.
concat
([
'-'
,
path
])
if
path
.
present?
File
.
join
(
segments
)
end
end
def
edit_blob_button
(
project
=
@project
,
ref
=
@ref
,
path
=
@path
,
options
=
{})
def
edit_blob_button
(
project
=
@project
,
ref
=
@ref
,
path
=
@path
,
options
=
{})
...
@@ -331,7 +333,6 @@ module BlobHelper
...
@@ -331,7 +333,6 @@ module BlobHelper
if
!
on_top_of_branch?
(
project
,
ref
)
if
!
on_top_of_branch?
(
project
,
ref
)
edit_disabled_button_tag
(
text
,
common_classes
)
edit_disabled_button_tag
(
text
,
common_classes
)
# This condition only applies to users who are logged in
# This condition only applies to users who are logged in
# Web IDE (Beta) requires the user to have this feature enabled
elsif
!
current_user
||
(
current_user
&&
can_modify_blob?
(
blob
,
project
,
ref
))
elsif
!
current_user
||
(
current_user
&&
can_modify_blob?
(
blob
,
project
,
ref
))
edit_link_tag
(
text
,
edit_path
,
common_classes
)
edit_link_tag
(
text
,
edit_path
,
common_classes
)
elsif
can?
(
current_user
,
:fork_project
,
project
)
&&
can?
(
current_user
,
:create_merge_request_in
,
project
)
elsif
can?
(
current_user
,
:fork_project
,
project
)
&&
can?
(
current_user
,
:create_merge_request_in
,
project
)
...
...
app/views/projects/tree/_tree_header.html.haml
View file @
8056a77d
...
@@ -82,7 +82,7 @@
...
@@ -82,7 +82,7 @@
-
if
can_collaborate
-
if
can_collaborate
=
succeed
" "
do
=
succeed
" "
do
=
link_to
ide_edit_path
(
@project
,
@
id
,
""
),
class:
'btn btn-default'
do
=
link_to
ide_edit_path
(
@project
,
@
ref
,
@path
),
class:
'btn btn-default'
do
=
_
(
'Web IDE'
)
=
_
(
'Web IDE'
)
=
render
'projects/buttons/download'
,
project:
@project
,
ref:
@ref
=
render
'projects/buttons/download'
,
project:
@project
,
ref:
@ref
spec/helpers/blob_helper_spec.rb
View file @
8056a77d
...
@@ -258,13 +258,19 @@ describe BlobHelper do
...
@@ -258,13 +258,19 @@ describe BlobHelper do
it
'returns full IDE path'
do
it
'returns full IDE path'
do
Rails
.
application
.
routes
.
default_url_options
[
:script_name
]
=
nil
Rails
.
application
.
routes
.
default_url_options
[
:script_name
]
=
nil
expect
(
helper
.
ide_edit_path
(
project
,
"master"
,
""
)).
to
eq
(
"/-/ide/project/
#{
project
.
namespace
.
path
}
/
#{
project
.
path
}
/edit/master/"
)
expect
(
helper
.
ide_edit_path
(
project
,
"master"
,
""
)).
to
eq
(
"/-/ide/project/
#{
project
.
namespace
.
path
}
/
#{
project
.
path
}
/edit/master"
)
end
it
'returns full IDE path with second -'
do
Rails
.
application
.
routes
.
default_url_options
[
:script_name
]
=
nil
expect
(
helper
.
ide_edit_path
(
project
,
"testing/slashes"
,
"readme.md"
)).
to
eq
(
"/-/ide/project/
#{
project
.
namespace
.
path
}
/
#{
project
.
path
}
/edit/testing/slashes/-/readme.md"
)
end
end
it
'returns IDE path without relative_url_root'
do
it
'returns IDE path without relative_url_root'
do
Rails
.
application
.
routes
.
default_url_options
[
:script_name
]
=
"/gitlab"
Rails
.
application
.
routes
.
default_url_options
[
:script_name
]
=
"/gitlab"
expect
(
helper
.
ide_edit_path
(
project
,
"master"
,
""
)).
to
eq
(
"/gitlab/-/ide/project/
#{
project
.
namespace
.
path
}
/
#{
project
.
path
}
/edit/master
/
"
)
expect
(
helper
.
ide_edit_path
(
project
,
"master"
,
""
)).
to
eq
(
"/gitlab/-/ide/project/
#{
project
.
namespace
.
path
}
/
#{
project
.
path
}
/edit/master"
)
end
end
end
end
end
end
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