Skip to content

Commit

Permalink
Merge branch 'version-check' into 'master'
Browse files Browse the repository at this point in the history
Version check

See merge request !1509
  • Loading branch information
dzaporozhets committed May 13, 2015
2 parents cb8f974 + 0928c3a commit f32a045
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 10 deletions.
1 change: 1 addition & 0 deletions app/controllers/admin/application_settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def application_setting_params
:default_project_visibility,
:default_snippet_visibility,
:restricted_signup_domains_raw,
:version_check_enabled,
restricted_visibility_levels: [],
)
end
Expand Down
7 changes: 7 additions & 0 deletions app/helpers/version_check_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module VersionCheckHelper
def version_status_badge
if Rails.env.production?
image_tag VersionCheck.new.url
end
end
end
6 changes: 6 additions & 0 deletions app/views/admin/application_settings/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
= f.check_box :twitter_sharing_enabled, :'aria-describedby' => 'twitter_help_block'
%strong Twitter enabled
%span.help-block#twitter_help_block Show users a button to share their newly created public or internal projects on twitter
.form-group
.col-sm-offset-2.col-sm-10
.checkbox
= f.label :version_check_enabled do
= f.check_box :version_check_enabled
Version check enabled
%fieldset
%legend Misc
.form-group
Expand Down
7 changes: 6 additions & 1 deletion app/views/admin/dashboard/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@
%span.light.pull-right
= boolean_to_icon Gitlab.config.omniauth.enabled
.col-md-4
%h4 Components
%h4
Components
- if current_application_settings.version_check_enabled
.pull-right
= version_status_badge

%hr
%p
GitLab
Expand Down
2 changes: 2 additions & 0 deletions app/views/help/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
GitLab
%span= Gitlab::VERSION
%small= Gitlab::REVISION
- if current_application_settings.version_check_enabled
= version_status_badge
%p.slead
GitLab is open source software to collaborate on code.
%br
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddVersionCheckToApplicationSettings < ActiveRecord::Migration
def change
add_column :application_settings, :version_check_enabled, :boolean, default: true
end
end
1 change: 1 addition & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
t.integer "default_branch_protection", default: 2
t.boolean "twitter_sharing_enabled", default: true
t.text "restricted_visibility_levels"
t.boolean "version_check_enabled", default: true
t.integer "max_attachment_size", default: 10, null: false
t.integer "default_project_visibility"
t.integer "default_snippet_visibility"
Expand Down
18 changes: 18 additions & 0 deletions lib/version_check.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require "base64"

# This class is used to build image URL to
# check if it is a new version for update
class VersionCheck
def data
{ version: Gitlab::VERSION }
end

def url
encoded_data = Base64.urlsafe_encode64(data.to_json)
"#{host}?gitlab_info=#{encoded_data}"
end

def host
'https://version.gitlab.com/check.png'
end
end
9 changes: 0 additions & 9 deletions safe/public.pem

This file was deleted.

0 comments on commit f32a045

Please sign in to comment.