Commit c0e3b39792cb7ad479af66c07685eb37e654ccb6
1 parent
97a9c229
Exists in
master
and in
4 other branches
Set @options in assing_ref_vars
@options enable to keep params when switching ref.
Showing
6 changed files
with
14 additions
and
12 deletions
Show diff stats
app/controllers/graph_controller.rb
... | ... | @@ -8,14 +8,8 @@ class GraphController < ProjectResourceController |
8 | 8 | before_filter :require_non_empty_project |
9 | 9 | |
10 | 10 | def show |
11 | - if params.has_key?(:q) | |
12 | - if params[:q].blank? | |
13 | - redirect_to project_graph_path(@project, params[:id]) | |
14 | - return | |
15 | - end | |
16 | - | |
17 | - @q = params[:q] | |
18 | - @commit = @project.repository.commit(@q) || @commit | |
11 | + if @options[:q] | |
12 | + @commit = @project.repository.commit(@options[:q]) || @commit | |
19 | 13 | end |
20 | 14 | |
21 | 15 | respond_to do |format| | ... | ... |
app/controllers/refs_controller.rb
... | ... | @@ -14,7 +14,7 @@ class RefsController < ProjectResourceController |
14 | 14 | elsif params[:destination] == "blob" |
15 | 15 | project_blob_path(@project, (@id)) |
16 | 16 | elsif params[:destination] == "graph" |
17 | - project_graph_path(@project, @id) | |
17 | + project_graph_path(@project, @id, @options) | |
18 | 18 | else |
19 | 19 | project_commits_path(@project, @id) |
20 | 20 | end | ... | ... |
app/views/graph/_head.html.haml
... | ... | @@ -10,7 +10,9 @@ |
10 | 10 | .control-group |
11 | 11 | = label_tag :search , "Looking for commit:", class: 'control-label light' |
12 | 12 | .controls |
13 | - = text_field_tag :q, @q, placeholder: "Input SHA", class: "search-input xlarge" | |
13 | + = text_field_tag :q, @options[:q], placeholder: "Input SHA", class: "search-input xlarge" | |
14 | 14 | = button_tag type: 'submit', class: 'btn vtop' do |
15 | 15 | %i.icon-search |
16 | + - @options.each do |key, value| | |
17 | + = hidden_field_tag(key, value, id: nil) unless key == "q" | |
16 | 18 | ... | ... |
app/views/graph/show.html.haml
... | ... | @@ -7,9 +7,8 @@ |
7 | 7 | |
8 | 8 | :javascript |
9 | 9 | var branch_graph; |
10 | - | |
11 | 10 | branch_graph = new BranchGraph($("#holder"), { |
12 | - url: '#{project_graph_path(@project, @ref, q: @q, format: :json)}', | |
11 | + url: '#{project_graph_path(@project, @ref, @options.merge(format: :json))}', | |
13 | 12 | commit_url: '#{project_commit_path(@project, 'ae45ca32').gsub("ae45ca32", "%s")}', |
14 | 13 | ref: '#{@ref}', |
15 | 14 | commit_id: '#{@commit.id}' | ... | ... |
app/views/shared/_ref_switcher.html.haml
lib/extracts_path.rb
... | ... | @@ -106,6 +106,11 @@ module ExtractsPath |
106 | 106 | @hex_path = Digest::SHA1.hexdigest(@path) |
107 | 107 | @logs_path = logs_file_project_ref_path(@project, @ref, @path) |
108 | 108 | |
109 | + # assign allowed options | |
110 | + allowed_options = ["filter_ref", "q"] | |
111 | + @options = params.select {|key, value| allowed_options.include?(key) && !value.blank? } | |
112 | + @options = HashWithIndifferentAccess.new(@options) | |
113 | + | |
109 | 114 | raise InvalidPathError unless @tree.exists? |
110 | 115 | rescue RuntimeError, NoMethodError, InvalidPathError |
111 | 116 | not_found! | ... | ... |