From ae06a0aab8be3ea3bad8066d2e19c12d86b85ad8 Mon Sep 17 00:00:00 2001
From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Date: Mon, 18 Mar 2013 22:43:14 +0200
Subject: [PATCH] Return own tab for wall. Improve Wiki nav. Removed
 attachments listing page

---
 app/contexts/projects/create_context.rb      |  3 +++
 app/controllers/projects_controller.rb       |  4 ----
 app/helpers/tab_helper.rb                    | 10 ---------
 app/views/layouts/project_resource.html.haml | 10 +++++++--
 app/views/projects/files.html.haml           | 22 --------------------
 app/views/projects/wall.html.haml            |  1 -
 app/views/snippets/index.html.haml           |  1 -
 app/views/wikis/_main_links.html.haml        | 12 ++---------
 app/views/wikis/_nav.html.haml               | 19 +++++++----------
 app/views/wikis/edit.html.haml               |  1 +
 app/views/wikis/git_access.html.haml         |  1 +
 app/views/wikis/history.html.haml            |  3 ++-
 12 files changed, 25 insertions(+), 62 deletions(-)
 delete mode 100644 app/views/projects/files.html.haml

diff --git a/app/contexts/projects/create_context.rb b/app/contexts/projects/create_context.rb
index fe8dde8c954..da666a71f0d 100644
--- a/app/contexts/projects/create_context.rb
+++ b/app/contexts/projects/create_context.rb
@@ -32,6 +32,9 @@ module Projects
         @project.namespace_id = current_user.namespace_id
       end
 
+      # Disable wall by default
+      @project.wall_enabled = false
+
       @project.creator = current_user
 
       # Import project from cloneable resource
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index f703cf6bc1d..b4fb3de317c 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -68,10 +68,6 @@ class ProjectsController < ProjectResourceController
     end
   end
 
-  def files
-    @notes = @project.notes.where("attachment != 'NULL'").order("created_at DESC").limit(100)
-  end
-
   #
   # Wall
   #
diff --git a/app/helpers/tab_helper.rb b/app/helpers/tab_helper.rb
index 62a380eb730..d2be4b1a7e6 100644
--- a/app/helpers/tab_helper.rb
+++ b/app/helpers/tab_helper.rb
@@ -80,16 +80,6 @@ module TabHelper
     end
   end
 
-  def project_wiki_tab_class
-    [:files, :wall].each do |action|
-      return "active" if current_page?(controller: "projects", action: action, id: @project)
-    end
-
-    if ['wikis', 'snippets'].include? controller.controller_name
-     "active"
-    end
-  end
-
   def branches_tab_class
     if current_page?(branches_project_repository_path(@project)) ||
       current_controller?(:protected_branches) ||
diff --git a/app/views/layouts/project_resource.html.haml b/app/views/layouts/project_resource.html.haml
index dfbb6a0394e..3f7c4322d63 100644
--- a/app/views/layouts/project_resource.html.haml
+++ b/app/views/layouts/project_resource.html.haml
@@ -35,11 +35,17 @@
               Merge Requests
               %span.count.merge_counter= @project.merge_requests.opened.count
 
-        = nav_link(html_options: {class: "#{project_wiki_tab_class}"}) do
-          = link_to 'Wiki', project_wiki_path(@project, :home)
+        - if @project.wiki_enabled
+          = nav_link(controller: :wikis) do
+            = link_to 'Wiki', project_wiki_path(@project, :home)
+
+        - if @project.wall_enabled
+          = nav_link(path: 'projects#wall') do
+            = link_to 'Wall', wall_project_path(@project)
 
         - if can? current_user, :admin_project, @project
           = nav_link(html_options: {class: "#{project_tab_class}"}) do
             = link_to edit_project_path(@project), class: "stat-tab tab " do
               Settings
+
       .content= yield
diff --git a/app/views/projects/files.html.haml b/app/views/projects/files.html.haml
deleted file mode 100644
index 3402e067081..00000000000
--- a/app/views/projects/files.html.haml
+++ /dev/null
@@ -1,22 +0,0 @@
-= render 'wikis/nav'
-- unless @notes.empty?
-  %table
-    %thead
-      %tr
-        %th File name
-        %th
-
-    - @notes.each do |note|
-      %tr
-        %td
-          = link_to note.attachment.secure_url, target: "_blank" do
-            = image_tag gravatar_icon(note.author_email), class: "avatar s24"
-            = note.attachment_identifier
-        %td
-          Added
-          = time_ago_in_words(note.created_at)
-          ago
-- else
-  %p.slead All files attached to project wall, issues etc will be displayed here
-
-
diff --git a/app/views/projects/wall.html.haml b/app/views/projects/wall.html.haml
index 1c2d907fddc..82b565def43 100644
--- a/app/views/projects/wall.html.haml
+++ b/app/views/projects/wall.html.haml
@@ -1,3 +1,2 @@
-= render 'wikis/nav'
 %div.wall_page
   = render "notes/reversed_notes_with_form"
