Commit 8ff5cf9cd5193b7135f53de3b62dd50bcbbfc2dc

Authored by Sato Hiroyuki
1 parent 81cc1cb8

Add search box for the commit.

app/controllers/graph_controller.rb
@@ -7,6 +7,16 @@ class GraphController < ProjectResourceController @@ -7,6 +7,16 @@ class GraphController < ProjectResourceController
7 before_filter :require_non_empty_project 7 before_filter :require_non_empty_project
8 8
9 def show 9 def show
  10 + if params.has_key?(:q) && params[:q].blank?
  11 + redirect_to project_graph_path(@project, params[:id])
  12 + return
  13 + end
  14 +
  15 + if params.has_key?(:q)
  16 + @q = params[:q]
  17 + @commit = @project.repository.commit(@q) || @commit
  18 + end
  19 +
10 respond_to do |format| 20 respond_to do |format|
11 format.html 21 format.html
12 format.json do 22 format.json do
app/views/graph/_head.html.haml 0 → 100644
@@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
  1 +%ul.nav.nav-tabs
  2 + %li
  3 + = render partial: 'shared/ref_switcher', locals: {destination: 'graph', path: @path}
  4 + %li.pull-right.search
  5 + = form_tag project_graph_path(@project, params[:id]), method: :get, class: 'navbar-form' do |f|
  6 + = label_tag :search , "Looking for commit:"
  7 + = text_field_tag :q, @q, placeholder: "Input SHA", class: "search-input"
  8 +
  9 +%h3.page_title Project Network Graph
app/views/graph/show.html.haml
1 -%h3.page_title Project Network Graph  
2 -%br  
3 -= render partial: 'shared/ref_switcher', locals: {destination: 'graph', path: @path}  
4 -%br 1 += render "head"
5 .graph_holder 2 .graph_holder
6 %h4 3 %h4
7 %small You can move around the graph by using the arrow keys. 4 %small You can move around the graph by using the arrow keys.
@@ -12,9 +9,9 @@ @@ -12,9 +9,9 @@
12 var branch_graph; 9 var branch_graph;
13 $(function(){ 10 $(function(){
14 branch_graph = new BranchGraph($("#holder"), { 11 branch_graph = new BranchGraph($("#holder"), {
15 - url: '#{project_graph_path(@project, @ref, format: :json)}', 12 + url: '#{project_graph_path(@project, @ref, q: @q, format: :json)}',
16 commit_url: '#{project_commit_path(@project, 'ae45ca32').gsub("ae45ca32", "%s")}', 13 commit_url: '#{project_commit_path(@project, 'ae45ca32').gsub("ae45ca32", "%s")}',
17 ref: '#{@ref}', 14 ref: '#{@ref}',
18 - commit_id: '#{@commit && @commit.id}' 15 + commit_id: '#{@commit.id}'
19 }); 16 });
20 }); 17 });