Permalink
Browse files

Move snippets to own tab as feature. Make it disabled for new project…

…s by default
  • Loading branch information...
dzaporozhets committed Mar 18, 2013
1 parent 112dc87 commit b765a7958d5d8602d0f8cc3b23b07cfa4f304208
@@ -32,8 +32,9 @@ def execute
@project.namespace_id = current_user.namespace_id
end
- # Disable wall by default
+ # Disable less important features by default
@project.wall_enabled = false
+ @project.snippets_enabled = false
@project.creator = current_user
@@ -1,4 +1,5 @@
class SnippetsController < ProjectResourceController
+ before_filter :module_enabled
before_filter :snippet, only: [:show, :edit, :destroy, :update, :raw]
# Allow read any snippet
@@ -84,4 +85,8 @@ def authorize_modify_snippet!
def authorize_admin_snippet!
return render_404 unless can?(current_user, :admin_snippet, @snippet)
end
+
+ def module_enabled
+ return render_404 unless @project.snippet_enabled
+ end
end
View
@@ -29,7 +29,7 @@ class Project < ActiveRecord::Base
class TransferError < StandardError; end
attr_accessible :name, :path, :description, :default_branch, :issues_tracker,
- :issues_enabled, :wall_enabled, :merge_requests_enabled, :issues_tracker_id,
+ :issues_enabled, :wall_enabled, :merge_requests_enabled, :snippets_enabled, :issues_tracker_id,
:wiki_enabled, :public, :import_url, as: [:default, :admin]
attr_accessible :namespace_id, :creator_id, as: :admin
@@ -43,6 +43,10 @@
= nav_link(path: 'projects#wall') do
= link_to 'Wall', wall_project_path(@project)
+ - if @project.snippets_enabled
+ = nav_link(controller: :snippets) do
+ = link_to 'Snippets', project_snippets_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
@@ -87,6 +87,12 @@
= f.check_box :wall_enabled
%span.descr Simple chat system for broadcasting inside project
+ .control-group
+ = f.label :snippets_enabled, "Snippets", class: 'control-label'
+ .controls
+ = f.check_box :snippets_enabled
+ %span.descr Share code pastes with others out of git repository
+
.control-group
= f.label :wiki_enabled, "Wiki", class: 'control-label'
.controls
@@ -0,0 +1,5 @@
+class AddSnippetsToFeatures < ActiveRecord::Migration
+ def change
+ add_column :projects, :snippets_enabled, :boolean, null: false, default: true
+ end
+end
View
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20130315124931) do
+ActiveRecord::Schema.define(:version => 20130318212250) do
create_table "events", :force => true do |t|
t.string "target_type"
@@ -155,6 +155,7 @@
t.boolean "public", :default => false, :null => false
t.string "issues_tracker", :default => "gitlab", :null => false
t.string "issues_tracker_id"
+ t.boolean "snippets_enabled", :default => true, :null => false
end
add_index "projects", ["creator_id"], :name => "index_projects_on_owner_id"

0 comments on commit b765a79

Please sign in to comment.