Skip to content

Commit

Permalink
Move snippets to own tab as feature. Make it disabled for new project…
Browse files Browse the repository at this point in the history
…s by default
  • Loading branch information
dzaporozhets committed Mar 18, 2013
1 parent 112dc87 commit b765a79
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/contexts/projects/create_context.rb
Expand Up @@ -32,8 +32,9 @@ def execute
@project.namespace_id = current_user.namespace_id @project.namespace_id = current_user.namespace_id
end end


# Disable wall by default # Disable less important features by default
@project.wall_enabled = false @project.wall_enabled = false
@project.snippets_enabled = false


@project.creator = current_user @project.creator = current_user


Expand Down
5 changes: 5 additions & 0 deletions app/controllers/snippets_controller.rb
@@ -1,4 +1,5 @@
class SnippetsController < ProjectResourceController class SnippetsController < ProjectResourceController
before_filter :module_enabled
before_filter :snippet, only: [:show, :edit, :destroy, :update, :raw] before_filter :snippet, only: [:show, :edit, :destroy, :update, :raw]


# Allow read any snippet # Allow read any snippet
Expand Down Expand Up @@ -84,4 +85,8 @@ def authorize_modify_snippet!
def authorize_admin_snippet! def authorize_admin_snippet!
return render_404 unless can?(current_user, :admin_snippet, @snippet) return render_404 unless can?(current_user, :admin_snippet, @snippet)
end end

def module_enabled
return render_404 unless @project.snippet_enabled
end
end end
2 changes: 1 addition & 1 deletion app/models/project.rb
Expand Up @@ -29,7 +29,7 @@ class Project < ActiveRecord::Base
class TransferError < StandardError; end class TransferError < StandardError; end


attr_accessible :name, :path, :description, :default_branch, :issues_tracker, 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] :wiki_enabled, :public, :import_url, as: [:default, :admin]


attr_accessible :namespace_id, :creator_id, as: :admin attr_accessible :namespace_id, :creator_id, as: :admin
Expand Down
4 changes: 4 additions & 0 deletions app/views/layouts/project_resource.html.haml
Expand Up @@ -43,6 +43,10 @@
= nav_link(path: 'projects#wall') do = nav_link(path: 'projects#wall') do
= link_to 'Wall', wall_project_path(@project) = 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 - if can? current_user, :admin_project, @project
= nav_link(html_options: {class: "#{project_tab_class}"}) do = nav_link(html_options: {class: "#{project_tab_class}"}) do
= link_to edit_project_path(@project), class: "stat-tab tab " do = link_to edit_project_path(@project), class: "stat-tab tab " do
Expand Down
6 changes: 6 additions & 0 deletions app/views/projects/_form.html.haml
Expand Up @@ -87,6 +87,12 @@
= f.check_box :wall_enabled = f.check_box :wall_enabled
%span.descr Simple chat system for broadcasting inside project %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 .control-group
= f.label :wiki_enabled, "Wiki", class: 'control-label' = f.label :wiki_enabled, "Wiki", class: 'control-label'
.controls .controls
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20130318212250_add_snippets_to_features.rb
@@ -0,0 +1,5 @@
class AddSnippetsToFeatures < ActiveRecord::Migration
def change
add_column :projects, :snippets_enabled, :boolean, null: false, default: true
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Expand Up @@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # 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| create_table "events", :force => true do |t|
t.string "target_type" t.string "target_type"
Expand Down Expand Up @@ -155,6 +155,7 @@
t.boolean "public", :default => false, :null => false t.boolean "public", :default => false, :null => false
t.string "issues_tracker", :default => "gitlab", :null => false t.string "issues_tracker", :default => "gitlab", :null => false
t.string "issues_tracker_id" t.string "issues_tracker_id"
t.boolean "snippets_enabled", :default => true, :null => false
end end


add_index "projects", ["creator_id"], :name => "index_projects_on_owner_id" add_index "projects", ["creator_id"], :name => "index_projects_on_owner_id"
Expand Down

0 comments on commit b765a79

Please sign in to comment.