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
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
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
9 deletions
+26
-9
application_controller.rb
app/controllers/application_controller.rb
+4
-0
edit_tree_controller.rb
app/controllers/projects/edit_tree_controller.rb
+19
-6
_diffs.html.haml
app/views/projects/commits/_diffs.html.haml
+1
-1
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
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
)
}
end
def
hexdigest
(
string
)
Digest
::
SHA1
.
hexdigest
string
end
end
app/controllers/projects/edit_tree_controller.rb
View file @
6c1af645
...
...
@@ -2,6 +2,8 @@ class Projects::EditTreeController < Projects::BaseTreeController
before_filter
:require_branch_head
before_filter
:blob
before_filter
:authorize_push!
before_filter
:from_merge_request
before_filter
:after_edit_path
def
show
@last_commit
=
Gitlab
::
Git
::
Commit
.
last_for_path
(
@repository
,
@ref
,
@path
).
sha
...
...
@@ -13,15 +15,11 @@ class Projects::EditTreeController < Projects::BaseTreeController
if
result
[
:status
]
==
:success
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
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
redirect_to
after_edit_path
else
flash
[
:alert
]
=
result
[
:error
]
render
:show
...
...
@@ -33,4 +31,19 @@ class Projects::EditTreeController < Projects::BaseTreeController
def
blob
@blob
||=
@repository
.
blob_at
(
@commit
.
id
,
@path
)
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
app/views/projects/commits/_diffs.html.haml
View file @
6c1af645
...
...
@@ -45,7 +45,7 @@
-
file
=
project
.
repository
.
blob_at
(
@commit
.
parent_id
,
diff
.
old_path
)
unless
file
-
next
unless
file
.diff-file
{
id:
"diff-#{i}"
}
.diff-header
.diff-header
{
id:
"file-path-#{hexdigest(diff.new_path || diff.old_path)}"
}
-
if
diff
.
deleted_file
%span
=
diff
.
old_path
...
...
app/views/projects/edit_tree/show.html.haml
View file @
6c1af645
...
...
@@ -11,7 +11,7 @@
%strong
=
@ref
%span
.options
.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
%pre
#editor
=
@blob
.
data
...
...
@@ -29,7 +29,7 @@
.message
to branch
%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
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