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
Léo-Paul Géneau
gitlab-ce
Commits
6c1af645
Commit
6c1af645
authored
Feb 26, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'improve/edit_cancel' into 'master'
Better redirect for edit blobs from MergeRequest
parents
5d6e4bd2
a9280de1
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
9 deletions
+26
-9
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+4
-0
app/controllers/projects/edit_tree_controller.rb
app/controllers/projects/edit_tree_controller.rb
+19
-6
app/views/projects/commits/_diffs.html.haml
app/views/projects/commits/_diffs.html.haml
+1
-1
app/views/projects/edit_tree/show.html.haml
app/views/projects/edit_tree/show.html.haml
+2
-2
No files found.
app/controllers/application_controller.rb
View file @
6c1af645
...
@@ -210,4 +210,8 @@ class ApplicationController < ActionController::Base
...
@@ -210,4 +210,8 @@ class ApplicationController < ActionController::Base
devise_parameter_sanitizer
.
for
(
:sign_in
)
{
|
u
|
u
.
permit
(
:username
,
:email
,
:password
,
:login
,
:remember_me
)
}
devise_parameter_sanitizer
.
for
(
:sign_in
)
{
|
u
|
u
.
permit
(
:username
,
:email
,
:password
,
:login
,
:remember_me
)
}
devise_parameter_sanitizer
.
for
(
:sign_up
)
{
|
u
|
u
.
permit
(
:username
,
:email
,
:name
,
:password
,
:password_confirmation
)
}
devise_parameter_sanitizer
.
for
(
:sign_up
)
{
|
u
|
u
.
permit
(
:username
,
:email
,
:name
,
:password
,
:password_confirmation
)
}
end
end
def
hexdigest
(
string
)
Digest
::
SHA1
.
hexdigest
string
end
end
end
app/controllers/projects/edit_tree_controller.rb
View file @
6c1af645
...
@@ -2,6 +2,8 @@ class Projects::EditTreeController < Projects::BaseTreeController
...
@@ -2,6 +2,8 @@ class Projects::EditTreeController < Projects::BaseTreeController
before_filter
:require_branch_head
before_filter
:require_branch_head
before_filter
:blob
before_filter
:blob
before_filter
:authorize_push!
before_filter
:authorize_push!
before_filter
:from_merge_request
before_filter
:after_edit_path
def
show
def
show
@last_commit
=
Gitlab
::
Git
::
Commit
.
last_for_path
(
@repository
,
@ref
,
@path
).
sha
@last_commit
=
Gitlab
::
Git
::
Commit
.
last_for_path
(
@repository
,
@ref
,
@path
).
sha
...
@@ -13,15 +15,11 @@ class Projects::EditTreeController < Projects::BaseTreeController
...
@@ -13,15 +15,11 @@ class Projects::EditTreeController < Projects::BaseTreeController
if
result
[
:status
]
==
:success
if
result
[
:status
]
==
:success
flash
[
:notice
]
=
"Your changes have been successfully committed"
flash
[
:notice
]
=
"Your changes have been successfully committed"
# If blob edit was initiated from merge request page
from_merge_request
=
MergeRequest
.
find_by
(
id:
params
[
:from_merge_request_id
])
if
from_merge_request
if
from_merge_request
from_merge_request
.
reload_code
from_merge_request
.
reload_code
redirect_to
diffs_project_merge_request_path
(
from_merge_request
.
target_project
,
from_merge_request
)
else
redirect_to
project_blob_path
(
@project
,
@id
)
end
end
redirect_to
after_edit_path
else
else
flash
[
:alert
]
=
result
[
:error
]
flash
[
:alert
]
=
result
[
:error
]
render
:show
render
:show
...
@@ -33,4 +31,19 @@ class Projects::EditTreeController < Projects::BaseTreeController
...
@@ -33,4 +31,19 @@ class Projects::EditTreeController < Projects::BaseTreeController
def
blob
def
blob
@blob
||=
@repository
.
blob_at
(
@commit
.
id
,
@path
)
@blob
||=
@repository
.
blob_at
(
@commit
.
id
,
@path
)
end
end
def
after_edit_path
@after_edit_path
||=
if
from_merge_request
diffs_project_merge_request_path
(
from_merge_request
.
target_project
,
from_merge_request
)
+
"#file-path-
#{
hexdigest
(
@path
)
}
"
else
project_blob_path
(
@project
,
@id
)
end
end
def
from_merge_request
# If blob edit was initiated from merge request page
@from_merge_request
||=
MergeRequest
.
find_by
(
id:
params
[
:from_merge_request_id
])
end
end
end
app/views/projects/commits/_diffs.html.haml
View file @
6c1af645
...
@@ -45,7 +45,7 @@
...
@@ -45,7 +45,7 @@
-
file
=
project
.
repository
.
blob_at
(
@commit
.
parent_id
,
diff
.
old_path
)
unless
file
-
file
=
project
.
repository
.
blob_at
(
@commit
.
parent_id
,
diff
.
old_path
)
unless
file
-
next
unless
file
-
next
unless
file
.diff-file
{
id:
"diff-#{i}"
}
.diff-file
{
id:
"diff-#{i}"
}
.diff-header
.diff-header
{
id:
"file-path-#{hexdigest(diff.new_path || diff.old_path)}"
}
-
if
diff
.
deleted_file
-
if
diff
.
deleted_file
%span
=
diff
.
old_path
%span
=
diff
.
old_path
...
...
app/views/projects/edit_tree/show.html.haml
View file @
6c1af645
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
%strong
=
@ref
%strong
=
@ref
%span
.options
%span
.options
.btn-group.tree-btn-group
.btn-group.tree-btn-group
=
link_to
"Cancel"
,
project_blob_path
(
@project
,
@id
)
,
class:
"btn btn-tiny btn-cancel"
,
data:
{
confirm:
leave_edit_message
}
=
link_to
"Cancel"
,
@after_edit_path
,
class:
"btn btn-tiny btn-cancel"
,
data:
{
confirm:
leave_edit_message
}
.file-content.code
.file-content.code
%pre
#editor
=
@blob
.
data
%pre
#editor
=
@blob
.
data
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
.message
.message
to branch
to branch
%strong
=
@ref
%strong
=
@ref
=
link_to
"Cancel"
,
project_blob_path
(
@project
,
@id
)
,
class:
"btn btn-cancel"
,
data:
{
confirm:
leave_edit_message
}
=
link_to
"Cancel"
,
@after_edit_path
,
class:
"btn btn-cancel"
,
data:
{
confirm:
leave_edit_message
}
:javascript
:javascript
ace
.
config
.
set
(
"
modePath
"
,
gon
.
relative_url_root
+
"
#{
Gitlab
::
Application
.
config
.
assets
.
prefix
}
/ace
"
)
ace
.
config
.
set
(
"
modePath
"
,
gon
.
relative_url_root
+
"
#{
Gitlab
::
Application
.
config
.
assets
.
prefix
}
/ace
"
)
...
...
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