]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6661 show update center in offline mode
authorStas Vilchik <vilchiks@gmail.com>
Wed, 29 Jul 2015 09:12:08 +0000 (11:12 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Wed, 29 Jul 2015 09:12:08 +0000 (11:12 +0200)
server/sonar-web/src/main/js/apps/nav/templates/nav-settings-navbar.hbs
server/sonar-web/src/main/js/apps/update-center/app.js
server/sonar-web/src/main/js/apps/update-center/search-view.js
server/sonar-web/src/main/js/apps/update-center/templates/update-center-search.hbs
server/sonar-web/src/main/less/init/forms.less
server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb
server/sonar-web/test/medium/base.html
server/sonar-web/test/medium/update-center.spec.js

index 750d44830be824efe6f7763f8b13de5025c3335f..5b356b8bc10c766733eecda88eb7a8abab2f06ac 100644 (file)
@@ -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">
         {{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>
index a88288a5e0bc4c84faaa6f97a2c4fcfa56e40c66..a866a0c2879faa0d54a6bf6d1e6b48924d25db57 100644 (file)
@@ -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 });
index 552d2d331b7df5df8821e6868b7ac64e9e7d7ee0..b46cf5ce293853c0d641a403782b097ef0f6c401 100644 (file)
@@ -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);
index 2ab5f06fc6ca1c330e6edc96b19ec75cb45d1599..7b8e410b18649eef5b07a30393f06b50a5f6949d 100644 (file)
@@ -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>
index 83d3614415f1e017ebf75e6968a33dc653a4c839..fc31428ed377c230840917af78fd14e90b1011ec 100644 (file)
@@ -262,4 +262,11 @@ label[for] {
     font-weight: 500;
   }
 
+  input[type="radio"]:disabled + label {
+    color: #bbb;
+    border-color: #ddd;
+    background: #ebebeb;
+    cursor: not-allowed;
+  }
+
 }
index 322c7bcbbf879c3c78d7c510db1af80c6eec2c10..076400764116813e798f9d4e10d4da83d772f092 100644 (file)
@@ -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>
index 4a241acad6038bec87bcd803322c93142fbf461d..69dd16cfef485ad84edfd41dfe59c29acc65b49e 100644 (file)
@@ -61,7 +61,8 @@
     lf: {
       enableGravatar: false,
       gravatarServerUrl: ''
-    }
+    },
+    updateCenterActive: true
   };
   </script>
   <script>requirejs.config({ baseUrl: baseUrl + '../../build/js' });</script>
index bcb2d66b0f897b8d422b8bb84322a6d294b4e3a0..40277c7ebc30c4a672bd66187b11d7c07b3a862f 100644 (file)
@@ -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')