summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2015-07-29 11:12:08 +0200
committerStas Vilchik <vilchiks@gmail.com>2015-07-29 11:12:08 +0200
commitfafe1f53f4367a20278a995b9e02f064fd4c8c8b (patch)
tree5b218848080fbeb800fa4b6f11fac786fc12e1b0
parent0fb3e470ecfcc6637cb80145aaff9236d6989a79 (diff)
downloadsonarqube-fafe1f53f4367a20278a995b9e02f064fd4c8c8b.tar.gz
sonarqube-fafe1f53f4367a20278a995b9e02f064fd4c8c8b.zip
SONAR-6661 show update center in offline mode
-rw-r--r--server/sonar-web/src/main/js/apps/nav/templates/nav-settings-navbar.hbs19
-rw-r--r--server/sonar-web/src/main/js/apps/update-center/app.js4
-rw-r--r--server/sonar-web/src/main/js/apps/update-center/search-view.js8
-rw-r--r--server/sonar-web/src/main/js/apps/update-center/templates/update-center-search.hbs24
-rw-r--r--server/sonar-web/src/main/less/init/forms.less7
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb3
-rw-r--r--server/sonar-web/test/medium/base.html3
-rw-r--r--server/sonar-web/test/medium/update-center.spec.js21
8 files changed, 71 insertions, 18 deletions
diff --git a/server/sonar-web/src/main/js/apps/nav/templates/nav-settings-navbar.hbs b/server/sonar-web/src/main/js/apps/nav/templates/nav-settings-navbar.hbs
index 750d44830be..5b356b8bc10 100644
--- a/server/sonar-web/src/main/js/apps/nav/templates/nav-settings-navbar.hbs
+++ b/server/sonar-web/src/main/js/apps/nav/templates/nav-settings-navbar.hbs
@@ -1,8 +1,8 @@
<div class="container">
<ul class="nav navbar-nav nav-crumbs">
- <li>
- <a href="{{link '/settings'}}">{{t 'layout.settings'}}</a>
- </li>
+ <li>
+ <a href="{{link '/settings'}}">{{t 'layout.settings'}}</a>
+ </li>
</ul>
<ul class="nav navbar-nav nav-tabs">
@@ -72,11 +72,14 @@
{{t 'sidebar.system'}}&nbsp;<i class="icon-dropdown"></i>
</a>
<ul class="dropdown-menu">
- {{#if settings.showUpdateCenter}}
- <li>
- <a href="{{link '/updatecenter'}}">{{t 'update_center.page'}}</a>
- </li>
- {{/if}}
+ <li>
+ <a href="{{link '/updatecenter'}}">
+ {{t 'update_center.page'}}
+ {{#unless settings.showUpdateCenter}}
+ <span class="spacer-left badge badge-warning">offline</span>
+ {{/unless}}
+ </a>
+ </li>
<li>
<a href="{{link '/system'}}">{{t 'system_info.page'}}</a>
</li>
diff --git a/server/sonar-web/src/main/js/apps/update-center/app.js b/server/sonar-web/src/main/js/apps/update-center/app.js
index a88288a5e0b..a866a0c2879 100644
--- a/server/sonar-web/src/main/js/apps/update-center/app.js
+++ b/server/sonar-web/src/main/js/apps/update-center/app.js
@@ -12,7 +12,9 @@ define([
var App = new Marionette.Application(),
init = function (options) {
// State
- this.state = new Backbone.Model();
+ this.state = new Backbone.Model({
+ updateCenterActive: window.SS.updateCenterActive
+ });
// Layout
this.layout = new Layout({ el: options.el });
diff --git a/server/sonar-web/src/main/js/apps/update-center/search-view.js b/server/sonar-web/src/main/js/apps/update-center/search-view.js
index 552d2d331b7..b46cf5ce293 100644
--- a/server/sonar-web/src/main/js/apps/update-center/search-view.js
+++ b/server/sonar-web/src/main/js/apps/update-center/search-view.js
@@ -24,6 +24,14 @@ define([
this.listenTo(this.options.state, 'change', this.render);
},
+ onRender: function () {
+ this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
+ },
+
+ onDestroy: function () {
+ this.$('[data-toggle="tooltip"]').tooltip('destroy');
+ },
+
onFilterChange: function () {
var value = this.$('[name="update-center-filter"]:checked').val();
this.filter(value);
diff --git a/server/sonar-web/src/main/js/apps/update-center/templates/update-center-search.hbs b/server/sonar-web/src/main/js/apps/update-center/templates/update-center-search.hbs
index 2ab5f06fc6c..7b8e410b186 100644
--- a/server/sonar-web/src/main/js/apps/update-center/templates/update-center-search.hbs
+++ b/server/sonar-web/src/main/js/apps/update-center/templates/update-center-search.hbs
@@ -8,28 +8,38 @@
</li>
<li>
<input type="radio" name="update-center-filter" value="updates" id="update-center-filter-updates"
- {{#eq state.section 'updates'}}checked{{/eq}}>
- <label for="update-center-filter-updates">Updates Only</label>
+ {{#eq state.section 'updates'}}checked{{/eq}} {{#unless state.updateCenterActive}}disabled{{/unless}}>
+ <label for="update-center-filter-updates"
+ {{#unless state.updateCenterActive}}data-toggle="tooltip" title="Update Center is not activated."{{/unless}}>
+ Updates Only
+ </label>
</li>
<li>
<input type="radio" name="update-center-filter" value="available" id="update-center-filter-available"
- {{#eq state.section 'available'}}checked{{/eq}}>
- <label for="update-center-filter-available">Available</label>
+ {{#eq state.section 'available'}}checked{{/eq}} {{#unless state.updateCenterActive}}disabled{{/unless}}>
+ <label for="update-center-filter-available"
+ {{#unless state.updateCenterActive}}data-toggle="tooltip" title="Update Center is not activated."{{/unless}}>
+ Available
+ </label>
</li>
</ul>
<ul class="radio-toggle">
<li>
<input type="radio" name="update-center-filter" value="system" id="update-center-filter-system"
- {{#eq state.section 'system'}}checked{{/eq}}>
- <label for="update-center-filter-system">System Upgrades</label>
+ {{#eq state.section 'system'}}checked{{/eq}} {{#unless state.updateCenterActive}}disabled{{/unless}}>
+ <label for="update-center-filter-system"
+ {{#unless state.updateCenterActive}}data-toggle="tooltip" title="Update Center is not activated."{{/unless}}>
+ System Upgrades
+ </label>
</li>
</ul>
</div>
{{#notEq state.section 'system'}}
<form id="update-center-search-form" class="search-box display-inline-block text-top">
- <button id="update-center-search-submit" class="search-box-submit button-clean"><i class="icon-search"></i></button>
+ <button id="update-center-search-submit" class="search-box-submit button-clean"><i class="icon-search"></i>
+ </button>
<input id="update-center-search-query" class="search-box-input" type="search" name="q" placeholder="Search"
maxlength="100" autocomplete="off">
</form>
diff --git a/server/sonar-web/src/main/less/init/forms.less b/server/sonar-web/src/main/less/init/forms.less
index 83d3614415f..fc31428ed37 100644
--- a/server/sonar-web/src/main/less/init/forms.less
+++ b/server/sonar-web/src/main/less/init/forms.less
@@ -262,4 +262,11 @@ label[for] {
font-weight: 500;
}
+ input[type="radio"]:disabled + label {
+ color: #bbb;
+ border-color: #ddd;
+ background: #ebebeb;
+ cursor: not-allowed;
+ }
+
}
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb
index 322c7bcbbf8..07640076411 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb
@@ -32,7 +32,8 @@
lf: {
enableGravatar: <%= configuration('sonar.lf.enableGravatar', true) %>,
gravatarServerUrl: '<%= configuration('sonar.lf.gravatarServerUrl') %>'
- }
+ },
+ updateCenterActive: <%= configuration('sonar.updatecenter.activate', true) %>
};
</script>
<script src="<%= ApplicationController.root_context -%>/js/sonar.js?v=<%= sonar_version -%>"></script>
diff --git a/server/sonar-web/test/medium/base.html b/server/sonar-web/test/medium/base.html
index 4a241acad60..69dd16cfef4 100644
--- a/server/sonar-web/test/medium/base.html
+++ b/server/sonar-web/test/medium/base.html
@@ -61,7 +61,8 @@
lf: {
enableGravatar: false,
gravatarServerUrl: ''
- }
+ },
+ updateCenterActive: true
};
</script>
<script>requirejs.config({ baseUrl: baseUrl + '../../build/js' });</script>
diff --git a/server/sonar-web/test/medium/update-center.spec.js b/server/sonar-web/test/medium/update-center.spec.js
index bcb2d66b0f8..40277c7ebc3 100644
--- a/server/sonar-web/test/medium/update-center.spec.js
+++ b/server/sonar-web/test/medium/update-center.spec.js
@@ -89,6 +89,27 @@ define(function (require) {
.checkElementExist('li[data-id="abap"]');
});
+ bdd.it('should work offline', function () {
+ return this.remote
+ .open('')
+ .mockFromString('/api/l10n/index', '{}')
+ .mockFromFile('/api/plugins/installed', 'update-center-spec/installed.json')
+ .mockFromFile('/api/plugins/updates', 'update-center-spec/updates.json')
+ .mockFromFile('/api/plugins/pending', 'update-center-spec/pending.json')
+ .execute(function () {
+ window.SS.updateCenterActive = false;
+ })
+ .startApp('update-center', { urlRoot: '/test/medium/base.html' })
+ .checkElementExist('.js-plugin-name')
+ .checkElementCount('li[data-id]', 5)
+ .checkElementExist('li[data-id="scmgit"]')
+ .checkElementExist('li[data-id="javascript"]')
+ .checkElementNotExist('#update-center-filter-installed[disabled]')
+ .checkElementExist('#update-center-filter-updates[disabled]')
+ .checkElementExist('#update-center-filter-available[disabled]')
+ .checkElementExist('#update-center-filter-system[disabled]');
+ });
+
bdd.it('should switch between views', function () {
return this.remote
.open('#installed')