summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSato Hiroyuki <sathiroyuki@gmail.com>2013-04-14 12:09:47 +0000
committerSato Hiroyuki <sathiroyuki@gmail.com>2013-05-13 18:44:33 +0900
commitc0e3b39792cb7ad479af66c07685eb37e654ccb6 (patch)
treec574680995d385213205c63e8f8e6fb44e38b574
parent97a9c2293affaeeba6f448b8760bb5dffd170f2c (diff)
downloadgitlab-ce-c0e3b39792cb7ad479af66c07685eb37e654ccb6.tar.gz
Set @options in assing_ref_vars
@options enable to keep params when switching ref.
-rw-r--r--app/controllers/graph_controller.rb10
-rw-r--r--app/controllers/refs_controller.rb2
-rw-r--r--app/views/graph/_head.html.haml4
-rw-r--r--app/views/graph/show.html.haml3
-rw-r--r--app/views/shared/_ref_switcher.html.haml2
-rw-r--r--lib/extracts_path.rb5
6 files changed, 14 insertions, 12 deletions
diff --git a/app/controllers/graph_controller.rb b/app/controllers/graph_controller.rb
index b4bf9565112..22544ad82aa 100644
--- a/app/controllers/graph_controller.rb
+++ b/app/controllers/graph_controller.rb
@@ -8,14 +8,8 @@ class GraphController < ProjectResourceController
before_filter :require_non_empty_project
def show
- if params.has_key?(:q)
- if params[:q].blank?
- redirect_to project_graph_path(@project, params[:id])
- return
- end
-
- @q = params[:q]
- @commit = @project.repository.commit(@q) || @commit
+ if @options[:q]
+ @commit = @project.repository.commit(@options[:q]) || @commit
end
respond_to do |format|
diff --git a/app/controllers/refs_controller.rb b/app/controllers/refs_controller.rb
index 69756bb8ecd..e7def3984f8 100644
--- a/app/controllers/refs_controller.rb
+++ b/app/controllers/refs_controller.rb
@@ -14,7 +14,7 @@ class RefsController < ProjectResourceController
elsif params[:destination] == "blob"
project_blob_path(@project, (@id))
elsif params[:destination] == "graph"
- project_graph_path(@project, @id)
+ project_graph_path(@project, @id, @options)
else
project_commits_path(@project, @id)
end
diff --git a/app/views/graph/_head.html.haml b/app/views/graph/_head.html.haml
index 04a66892584..e6be40aec9c 100644
--- a/app/views/graph/_head.html.haml
+++ b/app/views/graph/_head.html.haml
@@ -10,7 +10,9 @@
.control-group
= label_tag :search , "Looking for commit:", class: 'control-label light'
.controls
- = text_field_tag :q, @q, placeholder: "Input SHA", class: "search-input xlarge"
+ = text_field_tag :q, @options[:q], placeholder: "Input SHA", class: "search-input xlarge"
= button_tag type: 'submit', class: 'btn vtop' do
%i.icon-search
+ - @options.each do |key, value|
+ = hidden_field_tag(key, value, id: nil) unless key == "q"
diff --git a/app/views/graph/show.html.haml b/app/views/graph/show.html.haml
index 682d2798906..f361b8b2ea8 100644
--- a/app/views/graph/show.html.haml
+++ b/app/views/graph/show.html.haml
@@ -7,9 +7,8 @@
:javascript
var branch_graph;
-
branch_graph = new BranchGraph($("#holder"), {
- url: '#{project_graph_path(@project, @ref, q: @q, format: :json)}',
+ url: '#{project_graph_path(@project, @ref, @options.merge(format: :json))}',
commit_url: '#{project_commit_path(@project, 'ae45ca32').gsub("ae45ca32", "%s")}',
ref: '#{@ref}',
commit_id: '#{@commit.id}'
diff --git a/app/views/shared/_ref_switcher.html.haml b/app/views/shared/_ref_switcher.html.haml
index 8b44cf1944e..dc8c656e12e 100644
--- a/app/views/shared/_ref_switcher.html.haml
+++ b/app/views/shared/_ref_switcher.html.haml
@@ -3,3 +3,5 @@
= hidden_field_tag :destination, destination
- if defined?(path)
= hidden_field_tag :path, path
+ - @options && @options.each do |key, value|
+ = hidden_field_tag key, value, id: nil
diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb
index 6025bb2a9f6..a81c80cfc6f 100644
--- a/lib/extracts_path.rb
+++ b/lib/extracts_path.rb
@@ -106,6 +106,11 @@ module ExtractsPath
@hex_path = Digest::SHA1.hexdigest(@path)
@logs_path = logs_file_project_ref_path(@project, @ref, @path)
+ # assign allowed options
+ allowed_options = ["filter_ref", "q"]
+ @options = params.select {|key, value| allowed_options.include?(key) && !value.blank? }
+ @options = HashWithIndifferentAccess.new(@options)
+
raise InvalidPathError unless @tree.exists?
rescue RuntimeError, NoMethodError, InvalidPathError
not_found!