Commit c0e3b397 authored by Sato Hiroyuki's avatar Sato Hiroyuki

Set @options in assing_ref_vars

@options enable to keep params when switching ref.
parent 97a9c229
......@@ -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|
......
......@@ -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
......
......@@ -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"
......@@ -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}'
......
......@@ -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
......@@ -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!
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment