Commit 8ff5cf9cd5193b7135f53de3b62dd50bcbbfc2dc
1 parent
81cc1cb8
Exists in
master
and in
4 other branches
Add search box for the commit.
Showing
3 changed files
with
22 additions
and
6 deletions
Show diff stats
app/controllers/graph_controller.rb
... | ... | @@ -7,6 +7,16 @@ class GraphController < ProjectResourceController |
7 | 7 | before_filter :require_non_empty_project |
8 | 8 | |
9 | 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 | 20 | respond_to do |format| |
11 | 21 | format.html |
12 | 22 | format.json do | ... | ... |
... | ... | @@ -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 | 2 | .graph_holder |
6 | 3 | %h4 |
7 | 4 | %small You can move around the graph by using the arrow keys. |
... | ... | @@ -12,9 +9,9 @@ |
12 | 9 | var branch_graph; |
13 | 10 | $(function(){ |
14 | 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 | 13 | commit_url: '#{project_commit_path(@project, 'ae45ca32').gsub("ae45ca32", "%s")}', |
17 | 14 | ref: '#{@ref}', |
18 | - commit_id: '#{@commit && @commit.id}' | |
15 | + commit_id: '#{@commit.id}' | |
19 | 16 | }); |
20 | 17 | }); | ... | ... |