]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6928 apply feedback
authorStas Vilchik <vilchiks@gmail.com>
Thu, 22 Oct 2015 18:48:21 +0000 (20:48 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Thu, 22 Oct 2015 18:48:21 +0000 (20:48 +0200)
server/sonar-web/src/main/js/api/system.js
server/sonar-web/src/main/js/apps/system/item-log-level.js
server/sonar-web/src/main/js/helpers/request.js
server/sonar-web/src/main/js/main/nav/settings/settings-nav.js
server/sonar-web/src/main/webapp/WEB-INF/app/controllers/system_controller.rb
server/sonar-web/src/main/webapp/WEB-INF/app/views/system/new.html.erb [deleted file]
server/sonar-web/tests/apps/system-test.js

index fab447ccdbd760a84cc7978830f0496d85c35ee1..a1c3ca082eab8280e2f79a3a96741f586069be98 100644 (file)
@@ -1,9 +1,9 @@
-import { getJSON, postJSON } from '../helpers/request';
+import { getJSON, post } from '../helpers/request';
 
 export function setLogLevel (level) {
   let url = window.baseUrl + '/api/system/change_log_level';
   let data = { level };
-  return postJSON(url, data);
+  return post(url, data);
 }
 
 export function getSystemInfo () {
index 2f888d7100bdf565c5c0144b7a1915de31505883..3e924a2781ef94e6007f90c52b90eb427fb3723f 100644 (file)
@@ -4,17 +4,31 @@ import { setLogLevel } from '../../api/system';
 const LOG_LEVELS = ['INFO', 'DEBUG', 'TRACE'];
 
 export default React.createClass({
+  getInitialState () {
+    return { level: this.props.value };
+  },
+
   onChange() {
     let newValue = React.findDOMNode(this.refs.select).value;
-    setLogLevel(newValue);
+    setLogLevel(newValue).then(() => {
+      this.setState({ level: newValue });
+    });
   },
 
   render() {
     let options = LOG_LEVELS.map(level => {
       return <option key={level} value={level}>{level}</option>;
     });
-    return <select ref="select"
-                   onChange={this.onChange}
-                   defaultValue={this.props.value}>{options}</select>;
+    let warning = this.state.level !== 'INFO' ? (
+        <div className="alert alert-danger spacer-top" style={{ wordBreak: 'normal' }}>
+          {window.t('system.log_level.warning')}
+        </div>
+    ) : null;
+    return <div>
+      <select ref="select"
+              onChange={this.onChange}
+              value={this.state.level}>{options}</select>
+      {warning}
+    </div>
   }
 });
index 61eff255eafa4f538d66a59e834d1adc304d7a69..86e9b8242e3273bd067c9a9992e88d8a2a3aa425 100644 (file)
@@ -133,3 +133,17 @@ export function postJSON (url, data) {
       .then(checkStatus)
       .then(parseJSON);
 }
+
+
+/**
+ * Shortcut to do a POST request and return response json
+ * @param url
+ * @param data
+ */
+export function post (url, data) {
+  return request(url)
+      .setMethod('POST')
+      .setData(data)
+      .submit()
+      .then(checkStatus);
+}
index 5f186c494b02d476ff229afcb5e7f89fb9747bd6..13fae339cda61f8b197c8a046516f33661af5762 100644 (file)
@@ -57,8 +57,7 @@ export default React.createClass({
               </a>
               <ul className="dropdown-menu">
                 {this.renderLink('/updatecenter', window.t('update_center.page'))}
-                {this.renderLink('/system/index', window.t('system_info.page'))}
-                {this.renderNewLink('/system/new', window.t('system_info.page'))}
+                {this.renderLink('/system', window.t('system_info.page'))}
               </ul>
             </li>
           </ul>
index b570e238edd38e1662a107222c176698d6bd1fc1..af4c4d94b197d1e32d78510a98e9d4420d9427b4 100644 (file)
@@ -26,8 +26,4 @@ class SystemController < ApplicationController
 
   end
 
-  def new
-
-  end
-
 end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/system/new.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/system/new.html.erb
deleted file mode 100644 (file)
index 8e9f086..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<% content_for :extra_script do %>
-  <script src="<%= ApplicationController.root_context -%>/js/bundles/system.js?v=<%= sonar_version -%>"></script>
-<% end %>
-
index 274917cbc1c7c0352a4c6fca37aae12321f61557..1d2aa97bf9792f5ae0f2e61d0201a584069275a6 100644 (file)
@@ -72,6 +72,16 @@ describe('System', function () {
       expect(select.value).to.equal('DEBUG');
     });
 
+    it('should render warning', () => {
+      let result = TestUtils.renderIntoDocument(<ItemValue value="DEBUG" name="Logs Level"/>);
+      TestUtils.findRenderedDOMComponentWithClass(result, 'alert');
+    });
+
+    it('should not render warning', () => {
+      let result = TestUtils.renderIntoDocument(<ItemValue value="INFO" name="Logs Level"/>);
+      expect(TestUtils.scryRenderedDOMComponentsWithClass(result, 'alert')).to.be.empty;
+    });
+
     it('should change value', () => {
       let result = TestUtils.renderIntoDocument(<ItemValue value="INFO" name="Logs Level"/>);
       let select = React.findDOMNode(TestUtils.findRenderedDOMComponentWithTag(result, 'select'));