diff --git a/app/views/snippets/index.html.haml b/app/views/snippets/index.html.haml
index 5dd00be88d7..bacf23d8f8d 100644
--- a/app/views/snippets/index.html.haml
+++ b/app/views/snippets/index.html.haml
@@ -1,4 +1,3 @@
-= render 'wikis/nav'
 %h3.page_title
   Snippets
   %small share code pastes with others out of git repository
diff --git a/app/views/wikis/_main_links.html.haml b/app/views/wikis/_main_links.html.haml
index 262ed74681c..cb8ccf81c7b 100644
--- a/app/views/wikis/_main_links.html.haml
+++ b/app/views/wikis/_main_links.html.haml
@@ -1,16 +1,8 @@
 %span.pull-right
-  = link_to project_wiki_path(@project, :home), class: "btn btn-small grouped" do
-    Home
-  = link_to pages_project_wikis_path(@project), class: "btn btn-small grouped" do
-    Pages
   - if (@wiki && @wiki.persisted?)
     = link_to history_project_wiki_path(@project, @wiki), class: "btn btn-small grouped" do
-      History
-  - if can?(current_user, :write_wiki, @project)
-    - if @wiki && @wiki.persisted?
+      Page History
+    - if can?(current_user, :write_wiki, @project)
       = link_to edit_project_wiki_path(@project, @wiki), class: "btn btn-small grouped" do
         %i.icon-edit
         Edit
-    = link_to git_access_project_wikis_path(@project), class: "btn btn-small grouped" do
-      %i.icon-download-alt
-      Git Access
diff --git a/app/views/wikis/_nav.html.haml b/app/views/wikis/_nav.html.haml
index f4b0b1902b4..6a922e16d61 100644
--- a/app/views/wikis/_nav.html.haml
+++ b/app/views/wikis/_nav.html.haml
@@ -1,14 +1,11 @@
 %ul.nav.nav-tabs
-  - if @project.wiki_enabled
-    = nav_link(controller: 'wikis') do
-      = link_to 'Wiki', project_wiki_path(@project, :home)
+  = nav_link(html_options: {class: params[:id] == 'home' ? 'active' : '' }) do
+    = link_to 'Home', project_wiki_path(@project, :home)
 
-  - if @project.wall_enabled
-    = nav_link(path: 'projects#wall') do
-      = link_to 'Wall', wall_project_path(@project)
+  = nav_link(path: 'wikis#pages') do
+    = link_to 'Pages', pages_project_wikis_path(@project)
 
-  = nav_link(path: 'projects#files') do
-    = link_to 'Attachments', files_project_path(@project), class: "files-tab tab"
-
-  = nav_link(controller: :snippets) do
-    = link_to 'Snippets', project_snippets_path(@project), class: "snippets-tab tab"
+  = nav_link(path: 'wikis#git_access') do
+    = link_to git_access_project_wikis_path(@project) do
+      %i.icon-download-alt
+      Git Access
diff --git a/app/views/wikis/edit.html.haml b/app/views/wikis/edit.html.haml
index dd200a35522..7441ceff5c8 100644
--- a/app/views/wikis/edit.html.haml
+++ b/app/views/wikis/edit.html.haml
@@ -1,3 +1,4 @@
+= render 'wikis/nav'
 %h3.page_title
   Editing page
   = render partial: 'main_links'
diff --git a/app/views/wikis/git_access.html.haml b/app/views/wikis/git_access.html.haml
index 353d86f2d4d..58c8aa06aca 100644
--- a/app/views/wikis/git_access.html.haml
+++ b/app/views/wikis/git_access.html.haml
@@ -1,3 +1,4 @@
+= render 'wikis/nav'
 %h3.page_title
   Git Access
   %strong= @gollum_wiki.path_with_namespace
diff --git a/app/views/wikis/history.html.haml b/app/views/wikis/history.html.haml
index 609207106ab..599e9cf6793 100644
--- a/app/views/wikis/history.html.haml
+++ b/app/views/wikis/history.html.haml
@@ -1,5 +1,6 @@
+= render 'wikis/nav'
 %h3.page_title
-  %span.cgray History for
+  %span.light History for
   = @wiki.title.titleize
   = render partial: 'main_links'
 %br
-- 
GitLab